Create link to a folder.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2014 03:11 PM
Hi
I need to create a webscript to make links to folders from one site to another but I cannot find a function to do it, is there any function for this? I know there is a type link but I don't know how to create a node of that type.
Any help would be appreciated.
I need to create a webscript to make links to folders from one site to another but I cannot find a function to do it, is there any function for this? I know there is a type link but I don't know how to create a node of that type.
Any help would be appreciated.
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2014 02:43 AM
There is no difference between creating a node of link type and creating a node of other types.
Just passing ApplicationModel.TYPE_FILELINK or ApplicationModel.TYPE_FOLDERLINK as nodeTypeQName to NodeService.createNode() method,and adding ContentModel.PROP_LINK_DESTINATION property to your properties map will be ok.
ApplicationModel.TYPE_FILELINK and ApplicationModel.TYPE_FOLDERLINK are subtypes of cm:link.
Here is an example:
Just passing ApplicationModel.TYPE_FILELINK or ApplicationModel.TYPE_FOLDERLINK as nodeTypeQName to NodeService.createNode() method,and adding ContentModel.PROP_LINK_DESTINATION property to your properties map will be ok.
ApplicationModel.TYPE_FILELINK and ApplicationModel.TYPE_FOLDERLINK are subtypes of cm:link.
Here is an example:
Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_NAME, "an link node"); props.put(ContentModel.PROP_LINK_DESTINATION, folder red); // create File Link node ChildAssociationRef childRef = nodeService.createNode( parentRef, ContentModel.ASSOC_CONTAINS, QName.createQName(namespaceuri, "an link node"), ApplicationModel.TYPE_FOLDERLINK, props);
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2014 10:01 AM
Thanks for your answer kaynezhang, I tried that way but I couldn't make it work, but I was able to resolve it doing the following:
<javascript>
var result = node; //Target node
var path = companyhome.childByNamePath("Sites/comex-y-logistica/documentLibrary/Comex y Logistica"); //Where I create the link
pr["cm:name"] = node.name+" link.url";
pr["cm:destination"] = node.nodeRef; //(Alfresco Target Node Reference)
pr["cm:title"] = node.name+" enlace";
pr["cm:description"] = node.name+" link";
linkNode = path.createNode(node.name+ "link.url", "{http://www.alfresco.org/model/application/1.0}filelink", pr);
linkNode.save();
</javascript>
<javascript>
var result = node; //Target node
var path = companyhome.childByNamePath("Sites/comex-y-logistica/documentLibrary/Comex y Logistica"); //Where I create the link
pr["cm:name"] = node.name+" link.url";
pr["cm:destination"] = node.nodeRef; //(Alfresco Target Node Reference)
pr["cm:title"] = node.name+" enlace";
pr["cm:description"] = node.name+" link";
linkNode = path.createNode(node.name+ "link.url", "{http://www.alfresco.org/model/application/1.0}filelink", pr);
linkNode.save();
</javascript>
