cancel
Showing results for 
Search instead for 
Did you mean: 

change the childtype of a DocumentLibrary to cm:folder

yohanmaker
Champ on-the-rise
Champ on-the-rise

hello everyone, and thanks for reading this,

the document Library of one of my sites changed unexpectly to "type: websiteContainer", now it is not accesible anymore from the front-end in share.

is there a way to change it back to "type: cm_folder"?

image

1 ACCEPTED ANSWER

abhinavmishra14
World-Class Innovator
World-Class Innovator

You can use JSConsole or write a js repository webscript to change the type back to cm:folder. You can use nodeService's setType method to change the type.

These amps works with acs7 if you would like to install and use the JSConsole:

https://github.com/abhinavmishra14/js-console/releases/download/0.7-rc/javascript-console-repo-0.7.a...

https://github.com/abhinavmishra14/js-console/releases/download/0.7-rc/javascript-console-share-0.7....

Here is a video on how to use it: https://www.youtube.com/watch?v=c3JIeVY8Nnk

Here is a sample code that can be used to change the type via JSConsole:

var nodeRefStr = 'workspace://SpacesStore/e0df9384-9472-472e-95c0-2e091f452700'; //Node ref of the corrupted folder
try {
	var node=search.findNode(nodeRefStr);
	logger.log("NodeRef: "+ node.nodeRef+" | Name: "+node.name)
        var ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
        var nodeService =  ctxt.getBean('NodeService', org.alfresco.service.cmr.repository.NodeService);
        var QName = Packages.org.alfresco.service.namespace.QName;
        var nodeTypeFolder = QName.createQName("{http://www.alfresco.org/model/content/1.0}folder");
        nodeService.setType(node.nodeRef, nodeTypeFolder);
} catch (ex) {
   logger.log("Exception occurred: " + ex.message);
}

If you prefer to use js repository web script, here are the documentations to start with:

https://docs.alfresco.com/content-services/7.0/tutorial/platform/web-scripts/

https://docs.alfresco.com/content-services/5.2/develop/repo-ext-points/web-scripts/

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View answer in original post

2 REPLIES 2

abhinavmishra14
World-Class Innovator
World-Class Innovator

You can use JSConsole or write a js repository webscript to change the type back to cm:folder. You can use nodeService's setType method to change the type.

These amps works with acs7 if you would like to install and use the JSConsole:

https://github.com/abhinavmishra14/js-console/releases/download/0.7-rc/javascript-console-repo-0.7.a...

https://github.com/abhinavmishra14/js-console/releases/download/0.7-rc/javascript-console-share-0.7....

Here is a video on how to use it: https://www.youtube.com/watch?v=c3JIeVY8Nnk

Here is a sample code that can be used to change the type via JSConsole:

var nodeRefStr = 'workspace://SpacesStore/e0df9384-9472-472e-95c0-2e091f452700'; //Node ref of the corrupted folder
try {
	var node=search.findNode(nodeRefStr);
	logger.log("NodeRef: "+ node.nodeRef+" | Name: "+node.name)
        var ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
        var nodeService =  ctxt.getBean('NodeService', org.alfresco.service.cmr.repository.NodeService);
        var QName = Packages.org.alfresco.service.namespace.QName;
        var nodeTypeFolder = QName.createQName("{http://www.alfresco.org/model/content/1.0}folder");
        nodeService.setType(node.nodeRef, nodeTypeFolder);
} catch (ex) {
   logger.log("Exception occurred: " + ex.message);
}

If you prefer to use js repository web script, here are the documentations to start with:

https://docs.alfresco.com/content-services/7.0/tutorial/platform/web-scripts/

https://docs.alfresco.com/content-services/5.2/develop/repo-ext-points/web-scripts/

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

Namaskaram abhinavmishra14,  I have been trying to solve this problem for almost one month and i gave up at some point and this generated a lot of work, and lost time. if you are interested and your current situation allows it, i would like to stay in contact with you for future consultancies. regards. Yohan