Examples of DecodeException


Examples of ca.uhn.hl7v2.hoh.api.DecodeException

    if (myGzipCoding) {
      ourLog.debug("Decoding message contents using GZIP encoding style");
      try {
        bytes = GZipUtils.uncompress(bytes);
      } catch (IOException e) {
        throw new DecodeException("Failed to uncompress GZip content", e);
      }
    }

    Charset charset = getCharset();
    ourLog.debug("Message is {} bytes with charset {}", bytes.length, charset.name());
View Full Code Here

Examples of ca.uhn.hl7v2.hoh.api.DecodeException

      if ("transfer-encoding".equals(nextHeader)) {
        if ("chunked".equalsIgnoreCase(nextValue)) {
          myTransferEncoding = TransferEncoding.CHUNKED;
        } else {
          throw new DecodeException("Unknown transfer encoding: " + nextValue);
        }
      } else if ("content-length".equals(nextHeader)) {
        try {
          myContentLength = Integer.parseInt(nextValue);
        } catch (NumberFormatException e) {
          addConformanceProblem("Could not parse Content-Length header value: " + nextHeader);
        }
      } else if ("content-type".equals(nextHeader)) {
        int colonIndex = nextValue.indexOf(';');
        if (colonIndex == -1) {
          myContentType = nextValue;
        } else {
          myContentType = nextValue.substring(0, colonIndex);
          myEncodingStyle = EncodingStyle.withNameCaseInsensitive(myContentType);
          String charsetDef = nextValue.substring(colonIndex + 1).trim();
          if (charsetDef.startsWith("charset=")) {
            String charsetName = charsetDef.substring(8);
            Charset charset;
            try {
              charset = Charset.forName(charsetName);
            } catch (UnsupportedCharsetException e) {
              addConformanceProblem("Unsupported or invalid charset: " + charsetName);
              continue;
            }
            setCharset(charset);
          }
        }

        myContentType = myContentType.trim();

      } else if ("authorization".equals(nextHeader)) {
        int spaceIndex = nextValue.indexOf(' ');
        if (spaceIndex == -1) {
          throw new DecodeException("Invalid authorization header. No authorization style detected");
        }
        String type = nextValue.substring(0, spaceIndex);
        if ("basic".equalsIgnoreCase(type)) {
          String encodedCredentials = nextValue.substring(spaceIndex + 1);
          byte[] decodedCredentials = Base64.decodeBase64(encodedCredentials);
          String credentialsString = new String(decodedCredentials, getDefaultCharset());
          int colonIndex = credentialsString.indexOf(':');
          if (colonIndex == -1) {
            setUsername(credentialsString);
          } else {
            setUsername(credentialsString.substring(0, colonIndex));
            setPassword(credentialsString.substring(colonIndex + 1));
          }
        } else {
          addConformanceProblem("Invalid authorization type. Only basic authorization is supported.");
        }
      } else if ("content-coding".equals(nextHeader)) {
        if (StringUtils.isNotBlank(nextValue)) {
          if ("gzip".equals(nextValue)) {
            myGzipCoding = true;
          } else {
            throw new DecodeException("Unknown content-coding: " + nextValue);
          }
        }
      } else if (HTTP_HEADER_HL7_SIGNATURE_LC.equals(nextHeader)) {
        mySignature = nextValue;
      }
View Full Code Here

Examples of ca.uhn.hl7v2.hoh.api.DecodeException

    }

    decodeBody();
   
    if (getContentType() == null) {
      throw new DecodeException("Content-Type not specified");
    }
    if (getEncodingStyle() == null) {
      throw new NonHl7ResponseException("Invalid Content-Type: " + getContentType(), getContentType(), getMessage());
    }
   
View Full Code Here

Examples of ca.uhn.hl7v2.hoh.api.DecodeException

    while (true) {
      String nextSize;
      try {
        nextSize = readLine(theInputStream);
      } catch (IOException e) {
        throw new DecodeException("Failed to decode CHUNKED encoding", e);
      }

      if (nextSize.length() == 0) {
        break;
      }

      int nextSizeInt;
      try {
        nextSizeInt = Integer.parseInt(nextSize, 16);
      } catch (NumberFormatException e) {
        throw new DecodeException("Failed to decode CHUNKED encoding", e);
      }

      ourLog.debug("Next CHUNKED size: {}", nextSizeInt);

      if (nextSizeInt < 0) {
        throw new DecodeException("Received invalid octet count in chunked transfer encoding: " + nextSize);
      }

      if (nextSizeInt > 0) {
        int totalRead = 0;
        myLastStartedReading = System.currentTimeMillis();
        do {
          int nextRead = Math.min(nextSizeInt, byteBuffer.length);
          int bytesRead = theInputStream.read(byteBuffer, 0, nextRead);
          if (bytesRead == -1) {
            throw new DecodeException("Reached EOF while reading in message chunk");
          }
          if (bytesRead == 0 && totalRead < nextSizeInt) {
            pauseDuringTimedOutRead();
          }
          totalRead += bytesRead;
View Full Code Here

Examples of ca.uhn.hl7v2.hoh.api.DecodeException

    }
    if (getSigner() != null) {
      try {
        getSigner().verify(myBytes, mySignature);
      } catch (SignatureFailureException e) {
        throw new DecodeException("Failed to verify signature due to an error (signature may possibly be valid, but verification failed)", e);
      }
    }
  }
View Full Code Here

Examples of ca.uhn.hl7v2.hoh.api.DecodeException

          break;
        }

        int colonIndex = nextLine.indexOf(':');
        if (colonIndex == -1) {
          throw new DecodeException("Invalid HTTP header line detected. Value is: " + nextLine);
        }

        String key = nextLine.substring(0, colonIndex);
        String value = nextLine.substring(colonIndex + 1).trim();
        getHeaders().put(key, value);
View Full Code Here

Examples of ca.uhn.hl7v2.hoh.api.DecodeException

      if (firstLine == null || isBlank(firstLine)) {
        throw new NoMessageReceivedException();
      }

      if (!firstLine.startsWith("POST ")) {
        throw new DecodeException("HTTP request line message is not valid. Only POST action is supported. Request line was: " + firstLine);
      }

      firstLine = firstLine.substring(5);
      int nextSpace = firstLine.indexOf(' ');
      if (nextSpace == -1) {
        throw new DecodeException("HTTP request line message is not valid. Not HTTP version found. Request line was: " + firstLine);
      }

      setPath(firstLine.substring(0, nextSpace));
      if (isBlank(getPath())) {
        throw new DecodeException("HTTP request line message is not valid. No request URI found. Request line was: " + firstLine);
      }

      String protocolVersion = firstLine.substring(nextSpace + 1);
      if (!"HTTP/1.1".equals(protocolVersion)) {
        throw new DecodeException("HTTP request line message is not valid. HTTP version not supported. Request line was: " + firstLine);
      }

      myActionLine = firstLine;
    }
   
View Full Code Here

Examples of com.netflix.paas.json.DecodeException

  public static <T> T decodeValue(String str, Class<?> clazz) throws DecodeException {
    try {
      return (T)mapper.readValue(str, clazz);
    }
    catch (Exception e) {
      throw new DecodeException("Failed to decode:" + e.getMessage());
    }
  }
View Full Code Here

Examples of com.netflix.staash.json.DecodeException

  public static <T> T decodeValue(String str, Class<?> clazz) throws DecodeException {
    try {
      return (T)mapper.readValue(str, clazz);
    }
    catch (Exception e) {
      throw new DecodeException("Failed to decode:" + e.getMessage());
    }
  }
View Full Code Here

Examples of feign.codec.DecodeException

                if (HYSTRIX_CLASSES.contains(rawType)) {
                    //Let the Hystrix Proxy wrap this
                    return read(response, actualType);
                }
            } else if (HYSTRIX_CLASSES.contains(type)) {
                throw new DecodeException("Return type "+type+" must be parameterized");
            }

            return read(response, type);

        } catch(RuntimeJsonMappingException e) {
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.