12 Replies Latest reply on Nov 18, 2008 4:32 PM by Ryan Rutan

    attachment download counters?

       

      Hi,

       

       

      Any plans as to maybe having download counters for attachments that are displayed on viewing the document next to the attachment name or something?  Currently docs that are file uploads (have a binary body) have their downloads tracked (although you can only see the counter if you edit the doc, not on viewing it) so seems like it might be low-hanging fruit to add counters for attachments for regular documents as well that users could see which might help promote participation and rewards to contributors (i.e. someone sees an attachment has been downloaded thousands of times with no bad comments so probably a good attachment, contributor sees his attachment being downloaded thousands of times which might give him some satisfaction and motivate him to try to offer more quality content/attachments to the community).  Or is adding this ourselves a pretty simple dev task (haven't looked too in-depth in how the download counters for binary docs are working and could be adapted for non-binary doc attachments)?  Thanks.

       

       

        • Re: attachment download counters?

          Actually I see there's an AttachmentListenerAdapter with an attachmentdownloaded method taking in an attachmentevent which I guess could be extended to track downloads - I suppose we could just add an extended property for the doc (which we can get from the attachmentevent) that has the attachment name to keep it unique to the doc as the key and then the counter as the value that would get incremented on each download event?  Thread-safety/synchronization would have to be handled by us then I assume since hundreds of people could d/l the attachment at the same time or does clearspace have some built-in protection?

           

            • Re: attachment download counters?

               

              I went ahead and did this by adding an attachmentlistener extending AttachmentListenerAdapter and attachmentAdded/attachmentDeleted listener code fires off fine, but I have added logging statements to attachmentDownloaded method and am not seeing any messages in the logs - so it doesn't seem to be firing at all (I have tried downloading on both the view document page as well as the edit document page) any thoughts as to why?  I am running 1.5 and have a document listener that works fine and the attachmentListener is only messing up on attachmentDownloaded event it seems. 

               

               

              And if this is able to work somehow, is there some way to let doc.getProperties().put() be executed by an anonymous user if a doc is only editable by certain users - I noticed the javadoc said the getProperties() map is unmodifiable to users who aren't authorized to edit the doc but we would obviously like the download counter to be modifiable by anyone who downloads the attachment, not just certain users.  Thanks.

               

               

                • Re: attachment download counters?

                  hi James,

                   

                  I have added logging statements to attachmentDownloaded method and am not seeing any messages in the logs - so it doesn't seem to be firing at all

                  Yeah, this looks like a bug with JiveServlet. I believe it's the class that's responsible for giving users a copy of an attachment and so it should be the one firing the event. I filed a bug for it (http://www.jivesoftware.com/issues/browse/CS-2055) and hope to get it fixed for 1.9.

                   

                  is there some way to let doc.getProperties().put() be executed by an anonymous user if a doc is only editable by certain users

                  Yeah, you'd want to get the document as a system admin:

                  AuthToken admin = AuthFactory.getSystemAuthToken();
                  JiveContext context = JiveApplication.getContext(admin);
                  DocumentManager dm = context.getDocumentManager();
                  Document d = dm.getDocument(documentID);
                  d.getProperties().put("count", "10");

                   

                  Cheers,

                   

                  AJ

                    • Re: attachment download counters?

                      Cool, AJ.  Yeah, I think 1.9 is the last version we are thinking of going with for this phase given our release schedule (it'll be a toss-up between 1.8 and 1.9 depending on when they come out) so it'd be great if you could bust out the fix for this.  Just one other question related to this that you might have missed in my previous posts in the thread - if we use doc.getProperties.put() in the attachment download listener, concurrency issues/synchronization on incrementing the counter would have to be handled by us then I assume since

                      hundreds of people could d/l the attachment at the same time or does clearspace

                      have some automatic higher-level built-in protection that already takes care of such scenarios?  Thanks.

                       

                        • Re: attachment download counters?

                          hi James,

                           

                          I committed a fix for the bug to the 1.9 branch today, so pending a successful run through QA, it'll be in the 1.9 release.  As far as the concurrency issue with storing the download information in a property, yeah, you're right: you'd have to handle synchronization.

                           

                          Cheers,

                           

                          AJ

                            • Re: attachment download counters?

                               

                              Cool - so I guess there's no chance of this fix getting pushed into 1.8 - had to ask

                               

                               

                              Do you know what the eta is for 1.9?  Thanks again.

                               

                               

                                • Re: attachment download counters?

                                  hi James,

                                   

                                  Cool - so I guess there's no chance of this fix getting pushed into 1.8 - had to ask

                                  QA would kill me.

                                   

                                  1.9 is coming out three weeks from this Thursday, December 6th.

                                   

                                  Cheers,

                                   

                                  AJ

                                    • Re: attachment download counters?

                                      Actually I'm not sure how I missed this but I see there's a getDownloadCount() method in the Attachment class.  But using it always returns 0 no matter how many times I d/l the attachment (which might explain why I was also seeing 0 d/l count on the binary doc upload content types as well since I'm guessing BinaryBody uses similar logic).  I see in the AttachmentDownloadListener class that there is a call to dbAttachment.incrementDownloadCount() on the attachmentDownloaded event but I guess it is not working - would the fix you made for 1.9 take care of this (in which case we wouldn't have to worry about maintaining a counter ourselves at all and would just need to call attachment.getDownloadCount()) since it seems like you guys were already thinking of this functionality when creating the attachment classes.  Thanks again.

                                        • Re: attachment download counters?

                                          hi James,

                                           

                                          Would the fix you made for 1.9 take care of this

                                          It should, try out the beta if you have a chance:

                                           

                                          http://www.jivesoftware.com/community/blogs/clearspace/2007/11/29/clearspace-19-beta-now-available

                                           

                                          Cheers,

                                           

                                          AJ

                                            • Re: attachment download counters?

                                              Quick question - haven't installed 1.9 yet but do you know what table/field the attachment download count would be stored in (closest field I could find from schema documentation was  downloadComplete in the jiveAttachmentDL table but that's just a flag).  Only reason I ask is that we are migrating some non-csx content that has attachments with download counts and would like to insert those values rather than having all the counts reset to 0 if the download counting functionality is working and we go with 1.9.  Thanks.

                                               

                                                • Re: attachment download counters?

                                                  hi James,

                                                   

                                                  The download count is a computed value, it uses the jiveAttachmentDL table like you suspected and a SQL query to compute the value:

                                                  SELECT count(*) FROM jiveAttachmentDL WHERE attachmentID=? AND downloadComplete=1

                                                   

                                                  If you are going to migrate over download counts from another system, I'd insert n rows into the jiveAttachmentDL table per download of each attachment.

                                                   

                                                  Cheers,

                                                   

                                                  AJ

                                                    • Re: attachment download counters?
                                                      Ryan Rutan

                                                      Aaron,

                                                       

                                                      I've posted another idea on this topic.  What if a reserved property was named "jive.initial.dl.count" and the value could be used to add to the actual DL count calculated by the normal system query.  This would be a minor change, and would provide quite a bit of functionality for migration, as well as, cross-version & cross-community attachment where we want to start out the Attachment count based on prior knowledge of it's use.

                                                       

                                                      Any chance, we can get an update on this idea?   Thumbs up/down anyone?