cancel
Showing results for 
Search instead for 
Did you mean: 

Create tags via Webservice [urgent Pls Help]

jithusuji
Champ in-the-making
Champ in-the-making
Can somebody please help me its really urgent  Smiley Sad , I am using .net C# and alfresco webservices,
I want to create tags from my webservices and apply these tags to the file i upload from my application via webservices,
Is this possible is tagging services exposed on webservices, i am using alfresco 3.2
Any help is really appreciated……
11 REPLIES 11

jcustovic
Champ in-the-making
Champ in-the-making
You simply apply aspect CLASSIFIABLE and with property CATEGORIES and add categories you want.
In java it would look like

CMLAddAspect tagAspect = new CMLAddAspect(Constants.ASPECT_CLASSIFIABLE, new NamedValue[] { new NamedValue(PropertyNames.PROP_CATEGORIES, true, null, new String[] { yourCategoriesArray }) }, null, "1");

alv21
Champ in-the-making
Champ in-the-making
Hi,
I'm using Alfresco 4 java web services API and I'm trying to add a tag to a content node in Alfresco.
I'm trying your example:
   CMLAddAspect tagAspect = new CMLAddAspect(Constants.ASPECT_CLASSIFIABLE, new NamedValue[] { new NamedValue(PropertyNames.PROP_CATEGORIES, true, null, new String[] { yourCategoriesArray }) }, null, "1");
but I can't find the string PropertyNames.PROP_CATEGORIES. where should it be?

EDIT: the last post by _jcn explain clearly how to solve the tagging issue. thanks

jithusuji
Champ in-the-making
Champ in-the-making
@jcustovic
Thanks a lot for your reply But i am trying this in C# and the CMLAddaspect class Constructor is taking 0 arguments. :?
I dont know what is wrong, really worried now its an urgent work to be finished.

jcustovic
Champ in-the-making
Champ in-the-making
Try to see if there are getters and setters. I don't know C# so this is as far as I can help you…

jithusuji
Champ in-the-making
Champ in-the-making
Thanks again, i really appreciate your help. This is what i get when creating an object of the CMLAddaspect class


                CMLAddAspect tag1 = new CMLAddAspect();
                tag1.aspect = "tag";
                tag1.property = tagproperties;
                tag1.where_id = "1";
do you can any idea what should be the values for aspect ,property,where,where_id for tagging..

Thanks in Advance

jcustovic
Champ in-the-making
Champ in-the-making
Aspect name should be {http://www.alfresco.org/model/content/1.0}classifiable
Property is NamedValue object with name {http://www.alfresco.org/model/content/1.0}categories and your categories array as values (see above java example)
And you can use where or where_id. If you use where then you set your Predicate (new Predicate(new Reference[] { reference }, WORKSPACE_STORE, null); this is typically used when updating node and when you have a valid reference to your node) or you can use where_id (that is the same where_id of your CMLCreate and is used when you create the node for the first time so you can create and add aspect in one request)

jithusuji
Champ in-the-making
Champ in-the-making
Could you please tell me is the where_id is the guid of the document in alfresco
like 125d8132-91b9-4ca2-95aa-8e8736813256

jcustovic
Champ in-the-making
Champ in-the-making
No its not.
When you create node ref using CMLCreate your specified where_id because you do not have uuid because you are about to create a new node and that id is used to determin on which newly created node will you apply your aspect.
For example in one request I want to create 3 documents and apply aspects to them. I will create 3 CMLCreate and I will set where_id to "1", "2" and "3". After that i will apply aspects to those 3 (not yet created nodes) by creating 3 CMLAddAspect with where_id set to "1", "2" and "3" (linking them to correct CMLCreate). So that where_id is used to link yet to be created nodes with other actions in one request. Without that where_id you would have to make 2 request (in first request create node and get it's UUID and i second apply aspects).

If you want to update aspects then you cant use where_id (because it doesn't exist it is only used on first node creation), but use when instead which is reference (Predicate) of the actual existing node.

jithusuji
Champ in-the-making
Champ in-the-making
Thanks for you patience @jcustovic but i am really pulling my hair now  :cry:

                CMLCreate create = new CMLCreate();
                create.parent = parentReference;
                create.id = "1";
                create.type = Constants.TYPE_CONTENT;
                create.property = properties;
                taggable[0] = tag1;
This is my code for creating the file there is no where_id for CMLCreate but create.id = "1";
I gave the same id as the where_id for aspect, but it is resulting in SOAP exception (which do not have any further details)
But i think with your help i am almost there but i am missing something…
Thanks