Package org.exoplatform.services.jcr.core

Examples of org.exoplatform.services.jcr.core.ExtendedNode


   */
  public void testDeepAddAuditable() throws Exception {

    NodeImpl rootNode = (NodeImpl) session.getRootNode().getNode(ROOT_PATH);

    ExtendedNode node = (ExtendedNode) rootNode.addNode("deep");
    ExtendedNode childNode = (ExtendedNode) node.addNode("testDeepAddAuditableChild");
    session.save();
    assertTrue(node.isNodeType(AuditService.EXO_AUDITABLE));
    assertTrue(childNode.isNodeType(AuditService.EXO_AUDITABLE));
    assertTrue(service.hasHistory(node));
    assertTrue(service.hasHistory(childNode));
    node.remove();
    session.save();
  }
View Full Code Here


   */
  public void testNotDeepAddAuditable() throws Exception {

    NodeImpl rootNode = (NodeImpl) session.getRootNode().getNode(ROOT_PATH);

    ExtendedNode node = (ExtendedNode) rootNode.addNode("notdeep");
    ExtendedNode childNode = (ExtendedNode) node.addNode("testNotDeepAddAuditableChild");
    ExtendedNode childNode2 = (ExtendedNode) childNode.addNode("testNotDeepAddAuditableChild2");
    session.save();

    assertTrue(node.isNodeType(AuditService.EXO_AUDITABLE));
    assertTrue(childNode.isNodeType(AuditService.EXO_AUDITABLE));
    assertFalse(childNode2.isNodeType(AuditService.EXO_AUDITABLE));
    assertTrue(service.hasHistory(node));
    assertTrue(service.hasHistory(childNode));
    assertFalse(service.hasHistory(childNode2));
    node.remove();
    session.save();
View Full Code Here

   * @throws Exception
   */
  public void testAddAuditWithExistingNode() throws Exception {
    NodeImpl rootNode = (NodeImpl) session.getRootNode().getNode(ROOT_PATH);

    ExtendedNode node = (ExtendedNode) rootNode.addNode("test_add_audit_existing_node",
                                                        "nt:unstructured");
    node.addMixin("exo:auditable");
    service.createHistory(node);
    session.save();
    String auditHistoryUUID = node.getProperty("exo:auditHistory").getString();
    Node auditHistory = session.getNodeByUUID(auditHistoryUUID);

    assertTrue(auditHistory.isNodeType("exo:auditHistory"));
    assertEquals(auditHistory.getProperty("exo:targetNode").getString(), node.getUUID());

    session.save();
    service.removeHistory(node);
    node.remove();
    session.save();
  }
View Full Code Here

   /**
    *  Unit test for https://jira.exoplatform.org/browse/JCR-1832
    */
   public void testGetFileFromFolder() throws Exception
   {
      ExtendedNode folderA = (ExtendedNode)session.getRootNode().addNode("folderA", "nt:folder");
      folderA.addMixin("exo:privilegeable");
      folderA.setPermission("john", PermissionType.ALL);
      folderA.removePermission(IdentityConstants.ANY);
      session.save();
     
      assertEquals(4, folderA.getACL().getPermissionEntries().size());
      assertEquals("john read", folderA.getACL().getPermissionEntries().get(0).getAsString());
      assertEquals("john add_node", folderA.getACL().getPermissionEntries().get(1).getAsString());
      assertEquals("john set_property", folderA.getACL().getPermissionEntries().get(2).getAsString());
      assertEquals("john remove", folderA.getACL().getPermissionEntries().get(3).getAsString());
     
     
      Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()), "ws");
     
      ExtendedNode folderB = (ExtendedNode)sessJohn.getRootNode().getNode("folderA").addNode("folderB", "nt:folder");
     
      folderB.addMixin("exo:privilegeable");
      folderB.setPermission("any", new String[]{"read"});
      sessJohn.save();
     
      assertEquals(5, folderB.getACL().getPermissionEntries().size());
      assertEquals("john read", folderB.getACL().getPermissionEntries().get(0).getAsString());
      assertEquals("john add_node", folderB.getACL().getPermissionEntries().get(1).getAsString());
      assertEquals("john set_property", folderB.getACL().getPermissionEntries().get(2).getAsString());
      assertEquals("john remove", folderB.getACL().getPermissionEntries().get(3).getAsString());
      assertEquals("any read", folderB.getACL().getPermissionEntries().get(4).getAsString());
     
      // Login as anonim.
      // Tthis session use on server side, thank SessionProvider.
      repository.login(new CredentialsImpl(IdentityConstants.ANONIM, "exo".toCharArray()), "ws");

View Full Code Here

      {
         pathToCheck = "/" + artifact.getAsPath(); // "/" - is root path
      }

      LOG.debug("Checking Permission on node: " + pathToCheck);
      ExtendedNode rmNode = (ExtendedNode) session.getItem(pathToCheck);
      List<AccessControlEntry> list = rmNode.getACL().getPermissionEntries();
      return list;
   }
View Full Code Here

         pathToChange = "/" + artifact.getAsPath(); // "/" - is root path
      }

      LOG.debug("Changing Permission on node: " + pathToChange);

      ExtendedNode chNode = (ExtendedNode) session.getItem(pathToChange);
      if (!chNode.isNodeType("exo:privilegeable"))
      {
         if (chNode.canAddMixin("exo:privilegeable"))
            chNode.addMixin("exo:privilegeable");
         else
            throw new RepositoryException("Can't add mixin");
      }
      // log.info("PERMS-SIZE:" + permissions.length);
      try
      {
         if (!delete)
            chNode.setPermission(identity, permissions);
         else
         {
            if (permissions.length > 0)
            {
               for (int i = 0; i < permissions.length; i++)
                  chNode.removePermission(identity, permissions[i]);
            }
            else
            {
               chNode.removePermission(identity);
            }
         }
      }
      catch (RepositoryException e)
      {
View Full Code Here

  public void testAddAuditHistoryAction() throws Exception {
    // Should not be autocreated

    NodeImpl rootNode = (NodeImpl) session.getRootNode().getNode(ROOT_PATH);

    ExtendedNode node = (ExtendedNode) rootNode.addNode("deep");
    // node.addMixin("exo:auditable");
    session.save();
    String auditHistoryUUID = node.getProperty("exo:auditHistory").getString();
    Node auditHistory = session.getNodeByUUID(auditHistoryUUID);

    assertTrue(auditHistory.isNodeType("exo:auditHistory"));

    // pointed to target node
    assertEquals(auditHistory.getProperty("exo:targetNode").getString(), node.getUUID());

    assertEquals("1", auditHistory.getProperty("exo:lastRecord").getString());

    assertEquals(1, auditHistory.getNodes().getSize());

    session.save();
    service.removeHistory(node);
    node.remove();
    session.save();

    try {
      session.getNodeByUUID(auditHistoryUUID);
      fail("History should be removed");
View Full Code Here

   */
  public void testAddAuditHistoryMixinAction() throws Exception {
    NodeImpl rootNode = (NodeImpl) session.getRootNode().getNode(ROOT_PATH);

    // Should not be autocreated
    ExtendedNode node = (ExtendedNode) rootNode.addNode("mixin", "nt:unstructured");
    node.addMixin("exo:auditable");

    String auditHistoryUUID = node.getProperty("exo:auditHistory").getString();
    Node auditHistory = session.getNodeByUUID(auditHistoryUUID);

    // under audit
    node.setProperty("test", "testValue");

    assertTrue(auditHistory.isNodeType("exo:auditHistory"));

    // pointed to target node
    assertEquals(auditHistory.getProperty("exo:targetNode").getString(), node.getUUID());

    assertEquals("2", auditHistory.getProperty("exo:lastRecord").getString());

    assertEquals(2, auditHistory.getNodes().getSize());

    session.save();
    service.removeHistory(node);
    node.remove();
    session.save();

    try {
      session.getNodeByUUID(auditHistoryUUID);
      fail("History should be removed");
View Full Code Here

   *
   * @throws RepositoryException
   */
  public void testAddInfoToAuditStorage() throws RepositoryException {

    ExtendedNode node = null;
    try {
      node = (ExtendedNode) session.getRootNode().getNode(ROOT_PATH).addNode("testaudit");
      node.addMixin("exo:auditable");
      if (!service.hasHistory(node))
        service.createHistory(node);
      session.save();
    } catch (RepositoryException e) {
      e.printStackTrace();
      fail("Fail to init AuditStorage" + e.getLocalizedMessage());
    }
    Property property1 = node.setProperty("property1", "value1");
    service.addRecord(null, node, Event.NODE_ADDED);
    service.addRecord(null, property1, Event.PROPERTY_ADDED);

    Node auditHistory = session.getNodeByUUID(node.getProperty("exo:auditHistory").getString());
    assertNotNull(auditHistory);
    assertEquals(2, auditHistory.getNodes().getSize());

    assertTrue(service.hasHistory(node));
    assertNotNull(service.getHistory(node));
View Full Code Here

  public void testChangeSingleValueProperty() throws Exception {

    NodeImpl rootNode = (NodeImpl) session.getRootNode().getNode(ROOT_PATH);

    // Should not be autocreated
    ExtendedNode node = (ExtendedNode) rootNode.addNode("deep", "nt:unstructured");
    node.setProperty("test", "testValue1");
    node.setProperty("test", "testValue2");
    session.save();

    AuditHistory history = service.getHistory(node);
    assertEquals(3, history.getAuditRecords().size());
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.core.ExtendedNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.