[Hippo-cms7-user] Using a workflow to create a new document programatically

d.clayton d.clayton at lukkien.com
Fri Oct 14 09:52:20 CEST 2011


1. What's the difference between a "subject based session" and a "writable
session"?

request.getRequestContext().getSession()

vs

getPersistableSession(request);

In one example I read, getPersistableSession() was used, in Detail.java it
says "Don't need to use writable session here; use subject based session
instead." then later "no need to close the persistable session here because
subject based session was retrieved from rc.". Does that mean if I use a
persistable session I do need to close it? There isn't a close method. I
want to make sure I'm doing everything correctly.

2. I notice the "Document" in the demo (Document.java) seems to be a kind of
proxy that wraps the node and also caches the values written back to it.
However, in the bind() method overridden from ContentNodeBinder, I'm
confused with the logic. It seems as this is some kind of persistance
callback that passes the Document to be persisted in (the first argument),
so it does:

Document bean = (Document) content;
node.setProperty("hippogogreen:title", bean.getTitle());

Here it gets fields from the passed in document. However in the same
function to get the description, it calls getDescriptionContent() on this,
not on bean. Is this intentional or something we need to be aware of? Or
should it also be called on the bean that's passed in?

3. This doesn't create a node as far as I can tell, it updates an existing
one, so I'm not sure what my logic should be like. At the moment I'm using
getPersistableSession() then creating the node with the code I pasted
previously. Should I do this, then use
request.getRequestContext().getSession() to update it with the correct
properties, or can I use the first session to update the properties?

I know I ask a lot of questions, but I want to make sure I'm doing it
correctly. The offer to document this stuff still stands.

Kind regards,

Dave

--
View this message in context: http://hippo.2275632.n2.nabble.com/Using-a-workflow-to-create-a-new-document-programatically-tp6888352p6891589.html
Sent from the Hippo CMS 7 mailing list archive at Nabble.com.



More information about the Hippo-cms7-user mailing list