cancel
Showing results for 
Search instead for 
Did you mean: 

Api to update the 'Content Type' of the document

maheshkr81
Champ in-the-making
Champ in-the-making
Hi,

I need to know whether alfresco provides any Webservice Api's to Update both Content Type and its Properties of the document.

Below scenario explains what exactly I need to do….

1. Add a content with content type as 'X' (child of cm:content) .
2. Update the content type from  'X' to 'Y' (child of cm:content)

I tried to use CMLUpdate() Api to update both content type and its Properties, but its not working .

Please help me.

Thanks,
Mahesh
4 REPLIES 4

madez
Champ in-the-making
Champ in-the-making
I have the same question!

I don't find a web service that could solve this problem.

And I have think about to define a rule in the space to convert a type A to a type B. Is it possible?

Or anyone have other suggestions???

Regards
Marco

alexey
Champ in-the-making
Champ in-the-making
I'd got the same question, but i couldn't find answer.

icandir
Champ in-the-making
Champ in-the-making
I finally find the solution to update a document its name contentformat etc here is the code
public Reference updateFile(String uuid, String fileName, byte[] bytes){      Content content = new Content();      try {         content = findContentWithUUID(uuid);         // Set content         Reference reference = content.getNode();         NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, fileName)};         CMLUpdate update = new CMLUpdate(properties, new Predicate(               new Reference[] { reference }, STORE, null), "id2");                 CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_VERSIONABLE, null, new Predicate(               new Reference[] { reference }, STORE, null), "id1");         CML cml = new CML();         cml.setUpdate(new CMLUpdate[]{update});         cml.setAddAspect(new CMLAddAspect[]{addAspect});         //update document properties name         UpdateResult[] updateResults = getRepositoryService().update(cml);                     ContentFormat format = new ContentFormat(               findMimeType(fileName.substring(fileName.lastIndexOf(".")+1)), "UTF-8");                        //update the content of document         Content content2 = getContentService().write(content.getNode(), Constants.PROP_CONTENT, bytes, format);                  System.out.println(content2.getLength() + fileName + "  updated…");      } catch (Exception e) {         e.printStackTrace();      }      return reference;   }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

erolozcan
Champ in-the-making
Champ in-the-making
Icandir, can you share your "findMimeType()" method implementation details? Thanks..