示例#1
0
        public CmisObject ToCmis(object o, bool includeRelationships)
        {
            CmisObject cmisObject = new CmisObject();

            MediaContent content = (MediaContent)o;

            cmisObject.Id = ObjectService.GetObjectId(content);

            cmisObject.Properties = new CmisProperties()
            {
                Items = content.Keys.Select(key => CmisPropertyHelper.CreateProperty(key, content[key])).ToArray()
            };

            cmisObject.Properties.Items = cmisObject.Properties.Items.Concat(new CmisProperty[] {
                CmisPropertyHelper.CreateCmisPropertyCreatedBy(new [] { content.UserId }),
                CmisPropertyHelper.CreateCmisPropertyCreationDate(new [] { content.UtcCreationDate }),
                CmisPropertyHelper.CreateCmisPropertyLastModificationDate(new [] { content.UtcLastModificationDate }),
                CmisPropertyHelper.CreateCmisPropertyName(new [] { content.UserKey }),
                CmisPropertyHelper.CreateCmisPropertyObjectId(new [] { cmisObject.Id }),
                CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new [] { "cmis:document" }),
                CmisPropertyHelper.CreateCmisPropertyObjectTypeId(new [] { content.FolderName }),
            }).ToArray();

            if (includeRelationships)
            {
                var categories = Services.ServiceFactory.TextContentManager.QueryCategories(content.GetRepository(), content.FolderName, content.UUID);
                cmisObject.Relationship = categories.Select(it => it.Contents).SelectMany(it => it.Select(c => ObjectConvertor.ToCmis(c, includeRelationships))).ToArray();
            }

            return(cmisObject);
        }