Package nexj.core.meta

Examples of nexj.core.meta.MetadataException


      verifyNotReadOnly();
      m_attribute = attribute;

      if (attribute != null && attribute.isStatic())
      {
         throw new MetadataException("err.meta.persistence.staticAttribute",
            new Object[]{attribute.getName(), attribute.getMetaclass().getName()});
      }
   }
View Full Code Here


      if (oldAdapter != null)
      {
         m_adapterMap.put(adapter.getName(), oldAdapter);

         throw new MetadataException("err.meta.adapterDup", new Object[]
         {
            adapter.getName(),
            getName()
         });
      }
View Full Code Here

      if (sName != null)
      {
         if (part.getParent() == null)
         {
            throw new MetadataException("err.meta.integration.object.mapping.misplacedAttribute");
         }

         if (sName.length() > 0 && sName.charAt(0) == ':')
         {
            for (byte i = 0; i < SYSTEM_ATTRIBUTES.length; ++i)
View Full Code Here

            m_systemPartArray = new MessagePart[SYSTEM_ATTRIBUTES.length];
         }

         if (m_systemPartArray[nAttr] != null && part != m_systemPartArray[nAttr])
         {
            throw new MetadataException("err.meta.integration.object.mapping.systemMappingDup",
               new Object[]{SYSTEM_ATTRIBUTES[nAttr], part.getFullPath()});
         }

         m_systemPartArray[nAttr] = part;
      }
View Full Code Here

      if (m_attribute != null)
      {
         if (m_attribute.isStatic())
         {
            throw new MetadataException("err.meta.integration.object.mapping.staticAttribute",
               new Object[]{part.getFullPath()});
         }

         if ((part instanceof PrimitiveMessagePart) != m_attribute.getType().isPrimitive())
         {
            throw new MetadataException("err.meta.integration.object.mapping.attributeTypeMismatch",
               new Object[]{part.getFullPath()});
         }

         if (m_bLocal && part instanceof CompositeMessagePart && m_attribute.getReverse() == null)
         {
            throw new MetadataException("err.meta.integration.object.mapping.missingLocalReverseAssoc",
               new Object[]{m_attribute.getName(), part.getFullPath()});
         }
      }

      if (m_metaclass != null)
      {
         if (part instanceof PrimitiveMessagePart)
         {
            throw new MetadataException("err.meta.integration.object.mapping.misplacedClass");
         }
        
         if (m_attribute != null && !((Metaclass)m_attribute.getType()).isUpcast(m_metaclass))
         {
            throw new MetadataException("err.meta.integration.object.mapping.classTypeMismatch",
               new Object[]{m_metaclass.getName()});
         }
      }
      else
      {
         if (parent == null)
         {
            if (m_message.getDerivation() != Message.DERIVATION_ABSTRACT)
            {
               throw new MetadataException("err.meta.integration.object.mapping.missingClass");
            }
         }
        
         if (m_attribute != null && !m_attribute.getType().isPrimitive())
         {
            m_metaclass = (Metaclass)m_attribute.getType();
         }
      }

      if (part instanceof PrimitiveMessagePart)
      {
         if (part.isCollection())
         {
            throw new MetadataException("err.meta.integration.object.mapping.primitiveCollection");
         }

         if (m_where != Boolean.TRUE)
         {
            throw new MetadataException("err.meta.integration.object.mapping.primitivePartWhere",
               new Object[]{part.getFullPath()});
         }
      }

      if (parent == null)
      {
         m_bLocal = false;
      }
      else
      {
         ObjectMessagePartMapping mapping = (ObjectMessagePartMapping)parent.getMapping();

         if (mapping != null)
         {
            mapping.setSystemPart(part);
         }
      }

      if (m_bSubKey)
      {
         ObjectMessagePartMapping mapping = (parent == null) ? null : (ObjectMessagePartMapping)parent.getMapping();

         if (mapping != null)
         {
            mapping.m_bSubKeyParent = true;
         }
      }

      if (m_accessAttribute != null && m_accessAttribute.getType() != Primitive.BOOLEAN)
      {
         throw new MetadataException("err.meta.integration.object.mapping.accessAttributeType",
            new Object[]{m_accessAttribute.getName()});
      }

      if (parent == null && m_metaclass != null &&
         (m_message.getBaseMessage() != null || m_message.getDerivedMessageCount() > 0))
View Full Code Here

   {
      verifyNotReadOnly();

      if (association.getReverse() == null)
      {
         throw new MetadataException("err.meta.workflow.actionAssociation",
            new Object[]{association.getName(), association.getMetaclass().getName(),
            getActivity().getFlow().getFullName()});
      }
     
      if (association.getReverse().isCollection())
      {
         throw new MetadataException("err.meta.workflow.actionAssociationMultiplicity",
            new Object[]{association.getName(), association.getMetaclass().getName(),
            getActivity().getFlow().getFullName()});
      }

      if (m_associationList == null)
View Full Code Here

    */
   public void setEvent(String sName, int nArgCount)
   {
      if (nArgCount < 0)
      {
         throw new MetadataException("err.meta.workflow.negativeEventArgCount",
            new Object[]{sName, getActivity().getFlow().getFullName()});
      }

      Member member = getTarget().getSelector(sName).getMember(nArgCount);

      if (!(member instanceof Event))
      {
         throw new MetadataException("err.meta.workflow.invalidEvent",
            new Object[]{sName, member.getMetaclass().getName(),
            getActivity().getFlow().getFullName()});
      }

      setEvent((Event)member);
View Full Code Here

      if (event != null)
      {
         if (event.isStatic())
         {
            throw new MetadataException("err.meta.workflow.staticActionEvent",
               new Object[]{event.getName(), event.getMetaclass().getName(),
               getActivity().getFlow().getName(), getActivity().getFlow().getMetaclass().getName()});
         }
      }
     
View Full Code Here

    */
   public void finish(MessagePart part)
   {
      if (m_nCompression < 0 || m_nCompression > 9)
      {
         throw new MetadataException("err.meta.integration.zip.compressionOutOfRange",
            new Object[]{Primitive.createInteger(m_nCompression), part.getFullPath()});
      }

      if (m_nValue < VALUE_COMMENT || m_nValue > VALUE_TIME)
      {
         throw new IllegalStateException("Unknown value: " + m_nValue);
      }

      if (m_nLevel == 0)
      {
         // Check for a single child part to represent the Zip entries collection
         if (!(part instanceof CompositeMessagePart) ||
             ((CompositeMessagePart)part).getPartCount() != 1 ||
             !((CompositeMessagePart)((CompositeMessagePart)part).getPart(0)).isCollection())
         {
            throw new MetadataException("err.meta.integration.zip.missingCollectionUnderRoot",
               new Object[]{part.getFullPath()});
         }
      }
      else if (m_nLevel == 1)
      {
         // Require a child part with name set
         boolean bFoundNamePart = false;

         if (part instanceof CompositeMessagePart)
         {
            CompositeMessagePart composite = (CompositeMessagePart)part;

            for (int i = 0; i < composite.getPartCount(); i++)
            {
               MessagePart childPart = composite.getPart(i);

               if (((ZipMessagePartMapping)childPart.getMapping()).m_nValue == VALUE_NAME)
               {
                  bFoundNamePart = true;

                  break;
               }
            }
         }

         if (!bFoundNamePart)
         {
            throw new MetadataException("err.meta.integration.zip.missingNameChild",
               new Object[]{part.getFullPath()});
         }
      }
      else if (m_nLevel == 2)
      {
         // Check that the parts here are simple, single-valued
         if (!(part instanceof PrimitiveMessagePart) ||
             ((PrimitiveMessagePart)part).isCollection())
         {
            throw new MetadataException("err.meta.integration.zip.nonPrimitive",
               new Object[]{part.getFullPath()});
         }
      }
      else
      {
View Full Code Here

      loadPart(element, definition);
      definition.setVersion(XMLUtil.getStringAttr(element, "version", definition.getVersion()));

      if (m_definitionMap.put(definition.getNamePrefix(), definition) != null)
      {
         throw new MetadataException("err.meta.soa.definitionDup",
            new Object[] {definition.getName(), definition.getVersion(), definition.getNamePrefix()});
      }

      Element child = XMLUtil.findChildElement(element, "Types");

      if (child != null)
      {
         XMLUtil.forEachChildElement(child, "Type", new XMLUtil.ElementHandler()
         {
            public void handleElement(Element typeElement)
            {
               final ModelType type = new ModelType(definition);

               loadPart(typeElement, type);

               if (!definition.addType(type))
               {
                  throw new MetadataException("err.meta.soa.typeDup",
                     new Object[] {type.getName(), definition.getNamePrefix()});
               }

               m_globalMap.put(type.getGlobalName(), type);

               String sBases = StringUtil.trimToNull(XMLUtil.getStringAttr(typeElement, "bases"));

               if (sBases != null)
               {
                  final String[] sBaseArray = SPACE_PATTERN.split(sBases);

                  m_resolutionFixupList.add(new ContextFixup(m_helper)
                  {
                     public void fixup()
                     {
                        for (int i = 0; i < sBaseArray.length; i++)
                        {
                           String sBaseTypeName = definition.resolveTypeRef(sBaseArray[i]);
                           ModelType baseType = (ModelType)m_globalMap.get(sBaseTypeName);

                           if (baseType == null)
                           {
                              throw new MetadataException("err.meta.soa.unknownType",
                                 new Object[] {sBaseTypeName, type.getGlobalName(), definition.getNamePrefix()});
                           }

                           type.addBase(baseType);
                        }
                     }
                  });
               }

               Element attributesElement = XMLUtil.findChildElement(typeElement, "Attributes");

               if (attributesElement != null)
               {
                  XMLUtil.forEachChildElement(attributesElement, "Attribute", new XMLUtil.ElementHandler()
                  {
                     public void handleElement(Element attributeElement)
                     {
                        Attribute attribute = new Attribute();

                        loadPart(attributeElement, attribute);
                        attribute.setType(XMLUtil.getReqStringAttr(attributeElement, "type"))// TODO: Resolve later
                        attribute.setCollection(XMLUtil.getBooleanAttr(attributeElement, "collection", attribute.isCollection()));
                        attribute.setRequired(XMLUtil.getBooleanAttr(attributeElement, "required", attribute.isRequired()));

                        if (!type.addAttribute(attribute))
                        {
                           throw new MetadataException("err.meta.soa.attributeDup",
                              new Object[] {attribute.getName(), type.getName(), definition.getNamePrefix()});
                        }
                     }
                  });
               }
            }
         });
      }

      child = XMLUtil.findChildElement(element, "Interfaces");

      if (child != null)
      {
         XMLUtil.forEachChildElement(child, "Interface", new XMLUtil.ElementHandler()
         {
            public void handleElement(Element interfaceElement)
            {
               final Interface iface = new Interface(definition);

               loadPart(interfaceElement, iface);

               if (!definition.addInterface(iface))
               {
                  throw new MetadataException("err.meta.soa.interfaceDup",
                     new Object[] {iface.getName(), definition.getNamePrefix()});
               }

               m_globalMap.put(iface.getGlobalName(), iface);

               XMLUtil.forEachChildElement(interfaceElement, "Method", new XMLUtil.ElementHandler()
               {
                  public void handleElement(Element methodElement)
                  {
                     final Method method = new Method();

                     loadPart(methodElement, method);

                     Element argumentsElement = XMLUtil.findChildElement(methodElement, "Arguments");

                     if (argumentsElement != null)
                     {
                        XMLUtil.forEachChildElement(argumentsElement, "Argument", new XMLUtil.ElementHandler()
                        {
                           public void handleElement(Element argumentElement)
                           {
                              Argument argument = new Argument();

                              loadPart(argumentElement, argument);

                              if (!method.addArgument(argument))
                              {
                                 throw new MetadataException("err.meta.soa.argumentDup",
                                    new Object[] {argument.getName(), method.getName(), iface.getName(), definition.getNamePrefix()});
                              }

                              argument.setType(XMLUtil.getReqStringAttr(argumentElement, "type"))// TODO: Resolve later
                              argument.setCollection(XMLUtil.getBooleanAttr(argumentElement, "collection", argument.isCollection()));
                           }
                        });
                     }

                     if (!iface.addMethod(method))
                     {
                        throw new MetadataException("err.meta.soa.methodDup",
                           new Object[] {method.getName(), method.getArgString(), iface.getName(), definition.getNamePrefix()});
                     }

                     Element resultElement = XMLUtil.findChildElement(methodElement, "Result");

                     if (resultElement != null)
                     {
                        Result result = new Result();

                        method.setResult(result);
                        result.setType(XMLUtil.getReqStringAttr(resultElement, "type"))// TODO: Resolve later
                        result.setCollection(XMLUtil.getBooleanAttr(resultElement, "collection", result.isCollection()));
                        result.setDescription(XMLUtil.getStringAttr(resultElement, "description", result.getDescription()));
                     }

                     Element faultsElement = XMLUtil.findChildElement(methodElement, "Faults");

                     if (faultsElement != null)
                     {
                        XMLUtil.forEachChildElement(faultsElement, "Fault", new XMLUtil.ElementHandler()
                        {
                           public void handleElement(Element faultElement)
                           {
                              Fault fault = new Fault();

                              fault.m_sRef = XMLUtil.getReqStringAttr(faultElement, "type")// TODO: Resolve later
                              method.addFault(fault);
                           }
                        });
                     }
                  }
               });
            }
         });
      }

      child = XMLUtil.findChildElement(element, "Services");

      if (child != null)
      {
         XMLUtil.forEachChildElement(child, "Service", new XMLUtil.ElementHandler()
         {
            public void handleElement(Element serviceElement)
            {
               final Service service = new Service(definition);

               loadPart(serviceElement, service);

               if (!definition.addService(service))
               {
                  throw new MetadataException("err.meta.soa.serviceDup",
                     new Object[] {service.getName(), definition.getNamePrefix()});
               }

               m_globalMap.put(service.getGlobalName(), service);

               Element interfacesElement = XMLUtil.findChildElement(serviceElement, "Interfaces");
               final int nCounter[] = {0};

               XMLUtil.forEachChildElement(interfacesElement, "Interface", new XMLUtil.ElementHandler()
               {
                  public void handleElement(Element interfaceElement)
                  {
                     final String sInterfaceName = definition.resolveInterfaceRef(XMLUtil.getReqStringAttr(interfaceElement, "ref"));
                     final InterfaceRef ref = new InterfaceRef();

                     ref.setDefault(XMLUtil.getBooleanAttr(interfaceElement, "default", ref.isDefault()));
                     service.addInterfaceRef(ref);

                     if (ref.isDefault())
                     {
                        nCounter[0]++;
                     }

                     m_resolutionFixupList.add(new ContextFixup(m_helper)
                     {
                        public void fixup()
                        {
                           Interface iface = (Interface)m_globalMap.get(sInterfaceName);

                           if (iface == null)
                           {
                              throw new MetadataException("err.meta.soa.unknownInterface",
                                 new Object[] {sInterfaceName, service.getName(), definition.getNamePrefix()});
                           }

                           ref.setInterface(iface);
                        }
                     });
                  }
               });

               if (nCounter[0] == 0)
               {
                  throw new MetadataException("err.meta.soa.missingDefaultInterface",
                     new Object[] {service.getName(), definition.getNamePrefix()});
               }
               else if (nCounter[0] >= 2)
               {
                  throw new MetadataException("err.meta.soa.multipleDefaultInterface",
                     new Object[] {service.getName(), definition.getNamePrefix()});
               }
            }
         });
      }

      child = XMLUtil.findChildElement(element, "Bindings");

      XMLUtil.forEachChildElement(child, "Binding", new XMLUtil.ElementHandler()
      {
         public void handleElement(Element bindingElement)
         {
            String sBindingName = XMLUtil.getReqStringAttr(bindingElement, "protocol");

            if (!definition.addBinding(sBindingName))
            {
               throw new MetadataException("err.meta.soa.bindingDup",
                  new Object[] {sBindingName, definition.getNamePrefix()});
            }
         }
      });
View Full Code Here

TOP

Related Classes of nexj.core.meta.MetadataException

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.