cancel
Showing results for 
Search instead for 
Did you mean: 

Update Alfresco Aspect Properties Via DotCMIS

phil_barr
Champ in-the-making
Champ in-the-making
Hi all,

I have successfully managed to retrieve attributes belonging to an aspect (such as cm:description and cm:title) using the Extensions available through the DotCmis API. Is there any way to update these properties using DotCmis also?

I have tried adding the aspect properties to the properties passed in the document.UpdateProperties() method, which throws a "property does not exist" error.
I have tried manipulating the values of the CmisExtensionElements, but these were just ignored during the call to UpdateProperties() and the values stayed the same.

Below is my code for retrieving the properties from a document:
            IList<ICmisExtensionElement> cmisExtensionElements = cmisObject.GetExtensions(ExtensionLevel.Properties);
            foreach (ICmisExtensionElement element in cmisExtensionElements)
            {
                foreach (var v in element.Children)
                {
                    if (v.Name == "alf:properties")
                    {
                        if (v.Children != null)
                        {
                            foreach (var a in v.Children)
                            {
                                string propId = a.Attributes["propertyDefinitionId"];
                                string displayName = a.Attributes["displayName"];

                                if (a.Children == null || a.Children.Count == 1)
                                {
                                    string value = a.Children == null ? null : a.Children[0].Value;
                                    DoSomethingWithValue(value);
                                }
                            }
                        }
                    }
                }
            }

Kind Regards,
Phil.
6 REPLIES 6

tim1
Champ in-the-making
Champ in-the-making
Hi Phil,

I am currently integrating an Alfresco 4.x installation with a C# .NET WCF client. I noticed your post and was wondering if you had made any progress with your issue, and if so, could you report your findings back to the community?

Cheers,
Tim

alnedru
Champ in-the-making
Champ in-the-making
Can you tell me how did you do it??? or anyone know how to do it?

munnazz6
Champ in-the-making
Champ in-the-making
If you solved ur issue. Please post.

munnazz6
Champ in-the-making
Champ in-the-making
public static void Main()
    {
        string description = "this is a new description";

        string documentId = "workspace://SpacesStore/62e447a0-efc3-4ef0-b704-gd34fdsf23sa";

        Dictionary<string, string> objDictionaryParameters = new Dictionary<string, string>();      // define dictonary with key value pair
        objDictionaryParameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;        // define binding type.
        objDictionaryParameters[DotCMIS.SessionParameter.AtomPubUrl] = strURI;                      // define CMIS available path which is already available under alfresco
        objDictionaryParameters[DotCMIS.SessionParameter.User] = "user";                           // alfresco portal admin user name
        objDictionaryParameters[DotCMIS.SessionParameter.Password] = "password";                   // alfresco portal admin password


        SessionFactory factory = SessionFactory.NewInstance();
        ISession session = factory.GetRepositories(objDictionaryParameters)[0].CreateSession();
        IOperationContext operationContext = session.CreateOperationContext();
        operationContext.IncludeAcls = true;
        //iFolder = session.GetRootFolder(); 

        string repositoryId = session.RepositoryInfo.Id;


        //SessionFactory factory = SessionFactory.NewInstance();
        //ISession session = factory.CreateSession(objDictionaryParameters);

        string changeToken = null; // not sure why I need this

        Properties props = new Properties();
        props.Extensions = CreateData(description).Extensions;
        session.Binding.GetObjectService().UpdateProperties(repositoryId, ref documentId, ref changeToken, props, null);
    }

    private static ExtensionsData CreateData(string description)
    {
        ExtensionsData data = new ExtensionsData();
        data.Extensions = new List<ICmisExtensionElement>();
        CmisExtensionElement element = new CmisExtensionElement
            {
                Name = "alf:setAspects",
                Namespace = "http://www.alfresco.org",
                Children = new List<ICmisExtensionElement>
                    {
                        new CmisExtensionElement
                            {
                                Name = "alfSmiley Tongueroperties",
                                Namespace = "http://www.alfresco.org",
                                Children = new List<ICmisExtensionElement>
                                    {
                                        new CmisExtensionElement
                                            {
                                                Name = "cmisSmiley TongueropertyString",
                                                Namespace = "http://docs.oasis-open.org/ns/cmis/core/200908/",
                                                Attributes = new Dictionary<string, string>
                                                        {
                                                            {"propertyDefinitionId","cm:description"},
                                                            {"displayName","Description"},
                                                            {"queryName","cm:description"}
                                                        },
                                                Children = new List<ICmisExtensionElement>
                                                        {
                                                            new CmisExtensionElement
                                                                {
                                                                    Name = "cmis:value",
                                                                    Namespace = "http://docs.oasis-open.org/ns/cmis/core/200908/",
                                                                    Value = description
                                                                }
                                                        }
                                            }
                                    }
                            }
                    }
            };
        data.Extensions.Add(element);

        return data;
    }

esr89
Champ in-the-making
Champ in-the-making
Hi!!

I need to know how to do all this in asp.net and c#.

I hope that you can help me!

Thank you very much

mrogers
Star Contributor
Star Contributor
The Alf Extensions is obsolete.   It is not needed since CMIS 1.1 supports secondary types.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.