0

I am working in a .net web application than need to be able to create documents in Alfresco and then associate a particular aspect and his prperties to those documents.

I created my aspect (nameModel.xml, name-model-context.xml all this files in the extension folder, name.properties in messages folder and custom-slingshot-application-context.xml share-config-custom.xml in the web-extension folder) in /opt/bitnami/apache-tomcat/shared/classes/alfresco/ path.

In my C# code, i have two methods:

        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);
    }

        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);
        }
    }

With this code i have as result a error:

The first one is for create the document and the second one is for add the aspect and his properties.

I was looking for a answer, and i finded this: http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Fopencmis-ext-intro.html

But a really do not know how install Alfresco OpenCMIS Extension; they say that i need put the jar file in my class path. But i do not know what is my class path in bitnami virtual machine.

Other thing is if i forgot something in the creation of my aspect.

pd: It is important but nor urgent for me, that the way to do it could be work if one day a need change Alfresco to Sharepoint or another else enterprise content management

I will apreciate any help.


Thanks! Do you know where can i see a good example? I think that the first point: i need change my model. In this moment i have the properties inside of aspect tags. I will need create the types and the properties ... can you tell me if i am going in good way...?

This is my model xml file (aridocsModel.xml) resume:

<?xml version="1.0" encoding="UTF-8"?>
<model name="adm:aridocsModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

        ...

        <aspects>
                <aspect name="adm:aridocsBase">
                <title>AriDocs Base</title>
                                <properties>
                                  <property name="adm:createdate">
                                          <type>d:date</type>
                                  </property>
                                  <property name="adm:disabledate">
                                          <type>d:date</type>
                                  </property>
                                  <property name="adm:artiddoc">
                                          <type>d:text</type>
                                  </property>
                                  <property name="adm:accnumber">
                                          <type>d:text</type>
                                  </property>
                                  <property name="adm:actidcard">
                                          <type>d:text</type>
                                  </property>
                                </properties>
                </aspect>
        </aspects>
</model>

Now, how i can not work with aspects; and i need types ...

<?xml version="1.0" encoding="UTF-8"?>
<model name="adm:aridocsModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

        ...

        <types>
                <type name="adm:aridoctypBase">
                        <title>Ari Docs Type Base</title>
                        <parent>cm:content</parent>
                           <properties>
                                  <property name="adm:createdate">
                                          <type>d:date</type>
                                  </property>
                                  <property name="adm:disabledate">
                                          <type>d:date</type>
                                  </property>
                                  <property name="adm:artiddoc">
                                          <type>d:text</type>
                                  </property>
                                  <property name="adm:accnumber">
                                          <type>d:text</type>
                                  </property>
                                  <property name="adm:actidcard">
                                          <type>d:text</type>
                                  </property>
                                </properties>
                </type>
        </types>

        ...
        <!-- i need put the aspect here... Even if i will work with types... -->
        ...

</model>

I will appreciate any advice.

1 Answers1

2

You don't need the extensions on creating a document. The extension is only for managing aspects.

And from what I've heard the extension isn't available in all the languages, so I'm not sure if there is a .dll for you to include in your project.

Did you read these topics: integrate a .net application with alfresco using cmis

And: .net wcf and create document

Community
  • 1
  • 1
Tahir Malik
  • 6,623
  • 15
  • 22
  • Thanks for your answer, but i want manage aspects; for this reason i was mentioned the extension. I create the document "xyz.txt" now i want add some properties of a specific aspects to this document. How can i do it? – julio.aescobar Feb 25 '14 at 12:37
  • If there are no extensions available, then there is no other way. You will need to work with types with properties within. I did an implementation which had the same issue (no extensions possible) so I made multiple nested types with different content types which made some things complex but did provide the same result – Tahir Malik Feb 25 '14 at 13:04