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;

}

No comments:

Post a Comment