Is it possible to create a node in alfresco with a specific NodeRef?

1k Views Asked by At

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?

3

There are 3 best solutions below

1
On BEST ANSWER

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.

0
On

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!

0
On

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.