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

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


       * onParentVersion="VERSION" protected="false" sameNameSiblings="false"> <requiredPrimaryTypes>
       * <requiredPrimaryType>nt:base</requiredPrimaryType> </requiredPrimaryTypes>
       * </childNodeDefinition> </childNodeDefinitions> </nodeType>
       */
      ExtendedNodeTypeManager manager = repository.getNodeTypeManager();
      NodeTypeValue exoTaxonomy = new NodeTypeValue();

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

      NodeDefinitionValue childNodeDefinitionValue = new NodeDefinitionValue();
      childNodeDefinitionValue.setName("*");
      childNodeDefinitionValue.setDefaultNodeTypeName("");
      childNodeDefinitionValue.setMandatory(false);
      childNodeDefinitionValue.setAutoCreate(false);
      childNodeDefinitionValue.setRequiredNodeTypeNames(superTypeNames);
      childNodeDefinitionValue.setSameNameSiblings(false);
      List<NodeDefinitionValue> childNodeDefinitions = new ArrayList<NodeDefinitionValue>();
      childNodeDefinitions.add(childNodeDefinitionValue);
      childNodeDefinitionValue.setOnVersion(OnParentVersionAction.VERSION);
      exoTaxonomy.setDeclaredChildNodeDefinitionValues(childNodeDefinitions);

      manager.registerNodeType(exoTaxonomy, ExtendedNodeTypeManager.IGNORE_IF_EXISTS);
   }
View Full Code Here


   public NodeTypeValue getNodeTypeValue(String nodeTypeName) throws NoSuchNodeTypeException, RepositoryException
   {
      NodeTypeData ntdata = typesManager.getNodeType(locationFactory.parseJCRName(nodeTypeName).getInternalName());
      if (ntdata != null)
      {
         NodeTypeValue nodeTypeValue = new NodeTypeValue();
         nodeTypeValue.setMixin(ntdata.isMixin());
         nodeTypeValue.setName(locationFactory.createJCRName(ntdata.getName()).getAsString());
         nodeTypeValue.setOrderableChild(ntdata.hasOrderableChildNodes());
         if (ntdata.getPrimaryItemName() == null)
         {
            nodeTypeValue.setPrimaryItemName("");
         }
         else
         {
            nodeTypeValue.setPrimaryItemName(locationFactory.createJCRName(ntdata.getPrimaryItemName()).getAsString());
         }
         List<String> declaredSupertypeNames = new ArrayList<String>();
         for (int i = 0; i < ntdata.getDeclaredSupertypeNames().length; i++)
         {
            declaredSupertypeNames.add(locationFactory.createJCRName(ntdata.getDeclaredSupertypeNames()[i])
               .getAsString());
         }
         List<PropertyDefinitionValue> declaredPropertyDefinitionValues = new ArrayList<PropertyDefinitionValue>();

         for (int i = 0; i < ntdata.getDeclaredPropertyDefinitions().length; i++)
         {
            declaredPropertyDefinitionValues.add(convert(ntdata.getDeclaredPropertyDefinitions()[i]));
         }

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

         for (int i = 0; i < ntdata.getDeclaredChildNodeDefinitions().length; i++)
         {
            declaredChildNodeDefinitionValues.add(convert(ntdata.getDeclaredChildNodeDefinitions()[i]));
         }

         nodeTypeValue.setDeclaredSupertypeNames(declaredSupertypeNames);
         nodeTypeValue.setDeclaredPropertyDefinitionValues(declaredPropertyDefinitionValues);
         nodeTypeValue.setDeclaredChildNodeDefinitionValues(declaredChildNodeDefinitionValues);
         return nodeTypeValue;
      }

      throw new NoSuchNodeTypeException("Nodetype not found " + nodeTypeName);
View Full Code Here

         List<NodeTypeValue> nts = new ArrayList<NodeTypeValue>();
         for (int i = 0; i < ntvList.size(); i++)
         {
            if (ntvList.get(i) != null)
            {
               NodeTypeValue nodeTypeValue = (NodeTypeValue) ntvList.get(i);
               nts.add(nodeTypeValue);
            }
            else
            {
               // Hm! Smth is wrong in xml document
View Full Code Here

   public NodeTypeValue getNodeTypeValue(String nodeTypeName) throws NoSuchNodeTypeException, RepositoryException
   {
      NodeTypeData ntdata = typesManager.findNodeType(locationFactory.parseJCRName(nodeTypeName).getInternalName());
      if (ntdata != null)
      {
         NodeTypeValue nodeTypeValue = new NodeTypeValue();
         nodeTypeValue.setMixin(ntdata.isMixin());
         nodeTypeValue.setName(locationFactory.createJCRName(ntdata.getName()).getAsString());
         nodeTypeValue.setOrderableChild(ntdata.hasOrderableChildNodes());
         if (ntdata.getPrimaryItemName() == null)
         {
            nodeTypeValue.setPrimaryItemName("");
         }
         else
         {
            nodeTypeValue.setPrimaryItemName(locationFactory.createJCRName(ntdata.getPrimaryItemName()).getAsString());
         }
         List<String> declaredSupertypeNames = new ArrayList<String>();
         for (int i = 0; i < ntdata.getDeclaredSupertypeNames().length; i++)
         {
            declaredSupertypeNames.add(locationFactory.createJCRName(ntdata.getDeclaredSupertypeNames()[i])
                     .getAsString());
         }
         List<PropertyDefinitionValue> declaredPropertyDefinitionValues = new ArrayList<PropertyDefinitionValue>();

         for (int i = 0; i < ntdata.getDeclaredPropertyDefinitions().length; i++)
         {
            declaredPropertyDefinitionValues.add(convert(ntdata.getDeclaredPropertyDefinitions()[i]));
         }

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

         for (int i = 0; i < ntdata.getDeclaredChildNodeDefinitions().length; i++)
         {
            declaredChildNodeDefinitionValues.add(convert(ntdata.getDeclaredChildNodeDefinitions()[i]));
         }

         nodeTypeValue.setDeclaredSupertypeNames(declaredSupertypeNames);
         nodeTypeValue.setDeclaredPropertyDefinitionValues(declaredPropertyDefinitionValues);
         nodeTypeValue.setDeclaredChildNodeDefinitionValues(declaredChildNodeDefinitionValues);
         return nodeTypeValue;
      }

      throw new NoSuchNodeTypeException("Nodetype not found " + nodeTypeName);
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.getRepository().getNodeTypeManager();
      try
      {
         nodeTypeManager.getNodeType("exo:testNodeType2");
View Full Code Here

   public NodeTypeValue getNodeTypeValue(String nodeTypeName) throws NoSuchNodeTypeException, RepositoryException
   {
      NodeTypeData ntdata = typesManager.getNodeType(locationFactory.parseJCRName(nodeTypeName).getInternalName());
      if (ntdata != null)
      {
         NodeTypeValue nodeTypeValue = new NodeTypeValue();
         nodeTypeValue.setMixin(ntdata.isMixin());
         nodeTypeValue.setName(locationFactory.createJCRName(ntdata.getName()).getAsString());
         nodeTypeValue.setOrderableChild(ntdata.hasOrderableChildNodes());
         if (ntdata.getPrimaryItemName() == null)
         {
            nodeTypeValue.setPrimaryItemName("");
         }
         else
         {
            nodeTypeValue.setPrimaryItemName(locationFactory.createJCRName(ntdata.getPrimaryItemName()).getAsString());
         }
         List<String> declaredSupertypeNames = new ArrayList<String>();
         for (int i = 0; i < ntdata.getDeclaredSupertypeNames().length; i++)
         {
            declaredSupertypeNames.add(locationFactory.createJCRName(ntdata.getDeclaredSupertypeNames()[i])
               .getAsString());
         }
         List<PropertyDefinitionValue> declaredPropertyDefinitionValues = new ArrayList<PropertyDefinitionValue>();

         for (int i = 0; i < ntdata.getDeclaredPropertyDefinitions().length; i++)
         {
            declaredPropertyDefinitionValues.add(convert(ntdata.getDeclaredPropertyDefinitions()[i]));
         }

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

         for (int i = 0; i < ntdata.getDeclaredChildNodeDefinitions().length; i++)
         {
            declaredChildNodeDefinitionValues.add(convert(ntdata.getDeclaredChildNodeDefinitions()[i]));
         }

         nodeTypeValue.setDeclaredSupertypeNames(declaredSupertypeNames);
         nodeTypeValue.setDeclaredPropertyDefinitionValues(declaredPropertyDefinitionValues);
         nodeTypeValue.setDeclaredChildNodeDefinitionValues(declaredChildNodeDefinitionValues);
         return nodeTypeValue;
      }

      throw new NoSuchNodeTypeException("Nodetype not found " + nodeTypeName);
View Full Code Here

   public NodeTypeValue getNodeTypeValue(String nodeTypeName) throws NoSuchNodeTypeException, RepositoryException
   {
      NodeTypeData ntdata = typesManager.getNodeType(locationFactory.parseJCRName(nodeTypeName).getInternalName());
      if (ntdata != null)
      {
         NodeTypeValue nodeTypeValue = new NodeTypeValue();
         nodeTypeValue.setMixin(ntdata.isMixin());
         nodeTypeValue.setName(locationFactory.createJCRName(ntdata.getName()).getAsString());
         nodeTypeValue.setOrderableChild(ntdata.hasOrderableChildNodes());
         if (ntdata.getPrimaryItemName() == null)
         {
            nodeTypeValue.setPrimaryItemName("");
         }
         else
         {
            nodeTypeValue.setPrimaryItemName(locationFactory.createJCRName(ntdata.getPrimaryItemName()).getAsString());
         }
         List<String> declaredSupertypeNames = new ArrayList<String>();
         for (int i = 0; i < ntdata.getDeclaredSupertypeNames().length; i++)
         {
            declaredSupertypeNames.add(locationFactory.createJCRName(ntdata.getDeclaredSupertypeNames()[i])
               .getAsString());
         }
         List<PropertyDefinitionValue> declaredPropertyDefinitionValues = new ArrayList<PropertyDefinitionValue>();

         for (int i = 0; i < ntdata.getDeclaredPropertyDefinitions().length; i++)
         {
            declaredPropertyDefinitionValues.add(convert(ntdata.getDeclaredPropertyDefinitions()[i]));
         }

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

         for (int i = 0; i < ntdata.getDeclaredChildNodeDefinitions().length; i++)
         {
            declaredChildNodeDefinitionValues.add(convert(ntdata.getDeclaredChildNodeDefinitions()[i]));
         }

         nodeTypeValue.setDeclaredSupertypeNames(declaredSupertypeNames);
         nodeTypeValue.setDeclaredPropertyDefinitionValues(declaredPropertyDefinitionValues);
         nodeTypeValue.setDeclaredChildNodeDefinitionValues(declaredChildNodeDefinitionValues);
         return nodeTypeValue;
      }

      throw new NoSuchNodeTypeException("Nodetype not found " + nodeTypeName);
   }
View Full Code Here

       * onParentVersion="VERSION" protected="false" sameNameSiblings="false"> <requiredPrimaryTypes>
       * <requiredPrimaryType>nt:base</requiredPrimaryType> </requiredPrimaryTypes>
       * </childNodeDefinition> </childNodeDefinitions> </nodeType>
       */
      ExtendedNodeTypeManager manager = repository.getNodeTypeManager();
      NodeTypeValue exoTaxonomy = new NodeTypeValue();

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

      NodeDefinitionValue childNodeDefinitionValue = new NodeDefinitionValue();
      childNodeDefinitionValue.setName("*");
      childNodeDefinitionValue.setDefaultNodeTypeName("");
      childNodeDefinitionValue.setMandatory(false);
      childNodeDefinitionValue.setAutoCreate(false);
      childNodeDefinitionValue.setRequiredNodeTypeNames(superTypeNames);
      childNodeDefinitionValue.setSameNameSiblings(false);
      List<NodeDefinitionValue> childNodeDefinitions = new ArrayList<NodeDefinitionValue>();
      childNodeDefinitions.add(childNodeDefinitionValue);
      childNodeDefinitionValue.setOnVersion(OnParentVersionAction.VERSION);
      exoTaxonomy.setDeclaredChildNodeDefinitionValues(childNodeDefinitions);

      manager.registerNodeType(exoTaxonomy, ExtendedNodeTypeManager.IGNORE_IF_EXISTS);
   }
View Full Code Here

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

      List<String> superType = new ArrayList<String>();
      superType.add("nt:base");
      testNValue.setName("exo:testAddVersionableSuper");
      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();
      assertFalse(testNode.isNodeType("mix:versionable"));
      superType = testNValue.getDeclaredSupertypeNames();
      superType.add("mix:versionable");
      testNValue.setDeclaredSupertypeNames(superType);

      nodeTypeManager.registerNodeType(testNValue, ExtendedNodeTypeManager.REPLACE_IF_EXISTS);

      assertTrue(testNode.isNodeType("mix:versionable"));
      testNode.checkin();
      testNode.checkout();
      testNode.remove();

      testNode = root.addNode("testNode", testNValue.getName());
      session.save();
      assertTrue(testNode.isNodeType("mix:versionable"));
   }
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.