예제 #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);
        }
예제 #2
0
        public CmisObject CreateDocument(string repositoryId, NCMIS.ObjectModel.CmisProperties properties, string folderId, NCMIS.ObjectModel.ContentStream contentStream)
        {
            FolderObjectService folderObjectService = (FolderObjectService)ObjectService.GetService(typeof(Folder));

            if (folderObjectService.IsSystemFolder(folderId))
            {
                throw new Exception("Could not create document under system folder.");
            }
            Kooboo.CMS.Content.Models.Repository repository = new Repository(repositoryId);


            string objectId = folderId;

            folderObjectService.TryPraseObjectId(folderId, out folderId);
            var folder = CmisFolderHelper.Parse(repository, folderId);

            if (folder is TextFolder)
            {
                var textFolder = (TextFolder)folder.AsActual();

                var content = Services.ServiceFactory.TextContentManager.Add(repository, textFolder, UserId, properties.ToNameValueCollection(), contentStream.ToFileCollection(), null);

                return(ObjectConvertor.ToCmis(content, false));
            }
            else if (folder is MediaFolder)
            {
                var mediaFolder = (MediaFolder)folder.AsActual();
                if (contentStream != null)
                {
                    var content = Services.ServiceFactory.MediaContentManager.Add(repository, mediaFolder, UserId, contentStream.Filename, new MemoryStream(contentStream.Stream));
                    return(ObjectConvertor.ToCmis(content, false));
                }
            }
            return(ObjectConvertor.EmptyCmisObject());
        }
예제 #3
0
        public override NCMIS.ObjectModel.TokenedCmisObjectId UpdateProperties(string repositoryId, string objectId, NCMIS.ObjectModel.CmisProperties properties, string changeToken)
        {
            IObjectService objectService = ObjectService.GetService(objectId);

            objectService.UpdateProperties(repositoryId, objectId, properties);
            return(new NCMIS.ObjectModel.TokenedCmisObjectId()
            {
                ChangeToken = changeToken, ObjectId = objectId
            });
        }
예제 #4
0
        public override NCMIS.ObjectModel.TokenedDocumentId SetContentStream(string repositoryId, string documentId, NCMIS.ObjectModel.ContentStream contentStream, bool?overwriteFlag, string changeToken)
        {
            IObjectService objectService = ObjectService.GetService(documentId);

            objectService.SetContentStream(repositoryId, documentId, contentStream, overwriteFlag);
            return(new NCMIS.ObjectModel.TokenedDocumentId()
            {
                ChangeToken = changeToken, DocumentId = documentId
            });
        }
예제 #5
0
        // [WebGet(UriTemplate = "/{repositoryId}/object/{folderId}/parent")]
        public override NCMIS.ObjectModel.CmisObject GetFolderParent(string repositoryId, string folderId, string filter)
        {
            FolderObjectService folderService = (FolderObjectService)ObjectService.GetService(typeof(Folder));
            string objectId = folderId;

            if (folderService.TryPraseObjectId(objectId, out folderId))
            {
                return(folderService.GetParent(repositoryId, objectId));
            }
            return(ObjectConvertor.EmptyCmisObject());
        }
예제 #6
0
        public CmisObject ToCmis(object o, bool includeRelationships)
        {
            var        textFolder = (TextFolder)o;
            CmisObject cmisObject = new CmisObject();

            cmisObject.Id         = ObjectService.GetObjectId(textFolder);
            cmisObject.Properties = new CmisProperties()
            {
                Items = new CmisProperty[] {
                    CmisPropertyHelper.CreateCmisPropertyAllowedChildObjectTypeIds(null),
                    CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new string[] { "cmis:folder" }),
                    CmisPropertyHelper.CreateCmisPropertyCreatedBy(new string[] { textFolder.UserId }),
                    CmisPropertyHelper.CreateCmisPropertyCreationDate(new DateTime[] { textFolder.UtcCreationDate == DateTime.MinValue? DateTime.UtcNow:textFolder.UtcCreationDate }),
                    CmisPropertyHelper.CreateCmisPropertyLastModificationDate(new DateTime[] { DateTime.UtcNow }),
                    CmisPropertyHelper.CreateCmisPropertyLastModifiedBy(new string[] { textFolder.UserId }),
                    CmisPropertyHelper.CreateCmisPropertyName(new string[] { textFolder.Name }),
                    CmisPropertyHelper.CreateCmisPropertyObjectId(new string[] { cmisObject.Id }),
                    CmisPropertyHelper.CreateCmisPropertyBaseTypeId(new string[] { "cmis:folder" }),
                    CmisPropertyHelper.CreateCmisPropertyObjectTypeId(new string[] { textFolder.SchemaName }),
                    CmisPropertyHelper.CreateCmisPropertyParentId(new string[] { textFolder.Parent == null?CmisFolderHelper.RootFolderName:textFolder.Parent.FullName }),
                    CmisPropertyHelper.CreateCmisPropertyPath(new string[] { string.Join("/", textFolder.NamePath.ToArray()) }),
                    new CmisPropertyString()
                    {
                        DisplayName          = "Display Name",
                        LocalName            = "DispalyName",
                        PropertyDefinitionId = "DisplayName",
                        Value = new string[] { textFolder.DisplayName }
                    },
                    new CmisPropertyString()
                    {
                        DisplayName          = "Schema Name",
                        LocalName            = "SchemaName",
                        PropertyDefinitionId = "SchemaName",
                        Value = new string[] { textFolder.SchemaName }
                    },
                    new CmisPropertyString()
                    {
                        DisplayName          = "Category Folders",
                        LocalName            = "CategoryFolders",
                        PropertyDefinitionId = "CategoryFolders",
                        Value = new string[] { textFolder.CategoryFolders == null?"":string.Join(",", textFolder.CategoryFolders.ToArray()) }
                    }
                }
            };
            return(cmisObject);
        }
예제 #7
0
        public string CopyDocument(string repositoryId, string sourceId, NCMIS.ObjectModel.CmisProperties properties, string folderId)
        {
            string id;

            if (!TryPraseObjectId(sourceId, out id))
            {
                throw new Exception("Invalid docuemnt id. parameter name \"sourceId\"");
            }
            string contentUUID;

            Kooboo.CMS.Content.Models.Repository repository = new Repository(repositoryId);
            var sourceFolder = ParseDocumentId(repository, id, out contentUUID);

            IContentManager             contentManager;
            IContentQuery <ContentBase> contentQuery;

            if (sourceFolder is TextFolder)
            {
                contentManager = ServiceFactory.TextContentManager;
                contentQuery   = ((TextFolder)sourceFolder).CreateQuery().WhereEquals("UUID", contentUUID);
            }
            else
            {
                contentManager = ServiceFactory.MediaContentManager;
                contentQuery   = ((MediaFolder)sourceFolder).CreateQuery().WhereEquals("UUID", contentUUID);
            }
            FolderObjectService folderObjectService = (FolderObjectService)ObjectService.GetService(typeof(Folder));
            string objectId = folderId;

            folderObjectService.TryPraseObjectId(folderId, out folderId);
            var targetFolder = CmisFolderHelper.Parse(repository, folderId);

            var content = contentManager.Copy(contentQuery.First(), targetFolder, null, properties.ToNameValueCollection());

            return(GetObjectId(content));
        }
예제 #8
0
        public override NCMIS.ObjectModel.PathedCmisObjectList GetChildren(string repositoryId, string folderId, int?maxItems, int skipCount, string orderBy, string filter, IncludeRelationships includeRelationships, string renditionFilter, bool includeAllowableActions, bool includePathSegment)
        {
            Kooboo.CMS.Content.Models.Repository repository = new Models.Repository(repositoryId);
            IObjectService folderService = ObjectService.GetService(typeof(Folder));
            string         objectId      = folderId;

            folderService.TryPraseObjectId(objectId, out folderId);

            FolderType folderType = CmisFolderHelper.IdentifyFolderType(repository, folderId);

            PathedCmisObjectList           pathedList = new PathedCmisObjectList();
            IEnumerable <PathedCmisObject> children   = folderService.GetChildren(repositoryId, objectId, filter, includeRelationships)
                                                        .Select(it => new PathedCmisObject()
            {
                Object = it
            });

            var count = children.Count();

            pathedList.NumItems     = count.ToString();
            pathedList.HasMoreItems = false;

            //IEnumerable<ContentBase> contents = new ContentBase[0];
            if (folderType == FolderType.Content_Folder || folderType == FolderType.Media_Folder)
            {
                var folder = CmisFolderHelper.Parse(repository, folderId).AsActual();
                IContentQuery <ContentBase> contentQuery = null;
                if (folder is TextFolder)
                {
                    var textFolder = (TextFolder)folder;
                    var schema     = new Schema(repository, textFolder.SchemaName).AsActual();
                    contentQuery = textFolder.CreateQuery();
                    if (!string.IsNullOrEmpty(filter))
                    {
                        foreach (var item in schema.Columns)
                        {
                            contentQuery = contentQuery.Or(new WhereContainsExpression(null, item.Name, filter));
                        }
                    }
                }
                else
                {
                    var mediaFolder = (TextFolder)folder;
                    contentQuery = mediaFolder.CreateQuery();
                    if (!string.IsNullOrEmpty(filter))
                    {
                        contentQuery = contentQuery.WhereContains("FileName", filter);
                    }
                }
                if (!string.IsNullOrEmpty(orderBy))
                {
                    contentQuery = contentQuery.OrderBy(orderBy);
                }

                count = contentQuery.Count();
                var take = maxItems.HasValue ? maxItems.Value : count;
                pathedList.NumItems     = count.ToString();
                pathedList.HasMoreItems = count > count + take;

                children = children.Concat(contentQuery.Select(it => new PathedCmisObject()
                {
                    Object = ObjectConvertor.ToCmis((TextContent)(it), includeRelationships != IncludeRelationships.None)
                }).Take(take));
            }

            pathedList.Objects = children.ToArray();

            return(pathedList);
        }
예제 #9
0
        public override NCMIS.ObjectModel.CmisProperties GetProperties(string repositoryId, string objectId, string filter)
        {
            IObjectService objectService = ObjectService.GetService(objectId);

            return(objectService.GetProperties(repositoryId, objectId));
        }
예제 #10
0
        public override NCMIS.ObjectModel.CmisObject GetObject(string repositoryId, string objectId, string filter, bool includeAllowableActions, IncludeRelationships includeRelationships, string renditionFilter, bool includePolicyIds, bool includeAcl)
        {
            IObjectService objectService = ObjectService.GetService(objectId);

            return(objectService.GetObject(repositoryId, objectId));
        }
예제 #11
0
        public override NCMIS.ObjectModel.ContentStream GetContentStream(string repositoryId, string objectId, string streamId)
        {
            IObjectService objectService = ObjectService.GetService(objectId);

            return(objectService.GetContentStream(repositoryId, objectId, streamId));
        }
예제 #12
0
        public override AllowableActions GetAllowableActions(string repositoryId, string objectId)
        {
            IObjectService objectService = ObjectService.GetService(objectId);

            return(objectService.GetAllowableActions(repositoryId, objectId));
        }
예제 #13
0
        public override void DeleteObject(string repositoryId, string objectId, bool allVersions)
        {
            IObjectService objectService = ObjectService.GetService(objectId);

            objectService.DeleteObject(repositoryId, objectId);
        }
예제 #14
0
        public override NCMIS.ObjectModel.CmisObject CreateFolder(string repositoryId, NCMIS.ObjectModel.CmisProperties properties, string folderId, string[] policies, NCMIS.AccessControl.AccessControlList addACEs, NCMIS.AccessControl.AccessControlList removeACEs)
        {
            FolderObjectService folderObjectService = (FolderObjectService)ObjectService.GetService(typeof(Folder));

            return(folderObjectService.CreateFolder(repositoryId, properties, folderId));
        }
예제 #15
0
        public override string CreateDocumentFromSource(string repositoryId, string sourceId, NCMIS.ObjectModel.CmisProperties properties, string folderId, VersioningState?versioningState, string[] policies, NCMIS.AccessControl.AccessControlList addACEs, NCMIS.AccessControl.AccessControlList removeACEs)
        {
            DocumentObjectService documentService = (DocumentObjectService)ObjectService.GetService(typeof(ContentBase));

            return(documentService.CopyDocument(repositoryId, sourceId, properties, folderId));
        }
예제 #16
0
        public override NCMIS.ObjectModel.CmisObject CreateDocument(string repositoryId, NCMIS.ObjectModel.CmisProperties properties, string folderId, NCMIS.ObjectModel.ContentStream contentStream, VersioningState versioningState, string[] policies, NCMIS.AccessControl.AccessControlList addACEs, NCMIS.AccessControl.AccessControlList removeACEs)
        {
            DocumentObjectService documentService = (DocumentObjectService)ObjectService.GetService(typeof(ContentBase));

            return(documentService.CreateDocument(repositoryId, properties, folderId, contentStream));
        }