Пример #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());
  }
 @Override
 public Object getAdapter(DocumentModel doc, Class<?> cls) {
   if (doc.hasFacet(PICTURE_FACET) || doc.hasSchema(PICTURE_SCHEMA_NAME)) {
     PictureResourceAdapter adapter = new NoPictureAdapter();
     adapter.setDocumentModel(doc);
     return adapter;
   }
   return null;
 }
Пример #3
0
 protected DocumentModelList getSortedChildren(boolean queryDocuments) {
   String whereClause = buildChildrenWhereClause(queryDocuments);
   DocumentModelList children =
       getCoreSession().query("SELECT * FROM Document WHERE " + whereClause);
   if (!folder.hasFacet(FacetNames.ORDERABLE)) {
     DefaultDocumentTreeSorter sorter = new DefaultDocumentTreeSorter();
     sorter.setSortPropertyPath(DEFAULT_SORT_PROP_NAME);
     Collections.sort(children, sorter);
   }
   return children;
 }
Пример #4
0
  /**
   * Returns a List of type selected for the domain given as parameter
   *
   * @param document the domain to configure
   * @return List of documen type selected for the domain
   * @since 5.5
   */
  public List<Type> getSelectedTypes(DocumentModel document) {
    if (!document.hasFacet(UI_TYPES_CONFIGURATION_FACET)) {
      return Collections.emptyList();
    }

    List<String> allowedTypes = getAllowedTypes(document);

    List<Type> selectedTypes = new ArrayList<Type>();
    for (String type : allowedTypes) {
      Type existingType = typeManager.getType(type);
      if (existingType != null) {
        selectedTypes.add(existingType);
      }
    }

    Collections.sort(selectedTypes, new TypeLabelAlphabeticalOrder(messages));
    return selectedTypes;
  }
Пример #5
0
 public List<StoryboardItem> getStoryboard() throws PropertyException, ClientException {
   if (!doc.hasFacet(VideoConstants.HAS_STORYBOARD_FACET)) {
     return Collections.emptyList();
   }
   int size = doc.getProperty(STORYBOARD_PROPERTY).getValue(List.class).size();
   List<StoryboardItem> items = new ArrayList<StoryboardItem>(size);
   StoryboardItem previous = null;
   for (int i = 0; i < size; i++) {
     StoryboardItem next = new StoryboardItem(doc, STORYBOARD_PROPERTY, i, baseURL);
     next.setEndTimecode(String.valueOf(videoDocument.getVideo().getDuration()));
     if (previous != null) {
       previous.setEndTimecode(next.startTimecode);
     }
     items.add(next);
     previous = next;
   }
   return items;
 }
Пример #6
0
  @OperationMethod
  public DocumentModel run(DocumentModel doc) {
    if (!doc.hasFacet(SIMPLE_CONFIGURATION_FACET)) {
      doc.addFacet(SIMPLE_CONFIGURATION_FACET);
      doc = session.saveDocument(doc);
    }

    SimpleConfiguration simpleConfiguration =
        localConfigurationService.getConfiguration(
            SimpleConfiguration.class, SIMPLE_CONFIGURATION_FACET, doc);
    simpleConfiguration.putAll(parameters);
    simpleConfiguration.save(session);

    if (save) {
      doc = session.saveDocument(doc);
    }
    return doc;
  }
Пример #7
0
  /**
   * Returns a List of type not selected for the domain given as parameter
   *
   * @param document the domain to configure
   * @return a List of type of document, not currently selected for the domain
   * @since 5.5
   */
  public List<Type> getNotSelectedTypes(DocumentModel document) {
    if (!document.hasFacet(UI_TYPES_CONFIGURATION_FACET)) {
      return Collections.emptyList();
    }

    List<String> allowedTypes = getAllowedTypes(document);

    List<Type> notSelectedTypes =
        new ArrayList<Type>(typeManager.findAllAllowedSubTypesFrom(document.getType()));

    for (Iterator<Type> it = notSelectedTypes.iterator(); it.hasNext(); ) {
      Type type = it.next();
      if (allowedTypes.contains(type.getId())) {
        it.remove();
      }
    }

    Collections.sort(notSelectedTypes, new TypeLabelAlphabeticalOrder(messages));

    return notSelectedTypes;
  }
Пример #8
0
 public boolean hasSpeechTranscription() {
   return doc.hasFacet("HasSpeechTranscription");
 }
Пример #9
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());
  }