Exemplo n.º 1
0
  @Test
  public void testVersionRemoval() throws Exception {
    DocumentModel folder = session.createDocumentModel("/", "folder", "Folder");
    folder = session.createDocument(folder);
    DocumentModel file = session.createDocumentModel("/folder", "file", "File");
    file = session.createDocument(file);
    DocumentModel proxy = session.publishDocument(file, folder);
    DocumentModel version = session.getLastDocumentVersion(file.getRef());
    session.save();

    // even Administrator/system cannot remove a version with a proxy
    try {
      session.removeDocument(version.getRef());
      fail("Admin should not be able to remove version");
    } catch (DocumentSecurityException e) {
      // ok
    }

    // remove the proxy first
    session.removeDocument(proxy.getRef());
    session.save();
    // we can now remove the version
    session.removeDocument(version.getRef());
    session.save();
  }
Exemplo n.º 2
0
 protected void createVersions(int i) throws Exception {
   DocumentModel folder = new DocumentModelImpl("/", "fold" + i, "Folder");
   session.createDocument(folder);
   DocumentModel file = new DocumentModelImpl("/fold" + i, "file", "File");
   file = session.createDocument(file);
   createTrioVersions(file);
 }
Exemplo n.º 3
0
  @Test
  public void testCopy() {
    DocumentModel doc = session.createDocumentModel("/", "file", "File");
    doc = session.createDocument(doc);
    session.save();
    String versionSeriesId = doc.getVersionSeriesId();

    // copy
    DocumentModel copy =
        session.copy(doc.getRef(), session.getRootDocument().getRef(), "fileCopied");

    // check different version series id
    assertNotSame(versionSeriesId, copy.getVersionSeriesId());

    // create version and proxy
    DocumentModel folder = session.createDocumentModel("/", "folder", "Folder");
    folder = session.createDocument(folder);
    DocumentModel proxy = session.publishDocument(doc, folder);
    // check same version series id
    assertEquals(versionSeriesId, proxy.getVersionSeriesId());

    // copy proxy
    DocumentModel proxyCopy =
        session.copy(proxy.getRef(), session.getRootDocument().getRef(), "proxyCopied");
    // check same version series id
    assertEquals(versionSeriesId, proxyCopy.getVersionSeriesId());
  }
Exemplo n.º 4
0
  @Test
  public void testRemoveSingleDocVersion() throws Exception {
    DocumentModel folder = new DocumentModelImpl("/", "folder#1", "Folder");
    folder = session.createDocument(folder);

    DocumentModel file = new DocumentModelImpl(folder.getPathAsString(), "file#1", "File");
    file = session.createDocument(file);

    checkVersions(file);

    file.setPropertyValue("file:filename", "A");
    file.putContextData(
        ScopeType.REQUEST, VersioningDocument.CREATE_SNAPSHOT_ON_SAVE_KEY, Boolean.TRUE);
    file = session.saveDocument(file);

    checkVersions(file, "0.1");

    DocumentModel lastversion = session.getLastDocumentVersion(file.getRef());
    assertNotNull(lastversion);

    assertTrue(lastversion.isVersion());
    session.removeDocument(lastversion.getRef());

    checkVersions(file);
  }
Exemplo n.º 5
0
  @Test
  public void testPublishing() {
    DocumentModel folder = session.createDocumentModel("/", "folder", "Folder");
    folder = session.createDocument(folder);
    DocumentModel doc = session.createDocumentModel("/", "file", "File");
    doc = session.createDocument(doc);
    checkVersions(doc);

    // publish
    DocumentModel proxy = session.publishDocument(doc, folder);
    session.save();
    String versionSeriesId = doc.getVersionSeriesId();
    assertFalse(proxy.isVersion());
    assertTrue(proxy.isProxy());
    assertTrue(proxy.hasFacet(FacetNames.IMMUTABLE));
    assertTrue(proxy.isImmutable());
    assertEquals(versionSeriesId, proxy.getVersionSeriesId());
    assertNotSame(versionSeriesId, proxy.getId());
    assertEquals("0.1", proxy.getVersionLabel());
    assertNull(proxy.getCheckinComment());
    assertFalse(proxy.isMajorVersion());
    assertTrue(proxy.isLatestVersion());
    assertFalse(proxy.isLatestMajorVersion());

    checkVersions(doc, "0.1");
    VersionModel lastVersion = session.getLastVersion(doc.getRef());
    assertNotNull(lastVersion);
    assertEquals("0.1", lastVersion.getLabel());
    DocumentModel lastVersionDocument = session.getLastDocumentVersion(doc.getRef());
    assertNotNull(lastVersionDocument);
    assertEquals("file", lastVersionDocument.getName());
  }
Exemplo n.º 6
0
  @Before
  public void initRepo() throws Exception {
    document = coreSession.createDocumentModel("/", "task-root", "TaskRoot");
    document.setPropertyValue("dc:title", "Task");
    document = coreSession.createDocument(document);

    document = coreSession.createDocumentModel("/", "src", "Folder");
    document.setPropertyValue("dc:title", "Source");
    document = coreSession.createDocument(document);

    coreSession.save();
    document = coreSession.getDocument(document.getRef());

    Framework.getService(EventService.class).waitForAsyncCompletion();
  }
 public static List<DocumentModel> createTestFiles(CoreSession session, final int nbFile)
     throws ClientException {
   DocumentModel testWorkspace =
       session.createDocumentModel("/default-domain/workspaces", "testWorkspace", "Workspace");
   testWorkspace = session.createDocument(testWorkspace);
   List<DocumentModel> result = new ArrayList<DocumentModel>();
   for (int i = 1; i <= nbFile; i++) {
     DocumentModel testFile =
         session.createDocumentModel(
             testWorkspace.getPath().toString(), TEST_FILE_NAME + i, "File");
     testFile = session.createDocument(testFile);
     result.add(testFile);
   }
   return result;
 }
 private DocumentModel createSite() throws ClientException, PropertyException {
   DocumentModel site =
       session.createDocumentModel("/", "site1", LabsSiteConstants.Docs.SITE.type());
   site.setPropertyValue("dc:title", "le titre");
   site = session.createDocument(site);
   return site;
 }
 protected DocumentModel createNode(DocumentModel route, String name, CoreSession session)
     throws PropertyException {
   DocumentModel node =
       session.createDocumentModel(route.getPathAsString(), name, TYPE_ROUTE_NODE);
   node.setPropertyValue(GraphNode.PROP_NODE_ID, name);
   return session.createDocument(node);
 }
Exemplo n.º 10
0
  @Test
  public void testSaveRestoredVersionWithVersionAutoIncrement() {
    // check-in version 1.0, 2.0 and restore version 1.0
    DocumentModel doc = new DocumentModelImpl("/", "myfile", "File");
    doc = session.createDocument(doc);
    doc = session.saveDocument(doc);
    DocumentRef co = doc.getRef();
    DocumentRef ci1 = session.checkIn(co, VersioningOption.MAJOR, "first check-in");
    session.checkOut(co);
    maybeSleepToNextSecond();
    DocumentRef ci2 = session.checkIn(co, VersioningOption.MAJOR, "second check-in");
    waitForFulltextIndexing();
    maybeSleepToNextSecond();
    session.restoreToVersion(co, ci1);

    // save document with auto-increment should produce version 3.0
    doc = session.getDocument(co);
    assertEquals(doc.getVersionLabel(), "1.0");
    doc.getContextData()
        .putScopedValue(
            ScopeType.DEFAULT, VersioningService.VERSIONING_OPTION, VersioningOption.MAJOR);
    // mark as dirty - must change the value
    doc.setPropertyValue("dc:title", doc.getPropertyValue("dc:title") + " dirty");
    doc = session.saveDocument(doc);
    assertEquals(doc.getVersionLabel(), "3.0");
  }
Exemplo n.º 11
0
  @Test
  public void testAutoCheckOut() throws Exception {
    DocumentModel doc = new DocumentModelImpl("/", "file", "File");
    doc.setPropertyValue("dc:title", "t0");
    doc = session.createDocument(doc);
    assertTrue(doc.isCheckedOut());
    session.checkIn(doc.getRef(), null, null);
    doc.refresh();
    assertFalse(doc.isCheckedOut());

    // auto-checkout
    doc.setPropertyValue("dc:title", "t1");
    doc = session.saveDocument(doc);
    assertTrue(doc.isCheckedOut());

    session.checkIn(doc.getRef(), null, null);
    doc.refresh();
    assertFalse(doc.isCheckedOut());

    // disable auto-checkout
    doc.setPropertyValue("dc:title", "t2");
    doc.putContextData(VersioningService.DISABLE_AUTO_CHECKOUT, Boolean.TRUE);
    doc = session.saveDocument(doc);
    assertFalse(doc.isCheckedOut());
    assertEquals("t2", doc.getPropertyValue("dc:title"));

    // can still be checked out normally afterwards
    doc.checkOut();
    assertTrue(doc.isCheckedOut());
    assertEquals("t2", doc.getPropertyValue("dc:title"));
  }
Exemplo n.º 12
0
  @Test
  public void testCheckInCheckOut() throws Exception {
    DocumentModel doc = new DocumentModelImpl("/", "file#789", "File");
    assertTrue(doc.isCheckedOut());
    doc = session.createDocument(doc);
    assertTrue(session.isCheckedOut(doc.getRef()));
    assertTrue(doc.isCheckedOut());
    session.save();
    assertTrue(session.isCheckedOut(doc.getRef()));
    assertTrue(doc.isCheckedOut());

    DocumentRef verRef = session.checkIn(doc.getRef(), null, null);
    DocumentModel ver = session.getDocument(verRef);
    assertTrue(ver.isVersion());
    doc.refresh();
    assertFalse(session.isCheckedOut(doc.getRef()));
    assertFalse(doc.isCheckedOut());

    session.checkOut(doc.getRef());
    assertTrue(session.isCheckedOut(doc.getRef()));

    // using DocumentModel API
    DocumentRef verRef2 = doc.checkIn(null, null);
    DocumentModel ver2 = session.getDocument(verRef2);
    assertTrue(ver2.isVersion());
    assertFalse(doc.isCheckedOut());
    doc.checkOut();
    assertTrue(doc.isCheckedOut());
  }
Exemplo n.º 13
0
  @Test
  public void testAllowVersionWrite() {
    DocumentModel doc = session.createDocumentModel("/", "doc", "File");
    doc.setPropertyValue("icon", "icon1");
    doc = session.createDocument(doc);
    DocumentRef verRef = session.checkIn(doc.getRef(), null, null);

    // regular version cannot be written
    DocumentModel ver = session.getDocument(verRef);
    ver.setPropertyValue("icon", "icon2");
    try {
      session.saveDocument(ver);
      fail("Should not allow version write");
    } catch (PropertyException e) {
      assertTrue(e.getMessage(), e.getMessage().contains("Cannot set property on a version"));
    }

    // with proper option, it's allowed
    ver.setPropertyValue("icon", "icon3");
    ver.putContextData(CoreSession.ALLOW_VERSION_WRITE, Boolean.TRUE);
    session.saveDocument(ver);
    // refetch to check
    ver = session.getDocument(verRef);
    assertEquals("icon3", ver.getPropertyValue("icon"));
  }
Exemplo n.º 14
0
  @Test
  public void testPublishingAfterVersionDelete() {
    DocumentModel folder = session.createDocumentModel("/", "folder", "Folder");
    folder = session.createDocument(folder);
    DocumentModel doc = session.createDocumentModel("/", "file", "File");
    doc = session.createDocument(doc);
    checkVersions(doc);

    VersionModel lastVersion = session.getLastVersion(doc.getRef());
    assertNull(lastVersion);
    DocumentModel lastVersionDocument = session.getLastDocumentVersion(doc.getRef());
    assertNull(lastVersionDocument);

    // publish
    DocumentModel proxy = session.publishDocument(doc, folder);
    checkVersions(doc, "0.1");
    lastVersion = session.getLastVersion(doc.getRef());
    assertNotNull(lastVersion);
    assertEquals("0.1", lastVersion.getLabel());
    lastVersionDocument = session.getLastDocumentVersion(doc.getRef());
    assertNotNull(lastVersionDocument);
    assertEquals("file", lastVersionDocument.getName());

    // unpublish
    session.removeDocument(proxy.getRef());
    // delete the version
    List<VersionModel> versions = session.getVersionsForDocument(doc.getRef());
    assertEquals(1, versions.size());
    DocumentModel docVersion = session.getDocumentWithVersion(doc.getRef(), versions.get(0));
    session.removeDocument(docVersion.getRef());

    checkVersions(doc);
    lastVersion = session.getLastVersion(doc.getRef());
    assertNull(lastVersion);
    lastVersionDocument = session.getLastDocumentVersion(doc.getRef());
    assertNull(lastVersionDocument);

    // republish
    DocumentModel newProxy = session.publishDocument(doc, folder);
    checkVersions(doc, "0.2");
    lastVersion = session.getLastVersion(doc.getRef());
    assertNotNull(lastVersion);
    assertEquals("0.2", lastVersion.getLabel());
    lastVersionDocument = session.getLastDocumentVersion(doc.getRef());
    assertNotNull(lastVersionDocument);
    assertEquals("file", lastVersionDocument.getName());
  }
  @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();
  }
Exemplo n.º 16
0
  // security on versions, see TestLocalAPIWithCustomVersioning
  @Test
  public void testVersionSecurity() throws Exception {
    DocumentModel folder = new DocumentModelImpl("/", "folder", "Folder");
    folder = session.createDocument(folder);
    ACP acp = new ACPImpl();
    ACE ace = new ACE("princ1", "perm1", true);
    ACL acl = new ACLImpl("acl1", false);
    acl.add(ace);
    acp.addACL(acl);
    session.setACP(folder.getRef(), acp, true);
    DocumentModel file = new DocumentModelImpl("/folder", "file", "File");
    file = session.createDocument(file);
    // set security
    acp = new ACPImpl();
    ace = new ACE("princ2", "perm2", true);
    acl = new ACLImpl("acl2", false);
    acl.add(ace);
    acp.addACL(acl);
    session.setACP(file.getRef(), acp, true);
    session.save();

    DocumentModel proxy = session.publishDocument(file, folder);
    DocumentModel version = session.getLastDocumentVersion(file.getRef());
    session.save();

    // check security on version
    acp = session.getACP(version.getRef());
    ACL[] acls = acp.getACLs();
    assertEquals(2, acls.length);
    acl = acls[0];
    assertEquals(1, acl.size());
    assertEquals("princ2", acl.get(0).getUsername());
    acl = acls[1];
    assertEquals(1 + 3, acl.size()); // 1 + 3 root defaults
    assertEquals("princ1", acl.get(0).getUsername());

    // remove live document (there's a proxy so the version stays)
    session.removeDocument(file.getRef());
    session.save();
    // recheck security on version (works because we're administrator)
    acp = session.getACP(version.getRef());
    assertNull(acp);
    // check proxy still accessible (in another session)
    try (CoreSession session2 = openSessionAs(SecurityConstants.ADMINISTRATOR)) {
      session2.getDocument(proxy.getRef());
    }
  }
 protected DocumentModel createRoute(String name, CoreSession session) throws PropertyException {
   DocumentModel route = session.createDocumentModel("/", name, DOCUMENT_ROUTE_DOCUMENT_TYPE);
   route.setPropertyValue(EXECUTION_TYPE_PROPERTY_NAME, graph.name());
   route.setPropertyValue("dc:title", name);
   route.setPropertyValue(
       ATTACHED_DOCUMENTS_PROPERTY_NAME, (Serializable) Collections.singletonList(doc.getId()));
   return session.createDocument(route);
 }
Exemplo n.º 18
0
  private void createDocs() throws Exception {
    rootDocument = session.getRootDocument();
    workspace = session.createDocumentModel(rootDocument.getPathAsString(), "ws1", "Workspace");
    workspace.setProperty("dublincore", "title", "test WS");
    workspace = session.createDocument(workspace);

    docToExport = session.createDocumentModel(workspace.getPathAsString(), "file", "File");
    docToExport.setProperty("dublincore", "title", "MyDoc");

    Blob blob = Blobs.createBlob("SomeDummyContent");
    blob.setFilename("dummyBlob.txt");
    docToExport.setProperty("file", "content", blob);

    docToExport = session.createDocument(docToExport);

    session.save();
  }
Exemplo n.º 19
0
  protected DocumentModel doCreateDocument() {
    DocumentModel rootDocument = session.getRootDocument();
    DocumentModel model =
        session.createDocumentModel(rootDocument.getPathAsString(), "youps", "File");
    model.setProperty("dublincore", "title", "huum");

    return session.createDocument(model);
  }
Exemplo n.º 20
0
  // Creates 3 versions and removes the last.
  @Test
  public void testRemoveLastDocVersion() throws Exception {
    DocumentModel folder = new DocumentModelImpl("/", "folder#1", "Folder");
    folder = session.createDocument(folder);

    DocumentModel file = new DocumentModelImpl(folder.getPathAsString(), "file#1", "File");
    file = session.createDocument(file);

    createTrioVersions(file);

    final int VERSION_INDEX = 2;
    DocumentModel lastversion = session.getVersions(file.getRef()).get(VERSION_INDEX);
    assertNotNull(lastversion);

    assertTrue(lastversion.isVersion());
    session.removeDocument(lastversion.getRef());

    checkVersions(file, "0.1", "0.2");
  }
Exemplo n.º 21
0
 protected void buildTree() {
   String root = "/";
   for (int i = 0; i < 10; i++) {
     String name = "folder" + i;
     DocumentModel doc = session.createDocumentModel(root, name, "Folder");
     doc.setPropertyValue("dc:title", "Folder" + i);
     session.createDocument(doc);
     root = root + name + "/";
   }
 }
  @Override
  public void populate(CoreSession session) throws ClientException {
    super.populate(session);

    DocumentModel doc =
        session.createDocumentModel("/default-domain/sections", "section", "Section");
    doc.setProperty("dublincore", "title", "Section1");
    doc = session.createDocument(doc);
    session.saveDocument(doc);
  }
Exemplo n.º 23
0
  @Test
  public void addRemoveToFavoritesTest() {
    DocumentModel testWorkspace =
        session.createDocumentModel("/default-domain/workspaces", "testWorkspace", "Workspace");
    testWorkspace = session.createDocument(testWorkspace);
    DocumentModel testFile =
        session.createDocumentModel(testWorkspace.getPathAsString(), TEST_FILE_NAME, "File");
    testFile = session.createDocument(testFile);

    favoritesManager.addToFavorites(testFile, session);

    testFile = session.getDocument(testFile.getRef());

    assertTrue(favoritesManager.isFavorite(testFile, session));

    favoritesManager.removeFromFavorites(testFile, session);

    testFile = session.getDocument(testFile.getRef());

    assertFalse(favoritesManager.isFavorite(testFile, session));
  }
  @Override
  public LabsNews createNews(String pTitle) throws ClientException {
    CoreSession session = getSession();
    DocumentModel document =
        session.createDocumentModel(
            doc.getPathAsString(),
            LabsSiteUtils.doLabsSlugify(pTitle),
            LabsSiteConstants.Docs.LABSNEWS.type());

    document.setPropertyValue("dc:title", pTitle);
    return session.createDocument(document).getAdapter(LabsNews.class);
  }
Exemplo n.º 25
0
  @Override
  public DocumentModel create(
      CoreSession documentManager,
      Blob content,
      String path,
      boolean overwrite,
      String fullname,
      TypeManager typeService)
      throws ClientException, IOException {
    path = getNearestContainerPath(documentManager, path);
    doSecurityCheck(documentManager, path, getNoteTypeName(), typeService);

    String filename = FileManagerUtils.fetchFileName(fullname);

    String title = FileManagerUtils.fetchTitle(filename);

    // Looking if an existing Document with the same filename exists.
    DocumentModel docModel = FileManagerUtils.getExistingDocByTitle(documentManager, path, title);

    if (overwrite && docModel != null) {

      docModel.setProperty(NOTE_SCHEMA, NOTE_FIELD, getString(content));
      docModel.setProperty(NOTE_SCHEMA, MT_FIELD, content.getMimeType());
      docModel = overwriteAndIncrementversion(documentManager, docModel);
    } else {
      PathSegmentService pss;
      try {
        pss = Framework.getService(PathSegmentService.class);
      } catch (Exception e) {
        throw new ClientException(e);
      }
      // Create a new empty DocumentModel of type Note in memory
      docModel = documentManager.createDocumentModel(getNoteTypeName());

      // Update known attributes (title, note)
      docModel.setProperty(DUBLINCORE_SCHEMA, TITLE_FIELD, title);
      docModel.setProperty(NOTE_SCHEMA, NOTE_FIELD, getString(content));
      docModel.setProperty(NOTE_SCHEMA, MT_FIELD, content.getMimeType());

      // Create the new document in the repository
      docModel.setPathInfo(path, pss.generatePathSegment(docModel));
      docModel = documentManager.createDocument(docModel);
    }
    documentManager.save();

    log.debug(
        "Created the Note: "
            + docModel.getName()
            + " with icon: "
            + docModel.getProperty(COMMON_SCHEMA, ICON_FIELD));
    return docModel;
  }
  protected DocumentModel createFolder(CoreSession session, String path, String name, String type)
      throws InterruptedException {

    DocumentModel folder = session.createDocumentModel(path, name, type);
    folder = session.createDocument(folder);
    // If the test is run against MySQL or SQL Server, because of its
    // milliseconds limitation, we need to wait for 1 second between each
    // document creation to ensure correct ordering when fetching a folder's
    // children, the default page provider query being ordered by ascendant
    // creation date.
    waitIfMySQLOrSQLServer();
    return folder;
  }
  private void createAndDeleteFile(String name) throws PropertyException {
    DocumentModel file = new DocumentModelImpl("/testfolder", name, "File");
    file.setPropertyValue("dc:title", "testfile Title");
    file = session.createDocument(file);
    session.save();
    nextTransaction();

    // at this point fulltext update is triggered async

    session.removeDocument(new IdRef(file.getId()));
    session.save();

    waitForAsyncCompletion();
  }
Exemplo n.º 28
0
 @Test
 public void testAllowVersionWriteACL() {
   DocumentModel doc = session.createDocumentModel("/", "doc", "File");
   doc = session.createDocument(doc);
   DocumentRef verRef = session.checkIn(doc.getRef(), null, null);
   DocumentModel ver = session.getDocument(verRef);
   ACL acl = new ACLImpl("acl1", false);
   ACE ace = new ACE("princ1", "perm1", true);
   acl.add(ace);
   ACP acp = new ACPImpl();
   acp.addACL(acl);
   // check that ACP can be set
   ver.setACP(acp, true);
 }
Exemplo n.º 29
0
  @Test
  public void testPublishingAfterCopy() {
    DocumentModel folder = session.createDocumentModel("/", "folder", "Folder");
    folder = session.createDocument(folder);
    DocumentModel doc = session.createDocumentModel("/", "file", "File");
    doc = session.createDocument(doc);
    checkVersions(doc);

    // publish
    DocumentModel proxy = session.publishDocument(doc, folder);
    checkVersions(doc, "0.1");
    DocumentModel lastVersion = session.getLastDocumentVersion(doc.getRef());
    assertNotNull(lastVersion);
    assertEquals("0.1", lastVersion.getVersionLabel());
    DocumentModel lastVersionDocument = session.getLastDocumentVersion(doc.getRef());
    assertNotNull(lastVersionDocument);
    assertEquals("file", lastVersionDocument.getName());

    // copy published file, version is reset
    DocumentModel copy = session.copy(doc.getRef(), folder.getRef(), "fileCopied");
    checkVersions(copy);
    lastVersion = session.getLastDocumentVersion(copy.getRef());
    assertNull(lastVersion);
    lastVersionDocument = session.getLastDocumentVersion(copy.getRef());
    assertNull(lastVersionDocument);

    // republish
    DocumentModel newProxy = session.publishDocument(copy, folder);
    checkVersions(copy, "0.1");
    lastVersion = session.getLastDocumentVersion(copy.getRef());
    assertNotNull(lastVersion);
    assertEquals("0.1", lastVersion.getVersionLabel());
    lastVersionDocument = session.getLastDocumentVersion(copy.getRef());
    assertNotNull(lastVersionDocument);
    assertEquals("fileCopied", lastVersionDocument.getName());
  }
Exemplo n.º 30
0
  @Test
  public void testCopyCheckedIn() {
    DocumentModel doc = session.createDocumentModel("/", "file", "File");
    doc = session.createDocument(doc);
    doc.checkIn(VersioningOption.MAJOR, "comment");
    session.save();
    assertFalse(doc.isCheckedOut());
    assertEquals("1.0", doc.getVersionLabel());

    // copy
    DocumentModel copy =
        session.copy(doc.getRef(), session.getRootDocument().getRef(), "fileCopied");

    assertTrue(copy.isCheckedOut());
    assertEquals("0.0", copy.getVersionLabel());
  }