09-30-2010 11:06 AM
try {
Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
Reference CUSTOM_COMPANY_NODE = new Reference(STORE, null, "/app:company_home/custom:company_home");
WebServiceFactory.setEndpointAddress(this.repositoryURL);
AuthenticationUtils.startSession("admin", "admin");
monitor.subTask("Connection established");
// get services
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
// Check to see if the custom company root node has already been created or not
Node[] companyRootNode = repositoryService.get(new Predicate(new Reference[]{CUSTOM_COMPANY_NODE}, STORE, null));
if(companyRootNode != null && companyRootNode.length > 0){
// start to iterate through the tags list…
for(Entry<String, List<String>> entry : tagsList.entrySet()){
String docXpath = entry.getKey();
List<String> docTagsList = entry.getValue();
timestamp = getUpdateTimestamp(docTagsList);
monitor.subTask("copying tags for document '" + URLDecoder.decode(docXpath, "UTF-8") + "'");
Query query = new Query(Constants.QUERY_LANG_LUCENE, "+@mcm\\:xPath:\"*" + docXpath + "*\" AND TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"");
QueryResult queryResult = repositoryService.query(STORE, query, false);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows != null){
updateTagProperties(STORE, repositoryService, rows, docTagsList, timestamp, ADD_ACTION);
}
}
// clean tags that have been deleted
Query query = new Query(Constants.QUERY_LANG_LUCENE, "+TYPE:\"{http://www.alfresco.org/model/content/1.0}content\" AND +@tag\\:tags:* AND -@tag\\:timestamp:\""+ timestamp+"\"");
QueryResult queryResult = repositoryService.query(STORE, query, false);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows != null){
updateTagProperties(STORE, repositoryService, rows, null, timestamp, REMOVE_ACTION);
}
} else {
monitor.subTask("Error : client company home space does not exist yet…");
}
} catch (AuthenticationFault e){
monitor.subTask("connexion to Alfresco failed…");
} catch (Exception e){
monitor.subTask("error during tags copy");
} finally {
AuthenticationUtils.endSession();
}
10-11-2010 06:39 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.