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

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


      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
      {
View Full Code Here


      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
      {
View Full Code Here

      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);
View Full Code Here

      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);
View Full Code Here

      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>(),
         true));
      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");
      Node child1 = child.addNode("child");
      Node child2 = child.addNode("child");
      session.save();

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

      try
      {
View Full Code Here

      testNValue.setPrimaryItemName("");
      testNValue.setDeclaredSupertypeNames(superType);

      List<NodeDefinitionValue> nodes = new ArrayList<NodeDefinitionValue>();

      nodes.add(new NodeDefinitionValue("*", false, false, 1, false, "nt:unstructured", new ArrayList<String>(), true));
      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");
      Node child1 = child.addNode("child");
      Node child2 = child.addNode("child");
      session.save();

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

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

      testNValue.setPrimaryItemName("");
      testNValue.setDeclaredSupertypeNames(superType);

      List<NodeDefinitionValue> nodes = new ArrayList<NodeDefinitionValue>();

      nodes.add(new NodeDefinitionValue("child", false, false, 1, false, "nt:base", new ArrayList<String>(), true));
      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", "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();
      session.save();

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

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

      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>(),
         true));
      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");
      child.addNode("subchild1");
      child.addNode("subchild1");
      session.save();

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

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

      props.add(prop2);

      testNtValue.setDeclaredPropertyDefinitionValues(props);

      ArrayList nodes = new ArrayList();
      NodeDefinitionValue node1 = new NodeDefinitionValue();
      node1.setName("*");
      node1.setAutoCreate(false);
      // node1.setDefaultNodeTypeName("test:setProperty");
      node1.setDefaultNodeTypeName("nt:unstructured");
      node1.setMandatory(false);
      node1.setSameNameSiblings(false);
      node1.setOnVersion(OnParentVersionAction.COPY);
      node1.setReadOnly(false);
      ArrayList nodeTypes = new ArrayList();
      nodeTypes.add("nt:unstructured");
      node1.setRequiredNodeTypeNames(nodeTypes);
      nodes.add(node1);
      testNtValue.setDeclaredChildNodeDefinitionValues(nodes);

      return testNtValue;
   }
View Full Code Here

      }
   }

   private NodeDefinitionValue convert(NodeDefinitionData data) throws RepositoryException
   {
      NodeDefinitionValue value = new NodeDefinitionValue();

      value.setName((locationFactory.createJCRName(data.getName()).getAsString()));

      value.setAutoCreate(data.isAutoCreated());
      value.setMandatory(data.isMandatory());
      value.setOnVersion(data.getOnParentVersion());
      value.setReadOnly(data.isProtected());

      value.setSameNameSiblings(data.isAllowsSameNameSiblings());
      value.setDefaultNodeTypeName(locationFactory.createJCRName(data.getDeclaringNodeType()).getAsString());

      List<String> requiredNodeTypeNames = new ArrayList<String>();

      for (int i = 0; i < data.getRequiredPrimaryTypes().length; i++)
      {
         requiredNodeTypeNames.add(locationFactory.createJCRName(data.getRequiredPrimaryTypes()[i]).getAsString());
      }
      value.setRequiredNodeTypeNames(requiredNodeTypeNames);

      return value;
   }
View Full Code Here

TOP

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

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.