Examples of Hl7OverHttpRequestDecoder


Examples of ca.uhn.hl7v2.hoh.encoder.Hl7OverHttpRequestDecoder

   * {@inheritDoc}
   */
  @Override
  protected void doPost(HttpServletRequest theReq, HttpServletResponse theResp) throws ServletException, IOException {

    Hl7OverHttpRequestDecoder decoder = new Hl7OverHttpRequestDecoder();
    decoder.setHeaders(new LinkedHashMap<String, String>());

    Enumeration<?> headerNames = theReq.getHeaderNames();
    while (headerNames.hasMoreElements()) {
      String nextName = (String) headerNames.nextElement();
      decoder.getHeaders().put(nextName, theReq.getHeader(nextName));
    }

    decoder.setPath(theReq.getRequestURI());
    decoder.setAuthorizationCallback(myAuthorizationCallback);
    decoder.setSigner(mySigner);

    try {
      decoder.readContentsFromInputStreamAndDecode(theReq.getInputStream());
    } catch (AuthorizationFailureException e) {
      ourLog.error("Authorization failed on request for {}", theReq.getRequestURI());
      theResp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      HTTPUtils.write401Unauthorized(theResp.getOutputStream(), false);
      return;
    } catch (DecodeException e) {
      ourLog.error("Request failure for " + theReq.getRequestURI(), e);
      theResp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      HTTPUtils.write400BadRequest(theResp.getOutputStream(), e.getMessage(), false);
      return;
    } catch (SignatureVerificationException e) {
      ourLog.error("Signature verification failed on request for {}", theReq.getRequestURI());
      theResp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      HTTPUtils.write400SignatureVerificationFailed(theResp.getOutputStream(), false);
      return;
    }

    Charset charset = decoder.getCharset();
    ourLog.debug("Message charset is {}", charset.displayName());

    RawReceivable rawMessage = new RawReceivable(decoder.getMessage());
    rawMessage.addMetadata(MessageMetadataKeys.REMOTE_HOST_ADDRESS.name(), theReq.getRemoteAddr());

    IResponseSendable<String> response;
    try {
      response = myMessageHandler.messageReceived(rawMessage);
View Full Code Here

Examples of ca.uhn.hl7v2.hoh.encoder.Hl7OverHttpRequestDecoder

    AbstractHl7OverHttpDecoder decoder;

    if (myProtocol.getRole() == ServerRoleEnum.CLIENT) {
      decoder = new Hl7OverHttpResponseDecoder();
    } else {
      Hl7OverHttpRequestDecoder requestDecoder = new Hl7OverHttpRequestDecoder();
      requestDecoder.setAuthorizationCallback(myProtocol.getAuthorizationServerCallback());
      decoder = requestDecoder;
      decoder.setSigner(myProtocol.getSigner());
    }

   
View Full Code Here

Examples of ca.uhn.hl7v2.hoh.encoder.Hl7OverHttpRequestDecoder

    AbstractHl7OverHttpDecoder decoder;

    if (myProtocol.getRole() == ServerRoleEnum.CLIENT) {
      decoder = new Hl7OverHttpResponseDecoder();
    } else {
      Hl7OverHttpRequestDecoder requestDecoder = new Hl7OverHttpRequestDecoder();
      requestDecoder.setAuthorizationCallback(myProtocol.getAuthorizationServerCallback());
      decoder = requestDecoder;
      decoder.setSigner(myProtocol.getSigner());
    }

   
View Full Code Here

Examples of ca.uhn.hl7v2.hoh.encoder.Hl7OverHttpRequestDecoder

   * {@inheritDoc}
   */
  @Override
  protected void doPost(HttpServletRequest theReq, HttpServletResponse theResp) throws ServletException, IOException {

    Hl7OverHttpRequestDecoder decoder = new Hl7OverHttpRequestDecoder();
    decoder.setHeaders(new LinkedHashMap<String, String>());

    Enumeration<?> headerNames = theReq.getHeaderNames();
    while (headerNames.hasMoreElements()) {
      String nextName = (String) headerNames.nextElement();
      decoder.getHeaders().put(nextName, theReq.getHeader(nextName));
    }

    decoder.setUri(theReq.getRequestURI());
    decoder.setAuthorizationCallback(myAuthorizationCallback);
    decoder.setSigner(mySigner);

    try {
      decoder.readContentsFromInputStreamAndDecode(theReq.getInputStream());
    } catch (AuthorizationFailureException e) {
      ourLog.error("Authorization failed on request for {}", theReq.getRequestURI());
      theResp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      HTTPUtils.write401Unauthorized(theResp.getOutputStream(), false);
      return;
    } catch (DecodeException e) {
      ourLog.error("Request failure for " + theReq.getRequestURI(), e.getMessage(), e);
      theResp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      HTTPUtils.write400BadRequest(theResp.getOutputStream(), e.getMessage(), false);
      return;
    } catch (SignatureVerificationException e) {
      ourLog.error("Signature verification failed on request for {}", theReq.getRequestURI());
      theResp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      HTTPUtils.write400SignatureVerificationFailed(theResp.getOutputStream(), false);
      return;
    }

    Charset charset = decoder.getCharset();
    ourLog.debug("Message charset is {}", charset.displayName());

    RawReceivable rawMessage = new RawReceivable(decoder.getMessage());
    rawMessage.addMetadata(MessageMetadataKeys.REMOTE_HOST_ADDRESS.name(), theReq.getRemoteAddr());

    IResponseSendable<String> response;
    try {
      response = myMessageHandler.messageReceived(rawMessage);
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.