예제 #1
0
        public IEnumerable <NCMIS.ObjectModel.CmisObject> GetChildren(string repositoryId, string objectId, string filter, IncludeRelationships includeRelationships)
        {
            Kooboo.CMS.Content.Models.Repository repository = new Models.Repository(repositoryId);
            string folderId;

            TryPraseObjectId(objectId, out folderId);
            switch (CmisFolderHelper.IdentifyFolderType(repository, folderId))
            {
            case FolderType.Root:
                return(new[] {
                    CmisFolderHelper.CreateSystemFolderObject(CmisFolderHelper.Content_Folder_Root, CmisFolderHelper.RootFolderName),
                    CmisFolderHelper.CreateSystemFolderObject(CmisFolderHelper.Media_Folder_Root, CmisFolderHelper.RootFolderName)
                });

            case FolderType.Content_Folder_Root:
                return(ServiceFactory.TextFolderManager.All(repository, filter).Select(it => ObjectConvertor.ToCmis((TextFolder)(it.AsActual()), includeRelationships != IncludeRelationships.None)));

            case FolderType.Media_Folder_Root:
                return(ServiceFactory.MediaFolderManager.All(repository, filter).Select(it => ObjectConvertor.ToCmis((MediaFolder)(it.AsActual()), includeRelationships != IncludeRelationships.None)));

            case FolderType.Content_Folder:
                var textFolder = (TextFolder)CmisFolderHelper.Parse(repository, folderId);
                return(ServiceFactory.TextFolderManager.ChildFolders(textFolder, filter).Select(it => ObjectConvertor.ToCmis((TextFolder)(it.AsActual()), includeRelationships != IncludeRelationships.None)));

            case FolderType.Media_Folder:
                var mediaFolder = (MediaFolder)CmisFolderHelper.Parse(repository, folderId);
                return(ServiceFactory.MediaFolderManager.ChildFolders(mediaFolder, filter).Select(it => ObjectConvertor.ToCmis((MediaFolder)(it.AsActual()), includeRelationships != IncludeRelationships.None)));

            default:
                break;
            }
            return(new[] { ObjectConvertor.EmptyCmisObject() });
        }
예제 #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 CmisObject GetObject(string repositoryId, string objectId)
        {
            string folderId;

            TryPraseObjectId(objectId, out folderId);
            Kooboo.CMS.Content.Models.Repository repository = new Models.Repository(repositoryId);
            var folder = CmisFolderHelper.Parse(repository, folderId);

            return(ObjectConvertor.ToCmis(folder.AsActual(), false));
        }
예제 #4
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());
        }
예제 #5
0
        public NCMIS.ObjectModel.CmisObject GetParent(string repositoryId, string objectId)
        {
            Kooboo.CMS.Content.Models.Repository repository = new Models.Repository(repositoryId);
            string folderId;

            if (!IsSystemFolder(objectId) && TryPraseObjectId(objectId, out folderId))
            {
                var folder = CmisFolderHelper.Parse(repository, folderId);

                if (folder.Parent != null)
                {
                    return(ObjectConvertor.ToCmis(folder.Parent.AsActual(), false));
                }
            }

            return(ObjectConvertor.EmptyCmisObject());
        }
예제 #6
0
        private static CmisObject AddMediaFolder(Kooboo.CMS.Content.Models.Repository repository, Folder parent, System.Collections.Specialized.NameValueCollection values)
        {
            var mediaFolder = new MediaFolder(repository, values["name"], parent);

            mediaFolder.DisplayName = values["DisplayName"];
            var allowedExtensions = values["AllowedExtensions"];

            if (!string.IsNullOrEmpty(allowedExtensions))
            {
                mediaFolder.AllowedExtensions = allowedExtensions.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            }

            var creationDate = values["UtcCreationDate"];

            if (!string.IsNullOrEmpty(creationDate))
            {
                mediaFolder.UtcCreationDate = DateTime.Parse(creationDate).ToUniversalTime();
            }

            ServiceFactory.MediaFolderManager.Add(repository, mediaFolder);

            return(ObjectConvertor.ToCmis(mediaFolder, false));
        }
예제 #7
0
        private static CmisObject AddContentFolder(Kooboo.CMS.Content.Models.Repository repository, Folder parent, System.Collections.Specialized.NameValueCollection values)
        {
            var textFolder = new TextFolder(repository, values["name"], parent);

            textFolder.DisplayName = values["DisplayName"];
            textFolder.SchemaName  = values["schemaName"];
            var categories = values["CategoryFolders"];

            if (!string.IsNullOrEmpty(categories))
            {
                textFolder.CategoryFolders = categories.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            }
            var creationDate = values["UtcCreationDate"];

            if (!string.IsNullOrEmpty(creationDate))
            {
                textFolder.UtcCreationDate = DateTime.Parse(creationDate).ToUniversalTime();
            }

            ServiceFactory.TextFolderManager.Add(repository, textFolder);

            return(ObjectConvertor.ToCmis(textFolder, false));
        }
예제 #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 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);
        }