コード例 #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 string GetObjectId(object o)
        {
            var    content = (ContentBase)o;
            Folder folder  = content.GetFolder();

            return(prefix + CmisFolderHelper.CompositeFolderId(folder) + "$$" + content.UUID);
        }
コード例 #4
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));
        }
コード例 #5
0
ファイル: ObjectConvertor.cs プロジェクト: Epitomy/CMS
        public object ToCms(CmisObject cmisObject)
        {
            MediaFolder textFolder = (MediaFolder)CmisFolderHelper.Parse(null, cmisObject.Id);

            textFolder.DisplayName = cmisObject.GetProperty("DisplayName").Value;


            textFolder.UserId = cmisObject.Properties.CreatedBy.SingleValue;

            textFolder.AllowedExtensions = ((CmisPropertyString)cmisObject.GetProperty("AllowedExtensions")).Value;

            return(textFolder);
        }
コード例 #6
0
ファイル: ObjectConvertor.cs プロジェクト: Epitomy/CMS
        public object ToCms(CmisObject cmisObject)
        {
            TextFolder textFolder = (TextFolder)CmisFolderHelper.Parse(null, cmisObject.Id);

            textFolder.DisplayName = cmisObject.GetProperty("DisplayName").Value;
            if (!string.IsNullOrEmpty(cmisObject.GetProperty("CategoryFolders").Value))
            {
                textFolder.CategoryFolders = cmisObject.GetProperty("CategoryFolders").Value.Split(',');
            }

            textFolder.UserId = cmisObject.Properties.CreatedBy.SingleValue;

            textFolder.SchemaName = cmisObject.GetProperty("SchemaName").Value;

            return(textFolder);
        }
コード例 #7
0
        public void DeleteObject(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);

            if (folder is TextFolder)
            {
                ServiceFactory.TextFolderManager.Remove(repository, (TextFolder)folder);
            }
            else
            {
                ServiceFactory.MediaFolderManager.Remove(repository, (MediaFolder)folder);
            }
        }
コード例 #8
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());
        }
コード例 #9
0
        public void UpdateProperties(string repositoryId, string objectId, CmisProperties properties)
        {
            Kooboo.CMS.Content.Models.Repository repository = new Models.Repository(repositoryId);
            string folderId;

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

            var values = properties.ToNameValueCollection();

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

                if (values["DisplayName"] != null)
                {
                    textFolder.DisplayName = values["DisplayName"];
                }
                if (values["SchemaName"] != null)
                {
                    textFolder.SchemaName = values["SchemaName"];
                }
                if (values["CategoryFolders"] != null)
                {
                    textFolder.CategoryFolders = values["CategoryFolders"].Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries);
                }
                ServiceFactory.TextFolderManager.Update(repository, textFolder, textFolder);
            }
            else
            {
                var mediaFolder = (MediaFolder)folder;
                if (values["DisplayName"] != null)
                {
                    mediaFolder.DisplayName = values["DisplayName"];
                }
                if (values["AllowedExtensions"] != null)
                {
                    mediaFolder.AllowedExtensions = values["AllowedExtensions"].Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries);
                }
                ServiceFactory.MediaFolderManager.Update(repository, mediaFolder, mediaFolder);
            }
        }
コード例 #10
0
        public CmisObject CreateFolder(string repositoryId, NCMIS.ObjectModel.CmisProperties properties, string folderId)
        {
            Kooboo.CMS.Content.Models.Repository repository = new Models.Repository(repositoryId);
            Folder parent   = null;
            var    objectId = folderId;

            var values = properties.ToNameValueCollection();

            if (string.IsNullOrEmpty(values["name"]))
            {
                throw new Exception("The property \"Name\" is required.");
            }
            if (TryPraseObjectId(objectId, out folderId))
            {
                var folderType = CmisFolderHelper.IdentifyFolderType(repository, folderId);
                switch (folderType)
                {
                case FolderType.Root:
                    throw new Exception("Could not create folder under root folder.");

                case FolderType.Content_Folder_Root:
                    parent = null;
                    return(AddContentFolder(repository, parent, values));

                case FolderType.Media_Folder_Root:
                    parent = null;
                    return(AddMediaFolder(repository, parent, values));

                case FolderType.Content_Folder:
                    parent = CmisFolderHelper.Parse(repository, folderId);
                    return(AddContentFolder(repository, parent, values));

                case FolderType.Media_Folder:
                    parent = CmisFolderHelper.Parse(repository, folderId);
                    return(AddMediaFolder(repository, parent, values));

                default:
                    break;
                }
            }
            throw new InvalidOperationException("Create folder failed.");
        }
コード例 #11
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));
        }
コード例 #12
0
ファイル: NavigationProvider.cs プロジェクト: Epitomy/CMS
        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);
        }
コード例 #13
0
 private Folder ParseDocumentId(Repository repository, string id, out string contentUUID)
 {
     string[] idArr = id.Split(new string[] { "$$" }, StringSplitOptions.RemoveEmptyEntries);
     contentUUID = idArr[1];
     return(CmisFolderHelper.Parse(repository, idArr[0]));
 }
コード例 #14
0
 public NCMIS.ObjectModel.MetaData.AllowableActions GetAllowableActions(string repositoryId, string objectId)
 {
     if (IsSystemFolder(objectId))
     {
         return(new NCMIS.ObjectModel.MetaData.AllowableActions()
         {
             CanAddObjectToFolder = false,
             CanApplyACL = false,
             CanApplyPolicy = false,
             CanCancelCheckOut = false,
             CanCheckIn = false,
             CanCheckOut = false,
             CanCreateDocument = false,
             CanCreateFolder = CmisFolderHelper.IdentifyFolderType(new Kooboo.CMS.Content.Models.Repository(repositoryId), objectId) != FolderType.Root,
             CanCreateRelationship = false,
             CanDeleteContentStream = false,
             CanDeleteObject = true,
             CanDeleteTree = false,
             CanGetACL = false,
             CanGetAllVersions = false,
             CanGetAppliedPolicies = false,
             CanGetChildren = true,
             CanGetContentStream = false,
             CanGetDescendants = false,
             CanGetFolderParent = false,
             CanGetFolderTree = false,
             CanGetObjectParents = false,
             CanGetObjectRelationships = true,
             CanGetProperties = false,
             CanGetRenditions = false,
             CanMoveObject = false,
             CanRemoveObjectFromFolder = false,
             CanRemovePolicy = false,
             CanSetContentStream = false,
             CanUpdateProperties = false
         });
     }
     else
     {
         return(new NCMIS.ObjectModel.MetaData.AllowableActions()
         {
             CanAddObjectToFolder = false,
             CanApplyACL = false,
             CanApplyPolicy = false,
             CanCancelCheckOut = false,
             CanCheckIn = false,
             CanCheckOut = false,
             CanCreateDocument = true,
             CanCreateFolder = true,
             CanCreateRelationship = true,
             CanDeleteContentStream = false,
             CanDeleteObject = true,
             CanDeleteTree = false,
             CanGetACL = false,
             CanGetAllVersions = false,
             CanGetAppliedPolicies = false,
             CanGetChildren = true,
             CanGetContentStream = true,
             CanGetDescendants = false,
             CanGetFolderParent = true,
             CanGetFolderTree = false,
             CanGetObjectParents = false,
             CanGetObjectRelationships = true,
             CanGetProperties = true,
             CanGetRenditions = false,
             CanMoveObject = false,
             CanRemoveObjectFromFolder = false,
             CanRemovePolicy = false,
             CanSetContentStream = false,
             CanUpdateProperties = true
         });
     }
 }
コード例 #15
0
 public string GetObjectId(object o)
 {
     return(prefix + CmisFolderHelper.CompositeFolderId((Folder)o));
 }