Search in sources :

Example 11 with StringBlob

use of org.nuxeo.ecm.core.api.impl.blob.StringBlob in project nuxeo-drive-server by nuxeo.

the class TestDefaultTopLevelFolderItemFactory method testFactory.

@Test
public void testFactory() throws Exception {
    // -------------------------------------------------------------
    // Check TopLevelFolderItemFactory#getTopLevelFolderItem(String
    // Principal)
    // -------------------------------------------------------------
    FolderItem topLevelFolderItem = defaultTopLevelFolderItemFactory.getTopLevelFolderItem(session.getPrincipal());
    assertNotNull(topLevelFolderItem);
    assertTrue(topLevelFolderItem instanceof DefaultTopLevelFolderItem);
    assertTrue(topLevelFolderItem.getId().endsWith("DefaultTopLevelFolderItemFactory#"));
    assertTrue(topLevelFolderItem.getPath().endsWith("DefaultTopLevelFolderItemFactory#"));
    assertTrue(topLevelFolderItem.getPath().startsWith("/"));
    assertNull(topLevelFolderItem.getParentId());
    assertEquals("Nuxeo Drive", topLevelFolderItem.getName());
    assertTrue(topLevelFolderItem.isFolder());
    assertEquals("system", topLevelFolderItem.getCreator());
    assertEquals("system", topLevelFolderItem.getLastContributor());
    assertFalse(topLevelFolderItem.getCanRename());
    try {
        topLevelFolderItem.rename("newName");
        fail("Should not be able to rename the default top level folder item.");
    } catch (UnsupportedOperationException e) {
        assertEquals("Cannot rename a virtual folder item.", e.getMessage());
    }
    assertFalse(topLevelFolderItem.getCanDelete());
    try {
        topLevelFolderItem.delete();
        fail("Should not be able to delete the default top level folder item.");
    } catch (UnsupportedOperationException e) {
        assertEquals("Cannot delete a virtual folder item.", e.getMessage());
    }
    assertFalse(topLevelFolderItem.canMove(null));
    try {
        topLevelFolderItem.move(null);
        fail("Should not be able to move the default top level folder item.");
    } catch (UnsupportedOperationException e) {
        assertEquals("Cannot move a virtual folder item.", e.getMessage());
    }
    List<FileSystemItem> children = topLevelFolderItem.getChildren();
    assertNotNull(children);
    assertEquals(2, children.size());
    assertFalse(topLevelFolderItem.getCanScrollDescendants());
    try {
        topLevelFolderItem.scrollDescendants(null, 10, 1000);
        fail("Should not be able to scroll through the descendants of the default top level folder item.");
    } catch (UnsupportedOperationException e) {
        assertEquals("Cannot scroll through the descendants of a virtual folder item, please call getChildren() instead.", e.getMessage());
    }
    assertFalse(topLevelFolderItem.getCanCreateChild());
    for (FileSystemItem child : children) {
        assertEquals(topLevelFolderItem.getPath() + '/' + child.getId(), child.getPath());
    }
    try {
        topLevelFolderItem.createFile(new StringBlob("Child file content."));
        fail("Should not be able to create a file in the default top level folder item.");
    } catch (UnsupportedOperationException e) {
        assertEquals("Cannot create a file in a virtual folder item.", e.getMessage());
    }
    try {
        topLevelFolderItem.createFolder("subFolder");
        fail("Should not be able to create a folder in the default top level folder item.");
    } catch (UnsupportedOperationException e) {
        assertEquals("Cannot create a folder in a virtual folder item.", e.getMessage());
    }
    // -------------------------------------------------------------
    // Check VirtualFolderItemFactory#getVirtualFolderItem(Principal
    // userName)
    // -------------------------------------------------------------
    assertEquals(topLevelFolderItem, defaultTopLevelFolderItemFactory.getVirtualFolderItem(session.getPrincipal()));
}
Also used : DefaultSyncRootFolderItem(org.nuxeo.drive.adapter.impl.DefaultSyncRootFolderItem) FolderItem(org.nuxeo.drive.adapter.FolderItem) DefaultTopLevelFolderItem(org.nuxeo.drive.adapter.impl.DefaultTopLevelFolderItem) FileSystemItem(org.nuxeo.drive.adapter.FileSystemItem) DefaultTopLevelFolderItem(org.nuxeo.drive.adapter.impl.DefaultTopLevelFolderItem) StringBlob(org.nuxeo.ecm.core.api.impl.blob.StringBlob) Test(org.junit.Test)

Example 12 with StringBlob

use of org.nuxeo.ecm.core.api.impl.blob.StringBlob in project nuxeo-drive-server by nuxeo.

the class TestFileSystemItemManagerService method testWriteOperations.

@Test
public void testWriteOperations() throws Exception {
    // Not allowed to create a folder in a non FolderItem
    try {
        fileSystemItemManagerService.createFolder(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + file.getId(), "A new folder", principal, false);
        fail("Folder creation in a non folder item should fail.");
    } catch (NuxeoException e) {
        assertEquals(String.format("Cannot create a folder in file system item with id %s because it is not a folder but is: " + "DocumentBackedFileItem(id=\"%s\", name=\"Joe.odt\")", DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + file.getId(), DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + file.getId()), e.getMessage());
    }
    // Folder creation
    FolderItem newFolderItem = fileSystemItemManagerService.createFolder(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId(), "A new folder", principal, false);
    assertNotNull(newFolderItem);
    assertEquals(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId(), newFolderItem.getParentId());
    assertEquals("A new folder", newFolderItem.getName());
    DocumentModelList folderChildren = session.query(String.format("select * from Document where ecm:parentId = '%s' and ecm:primaryType = 'Folder' order by dc:title asc", folder.getId()));
    DocumentModel newFolder = folderChildren.get(0);
    assertTrue(newFolder.isFolder());
    assertEquals("A new folder", newFolder.getTitle());
    // Parent folder children check
    assertEquals(6, fileSystemItemManagerService.getChildren(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId(), principal).size());
    // NXP-21854: Check overwrite parameter
    // Test overwrite=false
    FolderItem differentFolderItem = fileSystemItemManagerService.createFolder(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId(), "A new folder", principal, false);
    assertNotNull(differentFolderItem);
    assertNotEquals(newFolderItem.getId(), differentFolderItem.getId());
    assertEquals("A new folder", differentFolderItem.getName());
    // Test overwrite=true
    FolderItem otherFolderItem = fileSystemItemManagerService.createFolder(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId(), "Test overwrite", principal, false);
    assertNotNull(otherFolderItem);
    assertEquals("Test overwrite", otherFolderItem.getName());
    FolderItem sameFolderItem = fileSystemItemManagerService.createFolder(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId(), "Test overwrite", principal, true);
    assertNotNull(sameFolderItem);
    assertEquals(otherFolderItem.getId(), sameFolderItem.getId());
    assertEquals("Test overwrite", sameFolderItem.getName());
    // ------------------------------------------------------
    // Check #createFile
    // ------------------------------------------------------
    // File creation
    Blob blob = new StringBlob("Content of a new file.");
    blob.setFilename("New file.odt");
    blob.setMimeType("application/vnd.oasis.opendocument.text");
    FileItem fileItem = fileSystemItemManagerService.createFile(newFolderItem.getId(), blob, principal, false);
    assertNotNull(fileItem);
    assertEquals(newFolderItem.getId(), fileItem.getParentId());
    assertEquals("New file.odt", fileItem.getName());
    folderChildren = session.query(String.format("select * from Document where ecm:parentId = '%s'", newFolder.getId()));
    assertEquals(1, folderChildren.size());
    DocumentModel newFile = folderChildren.get(0);
    assertEquals("File", newFile.getType());
    assertEquals("New file.odt", newFile.getTitle());
    assertEquals("/syncRoot1/aFolder/A new folder/New file.odt", newFile.getPathAsString());
    Blob newFileBlob = (Blob) newFile.getPropertyValue("file:content");
    assertEquals("New file.odt", newFileBlob.getFilename());
    assertEquals("Content of a new file.", newFileBlob.getString());
    assertEquals("nxfile/test/" + newFile.getId() + "/blobholder:0/New%20file.odt", fileItem.getDownloadURL());
    assertEquals("MD5", fileItem.getDigestAlgorithm());
    assertEquals(newFileBlob.getDigest(), fileItem.getDigest());
    // NXP-21854: Check overwrite parameter
    // Test overwrite=false
    FileItem differentFileItem = fileSystemItemManagerService.createFile(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId(), blob, principal, false);
    assertNotNull(differentFileItem);
    assertNotEquals(fileItem.getId(), differentFileItem.getId());
    assertEquals("New file.odt", differentFileItem.getName());
    // Test overwrite=true
    Blob otherBlob = new StringBlob("Content of a new file.");
    otherBlob.setFilename("Test overwrite.odt");
    otherBlob.setMimeType("application/vnd.oasis.opendocument.text");
    FileItem otherFileItem = fileSystemItemManagerService.createFile(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId(), otherBlob, principal, false);
    assertNotNull(otherFileItem);
    assertEquals("Test overwrite.odt", otherFileItem.getName());
    FileItem sameFileItem = fileSystemItemManagerService.createFile(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId(), otherBlob, principal, true);
    assertNotNull(sameFileItem);
    assertEquals(otherFileItem.getId(), sameFileItem.getId());
    assertEquals("Test overwrite.odt", sameFileItem.getName());
    // Parent folder children check
    assertEquals(1, fileSystemItemManagerService.getChildren(newFolderItem.getId(), principal).size());
    // ------------------------------------------------------
    // Check #updateFile
    // ------------------------------------------------------
    String fileItemId = fileItem.getId();
    String fileItemParentId = fileItem.getParentId();
    blob = new StringBlob("Modified content of an existing file.");
    fileItem = fileSystemItemManagerService.updateFile(fileItemId, blob, principal);
    assertNotNull(fileItem);
    assertEquals(fileItemId, fileItem.getId());
    assertEquals(fileItemParentId, fileItem.getParentId());
    assertEquals("New file.odt", fileItem.getName());
    folderChildren = session.query(String.format("select * from Document where ecm:parentId = '%s'", newFolder.getId()));
    assertEquals(1, folderChildren.size());
    DocumentModel updatedFile = folderChildren.get(0);
    assertEquals("File", updatedFile.getType());
    assertEquals("New file.odt", updatedFile.getTitle());
    assertEquals("/syncRoot1/aFolder/A new folder/New file.odt", updatedFile.getPathAsString());
    Blob updatedFileBlob = (Blob) updatedFile.getPropertyValue("file:content");
    assertEquals("New file.odt", updatedFileBlob.getFilename());
    assertEquals("Modified content of an existing file.", updatedFileBlob.getString());
    assertEquals("nxfile/test/" + updatedFile.getId() + "/blobholder:0/New%20file.odt", fileItem.getDownloadURL());
    assertEquals("MD5", fileItem.getDigestAlgorithm());
    assertEquals(updatedFileBlob.getDigest(), fileItem.getDigest());
    // ------------------------------------------------------
    // Check #delete
    // ------------------------------------------------------
    // File deletion
    fileSystemItemManagerService.delete(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + updatedFile.getId(), principal);
    updatedFile = session.getDocument(new IdRef(updatedFile.getId()));
    assertTrue(updatedFile.isTrashed());
    // Parent folder children check
    assertTrue(fileSystemItemManagerService.getChildren(newFolderItem.getId(), principal).isEmpty());
    // ------------------------------------------------------
    // Check #rename
    // ------------------------------------------------------
    // Folder rename
    String fsItemId = DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId();
    FileSystemItem fsItem = fileSystemItemManagerService.rename(fsItemId, "Jack's folder has a new name", principal);
    assertEquals(fsItemId, fsItem.getId());
    String expectedSyncRoot1Id = DEFAULT_SYNC_ROOT_ITEM_ID_PREFIX + syncRoot1.getId();
    assertEquals(expectedSyncRoot1Id, fsItem.getParentId());
    assertEquals("Jack's folder has a new name", fsItem.getName());
    folder = session.getDocument(folder.getRef());
    assertEquals("Jack's folder has a new name", folder.getTitle());
    // File rename with title != filename
    // => should rename filename but not title
    assertEquals("aFile", file.getTitle());
    assertEquals("Joe.odt", ((Blob) file.getPropertyValue("file:content")).getFilename());
    fsItemId = DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + file.getId();
    fsItem = fileSystemItemManagerService.rename(fsItemId, "File new name.odt", principal);
    assertEquals(fsItemId, fsItem.getId());
    assertEquals(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + folder.getId(), fsItem.getParentId());
    assertEquals("File new name.odt", fsItem.getName());
    file = session.getDocument(file.getRef());
    assertEquals("aFile", file.getTitle());
    Blob fileBlob = (Blob) file.getPropertyValue("file:content");
    assertEquals("File new name.odt", fileBlob.getFilename());
    fileItem = (FileItem) fsItem;
    assertEquals("nxfile/test/" + file.getId() + "/blobholder:0/File%20new%20name.odt", fileItem.getDownloadURL());
    assertEquals("MD5", fileItem.getDigestAlgorithm());
    assertEquals(fileBlob.getDigest(), fileItem.getDigest());
    // File rename with title == filename
    // => should rename filename and title
    blob = new StringBlob("File for a doc with title == filename.");
    blob.setFilename("Title-filename equality.odt");
    blob.setMimeType("application/vnd.oasis.opendocument.text");
    fileItem = fileSystemItemManagerService.createFile(newFolderItem.getId(), blob, principal, false);
    // Note that the PathSegmentService truncates doc title at 24 characters
    newFile = session.getDocument(new PathRef("/syncRoot1/aFolder/A new folder/Title-filename equality."));
    assertEquals("Title-filename equality.odt", newFile.getTitle());
    assertEquals("Title-filename equality.odt", ((Blob) newFile.getPropertyValue("file:content")).getFilename());
    fileItem = (FileItem) fileSystemItemManagerService.rename(DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + newFile.getId(), "Renamed title-filename equality.odt", principal);
    assertEquals("Renamed title-filename equality.odt", fileItem.getName());
    newFile = session.getDocument(newFile.getRef());
    assertEquals("Renamed title-filename equality.odt", newFile.getTitle());
    newFileBlob = (Blob) newFile.getPropertyValue("file:content");
    assertEquals("Renamed title-filename equality.odt", newFileBlob.getFilename());
    assertEquals("nxfile/test/" + newFile.getId() + "/blobholder:0/Renamed%20title-filename%20equality.odt", fileItem.getDownloadURL());
    assertEquals("MD5", fileItem.getDigestAlgorithm());
    assertEquals(newFileBlob.getDigest(), fileItem.getDigest());
    // ------------------------------------------------------
    // Check #move
    // ------------------------------------------------------
    // Not allowed to move a file system item to a non FolderItem
    String srcFsItemId = DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + note.getId();
    String destFsItemId = DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + file.getId();
    try {
        fileSystemItemManagerService.move(srcFsItemId, destFsItemId, principal);
        fail("Move to a non folder item should fail.");
    } catch (NuxeoException e) {
        assertEquals(String.format("Cannot move a file system item to file system item with id %s because it is not a folder.", DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + file.getId()), e.getMessage());
    }
    // Move to a FolderItem
    destFsItemId = DEFAULT_FILE_SYSTEM_ITEM_ID_PREFIX + subFolder.getId();
    FileSystemItem movedFsItem = fileSystemItemManagerService.move(srcFsItemId, destFsItemId, principal);
    assertEquals(srcFsItemId, movedFsItem.getId());
    assertEquals(destFsItemId, movedFsItem.getParentId());
    assertEquals("aNote.txt", movedFsItem.getName());
    note = session.getDocument(note.getRef());
    assertEquals("/syncRoot1/aFolder/aSubFolder/aNote", note.getPathAsString());
    assertEquals("aNote", note.getTitle());
}
Also used : FileItem(org.nuxeo.drive.adapter.FileItem) StringBlob(org.nuxeo.ecm.core.api.impl.blob.StringBlob) Blob(org.nuxeo.ecm.core.api.Blob) DefaultSyncRootFolderItem(org.nuxeo.drive.adapter.impl.DefaultSyncRootFolderItem) FolderItem(org.nuxeo.drive.adapter.FolderItem) FileSystemItem(org.nuxeo.drive.adapter.FileSystemItem) DocumentModelList(org.nuxeo.ecm.core.api.DocumentModelList) PathRef(org.nuxeo.ecm.core.api.PathRef) StringBlob(org.nuxeo.ecm.core.api.impl.blob.StringBlob) NuxeoException(org.nuxeo.ecm.core.api.NuxeoException) IdRef(org.nuxeo.ecm.core.api.IdRef) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel) Test(org.junit.Test)

Example 13 with StringBlob

use of org.nuxeo.ecm.core.api.impl.blob.StringBlob in project nuxeo-drive-server by nuxeo.

the class TestFileSystemItemManagerService method createTestDocs.

@Before
public void createTestDocs() throws Exception {
    principal = session.getPrincipal();
    // Create and register 2 synchronization roots for Administrator
    syncRoot1 = session.createDocument(session.createDocumentModel("/", "syncRoot1", "Folder"));
    syncRoot2 = session.createDocument(session.createDocumentModel("/", "syncRoot2", "Folder"));
    Principal administrator = session.getPrincipal();
    nuxeoDriveManager.registerSynchronizationRoot(administrator, syncRoot1, session);
    nuxeoDriveManager.registerSynchronizationRoot(administrator, syncRoot2, session);
    // Folder
    folder = session.createDocumentModel(syncRoot1.getPathAsString(), "aFolder", "Folder");
    folder.setPropertyValue("dc:title", "Jack's folder");
    folder = session.createDocument(folder);
    // File
    file = session.createDocumentModel(folder.getPathAsString(), "aFile", "File");
    Blob blob = new StringBlob("Content of Joe's file.");
    blob.setFilename("Joe.odt");
    file.setPropertyValue("file:content", (Serializable) blob);
    file = session.createDocument(file);
    // Note
    note = session.createDocumentModel(folder.getPathAsString(), "aNote", "Note");
    note.setPropertyValue("note:note", "Content of Bob's note.");
    note = session.createDocument(note);
    // Custom doc type with the "file" schema
    custom = session.createDocumentModel(folder.getPathAsString(), "aCustomDoc", "Custom");
    blob = new StringBlob("Content of Bonnie's file.");
    blob.setFilename("Bonnie's file.odt");
    custom.setPropertyValue("file:content", (Serializable) blob);
    custom = session.createDocument(custom);
    // FolderishFile: doc type with the "file" schema and the "Folderish"
    // facet
    folderishFile = session.createDocumentModel(folder.getPathAsString(), "aFolderishFile", "FolderishFile");
    folderishFile.setPropertyValue("dc:title", "Sarah's folderish file");
    folderishFile = session.createDocument(folderishFile);
    // Doc not adaptable as a FileSystemItem (not Folderish nor a
    // BlobHolder)
    notAFileSystemItem = session.createDocumentModel(folder.getPathAsString(), "notAFileSystemItem", "NotSynchronizable");
    notAFileSystemItem = session.createDocument(notAFileSystemItem);
    // Sub folder
    subFolder = session.createDocumentModel(folder.getPathAsString(), "aSubFolder", "Folder");
    subFolder.setPropertyValue("dc:title", "Tony's sub folder");
    subFolder = session.createDocument(subFolder);
    session.save();
}
Also used : StringBlob(org.nuxeo.ecm.core.api.impl.blob.StringBlob) Blob(org.nuxeo.ecm.core.api.Blob) StringBlob(org.nuxeo.ecm.core.api.impl.blob.StringBlob) Principal(java.security.Principal) Before(org.junit.Before)

Example 14 with StringBlob

use of org.nuxeo.ecm.core.api.impl.blob.StringBlob in project nuxeo-drive-server by nuxeo.

the class TestGetChangeSummaryMultiRepo method testGetDocumentChangesSummary.

@Test
public void testGetDocumentChangesSummary() throws Exception {
    // Register 3 sync roots and create 3 documents: 2 in the 'test'
    // repository, 1 in the 'other' repository
    DocumentModel doc1;
    DocumentModel doc2;
    DocumentModel doc3;
    Principal administrator = session.getPrincipal();
    nuxeoDriveManager.registerSynchronizationRoot(administrator, folder1, session);
    nuxeoDriveManager.registerSynchronizationRoot(administrator, folder2, session);
    nuxeoDriveManager.registerSynchronizationRoot(administrator, folder3, otherSession);
    doc1 = session.createDocumentModel("/folder1", "doc1", "File");
    doc1.setPropertyValue("file:content", new StringBlob("The content of file 1."));
    doc1 = session.createDocument(doc1);
    doc2 = session.createDocumentModel("/folder2", "doc2", "File");
    doc2.setPropertyValue("file:content", new StringBlob("The content of file 2."));
    doc2 = session.createDocument(doc2);
    doc3 = otherSession.createDocumentModel("/folder3", "doc3", "File");
    doc3.setPropertyValue("file:content", new StringBlob("The content of file 3."));
    doc3 = otherSession.createDocument(doc3);
    TransactionHelper.commitOrRollbackTransaction();
    TransactionHelper.startTransaction();
    // Look in all repositories => should find 3 changes
    FileSystemChangeSummary changeSummary = getChangeSummary();
    List<FileSystemItemChange> docChanges = changeSummary.getFileSystemChanges();
    assertEquals(3, docChanges.size());
    Set<SimpleFileSystemItemChange> expectedChanges = new HashSet<>();
    expectedChanges.add(new SimpleFileSystemItemChange(doc1.getId(), "documentChanged", "test"));
    expectedChanges.add(new SimpleFileSystemItemChange(doc2.getId(), "documentChanged", "test"));
    expectedChanges.add(new SimpleFileSystemItemChange(doc3.getId(), "documentChanged", "other"));
    Set<SimpleFileSystemItemChange> changes = new HashSet<>();
    docChanges.forEach(docChange -> {
        changes.add(new SimpleFileSystemItemChange(docChange.getDocUuid(), docChange.getEventId(), docChange.getRepositoryId()));
        assertNotNull(docChange.getFileSystemItem());
    });
    assertTrue(CollectionUtils.isEqualCollection(expectedChanges, changes));
    assertEquals(Boolean.FALSE, changeSummary.getHasTooManyChanges());
    // Update documents
    doc1.setPropertyValue("dc:description", "Added description to doc1.");
    doc2.setPropertyValue("dc:description", "Added description to doc1.");
    doc3.setPropertyValue("dc:description", "Added description to doc1.");
    session.saveDocument(doc1);
    session.saveDocument(doc2);
    otherSession.saveDocument(doc3);
    TransactionHelper.commitOrRollbackTransaction();
    TransactionHelper.startTransaction();
    changeSummary = getChangeSummary();
    docChanges = changeSummary.getFileSystemChanges();
    assertEquals(3, docChanges.size());
}
Also used : FileSystemChangeSummary(org.nuxeo.drive.service.FileSystemChangeSummary) StringBlob(org.nuxeo.ecm.core.api.impl.blob.StringBlob) SimpleFileSystemItemChange(org.nuxeo.drive.fixtures.SimpleFileSystemItemChange) FileSystemItemChange(org.nuxeo.drive.service.FileSystemItemChange) SimpleFileSystemItemChange(org.nuxeo.drive.fixtures.SimpleFileSystemItemChange) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel) Principal(java.security.Principal) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 15 with StringBlob

use of org.nuxeo.ecm.core.api.impl.blob.StringBlob in project nuxeo-drive-server by nuxeo.

the class TestPermissionHierarchyFileSystemChanges method createFile.

protected DocumentModel createFile(CoreSession session, String path, String name, String type, String fileName, String content) {
    DocumentModel file = session.createDocumentModel(path, name, type);
    Blob blob = new StringBlob(content);
    blob.setFilename(fileName);
    file.setPropertyValue("file:content", (Serializable) blob);
    return session.createDocument(file);
}
Also used : StringBlob(org.nuxeo.ecm.core.api.impl.blob.StringBlob) Blob(org.nuxeo.ecm.core.api.Blob) StringBlob(org.nuxeo.ecm.core.api.impl.blob.StringBlob) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel)

Aggregations

StringBlob (org.nuxeo.ecm.core.api.impl.blob.StringBlob)32 Test (org.junit.Test)24 DocumentModel (org.nuxeo.ecm.core.api.DocumentModel)24 Blob (org.nuxeo.ecm.core.api.Blob)17 FileSystemItemChange (org.nuxeo.drive.service.FileSystemItemChange)13 HashSet (java.util.HashSet)12 FileItem (org.nuxeo.drive.adapter.FileItem)7 Principal (java.security.Principal)5 FileSystemItem (org.nuxeo.drive.adapter.FileSystemItem)5 FolderItem (org.nuxeo.drive.adapter.FolderItem)5 CloseableCoreSession (org.nuxeo.ecm.core.api.CloseableCoreSession)5 Before (org.junit.Before)4 FileSystemChangeSummary (org.nuxeo.drive.service.FileSystemChangeSummary)4 RootlessItemException (org.nuxeo.drive.adapter.RootlessItemException)2 DefaultSyncRootFolderItem (org.nuxeo.drive.adapter.impl.DefaultSyncRootFolderItem)2 SimpleFileSystemItemChange (org.nuxeo.drive.fixtures.SimpleFileSystemItemChange)2 DocumentModelList (org.nuxeo.ecm.core.api.DocumentModelList)2 NuxeoException (org.nuxeo.ecm.core.api.NuxeoException)2 PathRef (org.nuxeo.ecm.core.api.PathRef)2 Deploy (org.nuxeo.runtime.test.runner.Deploy)2