Package nexj.core.integration

Examples of nexj.core.integration.IntegrationException


      {
         if (obj == null)
         {
            if (msg.isRequired())
            {
               throw new IntegrationException("err.integration.minPartCount", new Object[]{msg.getFullPath()});
            }

            return new InstanceArrayList(0);
         }

         List list = (List)obj;
         int nCount = list.size();

         if (nCount < msg.getMinCount())
         {
            throw new IntegrationException("err.integration.minPartCount", new Object[]{msg.getFullPath()});
         }

         if (nCount > msg.getMaxCount())
         {
            throw new IntegrationException("err.integration.maxPartCount", new Object[]{msg.getFullPath()});
         }

         InstanceList instanceList = new InstanceArrayList(list.size());

         for (int i = 0; i < nCount; ++i)
View Full Code Here


         if (obj == null)
         {
            if (part.isRequired())
            {
               throw new IntegrationException("err.integration.minPartCount", new Object[]{part.getFullPath()});
            }

            return null;
         }

         if (derivedPart instanceof CompositeMessagePart)
         {
            metaclass = (Metaclass)getSystemAttributeValue((CompositeMessagePart)derivedPart,
               (TransferObject)obj, ObjectMessagePartMapping.ATTR_CLASS);
         }

         if (m_context.isSecure())
         {
            if (attribute != null)
            {
               attribute.checkReadAccess(m_context.getPrivilegeSet());
            }

            if (metaclass != null)
            {
               metaclass.checkReadAccess(m_context.getPrivilegeSet());
            }
         }

         if (derivedPart instanceof PrimitiveMessagePart)
         {
            Object validatedValue = ((PrimitiveMessagePart)derivedPart).validateValue(obj);
           
            if (attribute == null)
            {
               return validatedValue;
            }

            validatedValue = attribute.getType().convert(validatedValue);

            int nMaxLength = attribute.getMaxLength();

            if (nMaxLength > 0 && mapping.isTruncated())
            {
               if (validatedValue instanceof String)
               {
                  String sValue = (String) validatedValue;

                  if (sValue.length() > nMaxLength)
                  {
                     validatedValue = sValue.substring(0, nMaxLength);

                     if (s_logger.isDebugEnabled())
                     {
                        s_logger.debug("Value of attribute " + attribute.getName()
                           + " has been truncated to maximum allowed length " + nMaxLength
                           + ". The original value is \"" + sValue + "\".");
                     }
                  }
               }
               else if (validatedValue instanceof Binary)
               {
                  byte[] binaryValue = ((Binary) validatedValue).getData();

                  if (binaryValue.length > nMaxLength)
                  {
                     byte[] truncatedValue = new byte[nMaxLength];

                     System.arraycopy(binaryValue, 0, truncatedValue, 0, nMaxLength);
                     validatedValue = new Binary(truncatedValue);

                     if (s_logger.isDebugEnabled())
                     {
                        s_logger.debug("Value of attribute " + attribute.getName()
                           + " has been truncated to maximum allowed length " + nMaxLength
                           + ". The original value is \"" + binaryValue + "\".");
                     }
                  }
               }
            }

            return validatedValue;
         }
      }

      CompositeMessagePart composite = (CompositeMessagePart)derivedPart;
      TransferObject tobj = (TransferObject)obj;
      Instance instance = (Instance)m_instanceByTobjMap.get(tobj);

      if (instance == null && "delete".equals(tobj.getEventName())) // Obsolete delete
      {
         if (part.isRequired())
         {
            throw new IntegrationException("err.integration.minPartCount", new Object[]{part.getFullPath()});
         }

         return null;
      }
View Full Code Here

   {
      if (obj == null)
      {
         if (msg.isRequired())
         {
            throw new IntegrationException("err.integration.minPartCount", new Object[]{msg.getFullPath()});
         }

         return Collections.EMPTY_LIST;
      }

      List list = (List)obj;
      int nCount = list.size();

      if (nCount < msg.getMinCount())
      {
         throw new IntegrationException("err.integration.minPartCount", new Object[]{msg.getFullPath()});
      }

      if (nCount > msg.getMaxCount())
      {
         throw new IntegrationException("err.integration.maxPartCount", new Object[]{msg.getFullPath()});
      }

      return list;
   }
View Full Code Here

         MessageTable table = service.getInterface().getRequestTable();
        
         if (!(message instanceof TransferObject) ||
            table.getMessageCount() != 0 && table.findMessage(((TransferObject)message).getClassName()) == null)
         {
            throw new IntegrationException("err.integration.service.inputMessage", new Object[]{service.getFullName()});
         }
      }

      if (s_logger.isDebugEnabled())
      {
         s_logger.debug("Invoking " + service);
      }

      Instance instance = null;

      try
      {
         m_context.setSecure(false);
         instance = new Instance(metaclass, m_context);

         State state = new State(service, true);

         state.setReservedValue(0, instance);
         state.setReservedValue(1, state);
         state.setValue(Service.OUTPUT, sOutput);
         state.setToken(service, message);

         int i = 0;

         for (Pair pair = args; pair != null; pair = pair.getNext())
         {
            if (i >= service.getArgumentCount())
            {
               i = -1;
               break;
            }
           
            state.setValue(service.getArgument(i++), pair.getHead());
         }

         if (i != service.getArgumentCount())
         {
            throw new IntegrationException("err.integration.service.argCount",
               new Object[]{Primitive.createInteger(Pair.length(args)),
                  Primitive.createInteger(service.getArgumentCount())});
         }

         instance.setNew();
View Full Code Here

         if (responseTable.getMessageCount() != 0)
         {
            if (!(value instanceof TransferObject) ||
               (message = responseTable.findMessage(((TransferObject)value).getClassName())) == null)
            {
               throw new IntegrationException("err.integration.service.outputMessage", new Object[]{service.getFullName()});
            }

            if (message.getFormat() == null)
            {
               message = null;
            }
         }
         else if (responseTable.getFormat() != null)
         {
            channel = null;
         }

         if (channel != null && message != null)
         {
            if (channel.getSender() == null)
            {
               throw new RPCException("err.rpc.notSender", new Object[]{channel.getName()});
            }

            Sender sender = (Sender)channel.getSender().getInstance(m_context);
            ObjectOutput output = sender.createOutput();

            ((MessageFormatter)message.getFormat().getFormatter().getInstance(m_context)).format((TransferObject)value, message, output);
            TransferObject tobj = new TransferObject(1);
            tobj.setValue(Sender.BODY, output.getObject());
            value = tobj;
         }
      }

      if (channel != null)
      {
         if (!(value instanceof TransferObject))
         {
            throw new IntegrationException("err.integration.service.outputMessage", new Object[]{service.getFullName()});
         }

         m_context.getUnitOfWork().addMessage(channel, (TransferObject)value);
      }
View Full Code Here

         Object body = tobj.findValue(BODY);
         Binary data;

         if (body == null)
         {
            throw new IntegrationException("err.rpc.file.missingBody",
               new Object[] {m_channel.getName()});
         }

         ObjectInput conv = new ObjectInput(body);

         if (m_channel.getEncoding() != null)
         {
            conv.setEncoding(m_channel.getEncoding());
         }

         data = conv.getBinary();
         conn = m_connectionFactory.getConnection();

         if (s_logger.isDebugEnabled())
         {
            s_logger.debug("Using file connection: " + conn);
         }

         String sOutgoingName = (String) tobj.findValue(FILE);

         if (sOutgoingName == null)
         {
            sOutgoingName = m_channel.getOutgoingName();
         }

         //Expand file name template
         sOutgoingName = FileNameExpander.expandString(sOutgoingName, m_context, null);

         if (!conn.attachToFile(sOutgoingName))
         {
            throw new IntegrationException("err.rpc.file.cannotSend",
               new Object[] {m_channel.getName(), sOutgoingName});
         }

         m_sentCounter.add(1);
         conn.write(data);
      }
      catch (IOException ex)
      {
         throw new FileConnectionException("err.rpc.file.ioErr", ex);
      }
      catch (ResourceException ex)
      {
         throw new IntegrationException("err.rpc.file.cannotSend",
            new Object[] {m_channel.getName()}, ex);
      }
      finally
      {
         if (conn != null)
View Full Code Here

      {
         return new OutputStreamWriter(m_ostream, m_sEncoding);
      }
      catch (UnsupportedEncodingException e)
      {
         throw new IntegrationException("err.integration.io", e);
      }
   }
View Full Code Here

      {
         m_ostream.write(msg.getData());
      }
      catch (IOException ex)
      {
         throw new IntegrationException("err.integration.io", ex);
      }
   }
View Full Code Here

   /**
    * @see nexj.core.integration.Output#setObject(java.lang.Object)
    */
   public void setObject(Object obj) throws IntegrationException
   {
      throw new IntegrationException("err.integration.outputObject");
   }
View Full Code Here

   /**
    * @see nexj.core.integration.Output#setString(java.lang.String)
    */
   public void setString(String sMsg) throws IntegrationException
   {
      throw new IntegrationException("err.integration.outputString");
   }
View Full Code Here

TOP

Related Classes of nexj.core.integration.IntegrationException

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.