@Override public Credentials getCredentials() { MuleCredentials creds = message.getOutboundProperty(MuleProperties.MULE_CREDENTIALS_PROPERTY); return (credentials != null ? credentials : creds); }
protected Map<String, Object> getPropertiesForTemplate(MuleMessage message) { Map<String, Object> props = new HashMap<String, Object>(); // Also add the endpoint properties so that users can set fallback values // when the property is not set on the event props.putAll(this.getProperties()); for (String propertyKey : message.getOutboundPropertyNames()) { props.put(propertyKey, message.getOutboundProperty(propertyKey)); } return props; }
public boolean containsHeader(String name) { return message.getOutboundProperty(name) != null; }
public String getContentType() { return message.getOutboundProperty(HttpConstants.HEADER_CONTENT_TYPE); }
public Object getHeader(String name) { return message.getOutboundProperty(name); }
protected Map<String, Object> getPropertiesForUriTemplate(MuleMessage message) { Map<String, Object> props = (Map) message.getOutboundProperty(CHANNEL.URI_PARAM_PROPERTIES); if (props == null) { throw new IllegalStateException(CHANNEL.URI_PARAM_PROPERTIES + " not set on message"); } return props; }
protected String getParam(MuleMessage message, String propertyName) throws NullPointerException { String value = message.getOutboundProperty(propertyName); if (value == null) { throw new IllegalArgumentException("Parameter '" + propertyName + "' must be set on the request"); } return value; } }
public Object get(Object key) { return message.getOutboundProperty(key.toString()); }
protected String getBodyParameterName(MuleMessage message) { String bodyParameter = message.getOutboundProperty(HttpConnector.HTTP_POST_BODY_PARAM_PROPERTY); if (bodyParameter == null) { bodyParameter = message.getInvocationProperty(HttpConnector.HTTP_POST_BODY_PARAM_PROPERTY); } return bodyParameter; }
public String getContentType() { return event.getMessage().getOutboundProperty(HttpConstants.HEADER_CONTENT_TYPE, HttpConstants.DEFAULT_CONTENT_TYPE); } }
protected String detectHttpMethod(MuleMessage msg) { String method = msg.getOutboundProperty(HttpConnector.HTTP_METHOD_PROPERTY, null); if (method == null) { method = msg.getInvocationProperty(HttpConnector.HTTP_METHOD_PROPERTY, HttpConstants.METHOD_POST); } return method; }
protected MuleMessage getResponseFromMethod(HttpMethod httpMethod, ExceptionPayload ep) throws IOException, MuleException { MuleMessage message = createMuleMessage(httpMethod); if (logger.isDebugEnabled()) { logger.debug("Http response is: " + message.getOutboundProperty(HttpConnector.HTTP_STATUS_PROPERTY)); } message.setExceptionPayload(ep); return message; }
protected URI getURI(MuleMessage message) throws URISyntaxException, TransformerException { String endpointAddress = message.getOutboundProperty(MuleProperties.MULE_ENDPOINT_PROPERTY, null); if (endpointAddress == null) { throw new TransformerException( HttpMessages.eventPropertyNotSetCannotProcessRequest(MuleProperties.MULE_ENDPOINT_PROPERTY), this); } return new URI(endpointAddress); }
protected void setPropertyFromEndpoint(MuleEvent event, MuleMessage msg, String prop) { Object o = msg.getOutboundProperty(prop); if (o == null) { o = endpoint.getProperty(prop); if (o != null) { msg.setOutboundProperty(prop, o); } } }
public MuleEvent process(MuleEvent event) throws MuleException { int timeout = event.getMessage().getOutboundProperty(MuleProperties.MULE_EVENT_TIMEOUT_PROPERTY, -1); if (timeout >= 0) { event.setTimeout(timeout); } return event; }
private void processMuleSession(MuleEvent event, HttpMethod httpMethod) { String muleSession = event.getMessage().getOutboundProperty(MuleProperties.MULE_SESSION_PROPERTY); if (muleSession != null) { httpMethod.setRequestHeader(new Header(HttpConstants.HEADER_MULE_SESSION, muleSession)); } }
private Integer resolveStatusCode(MuleEvent event) { if (statusCode != null) { return statusCodeEvaluator.resolveIntegerValue(event); } Object statusCodeOutboundProperty = event.getMessage().getOutboundProperty(HTTP_STATUS_PROPERTY); if (statusCodeOutboundProperty != null) { return NumberUtils.toInt(statusCodeOutboundProperty); } return null; }
protected void processReplyTo(MuleEvent event, MuleEvent result, ReplyToHandler replyToHandler, Object replyTo) throws MuleException { if (result != null && replyToHandler != null) { String requestor = result.getMessage().getOutboundProperty(MuleProperties.MULE_REPLY_TO_REQUESTOR_PROPERTY); if ((requestor != null && !requestor.equals(service.getName())) || requestor == null) { replyToHandler.processReplyTo(event, result.getMessage(), replyTo); } } }
private void sendFailureResponseToClient(MessagingException exception, int httpStatus) throws IOException, MuleException { MuleEvent response = exception.getEvent(); response.getMessage().setPayload(exception.getMessage()); httpStatus = response.getMessage().getOutboundProperty(HttpConnector.HTTP_STATUS_PROPERTY) != null ? Integer.valueOf(response.getMessage().getOutboundProperty(HttpConnector.HTTP_STATUS_PROPERTY).toString()) : httpStatus; response.getMessage().setOutboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, httpStatus); HttpResponse httpResponse = transformResponse(response.getMessage()); httpServerConnection.writeResponse(httpResponse, getThrottlingHeaders()); }
protected void processCookies(MuleEvent event) { MuleMessage msg = event.getMessage(); Object cookiesProperty = msg.getInboundProperty(HttpConnector.HTTP_COOKIES_PROPERTY); String cookieSpecProperty = (String) msg.getInboundProperty(HttpConnector.HTTP_COOKIE_SPEC_PROPERTY); processCookies(cookiesProperty, cookieSpecProperty, event); cookiesProperty = msg.getOutboundProperty(HttpConnector.HTTP_COOKIES_PROPERTY); cookieSpecProperty = (String) msg.getOutboundProperty(HttpConnector.HTTP_COOKIE_SPEC_PROPERTY); processCookies(cookiesProperty, cookieSpecProperty, event); cookiesProperty = endpoint.getProperty(HttpConnector.HTTP_COOKIES_PROPERTY); cookieSpecProperty = (String) endpoint.getProperty(HttpConnector.HTTP_COOKIE_SPEC_PROPERTY); processCookies(cookiesProperty, cookieSpecProperty, event); }