Package org.exoplatform.services.jcr.core

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


   */
  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

         if (sp == null)
            throw new RepositoryException("Access to JCR Repository denied. SessionProvider is null.");

         ses = sp.getSession(workspace, repositoryService.getRepository(repository));

         ExtendedNode node = (ExtendedNode)ses.getRootNode().getNode(resourcePath);

         if (isFile(node))
         {
            if (view != null && view.equalsIgnoreCase("true"))
            {
               ExtendedNode shaNode = null;
               try
               {
                  shaNode = (ExtendedNode)ses.getRootNode().getNode(shaResourcePath);
               }
               catch (RepositoryException e)
View Full Code Here

                                     VersionException,
                                     LockException,
                                     NoSuchNodeTypeException,
                                     RepositoryException {

    ExtendedNode node = (ExtendedNode) testRoot.addNode("deep");
    session.save();
    node.addMixin("mix:versionable");
    root.save();

    // check audit history
    AuditHistory ah = service.getHistory(node);
    for (AuditRecord ar : ah.getAuditRecords()) {
View Full Code Here

                               VersionException,
                               LockException,
                               NoSuchNodeTypeException,
                               RepositoryException {

    ExtendedNode node = (ExtendedNode) testRoot.addNode("deep");
    session.save();
    node.addMixin("mix:versionable");
    root.save();

    // ver.1
    node.checkin();
    final String v1UUID = node.getBaseVersion().getUUID();
    node.checkout();

    final String propName = "prop1";
    final InternalQName propQName = new InternalQName("", propName);

    node.setProperty(propName, "prop #1");
    root.save();

    // ver.2
    node.checkin();
    final String v2UUID = node.getBaseVersion().getUUID();
    node.getVersionHistory().addVersionLabel(node.getBaseVersion().getName(), "ver.1.1", false);
    node.checkout();

    node.setProperty(propName, "prop #1.1");
    // don't save now, but audit will contains records yet

    // check audit history
    AuditHistory ah = service.getHistory(node);
    for (AuditRecord ar : ah.getAuditRecords()) {
View Full Code Here

   * Test if versionable node's descendant nodes will have version records in audit history.
   *
   * @throws Exception
   */
  public void testVersionableAncestor() throws Exception {
    ExtendedNode node = (ExtendedNode) testRoot.addNode("deep");
    session.save();
    node.addMixin("mix:versionable");
    root.save();

    final String propName = "prop1";
    final InternalQName propQName = new InternalQName("", propName);

    // ver.1
    node.checkin();
    final String v1UUID = node.getBaseVersion().getUUID();
    node.checkout();

    // child node, non versionable but under the version control within their parent
    Node node1 = node.addNode("node1");
    // node1.addMixin("exo:auditable");
    node.save();
    node1.setProperty(propName, "prop #1"); // add property
    node1.save();

    // ver.2
    node.checkin();
    final String v2UUID = node.getBaseVersion().getUUID();
    node.checkout();

    // check node1 and v.1
    AuditHistory ah = service.getHistory(node1);
    for (AuditRecord ar : ah.getAuditRecords()) {
      String vuuid = ar.getVersion();
      // Version av = (Version) session.getNodeByUUID(vuuid);
      String vname = ar.getVersionName();
      if (ar.getEventType() == ExtendedEvent.PROPERTY_ADDED
          && ar.getPropertyName().equals(propQName)) {
        assertEquals("Version UUIDs should be equals", v1UUID, vuuid);
      }
    }

    // subnode, non versionable but under the version control within versionable ancestor
    Node node2 = node1.addNode("node2");
    // node2.addMixin("exo:auditable");
    node1.save();
    node2.setProperty(propName, "prop #2"); // add property
    node2.save();

    // ver.3
    node.checkin();
    node.checkout();

    // check node2 and v.2
    ah = service.getHistory(node2);
    for (AuditRecord ar : ah.getAuditRecords()) {
      String vuuid = ar.getVersion();
View Full Code Here

         if (sp == null)
            throw new RepositoryException("Access to JCR Repository denied. SessionProvider is null.");

         ses = sp.getSession(workspace, repositoryService.getRepository(repository));

         ExtendedNode node = (ExtendedNode)ses.getRootNode().getNode(resourcePath);

         if (isFile(node))
         {
            if (view != null && view.equalsIgnoreCase("true"))
            {
               ExtendedNode shaNode = null;
               try
               {
                  shaNode = (ExtendedNode)ses.getRootNode().getNode(shaResourcePath);
               }
               catch (RepositoryException e)
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 (Exception 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

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.