Use the cm:attachable aspect with WS

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010 11:55 AM
Hi all,
can anyone help me to add this aspect to a content using WebService API?
THANK YOU
can anyone help me to add this aspect to a content using WebService API?
<aspect name="cm:attachable"> <title>Attachable</title> <associations> <association name="cm:attachments"> <source> <mandatory>false</mandatory> <many>true</many> </source> <target> <class>cm:cmobject</class> <mandatory>false</mandatory> <many>true</many> </target> </association> </associations> </aspect>
THANK YOU
Labels:
- Labels:
-
Archive
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010 07:21 PM
Hi,
Take a look at the update method ( http://wiki.alfresco.com/wiki/Repository_Web_Service#update ) on the Repository web service. You should be able to construct some CML ( http://wiki.alfresco.com/wiki/CML ) to add an aspect to a node.
Alternatively you could take a look at the support for aspects in the CMIS web service API ( http://wiki.alfresco.com/wiki/CMIS#Aspect_Support )
Cheers,
Roy
Take a look at the update method ( http://wiki.alfresco.com/wiki/Repository_Web_Service#update ) on the Repository web service. You should be able to construct some CML ( http://wiki.alfresco.com/wiki/CML ) to add an aspect to a node.
Alternatively you could take a look at the support for aspects in the CMIS web service API ( http://wiki.alfresco.com/wiki/CMIS#Aspect_Support )
Cheers,
Roy

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2010 03:21 AM
OK, I've understand, but it's different from the sample aspect with, for example, type d:text.
If I've this piece of code:
But I don't understand what I must to insert in the ********** piece of code.
PLEASE, CAN YOU HELP ME?
THANK YOU
If I've this piece of code:
CMLAddAspect attachableAspect = new CMLAddAspect("{http://www.alfresco.org/model/content/1.0}attachable", new NamedValue[] { Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}attachments", **********) }, null, contentId);
But I don't understand what I must to insert in the ********** piece of code.
PLEASE, CAN YOU HELP ME?
THANK YOU

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 08:47 PM
Hi,
cm:attachments is an association. You are trying to set it as a property on the aspect in the example code you have provided.
If you are using CML you will need to use the AddAspect command and then the CreateAssociation command to achieve what you want.
Cheers,
Roy
cm:attachments is an association. You are trying to set it as a property on the aspect in the example code you have provided.
If you are using CML you will need to use the AddAspect command and then the CreateAssociation command to achieve what you want.
Cheers,
Roy

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2010 03:34 AM
Thank you for the response.
So, you say me that I use in combination the AddAspect and the CreateAssociation commands?
It's right?
Can you post a sample code?
THANK A LOT
So, you say me that I use in combination the AddAspect and the CreateAssociation commands?
It's right?
Can you post a sample code?
THANK A LOT

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2010 02:11 AM
This code snipit creates a node, adds an aspect and writes some content using CML. This should give an idea of how to combine the addAspect and association commands.
Cheers,
Roy
CMLCreate create = new CMLCreate(); create.setId("id1"); create.setType(Constants.TYPE_CONTENT); ParentReference parentReference = new ParentReference(); parentReference.setAssociationType(Constants.ASSOC_CHILDREN); parentReference.setChildName(Constants.ASSOC_CHILDREN); parentReference.setStore(BaseWebServiceSystemTest.store); parentReference.setUuid(BaseWebServiceSystemTest.rootReference.getUuid()); create.setParent(parentReference); create.setProperty(new NamedValue[] { new NamedValue( Constants.PROP_NAME, false, "name.txt", null)}); // Create a folder used for later tests CMLCreate createFolder = new CMLCreate(); createFolder.setId("folder1"); createFolder.setType(Constants.TYPE_FOLDER); createFolder.setParent(parentReference); createFolder.setProperty(new NamedValue[] { new NamedValue( Constants.PROP_NAME, false, "tempFolder", null)}); CMLAddAspect aspect = new CMLAddAspect(); aspect.setAspect(Constants.ASPECT_VERSIONABLE); aspect.setWhere_id("id1"); ContentFormat format = new ContentFormat(Constants.MIMETYPE_TEXT_PLAIN, "UTF-8"); CMLWriteContent write = new CMLWriteContent(); write.setProperty(Constants.PROP_CONTENT); write.setContent("this is a test".getBytes()); write.setFormat(format); write.setWhere_id("id1"); CML cml = new CML(); cml.setCreate(new CMLCreate[]{create, createFolder}); cml.setAddAspect(new CMLAddAspect[]{aspect}); cml.setWriteContent(new CMLWriteContent[]{write}); UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
Cheers,
Roy
