1

I am trying to set the modifier and modified properties with the custom values in Alfresco using java webscript. I am using the below code for achieving this:

try{

    behaviourFilter.disableBehaviour(mainNodeRef, ContentModel.ASPECT_AUDITABLE);

    serviceRegistry.getNodeService().setProperty(mainNodeRef, ContentModel.PROP_MODIFIED, migValuesVO.getModified());
    serviceRegistry.getNodeService().setProperty(mainNodeRef, ContentModel.PROP_MODIFIER, migValuesVO.getModifier());

}

finally{
    behaviourFilter.enableBehaviour(mainNodeRef, ContentModel.ASPECT_AUDITABLE);
}

This code is working properly in Alfresco community version. This code is not setting the values I have passed to the modifier and modified when I run it in Alfresco enterprise version.

Please help me on how to set the custom values to modifier and modified properties in Alfresco.

Santhosh
  • 55
  • 11

1 Answers1

0

When you're testing your code with Alfresco CE, have you logged in as admin user and when you're testing your code with Alfresco Enterprise, you logged in as non-admin user?

Run your code with elevated privileges like runAsSystem or runAs Admin user like below.

AuthenticationUtil.runAs(new RunAsWork<Void>() {
    @Override
    public Void doWork() throws Exception {
       try{
            behaviourFilter.disableBehaviour(mainNodeRef, ContentModel.ASPECT_AUDITABLE);
            serviceRegistry.getNodeService().setProperty(mainNodeRef, ContentModel.PROP_MODIFIED, migValuesVO.getModified());
            serviceRegistry.getNodeService().setProperty(mainNodeRef, ContentModel.PROP_MODIFIER, migValuesVO.getModifier());
        }
        finally{
            behaviourFilter.enableBehaviour(mainNodeRef, ContentModel.ASPECT_AUDITABLE);
        }
      return null;
    }
  }, ADMIN_USER_NAME);

Note, the above code not tested.

Hope this helps you.

  • I am executing the webscript using runAsSystem in both CE and enterprise versions of Alfresco and still facing this issue Murali. – Santhosh Oct 20 '17 at 06:48