Assign custom content type

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2010 05:54 AM
Hi all
I've succesfully created folder and files on alfresco server using web services API.
I can't assign a custom content type.
For example i have set a content type with this namespace
This is the code I use to write file on Alfresco
How can i assign the type mf.modFatture to the file just created??
Thanks
I've succesfully created folder and files on alfresco server using web services API.
I can't assign a custom content type.
For example i have set a content type with this namespace
<namespaces> <namespace uri="mf.modFatture" prefix="mf"/> </namespaces>
This is the code I use to write file on Alfresco
ParentReference parentReference = new ParentReference( STORE, Uuid, null, Constants.ASSOC_CONTAINS, Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, idCartella)); // Create the content NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, nomeFile)}; CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_CONTENT, properties); CML cml = new CML(); cml.setCreate(new CMLCreate[]{create}); UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml); // Get the created node and create the format Reference newContentNode = result[0].getDestination(); ContentFormat format = new ContentFormat("image/jpeg", "UTF-8"); // Open the file and convert to byte array //InputStream viewStream = newContentNode.getClass().getClassLoader().getResourceAsStream("c:\\Agenti\\" + nomeFile); // Write the content InputStream inpStr = new FileInputStream("c:\\Agenti\\" + nomeFile); byte[] bytes = ContentUtils.convertToByteArray(inpStr); WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, bytes, format);
How can i assign the type mf.modFatture to the file just created??
Thanks
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2010 08:32 AM
You have to specify the content type in the CMLCreate object:
String contentType = "{mf.modFatture}yourCustomContentTypeLocalName";CMLCreate create = new CMLCreate("1", parentReference, null, null, null, contentType, properties);
Hope this helps.
