Package org.exoplatform.services.jcr.core.nodetype

Examples of org.exoplatform.services.jcr.core.nodetype.NodeTypeValue


    * @throws Exception
    */
   public void testRemoveVersionableSuper() throws Exception
   {
      // create new NodeType value
      NodeTypeValue testNValue = new NodeTypeValue();

      List<String> superType = new ArrayList<String>();
      superType.add("nt:base");
      superType.add("mix:versionable");
      testNValue.setName("exo:testRemoveVersionableSuper");
      testNValue.setPrimaryItemName("");
      testNValue.setDeclaredSupertypeNames(superType);

      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.FAIL_IF_EXISTS);
      testNValue = nodeTypeManager.getNodeTypeValue(testNValue.getName());

      Node testNode = root.addNode("testNode", testNValue.getName());
      session.save();
      assertTrue(testNode.isNodeType("mix:versionable"));

      superType = new ArrayList<String>();
      superType.add("nt:base");
      testNValue.setDeclaredSupertypeNames(superType);

      try
      {
         nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);
         fail();
      }
      catch (ConstraintViolationException e)
      {
         // ok
      }

      testNode.remove();
      session.save();

      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);

      testNode = root.addNode("testNode", testNValue.getName());
      session.save();
      assertFalse(testNode.isNodeType("mix:versionable"));
   }
View Full Code Here


   /**
    * @throws Exception
    */
   public void testSplitNT() throws Exception
   {
      NodeTypeValue testNValue = new NodeTypeValue();

      List<String> superType = new ArrayList<String>();
      superType.add("nt:base");
      testNValue.setName("exo:SplitNT");
      testNValue.setPrimaryItemName("");
      testNValue.setDeclaredSupertypeNames(superType);
      List<PropertyDefinitionValue> props = new ArrayList<PropertyDefinitionValue>();

      props.add(new PropertyDefinitionValue("jcr:mimeType1", false, false, 1, false, new ArrayList<String>(), false,
         PropertyType.STRING, new ArrayList<String>()));
      props.add(new PropertyDefinitionValue("jcr:mimeType2", false, false, 1, false, new ArrayList<String>(), false,
         PropertyType.STRING, new ArrayList<String>()));

      testNValue.setDeclaredPropertyDefinitionValues(props);
      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.FAIL_IF_EXISTS);
      testNValue = nodeTypeManager.getNodeTypeValue(testNValue.getName());

      Node tNode = root.addNode("test", testNValue.getName());
      tNode.setProperty("jcr:mimeType1", "plain/text");
      tNode.setProperty("jcr:mimeType2", "plain/html");
      session.save();
      Property property = tNode.getProperty("jcr:mimeType1");
      assertEquals("plain/text", property.getString());
      session.save();

      NodeTypeValue testNValue2 = new NodeTypeValue();
      List<String> superType2 = new ArrayList<String>();
      superType2.add("nt:base");
      testNValue2.setName("exo:SplitNT2");
      testNValue2.setPrimaryItemName("");
      testNValue2.setDeclaredSupertypeNames(superType);
      List<PropertyDefinitionValue> props2 = new ArrayList<PropertyDefinitionValue>();

      props2.add(new PropertyDefinitionValue("jcr:mimeType2", false, false, 1, false, new ArrayList<String>(), false,
         PropertyType.STRING, new ArrayList<String>()));

      testNValue2.setDeclaredPropertyDefinitionValues(props);

      nodeTypeManager.registerNodeType(testNValue2, ExtendedNodeTypeManager.FAIL_IF_EXISTS);

      superType = new ArrayList<String>();
      superType.add("nt:base");
      superType.add(testNValue2.getName());
      testNValue.setDeclaredSupertypeNames(superType);

      props = new ArrayList<PropertyDefinitionValue>();

      props.add(new PropertyDefinitionValue("jcr:mimeType1", false, false, 1, false, new ArrayList<String>(), false,
View Full Code Here

   public void testRegisterNodeType() throws Exception
   {
      Session session = repository.getSystemSession(repository.getSystemWorkspaceName());
      NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
      NodeTypeValue nodeTypeValue = new NodeTypeValue();

      List<String> superType = new ArrayList<String>();
      superType.add("nt:base");
      nodeTypeValue.setName("exo:testNodeType");
      nodeTypeValue.setPrimaryItemName("");
      nodeTypeValue.setDeclaredSupertypeNames(superType);
      ExtendedNodeTypeManager extNodeTypeManager = (ExtendedNodeTypeManager)nodeTypeManager;
      try
      {
         nodeTypeManager.getNodeType("exo:testNodeType");
         fail("Node Type is registed");
View Full Code Here

      SimpleListener listener = new SimpleListener("testSessionOpen", log, 0);
      session.getWorkspace().getObservationManager().addEventListener(listener, Event.NODE_ADDED, root.getPath(),
         false, null, null, false);

      NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
      NodeTypeValue nodeTypeValue = new NodeTypeValue();

      nodeTypeValue.setName("exo:testNodeType2");
      nodeTypeValue.setMixin(false);
      nodeTypeValue.setOrderableChild(false);
      nodeTypeValue.setPrimaryItemName("");
      List<String> superTypeNames = new ArrayList<String>();
      superTypeNames.add("nt:base");
      nodeTypeValue.setDeclaredSupertypeNames(superTypeNames);
      nodeTypeValue.setPrimaryItemName("");

      ExtendedNodeTypeManager extNodeTypeManager = repositoryService.getDefaultRepository().getNodeTypeManager();
      try
      {
         nodeTypeManager.getNodeType("exo:testNodeType2");
View Full Code Here

    * @throws Exception
    */
   public void testReregisterRemoveChildNodeDefinition() throws Exception
   {
      // create new NodeType value
      NodeTypeValue testNValue = new NodeTypeValue();

      List<String> superType = new ArrayList<String>();
      superType.add("nt:base");
      testNValue.setName("exo:testReregisterRemoveChildNodeDefinition");
      testNValue.setPrimaryItemName("");
      testNValue.setDeclaredSupertypeNames(superType);

      List<NodeDefinitionValue> nodes = new ArrayList<NodeDefinitionValue>();
      nodes.add(new NodeDefinitionValue("child", false, false, 1, false, "nt:unstructured", new ArrayList<String>(),
         false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.FAIL_IF_EXISTS);
      testNValue = nodeTypeManager.getNodeTypeValue(testNValue.getName());
      Node testNode = root.addNode("testNode", testNValue.getName());
      Node child = testNode.addNode("child");
      session.save();

      nodes = new ArrayList<NodeDefinitionValue>();

      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      try
      {
         nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);
         fail();
View Full Code Here

    * @throws Exception
    */
   public void testReregisterMandatoryNotAutocreatedChildNodeDefinition() throws Exception
   {
      // create new NodeType value
      NodeTypeValue testNValue = new NodeTypeValue();

      List<String> superType = new ArrayList<String>();
      superType.add("nt:base");
      testNValue.setName("exo:testReregisterMandatoryNotAutocreatedChildNodeDefinition");
      testNValue.setPrimaryItemName("");
      testNValue.setDeclaredSupertypeNames(superType);

      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.FAIL_IF_EXISTS);
      testNValue = nodeTypeManager.getNodeTypeValue(testNValue.getName());

      Node testNode = root.addNode("testNode", testNValue.getName());
      session.save();

      List<NodeDefinitionValue> nodes = new ArrayList<NodeDefinitionValue>();
      nodes.add(new NodeDefinitionValue("child", false, true, 1, false, "nt:unstructured", new ArrayList<String>(),
         false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      try
      {
         nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);
         fail();
      }
      catch (RepositoryException e)
      {
         // ok;
      }
      testNValue = nodeTypeManager.getNodeTypeValue(testNValue.getName());
      nodes = new ArrayList<NodeDefinitionValue>();
      nodes.add(new NodeDefinitionValue("child", false, false, 1, false, "nt:unstructured", new ArrayList<String>(),
         false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);
      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);

      testNode.addNode("child");
      session.save();

      nodes = new ArrayList<NodeDefinitionValue>();
      nodes.add(new NodeDefinitionValue("child", false, true, 1, false, "nt:unstructured", new ArrayList<String>(),
         false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);
      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);

   }
View Full Code Here

    * @throws Exception
    */
   public void testReregisterMandatoryChildNodeDefinition() throws Exception
   {
      // create new NodeType value
      NodeTypeValue testNValue = new NodeTypeValue();

      List<String> superType = new ArrayList<String>();
      superType.add("nt:base");
      testNValue.setName("exo:testReregisterMandatoryChildNodeDefinition");
      testNValue.setPrimaryItemName("");
      testNValue.setDeclaredSupertypeNames(superType);

      List<NodeDefinitionValue> nodes = new ArrayList<NodeDefinitionValue>();
      nodes.add(new NodeDefinitionValue("child", false, false, 1, false, "nt:unstructured", new ArrayList<String>(),
         false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.FAIL_IF_EXISTS);
      testNValue = nodeTypeManager.getNodeTypeValue(testNValue.getName());
      Node testNode = root.addNode("testNode", testNValue.getName());
      // testNode.addNode("child");
      session.save();

      nodes = new ArrayList<NodeDefinitionValue>();
      nodes.add(new NodeDefinitionValue("child", false, true, 1, false, "nt:unstructured", new ArrayList<String>(),
         false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      try
      {
         nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);
         fail();
View Full Code Here

    * @throws Exception
    */
   public void testReregisterProtectedChildNodeDefinition() throws Exception
   {
      // create new NodeType value
      NodeTypeValue testNValue = new NodeTypeValue();

      List<String> superType = new ArrayList<String>();
      superType.add("nt:base");
      testNValue.setName("exo:testReregisterProtectedChildNodeDefinition");
      testNValue.setPrimaryItemName("");
      testNValue.setDeclaredSupertypeNames(superType);

      List<NodeDefinitionValue> nodes = new ArrayList<NodeDefinitionValue>();
      nodes.add(new NodeDefinitionValue("child", false, false, 1, false, "nt:unstructured", new ArrayList<String>(),
         false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.FAIL_IF_EXISTS);

      testNValue = nodeTypeManager.getNodeTypeValue(testNValue.getName());

      Node testNode = root.addNode("testNode", testNValue.getName());
      // testNode.addNode("child");
      session.save();

      nodes = new ArrayList<NodeDefinitionValue>();
      nodes.add(new NodeDefinitionValue("child", false, false, 1, true, "nt:unstructured", new ArrayList<String>(),
         false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      try
      {
         nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);
         fail();
View Full Code Here

   }

   public void testReregisterRequiredTypeChangeChildNodeDefinition() throws Exception
   {
      // create new NodeType value
      NodeTypeValue testNValue = new NodeTypeValue();

      List<String> superType = new ArrayList<String>();
      superType.add("nt:base");
      testNValue.setName("exo:testReregisterRequiredTypeChangeChildNodeDefinition");
      testNValue.setPrimaryItemName("");
      testNValue.setDeclaredSupertypeNames(superType);

      List<NodeDefinitionValue> nodes = new ArrayList<NodeDefinitionValue>();
      List<String> requeredPrimaryType = new ArrayList<String>();
      requeredPrimaryType.add("nt:hierarchyNode");
      nodes
         .add(new NodeDefinitionValue("child", false, false, 1, false, "nt:hierarchyNode", requeredPrimaryType, false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.FAIL_IF_EXISTS);
      testNValue = nodeTypeManager.getNodeTypeValue(testNValue.getName());
      Node testNode = root.addNode("testNode", testNValue.getName());
      session.save();

      try
      {
         testNode.addNode("wrongchild", "nt:unstructured");
         fail();
      }
      catch (ConstraintViolationException e)
      {
         // ok
      }
      Node child = testNode.addNode("child", "nt:file");
      Node cont = child.addNode("jcr:content", "nt:resource");
      cont.setProperty("jcr:mimeType", "text");
      cont.setProperty("jcr:lastModified", new GregorianCalendar(2011, 3, 4));
      cont.setProperty("jcr:data", "test text");
      session.save();

      nodes = new ArrayList<NodeDefinitionValue>();
      requeredPrimaryType = new ArrayList<String>();
      requeredPrimaryType.add("nt:folder");
      nodes
         .add(new NodeDefinitionValue("child", false, false, 1, false, "nt:hierarchyNode", requeredPrimaryType, false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      try
      {
         nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);
         fail();
View Full Code Here

   }

   public void testReregisterRequiredTypeChangeResidualChildNodeDefinition() throws Exception
   {
      // create new NodeType value
      NodeTypeValue testNValue = new NodeTypeValue();

      List<String> superType = new ArrayList<String>();
      superType.add("nt:base");
      testNValue.setName("exo:testReregisterRequiredTypeChangeResidualChildNodeDefinition");
      testNValue.setPrimaryItemName("");
      testNValue.setDeclaredSupertypeNames(superType);

      List<NodeDefinitionValue> nodes = new ArrayList<NodeDefinitionValue>();
      List<String> requeredPrimaryType = new ArrayList<String>();
      requeredPrimaryType.add("nt:base");
      nodes.add(new NodeDefinitionValue("*", false, false, 1, false, "nt:base", requeredPrimaryType, false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.FAIL_IF_EXISTS);

      testNValue = nodeTypeManager.getNodeTypeValue(testNValue.getName());

      Node testNode = root.addNode("testNode", testNValue.getName());
      session.save();

      Node child = testNode.addNode("child", "nt:file");
      Node cont = child.addNode("jcr:content", "nt:resource");
      cont.setProperty("jcr:mimeType", "text");
      cont.setProperty("jcr:lastModified", new GregorianCalendar(2011, 3, 4));
      cont.setProperty("jcr:data", "test text");
      session.save();

      nodes = new ArrayList<NodeDefinitionValue>();
      requeredPrimaryType = new ArrayList<String>();
      requeredPrimaryType.add("nt:unstructured");
      nodes.add(new NodeDefinitionValue("*", false, false, 1, false, "nt:base", requeredPrimaryType, false));
      testNValue.setDeclaredChildNodeDefinitionValues(nodes);

      try
      {
         nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);
         fail();
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.core.nodetype.NodeTypeValue

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.