Package nexj.core.integration

Examples of nexj.core.integration.IntegrationException


   /**
    * @see nexj.core.integration.Input#getBinary()
    */
   public Binary getBinary() throws IntegrationException
   {
      throw new IntegrationException("err.integration.binary");
   }
View Full Code Here


            addresses = InternetAddress.parse((String)addresses, false);
         }
      }
      catch (Exception e)
      {
         throw new IntegrationException("err.rpc.mailAddress", e);
      }

      if (addresses instanceof Address)
      {
         list.add(addresses);
      }
      else if (addresses instanceof Object[])
      {
         for (int i = 0, nCount = ((Object[])addresses).length; i < nCount; ++i)
         {
            addAddresses(list, ((Object[])addresses)[i]); // might cause expansion of nested lists
         }
      }
      else if (addresses instanceof List)
      {
         for (int i = 0, nCount = ((List)addresses).size(); i < nCount; ++i)
         {
            addAddresses(list, ((List)addresses).get(i)); // might cause expansion of nested lists
         }
      }
      else if (addresses != null)
      {
         throw new IntegrationException("err.rpc.mailAddress"); // unknown object type
      }

      return list;
   }
View Full Code Here

               nLength = reader.read(cbuf);
               reader.reset();
            }
            catch (IOException e)
            {
               throw new IntegrationException("err.rpc.mailType", e); // MIME type search failure
            }

            if (nLength > 0)
            {
               sMIMEType = MIMEUtil.getMIMEType(new String(cbuf, 0, nLength));
            }
         }
         else if (!(obj instanceof Binary || obj instanceof InputStream))
         {
            sMIMEType = MIMEUtil.getMIMEType(obj);
         }
      }

      if (sMIMEType == null)
      {
         throw new IntegrationException("err.rpc.mailType"); // MIME type could not be determined
      }

      // Determine the character set for text MIME types
      if (sMIMEType.startsWith("text/") && sMIMEType.indexOf("charset") < 0)
      {
View Full Code Here

    */
   public void send(TransferObject tobj) throws IntegrationException
   {
      if (!m_channel.isSendable())
      {
         throw new IntegrationException("err.rpc.notSender", new Object[]{m_channel.getName()});
      }

      if (s_logger.isDebugEnabled())
      {
         s_logger.debug("Sending a message on channel \"" + m_channel.getName() + "\"");
         s_logger.dump(tobj);
      }

      MailConnection con = null;

      try
      {
         con = m_factory.openConnection(tobj);

         MimeMessage msg = con.createMessage();
         List/*<Address>*/ list = new ArrayList/*<Address>*/(1);

         if (addAddresses(list, tobj.findValue(Mail.FROM, m_channel.getFrom())).isEmpty())
         {
            msg.setFrom();
         }
         else if (list.size() == 1)
         {
            msg.setFrom((Address)list.get(0));
         }
         else // FROM field cannot have more than 1 value
         {
            throw new IntegrationException("err.rpc.mailFromCount");
         }

         list.clear();

         if (addAddresses(list, tobj.findValue(Mail.TO)).isEmpty()) // TO field required
         {
            throw new IntegrationException("err.rpc.mailToMissing");
         }

         msg.setRecipients(javax.mail.Message.RecipientType.TO,
                           (Address[])list.toArray(new Address[list.size()]));
         list.clear();

         if (!addAddresses(list, tobj.findValue(Mail.CC)).isEmpty())
         {
            msg.setRecipients(javax.mail.Message.RecipientType.CC,
                              (Address[])list.toArray(new Address[list.size()]));
         }

         list.clear();

         if (!addAddresses(list, tobj.findValue(Mail.BCC)).isEmpty())
         {
            msg.setRecipients(javax.mail.Message.RecipientType.BCC,
                              (Address[])list.toArray(new Address[list.size()]));
         }

         list.clear();

         if (!addAddresses(list, tobj.findValue(Mail.REPLY)).isEmpty())
         {
            msg.setReplyTo((Address[])list.toArray(new Address[list.size()]));
         }

         String sSubject = (String)tobj.findValue(Mail.SUBJECT);

         if (sSubject != null)
         {
            msg.setSubject(sSubject);
         }

         msg.setSentDate(new Date());
         setContent(msg, tobj);

         if (s_logger.isDebugEnabled())
         {
            s_logger.debug("Sending an e-mail to " + msg.getRecipients(RecipientType.TO) +
                           " from " + msg.getFrom());

            if (s_logger.isDumpEnabled())
            {
               Object headers = tobj.findValue(Mail.HEADERS);

               s_logger.dump(
                  "Subject: \"" + msg.getSubject() + "\"" + SysUtil.LINE_SEP +
                  ((headers != null) ? "Headers: " + headers + SysUtil.LINE_SEP : "") +
                  tobj.findValue(Mail.BODY));
            }
         }

         Transport.send(msg);
         m_sentCounter.add(1);
      }
      catch (Exception e)
      {
         throw new IntegrationException("err.rpc.mail", e);
      }
      finally
      {
         if (con != null)
         {
View Full Code Here

            part.setContent(multipart); // set the message content to the MultiPart
         }
         else
         {
            throw new IntegrationException("err.rpc.mailMessage");//i.e. unknown/unhandled body type
         }
      }
      catch (Exception e) // MessagingException, IOException
      {
         throw new IntegrationException("err.rpc.mailMessage", e);
      }
   }
View Full Code Here

                  {
                     part.addHeader(sKey, (String)value);
                  }
                  catch (MessagingException e)
                  {
                     throw new IntegrationException("err.rpc.mailHeaderFormat", e);
                  }
               }
            }
            else // only String->String headers are valid
            {
               throw new IntegrationException("err.rpc.mailHeaderFormat");
            }
         }
      }

      setBody(part, content.findValue(Mail.BODY), sContentType, sDescription);
View Full Code Here

         m_formatter.format(root, m_referrerMessage, out);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         IntegrationException cause = (IntegrationException)ex.getCause();

         assertEquals("err.integration.messageTypeMismatch", cause.getErrorCode());
         assertEquals("XML_Inherit_Child1_Referrer ref", cause.getErrorArgs()[0]);
         assertEquals("XML_Inherit_Child1", cause.getErrorArgs()[1]);
         assertEquals("XML_Inherit_Child1_Child", cause.getErrorArgs()[2]);
      }
   }
View Full Code Here

         m_formatter.format(root, msgChild1, out);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         IntegrationException cause = (IntegrationException)ex.getCause();

         assertEquals("err.integration.messageTypeMismatch", cause.getErrorCode());
         assertEquals("XML_Inherit_Child1", cause.getErrorArgs()[0]);
         assertEquals("XML_Inherit_Child1", cause.getErrorArgs()[1]);
         assertEquals("XML_Inherit_Child1_Child", cause.getErrorArgs()[2]);
      }
   }
View Full Code Here

         m_formatter.format(root, m_referrerMessage, out);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         IntegrationException cause = (IntegrationException)ex.getCause();

         assertEquals("err.integration.messageTypeMismatch", cause.getErrorCode());
         assertEquals("XML_Inherit_Parent_Referrer ref", cause.getErrorArgs()[0]);
         assertEquals("XML_Inherit_Parent", cause.getErrorArgs()[1]);
         assertEquals("XML_Inherit_Parent_Parent", cause.getErrorArgs()[2]);
      }


      // Format the pure message
      Message msgParent = m_context.getMetadata().getMessage("XML_Inherit_Parent");

      root = polyRoot;
      writer = new StringWriter();
      out = new WriterOutput(writer);

      try
      {
         m_formatter.format(root, msgParent, out);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         IntegrationException cause = (IntegrationException)ex.getCause();

         assertEquals("err.integration.messageTypeMismatch", cause.getErrorCode());
         assertEquals("XML_Inherit_Parent", cause.getErrorArgs()[0]);
         assertEquals("XML_Inherit_Parent", cause.getErrorArgs()[1]);
         assertEquals("XML_Inherit_Parent_Parent", cause.getErrorArgs()[2]);
      }

      // Format the abstract message
      msgParent = m_context.getMetadata().getMessage("XML_Inherit_Parent_Parent");
      writer = new StringWriter();
      out = new WriterOutput(writer);

      try
      {
         m_formatter.format(root, msgParent, out);
         fail("Expected IntegrationException");
      }
      catch (IntegrationException ex)
      {
         IntegrationException cause = (IntegrationException)ex.getCause();

         assertEquals("err.integration.abstractMessage", cause.getErrorCode());
         assertEquals("XML_Inherit_Parent_Parent", cause.getErrorArgs()[0]);
         assertEquals("XML_Inherit_Parent_Parent", cause.getErrorArgs()[1]);
      }
   }
View Full Code Here

               Message message = context.getMetadata().getMessage(tobj.getClassName());
               Format format = message.getFormat();

               if (format == null || !format.getName().equals("Object"))
               {
                  throw new IntegrationException("err.integration.persistFormat",
                     new Object[]{message.getName(), (format == null) ? "" : message.getFormat().getName()});
               }

               context.getUnitOfWork().checkTransaction();
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.