Examples of EncodeException


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

      byte[] bytes = getMessage().getBytes(getCharset());
      if (myGzipData) {
        try {
          bytes = GZipUtils.compress(bytes);
        } catch (IOException e) {
          throw new EncodeException("Failed to apply GZip coding", e);
        }
      }
      setData(bytes);
    } else {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      OutputStream os;
      if (myGzipData) {
        try {
          os = new GZIPOutputStream(bos);
        } catch (IOException e) {
          throw new EncodeException("Failed to create GZip encoder", e);
        }
      } else {
        os = bos;
      }

      OutputStreamWriter w = new OutputStreamWriter(os, getCharset());
      try {
        mySendable.writeMessage(w);
      } catch (IOException e) {
        throw new EncodeException("Failed to convert message to sendable bytes");
      }
      setData(bos.toByteArray());
    }

    setActionLineAppropriately();

    setHeaders(new LinkedHashMap<String, String>());

    StringBuilder ctBuilder = new StringBuilder();
    if (mySendable != null) {
      ctBuilder.append(mySendable.getEncodingStyle().getContentType());
    } else {
      ctBuilder.append(EncodingStyle.detect(getMessage()).getContentType());
    }
    ctBuilder.append("; charset=");
    ctBuilder.append(getCharset().name());
    getHeaders().put("Content-Type", ctBuilder.toString());

    getHeaders().put("Content-Length", Integer.toString(getData().length));

    addSpecificHeaders();

    synchronized (ourRfc1123DateFormat) {
      getHeaders().put("Date", ourRfc1123DateFormat.format(new Date()));
    }

    if (getSigner() != null) {
      try {
        getHeaders().put(HTTP_HEADER_HL7_SIGNATURE, getSigner().sign(getData()));
      } catch (SignatureFailureException e) {
        throw new EncodeException(e);
      }
    }

    ourLog.trace("Exiting encode()");
  }
View Full Code Here

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

      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      OutputStreamWriter w = new OutputStreamWriter(bos, getCharset());
      try {
        mySendable.writeMessage(w);
      } catch (IOException e) {
        throw new EncodeException("Failed to convert message to sendable bytes");
      }
      setData(bos.toByteArray());
    }

    setActionLineAppropriately();

    setHeaders(new LinkedHashMap<String, String>());
   
    StringBuilder ctBuilder = new StringBuilder();
    if (mySendable != null) {
      ctBuilder.append(mySendable.getEncodingStyle().getContentType());
    } else {
      ctBuilder.append(EncodingStyle.detect(getMessage()).getContentType());
    }
    ctBuilder.append("; charset=");
    ctBuilder.append(getCharset().name());
    getHeaders().put("Content-Type", ctBuilder.toString());

    getHeaders().put("Content-Length", Integer.toString(getData().length));

    addSpecificHeaders();

    synchronized (ourRfc1123DateFormat) {
      getHeaders().put("Date", ourRfc1123DateFormat.format(new Date()));
    }
   
    if (getSigner() != null) {
      try {
        getHeaders().put(HTTP_HEADER_HL7_SIGNATURE, getSigner().sign(getData()));
      } catch (SignatureFailureException e) {
        throw new EncodeException(e);
      }
    }

    ourLog.trace("Exiting encode()");
  }
View Full Code Here

Examples of com.fineqt.fpb.lib.api.util.EncodeException

          //计算Checksum
          byte[] checksum = FpbUtils.internetChecksum(headerData);
          buffer.position(startOffset + CHECKSUM_FIELD_OFFSET);
          buffer.putByte(checksum);
        } catch (BitBufferException e) {
          throw new EncodeException(targetTypeMeta,
              MetaException.CODE.BIT_BUFFER_EXCEPTION_ERROR, e);
        }
        //恢复Position
        buffer.position(curPosition);
        return result;
View Full Code Here

Examples of com.fineqt.fpb.lib.api.util.EncodeException

          //计算Checksum
          byte[] checksum = FpbUtils.internetChecksum(pseudoBlock);
          buffer.position(startOffset + ICMP_CHECKSUM_FIELD_OFFSET);
          buffer.putByte(checksum);
        } catch (BitBufferException e) {
          throw new EncodeException(targetTypeMeta,
              MetaException.CODE.BIT_BUFFER_EXCEPTION_ERROR, e);
        }
        //恢复Position
        buffer.position(curPosition);
        return result;
View Full Code Here

Examples of com.fineqt.fpb.lib.api.util.EncodeException

      ByteBuffer byteBuffer = ByteBuffer.wrap(pseudoBlock);
      //取得上层IPV6协议的头部字段
      IRecordSetValue ipv6Header = (IRecordSetValue)cxt.getFieldStackMap().peekField(
          Ipv6TypeEVExtFactory.HEADER_FIELD);
      if (ipv6Header == null) {
        throw new EncodeException(targetTypeMeta,
            MetaException.CODE.FIELD_NOT_FOUND_IN_STACK_ERROR,
            Ipv6TypeEVExtFactory.HEADER_FIELD);
      }
      IOctetstringValue address;
      //Source Address
View Full Code Here

Examples of com.fineqt.fpb.lib.api.util.EncodeException

          //计算Checksum
          byte[] checksum = FpbUtils.internetChecksum(headerData);
          buffer.position(startOffset + CHECKSUM_FIELD_OFFSET);
          buffer.putByte(checksum);
        } catch (BitBufferException e) {
          throw new EncodeException(targetTypeMeta,
              MetaException.CODE.BIT_BUFFER_EXCEPTION_ERROR, e);
        }
        //回复Position
        buffer.position(curPosition);
        return result;
View Full Code Here

Examples of com.fineqt.fpb.lib.api.util.EncodeException

                Ipv6TypeEVExtFactory.HEADER_FIELD);
            if (ipHeader != null) {
              pseudoBlock = createV6PseudoHeader(cxt, (IContainerValue)value,
                  ipHeader, upperPrtlBytes, startOffset);
            } else {
              throw new EncodeException(targetTypeMeta,
                  MetaException.CODE.LOWER_LAYER_PROTOCOL_WRONG_ERROR,
                  "Ipv4Protocol or Ipv6Protocol");
            }
          }
          //计算Checksum
          byte[] checksum = FpbUtils.internetChecksum(pseudoBlock);
          if (isUdp) {
            buffer.position(startOffset + UDP_CHECKSUM_FIELD_OFFSET);
            //UDP的特殊处理0x0000->0xFFFF
            if (checksum[0] == 0 && checksum[1] == 0) {
              checksum[0] = (byte)0xFF;
              checksum[1] = (byte)0xFF;
            }
          } else {
            buffer.position(startOffset + TCP_CHECKSUM_FIELD_OFFSET);
          }
          buffer.putByte(checksum);
        } catch (BitBufferException e) {
          throw new EncodeException(targetTypeMeta,
              MetaException.CODE.BIT_BUFFER_EXCEPTION_ERROR, e);
        }
        //恢复Position
        buffer.position(curPosition);
        return result;
View Full Code Here

Examples of com.netflix.paas.json.EncodeException

  public static String encode(Object obj) throws EncodeException {
    try {
      return mapper.writeValueAsString(obj);
    }
    catch (Exception e) {
      throw new EncodeException("Failed to encode as JSON: " + e.getMessage());
    }
  }
View Full Code Here

Examples of com.netflix.paas.json.EncodeException

  public static String encodePrettily(Object obj) throws EncodeException {
    try {
      return prettyMapper.writeValueAsString(obj);
    } catch (Exception e) {
      throw new EncodeException("Failed to encode as JSON: " + e.getMessage());
    }
  }
View Full Code Here

Examples of com.netflix.staash.json.EncodeException

  public static String encode(Object obj) throws EncodeException {
    try {
      return mapper.writeValueAsString(obj);
    }
    catch (Exception e) {
      throw new EncodeException("Failed to encode as JSON: " + e.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.