06-16-2011 11:28 AM
06-17-2011 03:24 AM
06-17-2011 11:30 AM
06-17-2011 12:02 PM
06-20-2011 03:37 AM
public int translateStatus()
{
int nbStatus = 0;
buildStatusMap();
SearchParameters sp = new SearchParameters();
sp.addStore(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"));
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.addLocale(Locale.FRENCH);
String query = "(TYPE:\"cm:content\""
+ " OR TYPE:\"" + CeaModel.TYPE_DOCUMENT_PAPIER + "\")"
+ " AND @cm\\:status:*";
sp.setQuery(query);
ResultSet results = null;
if (logger.isDebugEnabled())
logger.debug("Query:\r\n" + query);
try
{
results = this.searchService.query(sp);
if (results.length() > 0) {
int total = results.length();
int nbNodesProcessed = 0;
int percent = 0;
logger.info("Number of nodes to process : "+total);
List<NodeRef> nodeRefList = results.getNodeRefs();
for(NodeRef nodeRef : nodeRefList){
if(nbNodesProcessed != 0 && nbNodesProcessed % 1000 == 0 ){
percent = (100*nbNodesProcessed) / total;
logger.info(nbNodesProcessed+" nodes processed out of "+total+". "+percent+"% complete.");
}
nbNodesProcessed++;
try{
if(this.nodeService.exists(nodeRef)){
logger.debug("NodeRef processed : " + nodeRef);
String oldDocStatus = (String)this.nodeService.getProperty(nodeRef, CeaModel.PROP_STATUS);
String newDocStatus = statusMap.get(oldDocStatus);
if (newDocStatus == null){
if (!statusMap.containsValue(oldDocStatus))
logger.error("Status \"" + oldDocStatus + "\" cannot be renamed (" + nodeRef + ")");
} else {
try{
this.nodeService.setProperty(nodeRef, CeaModel.PROP_STATUS, newDocStatus);
nbStatus++;
logger.debug("Status \"" + oldDocStatus
+ "\" was renamed \"" + newDocStatus + "\"");
} catch (Exception e){
logger.error("Status \"" + oldDocStatus + "\" cannot be renamed (" + nodeRef + ")");
}
}
}
else{
logger.error("NodeRef does not exist : " + nodeRef);
}
}
catch(DataIntegrityViolationException e){
logger.error("NodeRef ignored : "+nodeRef);
e.printStackTrace();
}
}
percent = (100*nbNodesProcessed) / total;
logger.info(nbNodesProcessed+" nodes processed out of "+total+". "+percent+"% complete.");
}
} catch (Exception e){
logger.error("Status translations failed.");
e.printStackTrace();
} finally {
if (results != null)
{
results.close();
}
}
return nbStatus;
}
06-22-2011 12:37 PM
07-05-2011 08:21 AM
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.