Unable to perform a versioning operation on a non versionable node

452 views
Skip to first unread message

jimmy...@gmail.com

unread,
Apr 1, 2015, 6:04:45 PM4/1/15
to hippo-c...@googlegroups.com
We are trying tom use the WorkflowPersistenceManager to update docs.  We are running into two big issues:
1. After everything we try we cannot seem to get the correct combination to simply update the document in the JCR.  To that end, we have taken to removing the object from the JCR and then recreating it.
2.  We we try to publish the node, we get the error:  Unable to perform a versioning operation on a non versionable node: /content/documents/subsite/sites/test-site/test-site

The crux of the issue is that the doc is being created, updated, and publish.  We are just seeing these errors in the logs.  Also, if we could use WPM to simply update the docs, without re-creating them, that would be ideal.

The code is below.  Thanks.
public Site updateSite(final Site site,
      final WorkflowPersistenceManager wpm,
      final HstRequestContext requestContext) throws DaoException {

    LOG.warn(site.toString());

    try {
      final HstQueryManager queryManager = requestContext
          .getQueryManager(requestContext.getSession());
      final HstQuery query = queryManager.createQuery(
          requestContext.getSiteContentBaseBean(), Site.class, true);

      final Filter filter = query.createFilter();
      filter.addEqualTo(Site.Attribute.SITE_ID.key, site.getSiteId());
      query.setFilter(filter);

      final HippoBeanIterator hippoBeans = query.execute()
          .getHippoBeans();

      if (hippoBeans.hasNext()) {
        Site bean = (Site) hippoBeans.next();

        if (bean.getSiteId() != null
            && bean.getSiteId().equals(site.getSiteId())) {

          String path = bean.getNode().getParent().getPath();

          Node pathNode = bean.getNode();
          while (!pathNode.getPrimaryNodeType().getName()
              .equals("hippostd:folder")) {
            LOG.warn(pathNode.getPath() + "::"
                + pathNode.getPrimaryNodeType().getName());
            pathNode = pathNode.getParent();
          }

          LOG.warn("Queried Bean Path::" + path);

          Object obj = wpm.getObject(path);

          if (obj != null) {
            // delete the doc and recreate
            wpm.remove(obj);
            wpm.save();

            LOG.warn("REMOVED DOC");
          }

          String beanPath = wpm.createAndReturn(pathNode.getPath(),
              Site.NODE_TYPE, bean.getName(), true);

          LOG.warn("New Bean Path::" + beanPath);

          Site node = (Site) wpm.getObject(beanPath);

          bindDocumentToNode(site, node.getNode());

          wpm.update(node);
          wpm.save();
          publishDoc(wpm, node);
        }
      }
    } catch (IllegalStateException | RepositoryException | QueryException
        | ObjectBeanManagerException e) {
      LOG.warn("Exception while updating Site document.", e);
    }

    return null;
  }

protected void publishDoc(WorkflowPersistenceManager wpm, T docBean)
      throws ObjectBeanPersistenceException {
    wpm.setWorkflowCallbackHandler(new BaseWorkflowCallbackHandler<DocumentWorkflow>() {
      public void processWorkflow(DocumentWorkflow wf)
          throws RepositoryException, RemoteException,
          WorkflowException {
        wf.publish();
      }
    });

    wpm.update(docBean);
    wpm.save();
  }

Jeroen Reijn

unread,
Apr 2, 2015, 4:23:37 AM4/2/15
to hippo-c...@googlegroups.com
Hi Jimmy,

see my comments inline.

On Thu, Apr 2, 2015 at 12:04 AM, <jimmy...@gmail.com> wrote:
We are trying tom use the WorkflowPersistenceManager to update docs.  We are running into two big issues:
1. After everything we try we cannot seem to get the correct combination to simply update the document in the JCR.  To that end, we have taken to removing the object from the JCR and then recreating it.

Well that should not be necessary. What kind of exceptions do you get when not removing the document?
 
2.  We we try to publish the node, we get the error:  Unable to perform a versioning operation on a non versionable node: /content/documents/subsite/sites/test-site/test-site


Well this message should only be the case when a node, which you are performing the action on is not versionable. Could you check the node at /content/documents/subsite/sites/test-site/test-site in the cms console to see if it has the versionable mixin (might be inhereted by the nodetype, i'm not sure). Perhaps you can also check the parent node.
Well i do not see something obvious except that you are calling the wpm.update twice. Can you also show what the bindDocumentToNode method does? 
 

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.



--
Jeroen Reijn
Hippo

Amsterdam office - Oosteinde 11, 1017 WT Amsterdam
Boston office - 745 Atlantic Ave, Eight Floor, Boston MA 02111, United states of America.

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

http://blog.jeroenreijn.com | @jreijn | http://about.me/jeroenreijn

jimmy...@gmail.com

unread,
Apr 2, 2015, 9:44:29 AM4/2/15
to hippo-c...@googlegroups.com, jimmy...@gmail.com
Is there a way to programmatically set the versionable Mixin?


@Override
  protected void bindDocumentToNode(final Site site, Node node)
      throws ValueFormatException, VersionException, LockException,
      ConstraintViolationException, RepositoryException {

    node.setProperty(<key>, site.getSomeField());
    ...
  }

-Jimmy

marijan milicevic

unread,
Apr 2, 2015, 10:09:14 AM4/2/15
to hippo-c...@googlegroups.com, jimmy...@gmail.com
Hi,

On Thu, Apr 2, 2015 at 3:44 PM, <jimmy...@gmail.com> wrote:
Is there a way to programmatically set the versionable Mixin?


node.addMixin("your:mixin") [1]

cheers
marijan 



Jeroen Reijn

unread,
Apr 2, 2015, 12:02:35 PM4/2/15
to hippo-c...@googlegroups.com, jimmy...@gmail.com
Yes but you should not have to do it yourself, so something else might be wrong here, which requires some more research I think.
--
Sent from Gmail Mobile

jimmy...@gmail.com

unread,
Apr 2, 2015, 2:14:29 PM4/2/15
to hippo-c...@googlegroups.com, jimmy...@gmail.com
It would help immensely if there were examples of how to update JCR nodes via the Hippo API using the WorkflowPersistenceManager.  We seem to be stumbling through this process, while many say it should be easy.  We agree that it should be easy, and we are trying to find examples that illustrate the best practices for binding beans to JCR nodes and updating those JCR nodes correctly using Hippo APIs and workflows.

-Jimmy

On Wednesday, 1 April 2015 18:04:45 UTC-4, jimmy...@gmail.com wrote:

Jeroen Reijn

unread,
Apr 3, 2015, 3:21:55 AM4/3/15
to hippo-c...@googlegroups.com, jimmy...@gmail.com
Hi Jimmy,

I'm not sure if you are trying this in the site or from a rest resource. For rest resources you might want to take a look at some of the rest resources in the test suite.


Code wise it's quite the same for site components. 

See this code from the go green demo.


And of course the existing docs.


I think it's good you point this out. I guess te existing docs were not helpful enough. If you have ideas On how to improve or provide more example use cases do let us know, so we can make love easier.

Jeroen
--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages