Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-2844

"Cannot set property of a checked-in node" when invoking FullReviewedActionsWorkflow.delete()

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • r2.06.06 (m13 - rc7)
    • r2.11.00
    • None
    • None
    • ubuntu

    Description

      I'm trying to delete a document from a client app, I wrote some code for that using the FullReviewedActionsWorkflow. I first look for a published document, and if that exists, I unpublish it first. After that, I look up the unpublished version of the document and invoke delete(). The result is that the document is deleted, but I get an exception:

      javax.jcr.version.VersionException: node /content/attic/2009/7/16/DocumentA/DocumentA/links/link: : cannot set property of a checked-in node
      at org.apache.jackrabbit.core.NodeImpl.checkSetProperty(NodeImpl.java:1287)
      at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:2297)
      at org.hippoecm.repository.decorating.NodeDecorator.setProperty(NodeDecorator.java:157)
      at org.hippoecm.repository.impl.WorkspaceDecorator$2.leaving(WorkspaceDecorator.java:210)
      at javax.jcr.util.TraversingItemVisitor.visit(TraversingItemVisitor.java:183)
      at org.hippoecm.repository.decorating.ItemVisitorDecorator.visit(ItemVisitorDecorator.java:48)
      at org.apache.jackrabbit.core.NodeImpl.accept(NodeImpl.java:2062)
      at org.hippoecm.repository.decorating.ItemDecorator.accept(ItemDecorator.java:138)
      at javax.jcr.util.TraversingItemVisitor.visit(TraversingItemVisitor.java:179)
      at org.hippoecm.repository.decorating.ItemVisitorDecorator.visit(ItemVisitorDecorator.java:48)
      at org.apache.jackrabbit.core.NodeImpl.accept(NodeImpl.java:2062)
      at org.hippoecm.repository.decorating.ItemDecorator.accept(ItemDecorator.java:138)
      at javax.jcr.util.TraversingItemVisitor.visit(TraversingItemVisitor.java:179)
      at org.hippoecm.repository.decorating.ItemVisitorDecorator.visit(ItemVisitorDecorator.java:48)
      at org.apache.jackrabbit.core.NodeImpl.accept(NodeImpl.java:2062)
      at org.hippoecm.repository.decorating.ItemDecorator.accept(ItemDecorator.java:138)
      at javax.jcr.util.TraversingItemVisitor.visit(TraversingItemVisitor.java:179)
      at org.hippoecm.repository.decorating.ItemVisitorDecorator.visit(ItemVisitorDecorator.java:48)
      at org.apache.jackrabbit.core.NodeImpl.accept(NodeImpl.java:2062)
      at org.hippoecm.repository.decorating.ItemDecorator.accept(ItemDecorator.java:138)
      at org.hippoecm.repository.impl.WorkspaceDecorator.touch(WorkspaceDecorator.java:201)
      at org.hippoecm.repository.impl.WorkspaceDecorator.move(WorkspaceDecorator.java:239)
      at org.hippoecm.repository.standardworkflow.FolderWorkflowImpl.doArchive(FolderWorkflowImpl.java:251)
      at org.hippoecm.repository.standardworkflow.FolderWorkflowImpl.archive(FolderWorkflowImpl.java:317)
      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.hippoecm.repository.impl.WorkflowManagerImpl$WorkflowInvocationHandler.invoke(WorkflowManagerImpl.java:508)
      at $Proxy2.archive(Unknown Source)
      at org.hippoecm.repository.standardworkflow.DefaultWorkflowImpl.archive(DefaultWorkflowImpl.java:119)
      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.hippoecm.repository.impl.WorkflowManagerImpl$WorkflowInvocationImpl.invoke(WorkflowManagerImpl.java:819)
      at org.hippoecm.repository.impl.WorkflowManagerImpl$WorkflowInvocationHandler.invoke(WorkflowManagerImpl.java:524)

      my code is as follows:

      protected Node getUnpublishedVariant(Node handle) throws RepositoryException

      { return getVariant(handle, "unpublished"); }

      protected Node getPublishedVariant(Node handle) throws RepositoryException

      { return getVariant(handle, "published"); }

      private Node getVariant(Node handle, String variant) throws RepositoryException{
      NodeIterator nodeIter = handle.getNodes();
      while (nodeIter.hasNext()){
      Node child = nodeIter.nextNode();
      String state = null;
      try

      { Property prop = child.getProperty("hippostd:state"); state = prop.getString(); }

      catch (PathNotFoundException pnfe){

      }
      if (variant.equals(state))

      { return child; }

      }
      return null;
      }

      protected void deleteNode(HippoWorkspace workspace, Node handleNodeToBeDeleted)
      throws RepositoryException, WorkflowException, RemoteException {

      Session session = handleNodeToBeDeleted.getSession();

      // first unpublish if published
      Node publishedNode = getPublishedVariant(handleNodeToBeDeleted);
      if (publishedNode != null){
      FullReviewedActionsWorkflow workflow = getWorkflowForConcreteNode(handleNodeToBeDeleted.getSession(),publishedNode);
      if (workflow == null)

      { throw new ContentException("Could not find a workflow for node at "+handleNodeToBeDeleted.getPath()); }

      workflow.depublish();
      }

      // next, delete unpublished version
      Node unpublishedNode = getUnpublishedVariant(handleNodeToBeDeleted);
      if (unpublishedNode == null)

      { throw new ContentException("Could not find unpublished version of "+handleNodeToBeDeleted.getPath()); }

      FullReviewedActionsWorkflow workflow = getWorkflowForConcreteNode(handleNodeToBeDeleted.getSession(),unpublishedNode);
      if (workflow == null)

      { throw new ContentException("Could not find a workflow for node at "+handleNodeToBeDeleted.getPath()); }

      workflow.delete();
      }

      protected FullReviewedActionsWorkflow getWorkflowForConcreteNode(Session session, Node concreteNode) throws RepositoryException {
      WorkflowManager workflowManager = ((HippoWorkspace)session.getWorkspace()).getWorkflowManager();
      Workflow reviewedActionsWorkflow = workflowManager.getWorkflow("default", concreteNode);
      if (reviewedActionsWorkflow instanceof FullReviewedActionsWorkflow)

      { return (FullReviewedActionsWorkflow) reviewedActionsWorkflow; }

      else

      { return null; }

      }

      Attachments

        Issue Links

          Activity

            People

              berry van halderen Berry van Halderen (Inactive)
              dennis dam Dennis Dam (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 3 hours
                  3h
                  Remaining:
                  Remaining Estimate - 3 hours
                  3h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified