How to add a node to all sites?

cancel
Showing results for 
Search instead for 
Did you mean: 
Member II

How to add a node to all sites?

Hi fellow devs,

What is the easiest way to create a node in all sites?

I'm aware of how to create nodes:
https://api-explorer.alfresco.com/api-explorer/#!/nodes/createNode

And how to get all sites:
https://api-explorer.alfresco.com/api-explorer/#!/sites/listSites

But a bit lost in what is the best way to connect both in order to create a node for all sites...

Any advice you can give?

Thanks for you time Smiley Happy

2 Replies
Moderator
Moderator

Re: How to add a node to all sites?

There is no ootb way to create a node in all available sites in repository at same time. 

If the node is meant to be shared, you should created in "Shared Files". 

If you still need to create the node in each and every available site, then implement a behavior which listens to node creation event, find the available sites before node creation and then loop through all sites and create the node.

Refer this post for more on implementing behaviors: https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html 

https://github.com/jpotts/alfresco-developer-series/blob/sdk-4.0/behaviors/behavior-tutorial/behavio...

Helpful in getting all sites or getting sites based on current user who is logged in via SiteService: 

https://dev.alfresco.com/resource/docs/java/org/alfresco/service/cmr/site/SiteService.html#listSites...

https://dev.alfresco.com/resource/docs/java/org/alfresco/service/cmr/site/SiteService.html#listSites...

NodeCreation via node service:

http://dev.alfresco.com/resource/AlfrescoOne/5.0/PublicAPI/org/alfresco/service/cmr/repository/NodeS...

http://dev.alfresco.com/resource/AlfrescoOne/5.0/PublicAPI/org/alfresco/service/cmr/repository/NodeS...

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)
Member II

Re: How to add a node to all sites?

Many thanks for the feedback  , currently trying to implement the advised solution.
After it will give my feedback how it was implemented.
In this case the folder is not supposed to be shared so I will focus on the other option.
And also thanks for reminding about the node creation event, it will be quite cool if this can be dynamic, in the sense that once the user creates a new node the folder is there.

Cheers, ARamos