1

I'm currently using openCMIS to create a node inside Alfresco. I want to specify that the newly made content uses a specific nodeRef id. For example:

workspace://SpacesStore/6e619192-61c0-46fc-85c1-81badbb9b93e

Currently I have this CMIS code:

Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, "TestFolder");
properties.put(PropertyIds.OBJECT_ID, "workspace://SpacesStore/6e619192-61c0-46fc-85c1-81badbb9b93e");
folder.createFolder(properties);

I want it that the newly made folder Names "TestFolder" has an nodeRef that matches the OBJECT_ID specified. However Alfresco still generates a different unique nodeRef.

Is there a way to specify a nodeRef when creating content in Alfresco?

Kevin Groen
  • 918
  • 1
  • 8
  • 20

3 Answers3

1

No, it is not possible to set your own node reference. It's an implementation detail that, in theory, you shouldn't care about.

However, you may have a valid reason for this (for example, importing data from an existing repository?). If for some reason you need to keep this node reference, consider storing this noderef as a separate metadata property.

You may want to submit a separate question explaining in more detail why you want to do something like this.

luiscolorado
  • 1,525
  • 2
  • 16
  • 23
  • It's as you said. I want to import data from an already existing repository. There are third party applications that reference to the nodeRefs. Therefore I want to retain the same nodeRefs when migrating the content – Kevin Groen Mar 31 '17 at 08:09
1

I will preface this by saying - there isn't a public API for this for a reason! You really shouldn't be doing that in normal use...

If you want to create a node with a well-known node reference, you should create an ACP file and bootstrap it in. This is how Alfresco creates some well known nodes, such as rendering_actions_space at /app:company_home/app:dictionary/app:rendering_actions with noderef workspace://SpacesStore/rendering_actions_space . See here in the Alfresco source code on github for how to do that

If you really really need to create a node with a specific noderef, which you normally don't, you can pass the ContentModel.PROP_NODE_UUID property to the NodeService, as part of the properties when creating a node, and if possible that'll be used to set the ID part of the new noderef. Generally though, you shouldn't be doing this!

Gagravarr
  • 47,320
  • 10
  • 111
  • 156
0

Actually, you could write Java class and provide Properties for node when creating it. If you will provide node-uuid, node will be created with it, and NodeRef consists basically of storeref and node-uuid.