AnsweredAssumed Answered

How to Install Alfresco OpenCMIS Extension

Question asked by julio.aescobar on Feb 24, 2014
Latest reply on Mar 25, 2015 by hpatel
Hello everybody,

I am creating a web application in .net (C# + dotcmis) and i want to create a document and then add some properties to this document.

I read that i need to install Alfresco OpenCmis extension to can work with alfresco aspects and properties.

My code is:

To create documents:

        public void PutFile(CMISDocument document)
        {
            IObjectId cmisObjectFolder = (IObjectId)session.GetObject(document.FolderId);

            IDictionary<string, object> properties = new Dictionary<string, object>();
            properties[PropertyIds.Name] = document.ContentStreamFileName;
            properties[PropertyIds.ObjectTypeId] = "cmis:document";
            properties[PropertyIds.CreationDate] = DateTime.Now;

            ContentStream contentStream = new ContentStream();
            contentStream.FileName = document.ContentStreamFileName;
            contentStream.MimeType = document.ContentStreamMimeType;
            contentStream.Length = document.Stream.Length;
            contentStream.Stream = document.Stream;

            IObjectId objectId = session.CreateDocument(properties, cmisObjectFolder, contentStream, DotCMIS.Enums.VersioningState.None);
           
            PutFileDetail(objectId,document.Owner);
        }


To add aspects and properties:


        internal void PutFileDetail(IObjectId objectId,string actorIdCard)
        {
            ICmisObject cmisObject = session.GetObject(objectId);

            IDictionary<string, object> properties = new Dictionary<string, object>();
            properties[PropertyIds.ObjectTypeId] = "adm:aridoctypBase";
            properties["adm:actidcard"] = actorIdCard;

            IObjectId newId = cmisObject.UpdateProperties(properties);

            if (newId.Id == cmisObject.Id)
            {
                // the repository updated this object - refresh the object
                cmisObject.Refresh();
            }
            else
            {
                // the repository created a new version - fetch the new version
                cmisObject = session.GetObject(newId);
            }
        }




The error message is:

Mensaje: Property +'adm:actidcard' is not valid for this type!   
Origen: DotCMIS   
Detalle:    at DotCMIS.Client.Impl.ObjectFactory.ConvertProperties(IDictionary`2 properties, IObjectType type, HashSet`1 updatabilityFilter)
   at DotCMIS.Client.Impl.AbstractCmisObject.UpdateProperties(IDictionary`2 properties, Boolean refresh)
   at DotCMIS.Client.Impl.AbstractCmisObject.UpdateProperties(IDictionary`2 properties)
   at CustomSystemFrameworks.CMISIntegration.CMISIntegrationRepository.PutFileDetail(IObjectId objectId, String actorIdCard) in C:\Corp\Projects\Colombia\CustomSystemFrameworks\AriDocsIntegration\CMISIntegrationRepository.cs:line 268
   at CustomSystemFrameworks.CMISIntegration.CMISIntegrationRepository.PutFile(CMISDocument document) in C:\Corp\Projects\Colombia\CustomSystemFrameworks\AriDocsIntegration\CMISIntegrationRepository.cs:line 257
   at WebUI.AriDocs.ibtnSave_Click(Object sender, ImageClickEventArgs e) in c:\Corp\Projects\Colombia\Presentation\AriDocs.aspx.cs:line 257



Thanks for all!

Outcomes