09-23-2010 10:05 AM
// get the corresponding nodeRef in the Repository
Query query = new Query(Constants.QUERY_LANG_LUCENE, "+TYPE:\"mcm:resource\" AND +PATH:\"/app:company_home/custom:company_home//*\" AND +@mcm\\:xpath:\"" + docXpath + "\"");
QueryResult queryResult = repositoryService.query(STORE, query, false);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows != null){
// Get the id of the first result
String firstResultId = rows[0].getNode().getId();
Reference reference = new Reference(STORE, firstResultId, null);
// Read the node from the respository
Content[] readResult = contentService.read(
new Predicate(new Reference[]{reference}, STORE, null),
Constants.PROP_CONTENT);
Content content = readResult[0];
09-24-2010 02:24 AM
09-24-2010 04:07 AM
if (rows != null){
// Create a reference to the node to manage its content
String firstResultId = rows[0].getNode().getId();
Reference reference = new Reference(STORE, firstResultId, null);
Predicate p = new Predicate(new Reference[]{reference},STORE,null);
// get tags and tags'xpaths as arrays
String[] tags = getTagsFromXpathAsArray(docTagsList);
String[] xpaths = getTagsXpathsAsArray(docTagsList);
// create CMLUpdate instances to update corresponding properties.
CMLUpdate updateTagsXpaths = new CMLUpdate( new NamedValue[]{Utils.createNamedValue(TAG_XPATH_PROP, xpaths)},p,null);
CMLUpdate updateTags = new CMLUpdate( new NamedValue[]{Utils.createNamedValue(TAG_TAGS_PROP, tags)},p,null);
// create a CML instance and execute updates.
CML cml = new CML();
cml.setUpdate(new CMLUpdate[]{updateTagsXpaths,updateTags});
UpdateResult[] result = repositoryService.update(cml);
System.out.println("tags successfully copied…");
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.