Hi
I'm facing a strange problem. In my application there is a button which trigger a method that connect to the alfresco repository via the webservice api, searches for some nodes and changes some of their properties' content.The first time the connection is made, it works perfectly. I use a lucene query to find a node according to a custom xpath property and I update its tag property. When it's done, I log in the web client to check that the changes have been made and they are.Then, I click again on my button and this time, the lucene query doesn't find the document, although it is exactly the same query with the same xpath property.I made some tests and I found out that if I restart the alfresco server, the method works again. Another thing is that if I clear the Firefox cache, it works again.It looks like it could have something to do with the alfresco session, in my application or in Firefox, but I'm not sure and I don't have enough experience in this domain to find what's happening. Here is my code:
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();
}
Thank you
Regards.