[Hippo-cms7-user] Exception when trying to create a workflow

Mansour Al Akeel mansour.alakeel at gmail.com
Wed May 19 18:50:10 CEST 2010


Thank you Woonsan and Ard:

It working like Ard suggested. The issue was in the path and I changed
it to the correct one:

    /mysite/comments to
 
    /content/documents/mysite/comments

I had a look at the Detalis.java and it looks close to what I am doing.
However, I am unable to get mine to work. Here's a piece of code:


	Session persistableSession = null;
	WorkflowPersistenceManager wpm = null;

	try {
	    persistableSession = getPersistableSession(request);
			
	    wpm = getWorkflowPersistenceManager(persistableSession);

	    wpm.setWorkflowCallbackHandler(new WorkflowCallbackHandler<FullReviewedActionsWorkflow>() {
			public void processWorkflow(
						    FullReviewedActionsWorkflow wf)
			    throws Exception {
			    FullReviewedActionsWorkflow fraw = (FullReviewedActionsWorkflow) wf;
			    log.debug("processing work flow");
			    fraw.requestPublication();
			}
		    });

	    log.debug("Obtained WorkflowCallbackHandler");
			
	    String siteCanonicalBasePath = this.getHstSite(request).getCanonicalContentPath();
	    String msg_name = "msg-" + System.currentTimeMillis();
	    String messagesPath = siteCanonicalBasePath + "/comments" ;
	    
	    log.debug("Comments path: " + messagesPath ) ;
	    
	    wpm.create( messagesPath , "contact:message",msg_name, true);
	    
	    ContactBean  bean = (ContactBean) wpm.getObject(messagesPath + "/" + msg_name);
	    
	    if(bean == null) {
		throw new HstComponentException("Failed to add Comment: " + messagesPath + "/" + msg_name);
	    }

	    log.debug("Recieved First Name: " + firstName);
	    log.debug("Recieved Last Name: " + lastName);
	    log.debug("Recieved Email: " + email);

	    bean.setFirstName(firstName);
	    bean.setLastName(lastName);
	    bean.setEmail(email);

	    wpm.update(bean);

	} catch (Exception e) {
	    log.warn("Failed to create a comment: ", e);
	    if (wpm != null) {
		try {
		    wpm.refresh();
		} catch (ObjectBeanPersistenceException e1) {
		    log.warn("Failed to refresh: ", e);
		}
	    }
	} finally {
	    if (persistableSession != null) {
		persistableSession.logout();
	    }
	}
    }

and here's the exception:

org.hippoecm.hst.content.beans.ObjectBeanPersistenceException: Exception while trying to update '/content/documents/mysite/comments/msg-1274285448844/msg-1274285448844'
    at org.hippoecm.hst.content.beans.manager.workflow.WorkflowPersistenceManagerImpl.update(WorkflowPersistenceManagerImpl.java:378)
    at org.hippoecm.hst.content.beans.manager.workflow.WorkflowPersistenceManagerImpl.update(WorkflowPersistenceManagerImpl.java:303)
    at com.sardonyxsolutions.hippocms.components.Contact.doAction(Contact.java:104)
    at org.hippoecm.hst.core.container.HstComponentInvokerImpl.invokeAction(HstComponentInvokerImpl.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

the problem is the node name is appended automatically when I call
wpm.getObject(path) 
for example: I want to update /content/documents/mysite/msg-123 but when
I pass the wpm.getObject("/content/documents/mysite/msg-123") I am
getting /content/documents/mysite/msg-123/msg-123

The code in Details.java is following the same steps ! 

Any help ? 
Thanks in advance.



On Wed May 19,2010 10:15 am, Ard Schrijvers wrote:
> Hello Mansour and Woonsan,
> 
> The problem is when the first folder that has to be created does not
> come below of node that is 'known' to be a folder by the workflow.
> 
> So, wrt to your error, it says:
> 
> The workflow is not a FolderWorkflow for /
> 
> This makes me believe, that from the path /mysite/comments, already
> 'mysite' does not exist. Hence, directly below the jcr:root. The
> problem is, that jcr:root is not known as a folder, hence, folder
> workflow cannot be applied.
> 
> Furthermore, I assume, you also want to expose comments again on your
> website, right? Therefore, they can better be part of the documents in
> your website. Most likely, if you change
> 
>  /mysite/comments to
> 
> /content/documents/mysite/comments
> 
> everything works just fine. And of course, instead of typing it by
> hand, I'd get it from the current hstSite. So, in your HstComponent
> extending from BaseHstComponent you can use:
> 
> // it is not important where we store comments. WE just use some
> (canonical) time path below our project content
> String siteCanonicalBasePath =
> this.getHstSite(request).getCanonicalContentPath();
> 
> Also see Detail.java from the demosuite.
> 
> Hope this helps,
> 
> regards Ard
> 
> 
> 
> On Wed, May 19, 2010 at 9:58 AM, Woonsan Ko <w.ko at onehippo.com> wrote:
> > Oh, I've looked into the code, but it seems omitting the empty folder
> > name correctly. So, just ignore my previous reply.
> >
> > By the way, have you modified some workflow configurations in hippo
> > repository for some reason such as category name?
> >
> > Regards,
> >
> > Woonsan
> >
> > On Wed, May 19, 2010 at 9:52 AM, Woonsan Ko <w.ko at onehippo.com> wrote:
> >> Hi Mansour,
> >>
> >> Could you try with this?
> >>
> >> ? ?wpm.create("/mysite/comment", "basic:textdocument", "msg", true);
> >>
> >> I guess the first parameter with ending slash made the problem.
> >> Please let us know the result. Then I'd like to fix this to allow ending slash.
> >>
> >> Regards,
> >>
> >> Woonsan
> >>
> >> On Wed, May 19, 2010 at 12:08 AM, Mansour Al Akeel
> >> <mansour.alakeel at gmail.com> wrote:
> >>> I am following the TodoList.java example in the demo to create a similar
> >>> function for a "Contact Us" page.
> >>>
> >>> ? ? ? ? ? ? ? ?Session persistableSession = null;
> >>> ? ? ? ? ? ? ? ?WorkflowPersistenceManager wpm = null;
> >>>
> >>> ? ? ? ? ? ? ? ?try {
> >>> ? ? ? ? ? ? ? ? ? ? ? ?persistableSession = getPersistableSession(request);
> >>> ? ? ? ? ? ? ? ? ? ? ? ?wpm = getWorkflowPersistenceManager(persistableSession);
> >>> ? ? ? ? ? ? ? ? ? ? ? ?wpm.setWorkflowCallbackHandler(new WorkflowCallbackHandler<FullReviewedActionsWorkflow>() {
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?public void processWorkflow(
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?FullReviewedActionsWorkflow wf)
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?throws Exception {
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?FullReviewedActionsWorkflow fraw = (FullReviewedActionsWorkflow) wf;
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?log.debug("processing work flow");
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?fraw.requestPublication();
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?});
> >>>
> >>> ? ? ? ? ? ? ? ? ? ? ? ?log.debug("Obtained WorkflowCallbackHandler");
> >>> ? ? ? ? ? ? ? ? ? ? ? ?wpm.create("/mysite/comment/", "basic:textdocument", "msg", true);
> >>>
> >>> ? ? ? ? ? ? ? ?} catch (Exception e) {
> >>> ? ? ? ? ? ? ? ? ? ? ? ?log.warn("Failed to create a comment: ", e);
> >>> ? ? ? ? ? ? ? ? ? ? ? ?if (wpm != null) {
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?try {
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?wpm.refresh();
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?} catch (ObjectBeanPersistenceException e1) {
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?log.warn("Failed to refresh: ", e);
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}
> >>> ? ? ? ? ? ? ? ? ? ? ? ?}
> >>> ? ? ? ? ? ? ? ?} finally {
> >>> ? ? ? ? ? ? ? ? ? ? ? ?if (persistableSession != null) {
> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?persistableSession.logout();
> >>> ? ? ? ? ? ? ? ? ? ? ? ?}
> >>> ? ? ? ? ? ? ? ?}
> >>>
> >>>
> >>>
> >>> I am getting this exception.
> >>>
> >>> org.hippoecm.hst.content.beans.ObjectBeanPersistenceException: The workflow is not a FolderWorkflow for /: Proxy[RepositoryWorkflow,RemoteObjectInvocationHandler[UnicastRef [liveRef:
> >>> [endpoint:[127.0.0.1:1099](remote),objID:[334dcf49:128abca20df:-2b2e, 4605523969412514468]]]]]
> >>> ? ? ? ?at org.hippoecm.hst.content.beans.manager.workflow.WorkflowPersistenceManagerImpl.createNodeByWorkflow(WorkflowPersistenceManagerImpl.java:249)
> >>> ? ? ? ?at org.hippoecm.hst.content.beans.manager.workflow.WorkflowPersistenceManagerImpl.createMissingFolders(WorkflowPersistenceManagerImpl.java:190)
> >>> ? ? ? ?at org.hippoecm.hst.content.beans.manager.workflow.WorkflowPersistenceManagerImpl.create(WorkflowPersistenceManagerImpl.java:161)
> >>> ? ? ? ?at com.sardonyxsolutions.hippocms.components.Contact.doAction(Contact.java:91)
> >>> ? ? ? ?at org.hippoecm.hst.core.container.HstComponentInvokerImpl.invokeAction(HstComponentInvokerImpl.java:67)
> >>> ? ? ? ?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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
> >>> ? ? ? ?at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
> >>> ? ? ? ?at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
> >>> ? ? ? ?at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
> >>> ? ? ? ?at org.hippoecm.hst.core.logging.HstComponentInvokerProfiler.profile(HstComponentInvokerProfiler.java:70)
> >>> ? ? ? ?at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
> >>> ? ? ? ?at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at
> >>>
> >>> Any idea what this means and how to fix it ?
> >>> thank you.
> >>>
> >>> _______________________________________________
> >>> Hippo-cms7-user mailing list and forums
> >>> http://www.onehippo.org/cms7/support/forums.html
> >>>
> >>
> >>
> >>
> >> --
> >> w.ko at onehippo.com ? ? www.onehippo.com
> >> EUROPE ? AMSTERDAM - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466
> >> NORTH AMERICA ? SAN FRANCISCO - Hippo USA Inc. 185 H Street, Suite B
> >> Petaluma CA 94952 +1 (877) 414-4776
> >>
> >
> >
> >
> > --
> > w.ko at onehippo.com ? ? www.onehippo.com
> > EUROPE ? AMSTERDAM - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466
> > NORTH AMERICA ? SAN FRANCISCO - Hippo USA Inc. 185 H Street, Suite B
> > Petaluma CA 94952 +1 (877) 414-4776
> > _______________________________________________
> > Hippo-cms7-user mailing list and forums
> > http://www.onehippo.org/cms7/support/forums.html
> >
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



More information about the Hippo-cms7-user mailing list