0

I'm having some troubles adding metadata to a document that I am programmatically creating in alfresco.

I'm using dotCMIS library for this.

I have the following code:

IDictionary<string, object> properties = new Dictionary<string, object>();
properties[PropertyIds.Name] = "title.doc";
properties[PropertyIds.ObjectTypeId] = "cmis:document";

ContentStream contentStream = new ContentStream();
contentStream.FileName = "title.doc";
contentStream.MimeType = "application/msword";
contentStream.Length = bytes.Length;
contentStream.Stream = new MemoryStream(bytes);
IDocument doc = folder.CreateDocument(properties, contentStream, null);

So i would also like to set for example, title and description aswell as keywords, references etc ... but I don't know how.

I tried something like that:

properties["cm:title"] = "some title";

OR

properties["cmis:title"] = "some title";

But still no success any idea, how to do it?

Note: i also tried to return all properties from document, but those are not in there, so how do i set them then?

I have this:

    string queryGetDoc = "SELECT * FROM cmis:document WHERE cmis:name='document.doc'";
    IItemEnumerable<IQueryResult> docResults = session.Query(queryGetDoc, false);
    IQueryResult docHit = docResults.FirstOrDefault();
    string docId = docHit["cmis:objectId"].FirstValue.ToString();

      IDocument document = session.GetObject(docId) as IDocument;

        IList<IProperty> listOfProperties = document.Properties;

        foreach(IProperty p in listOfProperties)
        {
            Console.WriteLine(p.QueryName); 
        }

And i receive this:

cmis:isLatestMajorVersion
cmis:contentStreamLength
cmis:contentStreamId
cmis:versionSeriesCheckedOutBy
cmis:objectTypeId
cmis:versionSeriesCheckedOutId
cmis:name
cmis:contentStreamMimeType
cmis:versionSeriesId
cmis:creationDate
cmis:changeToken
cmis:versionLabel
cmis:isLatestVersion
cmis:isVersionSeriesCheckedOut
cmis:lastModifiedBy
cmis:createdBy
cmis:checkinComment
cmis:objectId
cmis:isImmutable
cmis:isMajorVersion
cmis:baseTypeId
cmis:contentStreamFileName
cmis:lastModificationDate

Does it mean that other props do not exist on the document? Although in graphical user interface i can set the Title and Description, aswell as keywords and reference ...

What is going on, anyone any idea?

4

1 に答える 1

3

If you're new to CMIS, and want to easily check what properties / options / etc your repository contains, the best way to learn and investigate is with the Apache Chemistry CMIS Workbench. It's a standalone Java tool for querying and browsing your repo

First, as mentioned in the comments, create a test file in Alfresco with a Title and Description set: Properties

Next, fire up the Apache Chemistry CMIS Workbench, connect to your repo, browse to the node in question, and view the standard properties:

CMIS Props

Finally, look at the extensions, to see how the Alfresco specific parts (such as Title and Description) are exposed:

extensions

So, you'll need to work with the the Title and Description as extensions, as Documented on the Alfresco Wiki. You'll likely also want to look at the Alfresco Extension for OpenCMIS and then do something similar for .Net

于 2013-03-27T06:57:01.747 に答える