Package org.jvnet.mimepull

Examples of org.jvnet.mimepull.MIMEPart


          if (boundary == null || boundary.equals("")) {
              throw new WebServiceException("MIME boundary parameter not found" + contentType);
          }
          
          MIMEMessage message =  new MIMEMessage(input, boundary);
          MIMEPart  jsonPart  = null;   
      for(MIMEPart mimeAttach : message.getAttachments()){
        if(mimeAttach.getContentType().equalsIgnoreCase(JSONContentType.JSON_MIME_TYPE)) {
          jsonPart  = mimeAttach;
          break;
        } else {
          List<String> contentDisposition = mimeAttach.getHeader(JSONCodec.CONTENT_DISPOSITION_HEADER);
          if(contentDisposition != null && contentDisposition.size() > 0){
            try {
              ContentDisposition disp = new ContentDisposition(contentDisposition.get(0));
              if(disp.getParameter("name") != null && disp.getParameter("name").equals(JSON_PARAM_NAME)){
                jsonPart = mimeAttach;
                break;
              }
            } catch (ParseException e) {}
          }
        }
      }
      if(jsonPart == null){
        throw new RuntimeException(String.format("There is no request JSON found in multipart mime. Your JSON input http \"parameter\"" +
            " must be named as \"%s\" or pass %s: <Your json param name>. In alternate case body part content type should be %s " +
            " json content as mime part body.", JSONCodec.XJSONPARAM_DEFAULT, JSONCodec.XJSONPARAM_HEADER, JSONContentType.JSON_MIME_TYPE));
      }
      List<MIMEPart> attachments = message.getAttachments();
      /*
       * Remove JSON part from attachment list. JSON part reseved for codec. and handled by JSONDecoder.
       *
       */
      attachments.remove(jsonPart);
      /*
       * Put attachemnts into invoke properties of packet.
       */
      this.packet.invocationProperties.put(JSONCodec.MIME_ATTACHMENTS,attachments);
      /*
       * Decode message
       */
      com.sun.xml.ws.api.message.Message wsMessage = new JSONDecoder(this.codec,jsonPart.readOnce(),packet).getWSMessage();
      /*
       * Remove attachment. Else same packet object used in response. It leads attachment fall back in response.
       */
      this.packet.invocationProperties.remove(JSONCodec.MIME_ATTACHMENTS);
      /*
 
View Full Code Here


                        }
                    }
                } else {
                    if (useMimePull) {
                        MimePullMultipart mpMultipart = (MimePullMultipart)multiPart;
                        MIMEPart sp = mpMultipart.readAndReturnSOAPPart();
                        soapMessagePart = new MimeBodyPart(sp);
                        soapPartInputStream = sp.readOnce();
                    } else {
                        BMMimeMultipart bmMultipart =
                                (BMMimeMultipart) multiPart;
                        InputStream stream = bmMultipart.initStream();
View Full Code Here

     *
     * @return Map<String, StreamAttachment> for all attachment parts
     */
    public @NotNull Map<String, Attachment> getAttachmentParts() {
        if (!gotAll) {
            MIMEPart rootPart = (start != null) ? message.getPart(start) : message.getPart(0);
            List<MIMEPart> parts = message.getAttachments();
            for(MIMEPart part : parts) {
                if (part != rootPart) {
                    PartAttachment attach = new PartAttachment(part);
                    attachments.put(attach.getContentId(), attach);
View Full Code Here

     */
    public @Nullable Attachment getAttachmentPart(String contentId) throws IOException {
        //first see if this attachment is already parsed, if so return it
        Attachment attach = attachments.get(contentId);
        if (attach == null) {
            MIMEPart part = message.getPart(contentId);
            attach = new PartAttachment(part);
            attachments.put(contentId, attach);
        }
        return attach;
    }
View Full Code Here

     *
     * @return Map<String, StreamAttachment> for all attachment parts
     */
    public @NotNull Map<String, Attachment> getAttachmentParts() {
        if (!gotAll) {
            MIMEPart rootPart = (start != null) ? message.getPart(start) : message.getPart(0);
            List<MIMEPart> parts = message.getAttachments();
            for(MIMEPart part : parts) {
                if (part != rootPart) {
                    String cid = part.getContentId();
                    if (!attachments.containsKey(cid)) {
View Full Code Here

     */
    public @Nullable Attachment getAttachmentPart(String contentId) throws IOException {
        //first see if this attachment is already parsed, if so return it
        Attachment attach = attachments.get(contentId);
        if (attach == null) {
            MIMEPart part = message.getPart(contentId);
            attach = new PartAttachment(part);
            attachments.put(contentId, attach);
        }
        return attach;
    }
View Full Code Here

                        }
                    }
                } else {
                    if (useMimePull) {
                        MimePullMultipart mpMultipart = (MimePullMultipart)multiPart;
                        MIMEPart sp = mpMultipart.readAndReturnSOAPPart();
                        soapMessagePart = new MimeBodyPart(sp);
                        soapPartInputStream = sp.readOnce();
                    } else {
                        BMMimeMultipart bmMultipart =
                                (BMMimeMultipart) multiPart;
                        InputStream stream = bmMultipart.initStream();
View Full Code Here

TOP

Related Classes of org.jvnet.mimepull.MIMEPart

Copyright © 2018 www.massapicom. 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.