Hi mrogers,
Please find the entire code of GetNodeUUID below.
Please help
Thanks
Benson
[code
package test;
import org.alfresco.webservice.repository.QueryResult;
import org.alfresco.webservice.types.Query;
import org.alfresco.webservice.types.ResultSet;
import org.alfresco.webservice.types.ResultSetRow;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.WebServiceFactory;
public class GetNodeUUID{
public static final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
public static String getNodeUUID(String rootPath,String folderName){
String uuid="";
try {
Query query = new Query(
Constants.QUERY_LANG_LUCENE,
"PATH :\"//"+rootPath+"//*\" "
+ " AND @cm\\:name:\""+escapeStr(folderName)+"\""
+ " AND TYPE:\"cm:folder\""
);
System.out.println(query.getStatement());
QueryResult queryResult=null;
queryResult = WebServiceFactory.getRepositoryService().query(STORE, query, false);
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if(rows.length>0){
System.out.println(" UUID ID :"+rows[0].getNode().getId());
uuid= rows[0].getNode().getId();
resultSet=null;
rows=null;
}
} catch(Exception e) {
e.printStackTrace();
}
return uuid;
}
public static String escapeStr(String inStr){
StringBuilder resultStr=new StringBuilder();
for (int i=0;i<inStr.length();i++){
char c=inStr.charAt(i);
if(c=='('||c==')'){
resultStr.append("\\");
}
resultStr.append©;
}
return resultStr.toString();
}
}
]