@Override public Object transform(MuleMessage message, String outputEncoding) throws TransformerException { try { EbMSPing msg = (EbMSPing) message.getPayload(); EbMSPong result = EbMSMessageUtils.ebMSPingToEbMSPong(msg, hostname); message.setPayload(result); return message; } catch (DatatypeConfigurationException e) { throw new TransformerException(this, e); } }
@Override public boolean accept(MuleMessage message) { Object source = message.getPayload(); boolean validMessage = super.accept(message); List<String> errors = ((CustomSaxErrorHandler) getErrorHandler()).getErrors(); if (null != errors && !errors.isEmpty()) { message.setOutboundProperty("schemaErrors", errors.get(0)); validMessage = false; ((CustomSaxErrorHandler) getErrorHandler()).setErrors(new ArrayList<String>()); } else { message.setPayload(source); } return validMessage; }
protected <T> T deserializeJsonToEntity( final TypeReference<T> responseType, final MuleMessage response) throws MuleException { try { T entity; if (logger.isDebugEnabled()) { response.setPayload(IOUtils.toByteArray((InputStream) response.getPayload())); entity = OBJECT_MAPPER.<T>readValue((byte[]) response.getPayload(), responseType); } else { entity = OBJECT_MAPPER.<T>readValue((InputStream) response.getPayload(), responseType); } return entity; } catch (final IOException ioe) { throw new DefaultMuleException( "Failed to deserialize to: " + responseType.getType() + " from: " + renderMessageAsString(response), ioe); } }