Examples of RestfulHttpRequest


Examples of org.jembi.openhim.RestfulHttpRequest

  @SuppressWarnings("unchecked")
  @Override
  public Object transformMessage(MuleMessage msg, String enc) throws TransformerException {
   
    RestfulHttpRequest restMsg = new RestfulHttpRequest();
   
    String url = (String) msg.getInboundProperty("http.request");
    restMsg.setPath(url);
    String httpMethod = (String) msg.getInboundProperty("http.method");
    restMsg.setHttpMethod(httpMethod);
    Map<String, Object> httpHeaders = (Map<String, Object>) msg.getInboundProperty("http.headers");
    // set transaction uuid for outgoing http headers
    httpHeaders.put(OPENHIM_TX_UUID, restMsg.getUuid());
    restMsg.setHttpHeaders(httpHeaders);
   
    try {
      String body = msg.getPayloadAsString();
      if (body != url) {
        restMsg.setBody(body);
      }
    } catch (Exception e) {
      throw new TransformerException(this, e);
    }
   
    String scheme = ((String)msg.getInboundProperty("http.context.uri")).split(":")[0];
    if ("https".equals(scheme))
      restMsg.setScheme(Scheme.HTTPS);
    else if ("http".equals(scheme))
      restMsg.setScheme(Scheme.HTTP);
   
    return restMsg;
  }
View Full Code Here

Examples of org.jembi.openhim.RestfulHttpRequest

      });

  @Override
  public Object transformMessage(MuleMessage msg, String enc) throws TransformerException {
   
    RestfulHttpRequest req = (RestfulHttpRequest) msg.getPayload();
   
    msg.setProperty("http.method", req.getHttpMethod(), PropertyScope.OUTBOUND);
    msg.setProperty("http.path", req.buildUrlWithRequestParams(), PropertyScope.OUTBOUND);
   
    for (String header : req.getHttpHeaders().keySet()) {
      if (!httpHeaderBlackList.contains(header)) {
        msg.setProperty(header, req.getHttpHeaders().get(header), PropertyScope.OUTBOUND);
      }
    }

    String auth = msg.getProperty("http.auth", PropertyScope.OUTBOUND);
    if (auth!=null && !auth.isEmpty()) {
      msg.setProperty("Authorization", auth, PropertyScope.OUTBOUND);
    } else {
      msg.removeProperty("Authorization", PropertyScope.OUTBOUND);
    }
   
    if (req.getHttpMethod().equals("PUT") || req.getHttpMethod().equals("POST")) {
      msg.setPayload(req.getBody());
      return msg;
    }
   
    return msg;
   
View Full Code Here

Examples of org.jembi.openhim.RestfulHttpRequest

    this.sampleHttpHeaders.put("Content-Type", "application/xml");
  }
 
  private void setupMocks(String body, String uuid, Map<String, Object> httpHeaders, String httpMethod, String path) throws Exception {
   
    RestfulHttpRequest req = new RestfulHttpRequest();
    req.setHttpMethod(httpMethod);
    req.setBody(body);
    req.setPath(path);
    req.setHttpHeaders(httpHeaders);
    req.setUuid(uuid);
   
    msg = mock(MuleMessage.class);
    when(msg.getPayload()).thenReturn(req);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.