Showing posts with label noderef. Show all posts
Showing posts with label noderef. Show all posts

Thursday, December 26, 2013

Creating new nodeRef - Alfresco API



Sometime we need to create alfresco node and need to proceed that node. We can create alfresco node but for that we need store to choose, in which store that node will store its content.

e.g.
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
NodeRef nodeRef = new NodeRef(storeRef, "f8785545-beb0-4e4c-aedc-72a8db70bb30");


Here we used "SpacesStore" as the alfresco store area.

We can have following stores available :
archive://SpacesStore
system://system
user://alfrescoUserStore
workspace://lightWeightVersionStore
workspace://SpacesStore
workspace://version2Store


Friday, July 26, 2013

Getting nodeRef via resolveNamePath

Another way using we can get nodeRef of the content / folder in alfresco.

e.g If we have folder structure in DM is like below :
Company Home > Project > Draft > Account > Order
and we want nodeRef of Order folder we can get like below :

//Normal class
private NodeRef getOrderNodeRef() {

try {

NodeRef companyHomeRef = repoHelper.getCompanyHome();

List<String> pathElements = MyUtility.getOrderPathElements();

FileInfo info = this.getFileFolderService().resolveNamePath(companyHomeRef, pathElements);

return info.getNodeRef();

} catch (FileNotFoundException e)


     {
               e.printStackTrace();
     }
}
//MyUtility class
public static List<String> getOrderPathElements() {

List<String> pathElements = new ArrayList<String>();

pathElements.add(COSTANT_FOLDER_PROJECT);

pathElements.add(COSTANT_FOLDER_DRAFT);

pathElements.add(COSTANT_FOLDER_ACCOUNT);

pathElements.add(COSTANT_ORDERS_FOLDER_ORDER);

return pathElements;

}

Getting parent nodeRef in alfresco



Sometime we require to populate nodes and require parent nodeRef of the given node.
Following snippet will help us to get the parent nodeRef :

NodeRef titleRef = getNodeService().getPrimaryParent(contentXMLNodeRef).getParentRef();

hope this helps !