Package org.exoplatform.services.jcr.core

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


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

    ExtendedNode node = (ExtendedNode) rootNode.addNode("deep", "nt:unstructured");
    adminSession.save();
    assertTrue(node.isNodeType("exo:auditable"));
    String history = node.getProperty("exo:auditHistory").getString();
    assertNotNull(session.getNodeByUUID(history));
    node.remove();
    adminSession.save();

    try {
      adminSession.getNodeByUUID(history);
      fail("History doesn't removed");
View Full Code Here


  public void testRemovePropertyAudit() throws Exception {

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

    // Should not be autocreated
    ExtendedNode node = (ExtendedNode) rootNode.addNode("deep", "nt:unstructured");
    String auditHistoryUUID = node.getProperty("exo:auditHistory").getString();
    Node auditHistory = session.getNodeByUUID(auditHistoryUUID);

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

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

    node.getProperty("test").remove();

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

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

    assertEquals(3, 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 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

                                     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();
      log.info("Audit " + node1.getPath() + " " + ar.getEventTypeName() + ", version " + vuuid
          + " " + vname);
      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

public class AddOwnerTest extends BaseStandaloneTest
{

   public void testIfOwnerAdd() throws Exception
   {
      ExtendedNode node = (ExtendedNode)session.getRootNode().addNode("test");
      assertTrue(node.isNodeType("exo:owneable"));
      assertEquals(session.getUserID(), node.getProperty("exo:owner").getString());
   }
View Full Code Here

      assertEquals(session.getUserID(), node.getProperty("exo:owner").getString());
   }

   public void testIfNotOwnerAdd() throws Exception
   {
      ExtendedNode node = (ExtendedNode)session.getRootNode().addNode("test2");
      assertFalse(node.isNodeType("exo:owneable"));
   }
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.