cancel
Showing results for 
Search instead for 
Did you mean: 

update node properties via web services

ethan
Champ in-the-making
Champ in-the-making
Hello Smiley Happy

I'm trying to write a class which get a content via a lucene query, very if the content has a custom aspect and then update a specific property inside this aspect.
I'm new to the web service api. I've read the sample codes in the SDK but there are some points I don't understand…

Here is my current code :

// 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];‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I don't know what to do with my Content object. Could you give me a hand please ? Smiley Happy

Thank you.
2 REPLIES 2

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

You can find information about the Content object here http://wiki.alfresco.com/wiki/Content_Web_Service#Content

What do you want to do with the Content object?

Cheers,
Roy

ethan
Champ in-the-making
Champ in-the-making
Hi Smiley Happy

I would like to check if my content has the aspect tag:taggable ( or has the property tag:tags which is part of the tag:taggable aspect), add it if it's not the case and then set the property tag:tags.

I've changed a part of the code :

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…");}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Regarding performances is it better to use CMLupdate or Content object ?