You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Anjan <po...@gmail.com> on 2015/03/09 07:17:33 UTC

Datastore usage

Hi, our application is a document management system(DMS) based out of Sling. 
We have a requirement to limit the amount of data(files/documents), in terms
of size, stored by a user in the datastore.  Each user can only upload to a
folder under say "/content/userA" or any of its sub-folders.  We also allow
versions on the documents, so I need to increment this size whenever a new
version is created on an existing document.  Also when a document is deleted
I need to decrement the size by calculating the size of the document and all
it's versions.

Considering the above requirement, I am thinking of is using the Event
mechanism and register for the events SlingConstants.TOPIC_RESOURCE_ADDED,
SlingConstants.TOPIC_RESOURCE_CHANGED,
SlingConstants.TOPIC_RESOURCE_REMOVED.

Whenever a document is uploaded or a new version is added to the DMS, I will
get the size of this document in the Event Handler and increment the size of
the User's usage.  However I am not sure if I can get all the version
history in the event handler when a document is deleted.  Please let me
know.

Is there a better alternative to the above approach?  Please suggest.

I am thinking of setting the current usage of a user as a property of the
folder "/content/userA".  Or would it be better to set as a property of the
User itself?






--
View this message in context: http://apache-sling.73963.n3.nabble.com/Datastore-usage-tp4048204.html
Sent from the Sling - Users mailing list archive at Nabble.com.

Re: Datastore usage

Posted by Dominik Süß <do...@gmail.com>.
Hi Anjan,

as you noted the eventing is happening "post-mortem" so no way to get the
relevant metadata. If you'd use Apache Oak as persistence you could
register a commit hook that allows you to  to interact with the "before"
and "after" state. The alternative within Apache Sling would be to have a
custom ResourceProvider in between Sling and JCR where you could intercept
the delete operation and store the information that you need (check out the
superimposing resourceprovider in contrib to check out how such a
"delegating" resourceprovider could work).

HTH
Dominik

On Wed, Mar 11, 2015 at 6:50 AM, Anjan <po...@gmail.com> wrote:

> When a document is deleted, SlingConstants.TOPIC_RESOURCE_REMOVED event is
> fired.  But the node is already deleted by the time I try to access it by
> it's path.  So I cannot access the VersionHistory either.  So how to access
> the VersionHistory just before the node is deleted?
>
>
>
> --
> View this message in context:
> http://apache-sling.73963.n3.nabble.com/Datastore-usage-tp4048204p4048330.html
> Sent from the Sling - Users mailing list archive at Nabble.com.
>

Re: Datastore usage

Posted by connuser1 connuser1 <co...@gmail.com>.
Did you try using JCR Observation for NODE_REMOVED event ?

On Wed, Mar 11, 2015 at 11:20 AM, Anjan <po...@gmail.com> wrote:

> When a document is deleted, SlingConstants.TOPIC_RESOURCE_REMOVED event is
> fired.  But the node is already deleted by the time I try to access it by
> it's path.  So I cannot access the VersionHistory either.  So how to access
> the VersionHistory just before the node is deleted?
>
>
>
> --
> View this message in context:
> http://apache-sling.73963.n3.nabble.com/Datastore-usage-tp4048204p4048330.html
> Sent from the Sling - Users mailing list archive at Nabble.com.
>

Re: Datastore usage

Posted by Anjan <po...@gmail.com>.
When a document is deleted, SlingConstants.TOPIC_RESOURCE_REMOVED event is
fired.  But the node is already deleted by the time I try to access it by
it's path.  So I cannot access the VersionHistory either.  So how to access
the VersionHistory just before the node is deleted?



--
View this message in context: http://apache-sling.73963.n3.nabble.com/Datastore-usage-tp4048204p4048330.html
Sent from the Sling - Users mailing list archive at Nabble.com.