sitewriter javax.jcr.AccessDeniedException: ... hippostd:state: not allowed to add or modify item

376 views
Skip to first unread message

Tlabs

unread,
Nov 17, 2014, 10:18:53 AM11/17/14
to hippo-c...@googlegroups.com
Hi,
I wrote this code for creation of a HippoDocument(I have a PersistableSession session and WorkflowPersistenceManager wpm):

try {
    wpm.setWorkflowCallbackHandler(new BaseWorkflowCallbackHandler<DocumentWorkflow>() {
        public void processWorkflow(DocumentWorkflow wf) throws Exception {
            wf.requestPublication();
        }
    });
    
    final HstRequestContext requestContext = RequestContextProvider.get();
    
    final String siteCanonicalBasePath = requestContext.getResolvedMount().getMount().getCanonicalContentPath();
    final String dotoItemFolderPath = String.format("%s/%s", siteCanonicalBasePath, 
    JcrContentsScope.HippoCmsAppTodoList.JCR_TODOITEMS_FOLDER);
    
    final String todoNodeName = SlugString.makeSlug(itemDTO.getTitle());
    final String absPathNode = wpm.createAndReturn(dotoItemFolderPath, JcrContentsScope.HippoCmsAppTodoList.JCR_TODO_ITEM_TYPE, todoNodeName, true);//I have an exception here
    final Node todoItemNode = jcrSession.getNode(absPathNode);
    todoItemNode.setProperty("hippocmsapptodolist:title", SimpleHtmlExtractor.getText(itemDTO.getTitle()));
    todoItemNode.setProperty("hippocmsapptodolist:content", SimpleHtmlExtractor.getText(itemDTO.getContent()));
    wpm.update(todoItemNode);
    return true;
} catch (ObjectBeanPersistenceException | RepositoryException e) {
    e.printStackTrace();
}

"wpm.createAndReturn" throws an exception and I receive this message:

[INFO] [talledLocalContainer] org.hippoecm.hst.content.beans.ObjectBeanPersistenceException: javax.jcr.AccessDeniedException: /content/documents/hippocmsapptodolist/todoitems/todo-item-title-5/todo-item-title-5/hippostd:state: not allowed to add or modify item
[INFO] [talledLocalContainer] at org.hippoecm.hst.content.beans.manager.workflow.WorkflowPersistenceManagerImpl.createNodeByWorkflow(WorkflowPersistenceManagerImpl.java:298)
[INFO] [talledLocalContainer] at org.hippoecm.hst.content.beans.manager.workflow.WorkflowPersistenceManagerImpl.createAndReturn(WorkflowPersistenceManagerImpl.java:180)
...
...

Within the jcr repo I can see a new HippoDocument  node and it's in the correct place but my code crashes.
I logged as editor but document is created by sitewriter( I verified mu user by request.getUserPrincipal().getName() and it's ok )

<sv:node sv:name="todo-item-title-5">
  <sv:property sv:name="jcr:primaryType" sv:type="Name">
    <sv:value>hippo:handle</sv:value>
  </sv:property>
  <sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name">
    <sv:value>mix:referenceable</sv:value>
  </sv:property>
  <sv:property sv:name="jcr:uuid" sv:type="String">
    <sv:value>fdad2f56-9969-471d-aacb-241879fdc995</sv:value>
  </sv:property>

  <sv:node sv:name="todo-item-title-5">
    <sv:property sv:name="jcr:primaryType" sv:type="Name">
      <sv:value>hippocmsapptodolist:todoitem</sv:value>
    </sv:property>
    <sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name">
      <sv:value>mix:referenceable</sv:value>
    </sv:property>
    <sv:property sv:name="jcr:uuid" sv:type="String">
      <sv:value>963d3e9f-7b51-46b4-aa9c-378730169dce</sv:value>
    </sv:property>
    <sv:property sv:multiple="true" sv:name="hippo:availability" sv:type="String"/>
    <sv:property sv:name="hippo:related___pathreference" sv:type="String">
      <sv:value>hippocmsapptodolist/todoitems/todo-item-title-5</sv:value>
    </sv:property>
    <sv:property sv:name="hippocmsapptodolist:content" sv:type="String">
      <sv:value/>
    </sv:property>
    <sv:property sv:name="hippocmsapptodolist:title" sv:type="String">
      <sv:value/>
    </sv:property>
    <sv:property sv:name="hippostd:holder" sv:type="String">
      <sv:value>sitewriter</sv:value>
    </sv:property>
    <sv:property sv:name="hippostd:state" sv:type="String">
      <sv:value>draft</sv:value>
    </sv:property>
    <sv:property sv:name="hippostd:stateSummary" sv:type="String">
      <sv:value>new</sv:value>
    </sv:property>
    <sv:property sv:name="hippostdpubwf:createdBy" sv:type="String">
      <sv:value>sitewriter</sv:value>
    </sv:property>
    <sv:property sv:name="hippostdpubwf:creationDate" sv:type="Date">
      <sv:value>2014-11-17T15:46:08.202+01:00</sv:value>
    </sv:property>
    <sv:property sv:name="hippostdpubwf:lastModificationDate" sv:type="Date">
      <sv:value>2014-11-17T15:46:08.202+01:00</sv:value>
    </sv:property>
    <sv:property sv:name="hippostdpubwf:lastModifiedBy" sv:type="String">
      <sv:value>sitewriter</sv:value>
    </sv:property>
    <sv:property sv:name="hippotranslation:id" sv:type="String">
      <sv:value>51143f24-a5f2-4c94-bacb-6b765979c3e4</sv:value>
    </sv:property>
    <sv:property sv:name="hippotranslation:locale" sv:type="String">
      <sv:value>en</sv:value>
    </sv:property>
  </sv:node>

</sv:node>



I don't understand.
Help please

Jeroen Reijn

unread,
Nov 17, 2014, 10:31:50 AM11/17/14
to hippo-c...@googlegroups.com
Hi,

it seems the user cannot write to the repository. Did you enable write permissions for the site user?


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.



--
Jeroen Reijn
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 101 Main Street, Cambridge, MA 02142

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

http://blog.jeroenreijn.com
http://about.me/jeroenreijn

Tlabs

unread,
Nov 17, 2014, 11:22:10 AM11/17/14
to hippo-c...@googlegroups.com
Ok...sorry, it's ok.

I have two unclear scenarios:

(1). I set title and content but are empty.

My code:

final String absPathNode = wpm.createAndReturn(dotoItemFolderPath, JcrContentsScope.HippoCmsAppTodoList.JCR_TODO_ITEM_TYPE, todoNodeName, true);
final Todoitem todoItemHippoBean = (Todoitem)wpm.getObject(absPathNode);

todoItemHippoBean.getNode().setProperty("hippocmsapptodolist:title", SimpleHtmlExtractor.getText(itemDTO.getTitle()));

todoItemHippoBean.getNode().setProperty("hippocmsapptodolist:content", SimpleHtmlExtractor.getText(itemDTO.getContent()));

wpm.update(todoItemHippoBean);


(2). I logged as editor and I verified my user by request.getUserPrincipal() and it's ok, but the new document author is "sitewriter".
How I can authenticate as editor to jcr and create the new document?

Thanks

Niels van Kampenhout

unread,
Nov 18, 2014, 2:35:18 PM11/18/14
to hippo-c...@googlegroups.com
As explained at [1] (already linked to by Jeroen), you need to assign
the correct permissions to the "sitewriters" group.

Also, as explained in the other thread you started, you must implement
ContentNodeBinder in your content bean. See the example at [2].

Hope this helps.
Niels

[1] http://www.onehippo.org/library/concepts/security/access-rights-when-you-want-to-use-workflow-from-the-hst.html
[2] http://www.onehippo.org/library/concepts/component-development/hstcomponent-persistable-annotation-and-workflow.html
Boston - 745 Atlantic Ave, Third Floor, MA 02111
Reply all
Reply to author
Forward
0 new messages