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

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


   /**
    * {@inheritDoc}
    */
   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);
View Full Code Here


      }
   }

   public void nodeTypeRegistered(InternalQName ntName)
   {
      NodeTypeData def = nodeTypeDataManager.findNodeType(ntName);
      PropertyDefinitionData[] propDefs = def.getDeclaredPropertyDefinitions();
      synchronized (typeMapping)
      {
         for (int i = 0; i < propDefs.length; i++)
         {
            int type = propDefs[i].getRequiredType();
View Full Code Here

                  declaredChildNodes = new NodeDefinitionData[]
                  {};
               }

               // -------- NodeType done --------
               NodeTypeData ntype =
                        new NodeTypeData(ntName, primaryItemName, mixin, hasOrderableChilds, declaredSupertypes,
                                 declaredProperties, declaredChildNodes);
               loadedList.add(ntype);

               if (LOG.isDebugEnabled())
                  LOG.debug("NodeType " + ntype.getName().getAsString() + " readed. "
                           + (System.currentTimeMillis() - ntStart) + " ms");

            }
            catch (IOException e)
            {
View Full Code Here

         if (i < 0)
            name = primaryType;
         else
            name = mixinTypes[i];

         NodeTypeData nt = hierarchy.getNodeType(name);

         if (nt != null)
         {
            if (nt.hasOrderableChildNodes())
               return true;

            Set<InternalQName> supers = hierarchy.getSupertypes(nt.getName());
            for (InternalQName suName : supers)
            {
               NodeTypeData su = hierarchy.getNodeType(suName);
               if (su != null && su.hasOrderableChildNodes())
                  return true;
            }
         }
      }
View Full Code Here

            LOG.warn("Node already of mixin type " + mixinName + " " + getPath());
            return;
         }
      }

      NodeTypeData type = session.getWorkspace().getNodeTypesHolder().findNodeType(name);

      // Mixin or not
      if (type == null || !type.isMixin())
         throw new NoSuchNodeTypeException("Nodetype " + mixinName + " not found or not mixin type.");

      // Validate
      if (session.getWorkspace().getNodeTypesHolder().isNodeType(type.getName(), nodeData().getPrimaryTypeName(),
               nodeData().getMixinTypeNames()))
         throw new ConstraintViolationException("Can not add mixin type " + mixinName + " to " + getPath());

      if (definition.isProtected())
         throw new ConstraintViolationException("Can not add mixin type. Node is protected " + getPath());
View Full Code Here

   public boolean canAddMixin(String mixinName) throws RepositoryException
   {

      checkValid();

      NodeTypeData type =
               session.getWorkspace().getNodeTypesHolder().findNodeType(
                        locationFactory.parseJCRName(mixinName).getInternalName());

      if (type == null)
         throw new NoSuchNodeTypeException("Nodetype not found (mixin) " + mixinName);

      if (session.getWorkspace().getNodeTypesHolder().isNodeType(type.getName(), nodeData().getPrimaryTypeName(),
               nodeData().getMixinTypeNames()))
         return false;

      if (definition.isProtected())
         return false;
View Full Code Here

            RepositoryException, ConstraintViolationException, VersionException, LockException
   {

      // Check if nodeType exists and not mixin
      NodeTypeDataManager nodeTypeDataManager = session.getWorkspace().getNodeTypesHolder();
      NodeTypeData nodeType = nodeTypeDataManager.findNodeType(primaryTypeName);
      if (nodeType == null)
         throw new NoSuchNodeTypeException("Nodetype not found "
                  + sysLocFactory.createJCRName(primaryTypeName).getAsString());

      if (nodeType.isMixin())
         throw new ConstraintViolationException("Add Node failed, "
                  + sysLocFactory.createJCRName(primaryTypeName).getAsString() + " is MIXIN type!");

      // Check if new node's node type is allowed by its parent definition
View Full Code Here

         String mixinTypesField = resolver.createJCRName(Constants.JCR_MIXINTYPES).getAsString();
         String primaryTypeField = resolver.createJCRName(Constants.JCR_PRIMARYTYPE).getAsString();

         // ExtendedNodeTypeManager ntMgr =
         // session.getWorkspace().getNodeTypeManager();
         NodeTypeData base = nodeTypeDataManager.findNodeType(node.getValue());

         if (base.isMixin())
         {
            // search for nodes where jcr:mixinTypes is set to this mixin
            Term t =
                     new Term(FieldNames.PROPERTIES, FieldNames.createNamedValue(mixinTypesField, resolver
                              .createJCRName(node.getValue()).getAsString()));
            terms.add(t);
         }
         else
         {
            // search for nodes where jcr:primaryType is set to this type
            Term t =
                     new Term(FieldNames.PROPERTIES, FieldNames.createNamedValue(primaryTypeField, resolver
                              .createJCRName(node.getValue()).getAsString()));
            terms.add(t);
         }

         // now search for all node types that are derived from base
         Collection<NodeTypeData> allTypes = nodeTypeDataManager.getAllNodeTypes();
         for (NodeTypeData nodeTypeData : allTypes)
         {
            // ExtendedNodeType nt = (ExtendedNodeType) allTypes.nextNodeType();
            InternalQName[] superTypes = nodeTypeData.getDeclaredSupertypeNames();
            if (Arrays.asList(superTypes).contains(base.getName()))
            {
               String ntName = nsMappings.translatePropertyName(nodeTypeData.getName());
               Term t;
               if (nodeTypeData.isMixin())
               {
View Full Code Here

         }, null);
         if (ntName[0] == null)
         {
            ntName[0] = Constants.NT_BASE;
         }
         NodeTypeData nt = propReg.getNodeTypeDataManager().findNodeType(ntName[0]);

         PropertyDefinitionData[] propDefs = nt.getDeclaredPropertyDefinitions();
         for (int i = 0; i < propDefs.length; i++)
         {
            PropertyDefinitionData propDef = propDefs[i];
            if (!propDef.isResidualSet() && !propDef.isMultiple())
            {
View Full Code Here

         NodeData parent = getParent();

         NodeDefinitionData nodeNt =
            nodeTypeDataManager.getChildNodeDefinition(nodeName, parent.getPrimaryTypeName(), parent
               .getMixinTypeNames());
         NodeTypeData nodeType;
         if (nodeNt.getName().equals(Constants.JCR_ANY_NAME) && nodeNt.getDefaultPrimaryType() != null)
         {
            nodeType = nodeTypeDataManager.getNodeType(nodeNt.getDefaultPrimaryType());
         }
         else
         {
            nodeType = nodeTypeDataManager.getNodeType(nodeNt.getName());
         }

         if (nodeType == null)
            throw new ConstraintViolationException("Can not define node-type for node " + nodeName.getAsString()
               + ", parent node type " + parent.getPrimaryTypeName().getAsString());

         nodeTypes.add(nodeType);
         props.put(Constants.JCR_PRIMARYTYPE, locationFactory.createJCRName(nodeType.getName()).getAsString());
      }

      if (atts != null)
      {
         for (String key : atts.keySet())
         {

            String attValue = atts.get(key);

            String propName = ISO9075.decode(key);
            if (log.isDebugEnabled())
            {
               log.debug(propName + ":" + attValue);
            }
            InternalQName propInternalQName = locationFactory.parseJCRName(propName).getInternalName();

            if (Constants.JCR_PRIMARYTYPE.equals(propInternalQName))
            {
               String primaryNodeType = StringConverter.denormalizeString(attValue);
               InternalQName ntName = locationFactory.parseJCRName(primaryNodeType).getInternalName();
               NodeTypeData nodeType = nodeTypeDataManager.getNodeType(ntName);
               if (nodeType == null)
                  throw new ConstraintViolationException("Can not find node type " + primaryNodeType);
               nodeTypes.add(nodeType);
               props.put(propInternalQName, primaryNodeType);
            }
            else if (Constants.JCR_MIXINTYPES.equals(propInternalQName))
            {
               String[] amTypes = attValue.split(" ");
               for (int mi = 0; mi < amTypes.length; mi++)
               {
                  amTypes[mi] = StringConverter.denormalizeString(amTypes[mi]);
                  InternalQName name = locationFactory.parseJCRName(amTypes[mi]).getInternalName();
                  mixinNodeTypes.add(name);
                  NodeTypeData nodeType = nodeTypeDataManager.getNodeType(name);
                  if (nodeType == null)
                     throw new ConstraintViolationException("Can not find node type " + amTypes[mi]);

                  nodeTypes.add(nodeType);
               }
View Full Code Here

TOP

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

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.