Пример #1
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());
  }
Пример #2
0
  @Test
  public void testCmisProperties() throws Exception {

    /*
     * checked out doc (live; private working copy)
     */

    DocumentModel doc = new DocumentModelImpl("/", "myfile", "File");
    doc = session.createDocument(doc);

    assertTrue(doc.isCheckedOut()); // nuxeo prop, false only on live
    assertFalse(doc.isVersion());
    assertFalse(doc.isProxy());
    assertFalse(doc.hasFacet(FacetNames.IMMUTABLE));
    assertFalse(doc.isImmutable());
    String versionSeriesId = doc.getVersionSeriesId();
    assertNotNull(versionSeriesId);
    // assertNotSame(versionSeriesId, doc.getId());
    assertEquals("0.0", doc.getVersionLabel());
    assertNull(doc.getCheckinComment());
    assertFalse(doc.isMajorVersion());
    assertFalse(doc.isLatestVersion());
    assertFalse(doc.isLatestMajorVersion());
    assertTrue(doc.isVersionSeriesCheckedOut());
    assertEquals(doc.getId(), session.getWorkingCopy(doc.getRef()).getId());

    /*
     * proxy to checked out doc (live proxy)
     */

    DocumentModel proxy = session.createProxy(doc.getRef(), session.getRootDocument().getRef());

    assertTrue(proxy.isCheckedOut()); // nuxeo prop, false only on live
    assertFalse(proxy.isVersion());
    assertTrue(proxy.isProxy());
    assertFalse(proxy.hasFacet(FacetNames.IMMUTABLE));
    assertFalse(proxy.isImmutable());
    assertEquals(versionSeriesId, proxy.getVersionSeriesId());
    assertEquals("0.0", proxy.getVersionLabel());
    assertNull(proxy.getCheckinComment());
    assertFalse(proxy.isMajorVersion());
    assertFalse(proxy.isLatestVersion());
    assertFalse(proxy.isLatestMajorVersion());
    assertTrue(proxy.isVersionSeriesCheckedOut());
    assertTrue(doc.isVersionSeriesCheckedOut());
    assertEquals(doc.getId(), session.getWorkingCopy(proxy.getRef()).getId());

    /*
     * checked in doc
     */

    DocumentRef verRef = doc.checkIn(VersioningOption.MINOR, "comment");
    session.save();
    DocumentModel ver = session.getDocument(verRef);
    proxy.refresh();

    assertFalse(doc.isCheckedOut());
    assertFalse(doc.isVersion());
    assertFalse(doc.isProxy());
    // assertTrue(doc.hasFacet(FacetNames.IMMUTABLE)); // debatable
    // assertTrue(doc.isImmutable()); // debatable
    assertEquals(versionSeriesId, doc.getVersionSeriesId());
    assertEquals("0.1", doc.getVersionLabel());
    assertNull(doc.getCheckinComment());
    assertFalse(doc.isMajorVersion());
    assertFalse(doc.isLatestVersion());
    assertFalse(doc.isLatestMajorVersion());
    assertFalse(doc.isVersionSeriesCheckedOut());
    assertFalse(proxy.isVersionSeriesCheckedOut());
    assertEquals(doc.getId(), session.getWorkingCopy(proxy.getRef()).getId());

    // TODO proxy to checked in doc

    /*
     * version
     */

    // assertFalse(ver.isCheckedOut()); // TODO
    assertTrue(ver.isVersion());
    assertFalse(ver.isProxy());
    assertTrue(ver.hasFacet(FacetNames.IMMUTABLE));
    assertTrue(ver.isImmutable());
    assertEquals(versionSeriesId, ver.getVersionSeriesId());
    assertEquals("0.1", ver.getVersionLabel());
    assertEquals("comment", ver.getCheckinComment());
    assertFalse(ver.isMajorVersion());
    assertTrue(ver.isLatestVersion());
    assertFalse(ver.isLatestMajorVersion());
    assertFalse(ver.isVersionSeriesCheckedOut());
    assertEquals(doc.getId(), session.getWorkingCopy(ver.getRef()).getId());

    /*
     * proxy to version
     */

    proxy = session.createProxy(ver.getRef(), session.getRootDocument().getRef());

    assertFalse(proxy.isCheckedOut());
    assertFalse(proxy.isVersion());
    assertTrue(proxy.isProxy());
    assertTrue(proxy.hasFacet(FacetNames.IMMUTABLE));
    assertTrue(proxy.isImmutable());
    assertEquals(versionSeriesId, proxy.getVersionSeriesId());
    assertEquals("0.1", proxy.getVersionLabel());
    assertEquals("comment", proxy.getCheckinComment());
    assertFalse(proxy.isMajorVersion());
    assertTrue(proxy.isLatestVersion());
    assertFalse(proxy.isLatestMajorVersion());
    assertFalse(proxy.isVersionSeriesCheckedOut());
    assertFalse(doc.isVersionSeriesCheckedOut());
    assertFalse(ver.isVersionSeriesCheckedOut());
    assertEquals(doc.getId(), session.getWorkingCopy(proxy.getRef()).getId());

    /*
     * re-checked out doc
     */

    doc.checkOut();
    ver.refresh();
    proxy.refresh();

    assertTrue(doc.isCheckedOut());
    assertFalse(doc.isVersion());
    assertFalse(doc.isProxy());
    assertFalse(doc.hasFacet(FacetNames.IMMUTABLE));
    assertFalse(doc.isImmutable());
    assertEquals(versionSeriesId, doc.getVersionSeriesId());
    assertEquals("0.1+", doc.getVersionLabel());
    assertNull(doc.getCheckinComment());
    assertFalse(doc.isMajorVersion());
    assertFalse(doc.isLatestVersion());
    assertFalse(doc.isLatestMajorVersion());
    assertTrue(doc.isVersionSeriesCheckedOut());
    assertTrue(ver.isVersionSeriesCheckedOut());
    assertTrue(proxy.isVersionSeriesCheckedOut());
    assertEquals(doc.getId(), session.getWorkingCopy(doc.getRef()).getId());

    /*
     * major checkin
     */

    DocumentRef majRef = doc.checkIn(VersioningOption.MAJOR, "yo");
    DocumentModel maj = session.getDocument(majRef);
    ver.refresh();
    proxy.refresh();

    assertTrue(maj.isMajorVersion());
    assertTrue(maj.isLatestVersion());
    assertTrue(maj.isLatestMajorVersion());
    assertFalse(maj.isVersionSeriesCheckedOut());
    assertEquals(doc.getId(), session.getWorkingCopy(maj.getRef()).getId());
    // previous ver
    assertFalse(ver.isMajorVersion());
    assertFalse(ver.isLatestVersion());
    assertFalse(ver.isLatestMajorVersion());
    assertFalse(ver.isVersionSeriesCheckedOut());
    assertFalse(doc.isVersionSeriesCheckedOut());
    assertFalse(proxy.isVersionSeriesCheckedOut());
    assertEquals(doc.getId(), session.getWorkingCopy(ver.getRef()).getId());
  }