Thanks Jan, 

Really good inputs and you definitely put me to the right direction, especially 
in regards to point 17.10, that taught me a lot!
And yes, i see that my sample snippet is full of misleading errors, i was 
trying to make it simple but i think i over simplified it:S

Another correction  to my earlier point. This is an issue to any workspace not 
just DAM. 

Nonetheless, i do think there is a bug when it comes to performing locks by 
public users

see [i]"slightly"[/i] better code below:

[code]  Session sess = MgnlContext.getJCRSession("dam");
                LockManager lock = sess.getWorkspace().getLockManager();
                Node one = NodeUtil.createPath(sess.getRootNode(), "one", 
"mgnl:folder", true);
                //NOTE: MgnlContext.getJCRSession("dam").getUserID() will 
return null if session is instantiated by public user.
                //sess.toString() give something like session-123 for public 
users and session-admin-123 for superuser (im using this  as a workaround, when 
getting null for getUserID())
                String owner = StringUtils.defaultIfEmpty(sess.getUserID(), 
                lock.lock(one.getPath(), true, true, 5000, owner);
      ; //saving the lock that has just been applied
                Node two = NodeUtil.createPath(one, "two", "mgnl:folder"); 
      ; //will EXPLODE here!!!!!!

As you can see in the code above i invoke the save() method which in turn 
in this save() method there is a line (line 498 if my decompiler is correct):
[code] Session sysSession = 

This line is the culprit, as it creates new session, also it creates the 
session as an admin, which looks something like "session-admin-123" 
My previously created session (sess) had a name of session-123, see the 

Then this save() method attempts to modify my node "two" to apply pending 
changes such as creation date etc...
However it attempts to apply those changes using new session 
(session-admin-123), but my node is locked by session-123. 

which is why i get the error posted in my first post, stating that the node is 

slight modification to my code such as
[b]FROM[/b] Session sess = MgnlContext.getJCRSession("dam");
[b]TO[/b] Session sess = MgnlContext.getSystemContext().getJCRSession("dam");

solves the problem as my "sess" becomes session-admin-123, and later same 
session is retrieved by save() method..... but feels like a dirty workaround?...

To answer your question why use locking? 
well we have multiple instances of public, and DAM workspace is in clustered 
repository (shared between publics). 
Our public users can add images, and we store them in DAM, so we use locking to 
assure that two users dont modify same node at once... 

Once again, thanks for your support,  any  help is always appreciated! 


Context is everything:

For list details, see:
Alternatively, use our forums:
To unsubscribe, E-mail to: <>

Reply via email to