Examples of LLPException


Examples of ca.uhn.hl7v2.llp.LLPException

   
    try {
      decoder.readHeadersAndContentsFromInputStreamAndDecode(myInputStream);
    } catch (DecodeException e) {
      if (myProtocol.getRole() == ServerRoleEnum.CLIENT) {
        throw new LLPException("Failed to process response", e);
      } else {
        ourLog.info("Failed to read contents", e);
        HTTPUtils.write400BadRequest(myWriter.getOutputStream(), e.getMessage());

        myInputStream.close();
        myWriter.getOutputStream().close();

        throw new LLPException("Failed to read message", e);
      }
    } catch (NoMessageReceivedException e) {
      return null;
    } catch (SignatureVerificationException e) {
      throw new LLPException("Failed to verify message signature", e);
    }
   
    if (myProtocol.getRole() == ServerRoleEnum.SERVER) {
      Charset charset = decoder.getCharset();
      myWriter.setCharsetForNextMessage(charset);
     
      IAuthorizationServerCallback authorizationCallback = myProtocol.getAuthorizationServerCallback();
      if (authorizationCallback != null) {
        boolean auth = authorizationCallback.authorize(decoder.getPath(), decoder.getUsername(), decoder.getPassword());
        if (!auth) {
          HTTPUtils.write401Unauthorized(myWriter.getOutputStream());
          throw new LLPException("Authorization at URI[" + decoder.getPath() + "] failed for user[" + decoder.getUsername() + "]");
        }
      }
    }

    return decoder.getMessage();
View Full Code Here

Examples of ca.uhn.hl7v2.llp.LLPException

   */
  @Override
  public HL7Reader getReader(InputStream theArg0) throws LLPException {
    if (myNextReader == null && myNextWriter != null) {
      myNextWriter = null;
      throw new LLPException("Hl7OverHttpLowerLayerProtocol can not be used with a multi socket implementation");
    }
    prepareReadersIfNeeded();
    HohLlpReader retVal = myNextReader;
    try {
      retVal.setInputStream(theArg0);
    } catch (IOException e) {
      throw new LLPException("Failed to set stream: " + e.getMessage(), e);
    }

    myNextReader = null;
    return retVal;
  }
View Full Code Here

Examples of ca.uhn.hl7v2.llp.LLPException

   */
  @Override
  public HL7Writer getWriter(OutputStream theArg0) throws LLPException {
    if (myNextReader != null && myNextWriter == null) {
      myNextReader = null;
      throw new LLPException("Hl7OverHttpLowerLayerProtocol can not be used with a multi socket implementation");
    }
    prepareReadersIfNeeded();
    HohLlpWriter retVal = myNextWriter;
    retVal.setPreferredCharset(myPreferredCharset);
    try {
      retVal.setOutputStream(theArg0);
    } catch (IOException e) {
      throw new LLPException("Failed to set stream: " + e.getMessage(), e);
    }

    myNextWriter = null;
    return retVal;
  }
View Full Code Here

Examples of ca.uhn.hl7v2.llp.LLPException

    e.setPath(myProtocol.getUriPath());
    DataOutputStream dos = new DataOutputStream(myOutputStream);
    try {
      e.encodeToOutputStream(dos);
    } catch (EncodeException e1) {
      throw new LLPException("Failed to encode message", e1);
    }

    dos.flush();

  }
View Full Code Here

Examples of ca.uhn.hl7v2.llp.LLPException

    e.setUri(myProtocol.getUriPath());
    DataOutputStream dos = new DataOutputStream(myOutputStream);
    try {
      e.encodeToOutputStream(dos);
    } catch (EncodeException e1) {
      throw new LLPException("Failed to encode message", e1);
    }

    dos.flush();

  }
View Full Code Here

Examples of ca.uhn.hl7v2.llp.LLPException

   
    try {
      decoder.readHeadersAndContentsFromInputStreamAndDecode(myInputStream);
    } catch (DecodeException e) {
      if (myProtocol.getRole() == ServerRoleEnum.CLIENT) {
        throw new LLPException("Failed to process response", e);
      } else {
        ourLog.info("Failed to read contents", e);
        HTTPUtils.write400BadRequest(myWriter.getOutputStream(), e.getMessage());

        myInputStream.close();
        myWriter.getOutputStream().close();

        throw new LLPException("Failed to read message", e);
      }
    } catch (NoMessageReceivedException e) {
      return null;
    } catch (SignatureVerificationException e) {
      throw new LLPException("Failed to verify message signature", e);
    }
   
    if (myProtocol.getRole() == ServerRoleEnum.SERVER) {
      Charset charset = decoder.getCharset();
      myWriter.setCharsetForNextMessage(charset);
     
      IAuthorizationServerCallback authorizationCallback = myProtocol.getAuthorizationServerCallback();
      if (authorizationCallback != null) {
        boolean auth = authorizationCallback.authorize(decoder.getUri(), decoder.getUsername(), decoder.getPassword());
        if (!auth) {
          HTTPUtils.write401Unauthorized(myWriter.getOutputStream());
          throw new LLPException("Authorization at URI[" + decoder.getUri() + "] failed for user[" + decoder.getUsername() + "]");
        }
      }
    }

    return decoder.getMessage();
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.