Package org.exoplatform.services.jcr.core

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


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

  public void testChangeMultiValueProperty() 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", new String[] { "testValue11", "testValue12" });
    node.setProperty("test", new String[] { "testValue21", "testValue22", "testValue23" });
    session.save();

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

  public void testChangeBLOBValueProperty() throws Exception {

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

    // Should not be autocreated
    ExtendedNode node = (ExtendedNode) rootNode.addNode("deep", "nt:unstructured");

    // create BLOB property
    node.setProperty("test", new StringBufferInputStream("testValue1"));
    node.setProperty("test", new StringBufferInputStream("testValue2"));
    session.save();

    AuditHistory history = service.getHistory(node);
    assertEquals(ExtendedEventType.PROPERTY_CHANGED, history.getAuditRecords()
                                                            .get(2)
View Full Code Here

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

    // Should not be autocreated
    ExtendedNode node = (ExtendedNode) rootNode.addNode("deep", "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"));
    node.getProperty("test").remove();
    session.save();

    assertTrue(service.hasHistory(node));
    assertFalse(service.hasHistory(session.getRootNode()));

    AuditHistory history = service.getHistory(node);
    assertTrue(node.isSame(history.getAuditableNode()));
    assertEquals(3, history.getAuditRecords().size());

    assertEquals(Event.PROPERTY_ADDED, history.getAuditRecords().get(1).getEventType());
    assertEquals(ExtendedEventType.PROPERTY_ADDED, history.getAuditRecords()
                                                          .get(1)
View Full Code Here

   * @throws Exception
   */
  public void testCheckPermissions() throws Exception {
    // user
    NodeImpl rootNode = (NodeImpl) session.getRootNode().getNode(ROOT_PATH);
    ExtendedNode node = (ExtendedNode) rootNode.addNode("testAuditHistory", "nt:unstructured");
    node.addMixin("exo:auditable");
    if (!service.hasHistory(node))
      service.createHistory(node);
    session.save();
    service.addRecord(null, node, Event.NODE_ADDED);
    session.save();

    // user
    NodeImpl rootNode1 = (NodeImpl) exo1Session.getRootNode().getNode(ROOT_PATH);
    // Should not be autocreated
    ExtendedNode node1 = (ExtendedNode) rootNode1.addNode("testAuditHistory", "nt:unstructured");
    node1.addMixin("exo:auditable");
    if (!service.hasHistory(node1))
      service.createHistory(node1);
    exo1Session.save();
    service.addRecord(null, node1, Event.NODE_ADDED);
    exo1Session.save();
View Full Code Here

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

    ExtendedNode node = null;
    try {
      node = (ExtendedNode) session.getRootNode().getNode(ROOT_PATH).addNode("teststotage");
      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());
    }
    Node auditHistory = session.getNodeByUUID(node.getProperty("exo:auditHistory").getString());
    assertNotNull("Audit history does'n created correctly", auditHistory);
  }
View Full Code Here

   * Test creating audit storage
   */
  public void testIfAuditStorageCreated() {

    AuditService service = (AuditService) container.getComponentInstanceOfType(AuditService.class);
    ExtendedNode node = null;
    try {
      node = (ExtendedNode) adminSession.getRootNode().getNode(ROOT_PATH).addNode("auditablenode");
      node.addMixin("exo:auditable");
    } catch (RepositoryException e) {
      fail("Fail to add node or add mixin");
    }
    try {
      service.createHistory(node);
      adminSession.save();
      assertNotNull(adminSession.getNodeByUUID(AuditService.AUDIT_STORAGE_ID));
    } catch (RepositoryException e) {
      e.printStackTrace();
      fail("Fail to create AUDIT_STORAGE " + e.getLocalizedMessage());
    }

    try {
      assertNotNull(adminSession.getNodeByUUID(node.getProperty("exo:auditHistory").getString()));
    } catch (RepositoryException e) {
      fail("Fail to create AUDITHISTORY");
    }
  }
View Full Code Here

   *
   * @throws Exception
   */
  public void testReadHistory() throws Exception {
    NodeImpl rootNode = (NodeImpl) session.getRootNode().getNode(ROOT_PATH);
    ExtendedNode node = (ExtendedNode) rootNode.addNode("testReadHistory", "nt:unstructured");
    node.addMixin("exo:auditable");
    if (!service.hasHistory(node))
      service.createHistory(node);
    session.save();
    service.addRecord(null, node, Event.NODE_ADDED);
    session.save();
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.