You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Daniel Varga <da...@gmail.com> on 2010/05/14 15:32:53 UTC

jcr 2 mix:lifecycle

Hi All,

I've just discovered the mix:lifecycle type in jcr 2 and have a question
regarding it since I did not find enough explanation either in jackrabbit
docs nor in jcr specs.
So the question is whether it is meant to define application specific
lifecycle so that I can define my states, transitions and actions (or
listeneres for state changes) or is for managing repository implementation
specific lifecycle that is not to be customized by an application built on
top?
Thanks a lot,
Daniel

Re: jcr 2 mix:lifecycle

Posted by s1a2 <s1...@yahoo.it>.
Hi Jukka,
   thanks for your quickly and helpful response.

I have totally misunderstood the doc you linked. :/

Thanks again !

Klaus.

--
View this message in context: http://jackrabbit.510166.n4.nabble.com/jcr-2-mix-lifecycle-tp2216584p3721286.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: jcr 2 mix:lifecycle

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Fri, Aug 5, 2011 at 3:03 PM, s1a2 <s1...@yahoo.it> wrote:
> Can someone help me to understand what I'm doing wrong
> or link me a page where I can find an example or documentation ?

As described in [1], you need to put the transition nodes under a
"transitions" child of the policy node. Note also that the current
lifecycle implementation doesn't care about specific state nodes, the
state names are only encoded as possible values of the "from" and "to"
properties (not "jcr:from" or "jcr:to") of the transition nodes.

If I understand your example correctly, what you really should be
doing is something like this:

--------------
Node lifecycle = root.addNode("lifecycle", "nt:unstructured");
lifecycle.addMixin("mix:referenceable");
Node transitions = lifecycle.addNode("transitions", "nt:unstructured");

Node release = transitions.addNode("release", "nt:unstructured");
release.setProperty("from", "CREATED");
release.setProperty("to", "RELEASED");

Node unrelease = transitions.addNode("unrelease", "nt:unstructured");
unrelease.setProperty("from", "RELEASED");
unrelease.setProperty("to", "CREATED");
--------------

Then, once this lifecycle definition has been saved, you can use it like this:

--------------
Node NodeWL= root.addNode("NodeWL");
NodeWL.addMixin("mix:lifecycle");

NodeWL.assignLifecyclePolicy(lifecycle, "CREATED");

String[] StatesAllowed=NodeWL.getAllowedLifecycleTransistions();
--------------

As a result the StatesAllowed array should contain the string "RELEASED".

[1] http://jackrabbit.apache.org/api/2.1/org/apache/jackrabbit/core/NodeImpl.html#getAllowedLifecycleTransistions()

BR,

Jukka Zitting

Re: jcr 2 mix:lifecycle

Posted by s1a2 <s1...@yahoo.it>.
Hi all,

I'm stuck here with this topic.

I had defined these 2 NodeTypes, one as "lifecycle policy node"
(cpns:Stateslist) and one as "transition node" (cpns:State):

--------------
[cpns:Stateslist]
> nt:base, mix:referenceable
+ * (cpns:State) = cpns:State

[cpns:State]
> nt:base, mix:referenceable
- jcr:from (string)
- jcr:to (string)
--------------

Then, in the code, I've created them:

--------------
Node Stateslist = root.addNode("Stateslist", "cpns:Stateslist");

Node State1 = Stateslist.addNode("CREATED", "cpns:State");
State1.setProperty("jcr:from", "");
State1.setProperty("jcr:to", "RELEASED");

Node State2 = Stateslist.addNode("RELEASED", "cpns:State");
State2.setProperty("jcr:from", "RELEASED");
State2.setProperty("jcr:to", "");
--------------

and finally, I tried to assign the lifecycle policy to a new Node:

--------------
NodeImpl NodeWL=(NodeImpl)root.addNode("NodeWL");
NodeWL.addMixin("mix:lifecycle");

NodeWL.assignLifecyclePolicy(StatesList, "CREATED");

String[] StatesAllowed=NodeWL.getAllowedLifecycleTransistions();
--------------

but at the end "StatesAllowed" is empty.

Can someone help me to understand what I'm doing wrong
or link me a page where I can find an example or documentation ?

Thanks in advance,
Klaus


--
View this message in context: http://jackrabbit.510166.n4.nabble.com/jcr-2-mix-lifecycle-tp2216584p3721149.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: jcr 2 mix:lifecycle

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Fri, May 14, 2010 at 3:32 PM, Daniel Varga <da...@gmail.com> wrote:
> So the question is whether it is meant to define application specific
> lifecycle so that I can define my states, transitions and actions (or
> listeneres for state changes) or is for managing repository implementation
> specific lifecycle that is not to be customized by an application built on
> top?

The JCR spec leaves the details of the lifecycle feature up to the
repository implementation to decide.

The current implementation in Jackrabbit is summarized in the javadocs
of the NodeImpl.assignLifeCyclePolicy [1] and
NodeImpl.getAllowedLifecycleTransitions [2] methods. There is
currently no support for lifecycle actions or state change listeners
(beyond normal JCR observation), but you can define your own lifecycle
states and transitions as described in [2].

[1] http://jackrabbit.apache.org/api/2.1/org/apache/jackrabbit/core/NodeImpl.html#assignLifecyclePolicy(javax.jcr.Node,
java.lang.String)
[2] http://jackrabbit.apache.org/api/2.1/org/apache/jackrabbit/core/NodeImpl.html#getAllowedLifecycleTransistions()

BR,

Jukka Zitting