Package org.jboss.soa.esb.actions

Examples of org.jboss.soa.esb.actions.ActionProcessingException


        Object payload = null;
        try {
            payload = payloadProxy.getPayload(message);
        } catch (MessageDeliverException e) {
            throw new ActionProcessingException(e);
        }
     
        try {
          if(payload instanceof byte[]) {
            payload = new String((byte[])payload, "UTF-8");
          }

            if(payload == null) {
                logger.warn("Null message payload.  Returning message unmodified.");
            } else if(payload instanceof String) {
              long start = System.currentTimeMillis();
                ExecutionContext executionContext;

                // Register the message profile with Smooks (if there is one and it's not already registered)...
                messageProfile = registerMessageProfile(message, smooks);

              // Filter and Serialise...
                if(messageProfile == null) {
                    // Not using profiles on this transformation.
                    executionContext = smooks.createExecutionContext();
                } else {
                    executionContext = smooks.createExecutionContext(messageProfile);
                }
               
                StringResult result = new StringResult();
                smooks.filterSource(executionContext, new StringSource((String) payload), result);

                HashMap beanHash = new HashMap(executionContext.getBeanContext().getBeanMap());
              if(beanHash != null) {
                message.getBody().add(EXTRACTED_BEANS_HASH, beanHash); // Backward compatibility.
              } else {
                    message.getBody().remove(EXTRACTED_BEANS_HASH); // Backward compatibility.
                }
             
              if(logger.isDebugEnabled()) {
                long timeTaken = System.currentTimeMillis() - start;
                logger.debug("Transformed message for profile [" + messageProfile + "]. Time taken: "
                    + timeTaken + ".  Message in:\n[" + payload.toString()+ "].  \nMessage out:\n[" + result.toString() + "].");
              }

                setTransformationOutput(message, result.toString(), executionContext);
            } else {
              logger.warn("Only java.lang.String payload types supported.  Input message was of type [" + payload.getClass().getName() + "].  Returning message untransformed.");
          }
           
        } catch(Throwable thrown) {
        throw new ActionProcessingException("Message transformation failed.", thrown);
      }
       
        // TODO: Cater for more message input types e.g. InputStream, DOM Document...
        // TODO: Cater for more message output types e.g. InputStream, DOM Document...
     
View Full Code Here


    private void setTransformationOutput(Message message, String transformedMessage, ExecutionContext executionContext) throws ActionProcessingException {
        // Set the transformation text output...
        try {
            payloadProxy.setPayload(message, transformedMessage);
        } catch (MessageDeliverException e) {
            throw new ActionProcessingException(e);
        }

        // Set the transformation Java output.  Will be the individual
        // java objects directly on the message and (optionally) the map itself...
        Map beanMap = executionContext.getBeanContext().getBeanMap();
View Full Code Here

        if(reportPath != null) {
            try {
                executionContext.setEventListener(new HtmlReportGenerator(reportPath));
            } catch (IOException e) {
                throw new ActionProcessingException("Failed to create HtmlReportGenerator instance.", e);
            }
        }

        //  Use the Smooks PayloadProcessor to execute the transformation....
        final Object payload;
        try {
            payload = payloadProxy.getPayload(message);
        } catch (MessageDeliverException e) {
            throw new ActionProcessingException("MessgeDeliveryException while trying to retrieve the message payload:", e);
        }
        final Object newPayload = payloadProcessor.process( payload, executionContext );

        //  Set the ExecutionContext's attributes on the message instance so other actions can access them.
        message.getBody().add( EXECUTION_CONTEXT_ATTR_MAP_KEY, getSerializableObjectsMap( executionContext.getAttributes() ) );

        try {
            payloadProxy.setPayload( message, newPayload );
        } catch (MessageDeliverException e) {
            throw new ActionProcessingException("MessgeDeliveryException while trying to retrieve the message payload:", e);
        }

        return message;
    }
View Full Code Here

      counter++;
    }
    catch (Exception e)
    {
      log.error( "Exception " , e );
      throw new ActionProcessingException( e );
    }
    finally
    {
      if (stmnt != null)   try { stmnt.close();}   catch (SQLException e) { log.warn( e ); /* ignore */ }
      if (con != null)   try { con.close()}   catch (SQLException e) { log.warn( e ); /* ignore */ }
View Full Code Here

            {
                return new MockWSDynamicClient(new WiseProperties("wise-core.properties"));
            }
            catch (WiseException e)
            {
                throw new ActionProcessingException(e.getMessage(), e);
            }
        }
View Full Code Here

    public Message process(Message message) throws ActionProcessingException {
        Endpoint endpoint = WebServiceUtils.getServiceEndpoint(jbossws_endpoint, jbossws_context);
        byte[] soapMessage;

        if(endpoint == null) {
            throw new ActionProcessingException("Unknown Service Endpoint '" + jbossws_endpoint + "'.");
        }

        soapMessage = getSOAPMessagePayload(message);
        try {
            messageTL.set(message);

            RequestHandler requestHandler = endpoint.getRequestHandler();

            final Map<String, List<String>> headers = new HashMap<String, List<String>>() ;
            final Properties properties = message.getProperties() ;
            final String[] names = properties.getNames() ;
            for(final String name: names)
            {
                final Object value = properties.getProperty(name) ;
                if (value != null)
                {
                    String normalisedName = name.toLowerCase() ;

                    if ("content-type".equals(normalisedName))
                    {
                        if ("application/octet-stream".equals(value))
                        {
                            continue;
                        }
                        else
                        {
                            // CXF needs it to be case sensitive
                            normalisedName = "Content-Type";
                        }
                    }

                    final List<String> values = headers.get(normalisedName) ;
                    if (values == null)
                    {
                        final List<String> newValues = new ArrayList<String>() ;
                        newValues.add(value.toString()) ;
                        headers.put(normalisedName, newValues) ;
                    }
                    else
                    {
                        values.add(value.toString()) ;
                    }
                }
            }

            //CXF throws NPE in handler if content-length not set
            List<String> newValues = new ArrayList<String>();
            newValues.add(String.valueOf(soapMessage.length));
            headers.put("content-length", newValues);

            final String endpointAddress = endpoint.getAddress() ;
            String path = null ;
            if (endpointAddress != null)
            {
                try
                {
                    path = new URI(endpointAddress).getPath() ;
                }
                catch (final URISyntaxException urise) {} //ignore
            }
            if (path == null)
            {
                path = getHeaderValue(headers, "path") ;
            }

            final SOAPProcessorHttpServletRequest servletRequest = new SOAPProcessorHttpServletRequest(path, soapMessage, headers) ;
            final SOAPProcessorHttpServletResponse servletResponse = new SOAPProcessorHttpServletResponse() ;
            final ServletContext servletContext = SOAPProcessorFactory.getFactory().createServletContext(endpoint) ;

            EndpointAssociation.setEndpoint(endpoint);
            final ClassLoader old = Thread.currentThread().getContextClassLoader();
            try
            {
                initialiseContextClassLoader(endpoint);
                requestHandler.handleHttpRequest(endpoint, servletRequest, servletResponse, servletContext) ;
            }
            finally
            {
                Thread.currentThread().setContextClassLoader(old);
                EndpointAssociation.removeEndpoint();
            }
           
            // This may have been changed, make sure we get the current version.
            message = messageTL.get();
            final Properties responseProperties = message.getProperties() ;
            final String contentType = servletResponse.getContentType() ;
            final Map<String, List<String>> responseHeaders = servletResponse.getHeaders() ;
            // We deal with Content-Type below
            // HTTP Headers *should* be case-insensitive but not with JBR
            responseHeaders.remove("content-type") ;
          
            for(Map.Entry<String, List<String>> header: responseHeaders.entrySet())
            {
                // We can only deal with the first value in the list.
              // JBESB-2511
              new ResponseHeader(header.getKey(), header.getValue().get(0)).setPropertyNameThis(properties);
            }
            // JBESB-2761
            if (httpResponseStatusEnabled) {
              ResponseStatus.setHttpProperties(properties, servletResponse.getStatus(), servletResponse.getStatusMessage());
            }
           
            final byte[] responseData = servletResponse.getContent() ;
            if(contentType != null) {
                responseProperties.setProperty("Content-Type", new ResponseHeader("Content-Type", contentType));
            } else {
                responseProperties.setProperty("Content-Type", new ResponseHeader("Content-Type", "text/xml"));
            }
           
            if ((contentType != null) && contentType.startsWith("multipart/")) {
                payloadProxy.setPayload(message, responseData) ;
            } else {
                final String charset = servletResponse.getCharset() ;
                if (charset == null) {
                    payloadProxy.setPayload(message, new String(responseData)) ;
                } else {
                    payloadProxy.setPayload(message, new String(responseData, charset)) ;
                }
            }
        } catch (Exception ex) {
            throw new ActionProcessingException("Cannot process SOAP request", ex);
        } finally {
            messageTL.remove();
        }

        return message;
View Full Code Here

            if (tccl != null)
            {
                Thread.currentThread().setContextClassLoader(tccl);
                return ;
            }
            throw new ActionProcessingException("Could not locate ENC ClassLoader for service endpoint '" + jbossws_endpoint + "'.");
        }
    }
View Full Code Here

        Object messagePayload;

        try {
            messagePayload = payloadProxy.getPayload(message);
        } catch (MessageDeliverException e) {
            throw new ActionProcessingException(e);
        }

        if(messagePayload instanceof byte[]) {
            soapMessage = (byte[])messagePayload;
        } else if(messagePayload instanceof String) {
            try {
                soapMessage = ((String)messagePayload).getBytes("UTF-8");
            } catch (UnsupportedEncodingException e) {
                throw new ActionProcessingException("Unable to decode SOAP message payload.", e);
            }
        } else {
            throw new ActionProcessingException("Unable to decode SOAP message payload.  Must be either a byte[] or java.lang.String.");
        }
        return soapMessage;
    }
View Full Code Here

      return message;          
  }
  
   public Message causesException(Message message) throws ActionProcessingException {
       System.out.println("About to cause an exception");
       throw new ActionProcessingException("BAD STUFF HAPPENED");
   }
View Full Code Here

       try {
         // some logic that bubbles up MyBusinessException
         throw new MyBusinessException("Business Logic Violation");
       } catch (MyBusinessException mbe) {
         System.out.println(mbe.getMessage());
         throw new ActionProcessingException(mbe);
       }
       //     return message;  // unreachable due to the way this demo code is setup
   }
View Full Code Here

TOP

Related Classes of org.jboss.soa.esb.actions.ActionProcessingException

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.