@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());
  }
Example #2
0
  @Override
  public void initTree(
      String sid,
      CoreSession coreSession,
      Map<String, String> parameters,
      PublishedDocumentFactory factory,
      String configName,
      String title) {
    super.initTree(sid, coreSession, parameters, factory, configName, title);

    DocumentRef ref = new PathRef(rootPath);
    boolean exists = coreSession.exists(ref);
    if (!exists) {
      log.debug(
          "Root section "
              + rootPath
              + " doesn't exist. Check "
              + "publicationTreeConfig with name "
              + configName);
    }
    if (exists && coreSession.hasPermission(ref, SecurityConstants.READ)) {
      treeRoot = coreSession.getDocument(new PathRef(rootPath));
      rootNode = new CoreFolderPublicationNode(treeRoot, getConfigName(), sid, factory);
    } else {
      rootNode =
          new VirtualCoreFolderPublicationNode(
              coreSession.getSessionId(), rootPath, getConfigName(), sid, factory);
      sessionId = coreSession.getSessionId();
    }
  }
Example #3
0
 protected void getAllTasks() {
   error = null;
   errorMessage = null;
   userTasks = new ArrayList<>();
   CoreSession coreSession = getCoreSession();
   boolean filterTrashDocs = getFilterDocumentsInTrash();
   NuxeoPrincipal pal = (NuxeoPrincipal) coreSession.getPrincipal();
   TaskService taskService = Framework.getService(TaskService.class);
   List<Task> tasks = taskService.getAllCurrentTaskInstances(coreSession, getSortInfos());
   if (tasks != null) {
     for (Task task : tasks) {
       List<String> targetDocumentsIds = task.getTargetDocumentsIds();
       boolean hasTargetDocuments = targetDocumentsIds != null && !targetDocumentsIds.isEmpty();
       if (task.hasEnded() || task.isCancelled() || !hasTargetDocuments) {
         continue;
       }
       DocumentModel doc = taskService.getTargetDocumentModel(task, coreSession);
       if (doc != null) {
         if (filterTrashDocs
             && LifeCycleConstants.DELETED_STATE.equals(doc.getCurrentLifeCycleState())) {
           continue;
         } else {
           userTasks.add(new DashBoardItemImpl(task, doc, getLocale()));
         }
       } else {
         log.warn(
             String.format(
                 "User '%s' has a task of type '%s' on a missing or deleted document",
                 pal.getName(), task.getName()));
       }
     }
   }
 }
  protected void notifyEvent(
      CoreSession session,
      String eventId,
      Map<String, Serializable> properties,
      String comment,
      String category,
      DocumentModel dm) {

    // Default category
    if (category == null) {
      category = DocumentEventCategories.EVENT_DOCUMENT_CATEGORY;
    }

    if (properties == null) {
      properties = new HashMap<String, Serializable>();
    }

    properties.put(CoreEventConstants.REPOSITORY_NAME, session.getRepositoryName());
    properties.put(CoreEventConstants.SESSION_ID, session.getSessionId());
    properties.put(CoreEventConstants.DOC_LIFE_CYCLE, dm.getCurrentLifeCycleState());

    DocumentEventContext ctx = new DocumentEventContext(session, session.getPrincipal(), dm);

    ctx.setProperties(properties);
    ctx.setComment(comment);
    ctx.setCategory(category);

    EventProducer evtProducer = Framework.getService(EventProducer.class);
    Event event = ctx.newEvent(eventId);
    evtProducer.fireEvent(event);
  }
 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;
 }
  @Test
  public void iCanGetLatestUploadsPageProvider() throws Exception {
    DocumentModel site = createSite();

    PageClasseur classeur =
        new PageClasseurAdapter.Model(
                session,
                site.getPathAsString() + "/" + LabsSiteConstants.Docs.TREE.docName(),
                "ma page classeur")
            .desc("desc page classeur")
            .create();
    assertThat(classeur.getFolders().size(), is(0));

    classeur.addFolder("My Folder", null);
    session.save();
    PageClasseurFolder folder = classeur.getFolders().get(0);
    assertThat(folder.getFiles().size(), is(0));
    folder.addFile(getTestBlob(), "Pomodoro cheat sheet", "title");
    session.save();
    assertThat(folder.getFiles().size(), is(1));
    session.save();

    Tools.getAdapter(LabsPublisher.class, classeur.getDocument(), null).publish();

    PageProvider<DocumentModel> latestUploadsPageProvider =
        LabsSiteWebAppUtils.getLatestUploadsPageProvider(site, 0, session);
    assertNotNull(latestUploadsPageProvider);
    List<DocumentModel> lastUploadedDoc = latestUploadsPageProvider.getCurrentPage();
    assertNotNull(lastUploadedDoc);
    assertEquals(1, lastUploadedDoc.size());
  }
Example #7
0
  @Test
  public void testDefaultCreateTwiceFromSameBlob() throws Exception {
    // create doc
    File file = getTestFile("test-data/hello.doc");
    Blob input = Blobs.createBlob(file, "application/msword");

    DocumentModel doc =
        service.createDocumentFromBlob(
            coreSession, input, workspace.getPathAsString(), true, "test-data/hello.doc");
    DocumentRef docRef = doc.getRef();

    assertNotNull(doc);
    assertEquals("hello.doc", doc.getProperty("dublincore", "title"));
    assertEquals("hello.doc", doc.getProperty("file", "filename"));
    assertNotNull(doc.getProperty("file", "content"));

    List<DocumentModel> versions = coreSession.getVersions(docRef);
    assertEquals(0, versions.size());

    // create again with same file
    doc =
        service.createDocumentFromBlob(
            coreSession, input, workspace.getPathAsString(), true, "test-data/hello.doc");
    assertNotNull(doc);

    DocumentRef newDocRef = doc.getRef();
    assertEquals(docRef, newDocRef);
    assertEquals("hello.doc", doc.getProperty("dublincore", "title"));
    assertEquals("hello.doc", doc.getProperty("file", "filename"));
    assertNotNull(doc.getProperty("file", "content"));

    versions = coreSession.getVersions(docRef);
    assertEquals(1, versions.size());
  }
  @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());
  }
 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);
 }
 public static void updatePageTemplate(CoreSession session) {
   try {
     DocumentModelList docs = session.query("SELECT * FROM Page");
     LabsTemplate template = null;
     String templateName = null;
     for (DocumentModel doc : docs) {
       template = Tools.getAdapter(LabsTemplate.class, doc, session);
       templateName = template.getDocumentTemplateName();
       if (!StringUtils.isEmpty(templateName)) {
         if (templateName.equals("homeSimple")) {
           template.setTemplateName("left");
         } else if (templateName.equals("homeLeftComplex")) {
           template.setTemplateName("left");
         } else if (templateName.equals("homeRightComplex")) {
           template.setTemplateName("right");
         } else if (templateName.equals("homeRightSimple")) {
           template.setTemplateName("right");
         }
         session.saveDocument(doc);
       }
     }
     session.save();
   } catch (ClientException e) {
     LOG.error("updatePageTemplate : ", e);
   }
 }
 public static final List<LabsSite> getTemplateSites() throws ClientException {
   SiteManager sm;
   List<LabsSite> adaptersList = new ArrayList<LabsSite>();
   try {
     sm = Framework.getService(SiteManager.class);
   } catch (Exception e) {
     return adaptersList;
   }
   StringBuilder query = new StringBuilder();
   CoreSession session = getCoreSession();
   query
       .append("SELECT * FROM ")
       .append(Docs.SITE.type())
       .append(" WHERE ")
       .append(NXQL.ECM_LIFECYCLESTATE)
       .append(" = '")
       .append(State.PUBLISH.getState())
       .append("'")
       .append(" AND ")
       .append(NXQL.ECM_PATH)
       .append(" STARTSWITH '")
       .append(sm.getSiteRoot(session).getPathAsString().replace("'", "\\'"))
       .append("'")
       .append(" AND ")
       .append(NXQL.ECM_MIXINTYPE)
       .append("='")
       .append(LabsSiteConstants.FacetNames.LABS_ELEMENT_TEMPLATE)
       .append("'");
   DocumentModelList list = session.query(query.toString());
   for (DocumentModel site : list) {
     adaptersList.add(Tools.getAdapter(LabsSite.class, site, session));
   }
   return adaptersList;
 }
  @Override
  public List<LabsNews> getAllNews() throws ClientException {
    List<LabsNews> listNews = new ArrayList<LabsNews>();
    CoreSession session = getSession();
    DocumentModelList listDoc = null;
    Sorter pageNewsSorter = new PageNewsSorter();
    if (session.hasPermission(doc.getRef(), SecurityConstants.WRITE)) {
      listDoc =
          session.getChildren(
              doc.getRef(), LabsSiteConstants.Docs.LABSNEWS.type(), null, null, pageNewsSorter);
    } else {
      listDoc =
          session.getChildren(
              doc.getRef(),
              LabsSiteConstants.Docs.LABSNEWS.type(),
              null,
              new PageNewsFilter(Calendar.getInstance()),
              pageNewsSorter);
    }

    for (DocumentModel doc : listDoc) {
      LabsNews news = Tools.getAdapter(LabsNews.class, doc, session);
      listNews.add(news);
    }
    return listNews;
  }
Example #13
0
  @Test
  public void shouldUnIndexSubTree() throws Exception {
    buildAndIndexTree();

    DocumentRef ref = new PathRef("/folder0/folder1/folder2");
    Assert.assertTrue(session.exists(ref));

    startTransaction();
    session.removeDocument(ref);
    TransactionHelper.commitOrRollbackTransaction();
    waitForCompletion();
    assertNumberOfCommandProcessed(1);

    startTransaction();
    SearchResponse searchResponse =
        esa.getClient()
            .prepareSearch(IDX_NAME)
            .setTypes(TYPE_NAME)
            .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
            .setFrom(0)
            .setSize(60)
            .execute()
            .actionGet();
    Assert.assertEquals(2, searchResponse.getHits().getTotalHits());
  }
  public int lock(String userName) throws ClientException {

    LockInfo lockInfo = getLockInfo();
    boolean canLock = false;
    int returnCode = LOCKED_OK;

    if (lockInfo != null) {
      // document is already locked
      String lockingUser = lockInfo.getUserName();

      if (lockingUser == null) {
        canLock = true;
      } else {
        if (lockingUser.equals(userName)) {
          canLock = true;
          return ALREADY_LOCKED_BY_YOU;
        } else {
          if (isLockExpired()) {
            canLock = true;
            returnCode = LOCK_BORROWED;
          } else {
            canLock = false;
            return CAN_NOT_BORROW_LOCK;
          }
        }
      }
    }

    CoreSession session = getSessionFromDoc(targetDoc);
    session.setLock(targetDoc.getRef(), getLockToken(userName));
    session.save();

    return returnCode;
  }
  @Test
  public void testReadAclAfterCopy() {
    DocumentModel folder1 = new DocumentModelImpl("/", "folder1", "Folder");
    folder1 = session.createDocument(folder1);
    DocumentModel folder2 = new DocumentModelImpl("/", "folder2", "Folder");
    folder2 = session.createDocument(folder2);
    DocumentModel doc = new DocumentModelImpl("/folder1", "doc", "File");
    doc = session.createDocument(doc);

    // set ACL on folder2
    ACL acl = new ACLImpl();
    acl.add(new ACE("Everyone", "Read", true));
    ACP acp = new ACPImpl();
    acp.addACL(acl);
    folder2.setACP(acp, true);
    session.save();

    // doc under folder1 cannot be read by joe
    try (CoreSession joeSession = openSessionAs("joe")) {
      DocumentModelList list = joeSession.query("SELECT * FROM File");
      assertEquals(0, list.size());
    }

    // copy doc under folder2
    session.copy(doc.getRef(), folder2.getRef(), "doccopy");
    session.save();

    // check doc copy now readable by joe
    try (CoreSession joeSession = openSessionAs("joe")) {
      DocumentModelList list = joeSession.query("SELECT * FROM File");
      assertEquals(1, list.size());
      assertEquals("doccopy", list.get(0).getName());
    }
  }
  // Rux INA-221: create a new method for the 2 separated links
  public String navigateToOverallWorkspace() {
    if (!initialized) {
      initialize();
    }
    String returnView = DOCUMENT_VIEW;

    // force return to Documents tab
    webActions.setCurrentTabIds(DOCUMENT_MANAGEMENT_TAB);

    if (lastAccessedDocument != null) {
      navigationContext.setCurrentDocument(lastAccessedDocument);
    } else if (navigationContext.getCurrentDomain() != null) {
      navigationContext.setCurrentDocument(navigationContext.getCurrentDomain());
    } else if (documentManager.hasPermission(
        documentManager.getRootDocument().getRef(), SecurityConstants.READ_CHILDREN)) {
      navigationContext.setCurrentDocument(documentManager.getRootDocument());
    } else {
      navigationContext.setCurrentDocument(null);
      returnView = dashboardNavigationHelper.navigateToDashboard();
    }
    showingPersonalWorkspace = false;

    Events.instance().raiseEvent(EventNames.GO_HOME);

    return returnView;
  }
  @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"));
  }
Example #18
0
  @POST
  @Path("@manage-sidebar")
  public Object manageSidebar() {
    FormData form = ctx.getForm();
    CoreSession session = getCoreSession();
    try {
      int nbRows = new Integer(form.getString("nbRows")).intValue();
      HtmlPage sidebar = site.getSidebar();
      HtmlSection section = sidebar.section(0);
      section.remove();
      sidebar.addSection();
      section = sidebar.section(0);
      HtmlRow row = null;
      String widget = "";
      for (int i = 0; i < nbRows; i++) {
        widget = form.getString("bloc" + i);
        if (!"html/editor".equals(widget)) {
          row = section.addRow();
          row.addContent(0, "");
          session.saveDocument(sidebar.getDocument());
          session.save();
          GadgetUtils.syncWidgetsConfig(row.content(0), widget, sidebar.getDocument(), session);
        }
      }
    } catch (Exception e) {
      throw WebException.wrap("Problème lors de la sauvegarde des widgets de la sidebar", e);
    }
    // TODO row's widget config

    return Response.ok().build();
  }
  private void createTrioVersions(DocumentModel file) throws Exception {
    // create a first version
    file.setProperty("file", "filename", "A");
    file.putContextData(
        ScopeType.REQUEST, VersioningDocument.CREATE_SNAPSHOT_ON_SAVE_KEY, Boolean.TRUE);
    file = session.saveDocument(file);

    checkVersions(file, "0.1");

    // create a second version
    // make it dirty so it will be saved
    file.setProperty("file", "filename", "B");
    file.putContextData(
        ScopeType.REQUEST, VersioningDocument.CREATE_SNAPSHOT_ON_SAVE_KEY, Boolean.TRUE);
    maybeSleepToNextSecond();
    file = session.saveDocument(file);

    checkVersions(file, "0.1", "0.2");

    // create a third version
    file.setProperty("file", "filename", "C");
    file.putContextData(
        ScopeType.REQUEST, VersioningDocument.CREATE_SNAPSHOT_ON_SAVE_KEY, Boolean.TRUE);
    maybeSleepToNextSecond();
    file = session.saveDocument(file);

    checkVersions(file, "0.1", "0.2", "0.3");
  }
  @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);
  }
 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);
 }
 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);
 }
  protected DocumentModel doCreateDocument() {
    DocumentModel rootDocument = session.getRootDocument();
    DocumentModel model =
        session.createDocumentModel(rootDocument.getPathAsString(), "youps", "File");
    model.setProperty("dublincore", "title", "huum");

    return session.createDocument(model);
  }
 protected void setPermission(
     DocumentModel doc, String userName, String permission, boolean isGranted) {
   ACP acp = session.getACP(doc.getRef());
   ACL localACL = acp.getOrCreateACL(ACL.LOCAL_ACL);
   localACL.add(new ACE(userName, permission, isGranted));
   session.setACP(doc.getRef(), acp, true);
   session.save();
 }
  @Override
  public String endTask(
      CoreSession coreSession,
      NuxeoPrincipal principal,
      Task task,
      String comment,
      String eventName,
      boolean isValidated)
      throws ClientException {

    // put user comment on the task
    if (!StringUtils.isEmpty(comment)) {
      task.addComment(principal.getName(), comment);
    }

    // end the task, adding boolean marker that task was validated or
    // rejected
    task.setVariable(TaskService.VariableName.validated.name(), String.valueOf(isValidated));
    task.end(coreSession);
    coreSession.saveDocument(task.getDocument());
    // notify
    Map<String, Serializable> eventProperties = new HashMap<String, Serializable>();
    ArrayList<String> notificationRecipients = new ArrayList<String>();
    notificationRecipients.add(task.getInitiator());
    notificationRecipients.addAll(task.getActors());
    eventProperties.put(NotificationConstants.RECIPIENTS_KEY, notificationRecipients);
    // try to resolve document when notifying
    DocumentModel document = null;
    String docId = task.getVariable(TaskService.VariableName.documentId.name());
    String docRepo = task.getVariable(TaskService.VariableName.documentRepositoryName.name());
    if (coreSession.getRepositoryName().equals(docRepo)) {
      try {
        document = coreSession.getDocument(new IdRef(docId));
      } catch (Exception e) {
        log.error(
            String.format(
                "Could not fetch document with id '%s:%s' for notification", docRepo, docId),
            e);
      }
    } else {
      log.error(
          String.format(
              "Could not resolve document for notification: "
                  + "document is on repository '%s' and given session is on "
                  + "repository '%s'",
              docRepo, coreSession.getRepositoryName()));
    }

    TaskEventNotificationHelper.notifyEvent(
        coreSession, document, principal, task, eventName, eventProperties, comment, null);

    String seamEventName =
        isValidated
            ? TaskEventNames.WORKFLOW_TASK_COMPLETED
            : TaskEventNames.WORKFLOW_TASK_REJECTED;
    return seamEventName;
  }
 protected void doTestMultipleRepositoriesPerTransaction(CoreSession session2) throws Exception {
   assertEquals(database.getRepositoryName(), session.getRepositoryName());
   assertEquals(database.getRepositoryName() + "2", session2.getRepositoryName());
   assertTrue(TransactionHelper.isTransactionActive());
   assertNotSame(
       "Sessions from two different repos",
       session.getRootDocument().getId(),
       session2.getRootDocument().getId());
 }
  @Test
  public void testGetParentDocuments() {

    setPermissionToAnonymous(EVERYTHING);

    DocumentModel root = session.getRootDocument();

    String name = "Workspaces#1";
    DocumentModel workspaces = new DocumentModelImpl(root.getPathAsString(), name, "Workspace");
    session.createDocument(workspaces);
    String name2 = "repositoryWorkspace2#";
    DocumentModel repositoryWorkspace =
        new DocumentModelImpl(workspaces.getPathAsString(), name2, "Workspace");
    repositoryWorkspace = session.createDocument(repositoryWorkspace);

    String name3 = "ws#3";
    DocumentModel ws1 =
        new DocumentModelImpl(repositoryWorkspace.getPathAsString(), name3, "Workspace");
    ws1 = session.createDocument(ws1);
    String name4 = "ws#4";
    DocumentModel ws2 = new DocumentModelImpl(ws1.getPathAsString(), name4, "Workspace");
    session.createDocument(ws2);

    if (session.isNegativeAclAllowed()) { // always false for Mem
      ACP acp = new ACPImpl();
      ACE denyRead = new ACE("test", READ, false);
      ACL acl = new ACLImpl();
      acl.setACEs(new ACE[] {denyRead});
      acp.addACL(acl);
      // TODO this produces a stack trace
      repositoryWorkspace.setACP(acp, true);
      ws1.setACP(acp, true);
    }

    session.save();

    List<DocumentModel> ws2ParentsUnderAdministrator = session.getParentDocuments(ws2.getRef());
    assertTrue(
        "list parents for"
            + ws2.getName()
            + "under "
            + session.getPrincipal().getName()
            + " is not empty:",
        !ws2ParentsUnderAdministrator.isEmpty());

    CoreSession testSession = openSessionAs("test");
    List<DocumentModel> ws2ParentsUnderTest = testSession.getParentDocuments(ws2.getRef());
    assertTrue(
        "list parents for"
            + ws2.getName()
            + "under "
            + testSession.getPrincipal().getName()
            + " is empty:",
        ws2ParentsUnderTest.isEmpty());
    closeSession(testSession);
  }
Example #28
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 + "/";
   }
 }
  @After
  public void tearDown() {
    // Close core sessions
    session1.close();
    session2.close();

    // Delete test users
    deleteUser("user1");
    deleteUser("user2");
  }
  @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);
  }