Example #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);
        }
Example #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();
        }
Example #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.");
        }
Example #4
0
 public IEnumerable<NCMIS.ObjectModel.CmisObject> GetChildren(string repositoryId, string objectId, string filter, NCMIS.Produce.IncludeRelationships includeRelationships)
 {
     throw new NotImplementedException();
 }
Example #5
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);
        }
Example #6
0
 // only for content category relationship
 public override string CreateRelationship(string repositoryId, NCMIS.ObjectModel.CmisProperties properties, string[] policies, NCMIS.AccessControl.AccessControlList addACEs, NCMIS.AccessControl.AccessControlList removeACEs)
 {
     throw new NotImplementedException();
 }
Example #7
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);
 }
Example #8
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);
 }
Example #9
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 };
 }
Example #10
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 };
 }
Example #11
0
 public CmisHttpPostedFileWrapper(NCMIS.ObjectModel.ContentStream contentStream)
 {
     this.contentLength = contentStream.Length.HasValue ? (int)contentStream.Length.Value : 0;
     this.contentType = contentStream.MimeType;
     this.fileName = contentStream.Filename;
     this.inputStream = new MemoryStream(contentStream.Stream);
 }