示例#1
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);
        }
示例#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 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.");
        }