Re: problem with removeMixin

2011-04-13 Thread Gazi Mushfiqur Rahman
)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:401)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:267)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:245)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:260)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.jcr.UnsupportedRepositoryOperationException: Removing
mix:shareable is not supported.
at
org.apache.jackrabbit.core.ItemImpl.processShareableNodes(ItemImpl.java:743)
at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1116)
at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:920)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.sling.jcr.base.SessionProxyHandler$SessionProxyInvocationHandler.invoke(SessionProxyHandler.java:109)
at $Proxy74.save(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
... 50 more


So, how do you think properties for 'mix:shareable' is still present in the
node? But it seems to be something else to me from the log.

Thank you,
Gazi Mushfiqur Rhaman

On Tue, Apr 12, 2011 at 8:31 PM, Alexander Klimetschek
aklim...@adobe.comwrote:

 On 11.04.11 23:16, Gazi Mushfiqur Rahman gazimushfiqurrah...@gmail.com
 wrote:

 In my case, I added 'mix:shareable' mixin to a node created earler. But
 later if I try to remove the mixin, I get the error message that
 'mix:shareable' mixin can not be removed from the node. Any idea why this
 is
 happening or how I can fix this issue?

 This could be the case because (mandatory) properties defined by the mixin
 are still set on the node.

 Regards,
 Alex

 --
 Alexander Klimetschek
 Developer // Adobe (Day) // Berlin - Basel







Re: problem with removeMixin

2011-04-12 Thread Gazi Mushfiqur Rahman
In my case, I added 'mix:shareable' mixin to a node created earler. But
later if I try to remove the mixin, I get the error message that
'mix:shareable' mixin can not be removed from the node. Any idea why this is
happening or how I can fix this issue?

On Tue, Apr 12, 2011 at 12:29 AM, Alexander Klimetschek
aklim...@adobe.comwrote:

 On 11.04.11 09:55, Justin Edelson jus...@justinedelson.com wrote:

 You should use removeMixin(). But, as the OP noted, you can't remove a
 mixin which wasn't added by addMixin().

 Exactly. Because a mixin that is part of a (primary) node type because
 that node type includes it / inherits from it, is not really a mixin
 anymore.

 Regards,
 Alex

 --
 Alexander Klimetschek
 Developer // Adobe (Day) // Berlin - Basel







Locking on nodes are not preserved in following sessions or requests

2011-01-25 Thread Gazi Mushfiqur Rahman
Hi all,

I am facing a problem on locking a node or resource. I am using Jackrabbit
from Apache Sling and I have the following code (esp file) to lock a node:

!DOCTYPE html
%
var session =
request.getResourceResolver().adaptTo(Packages.javax.jcr.Session);;
var wasLockableNode = currentNode.isNodeType(mix:lockable);
if (!wasLockableNode) {
currentNode.addMixin(mix:lockable);
session.save();
}
var lockOwner = null;
var workspace = session.workspace;
var lockManager = workspace.lockManager;
var wasLocked = lockManager.isLocked(currentNode.path);
var locked = false;
if (!wasLocked) {
var lock = lockManager.lock(currentNode.path, true, false, 120,
lockOwner);
lockManager.addLockToken(lock.lockToken);
locked = true;
} else {
var lock = lockManager.getLock(currentNode.path);
}
session.save();
%
html
head
title%= currentNode.title % is locked: %= locked %/title
/head
body
p
Is Locking Supported by Repository %=
session.repository.getDescriptorValue(session.repository.OPTION_LOCKING_SUPPORTED).string
%br /
Is Locked %= locked %br /
Lock Owner: span id=owner%= lock.lockOwner %/spanbr/
Lock Token: span id=token%= lock.lockToken %/spanbr /
Is Deep: span id=deep%= lock.deep %/spanbr /
Is Session Scoped: span%= lock.sessionScoped %/spanbr /
Is Current Session Owning Lock: span
id=isLockOwningSession%= lock.lockOwningSession %/spanbr/
Was lockable node: %= wasLockableNode %br /
Was Locked: %= wasLocked %br /
Remaining Seconds for the Lock %= lock.secondsRemaining %br
/
Current Lock Tokens: %=
Packages.java.util.Arrays.toString(lockManager.lockTokens) %br /
/p
/body
/html

After executing the above script, I find that the node was locked. But if I
execute the following script just after executing the previous one, I find
that node ia not locked!:
code
!DOCTYPE html
html
head
title%= currentNode.title %/title
meta http-equiv=Content-Type content=text/html; charset=UTF-8/
/head
body
h1%= currentNode.title %/h1
p
Title: span id=title%= currentNode.title %/spanbr /
Is Locked: span id=locked%= currentNode.locked %/spanbr /
/p
/body
/html
/code

Can anyone help me to find out the problem in my code or give me suggestion
on how to implement locking on nodes using Sling?

Thanks  Regards.