@Override protected InputPart extractPart(BodyPart bodyPart) throws IOException { InputPart currPart = super.extractPart(bodyPart); Field disposition = bodyPart.getHeader().getField( FieldName.CONTENT_DISPOSITION); if (disposition == null) throw new RuntimeException(Messages.MESSAGES.couldFindNoContentDispositionHeader()); if (disposition instanceof ContentDispositionField) { String name = ((ContentDispositionField) disposition) .getParameter("name"); List<InputPart> list = formDataMap.get(name); if (list == null) { list = new LinkedList<InputPart>(); formDataMap.put(name, list); } list.add(currPart); } else { throw new RuntimeException(Messages.MESSAGES.couldNotParseContentDisposition(disposition)); } return currPart; }
public PartImpl(final BodyPart bodyPart) { this.bodyPart = bodyPart; for (Field field : bodyPart.getHeader()) { headers.add(field.getName(), field.getBody()); if (field instanceof ContentTypeField) { contentType = MediaType.valueOf(field.getBody()); contentTypeFromMessage = true; } } if (contentType == null) contentType = defaultPartContentType; if (getCharset(contentType) == null) { if (defaultPartCharset != null) { contentType = getMediaTypeWithDefaultCharset(contentType); } else if (contentType.getType().equalsIgnoreCase("text")) { contentType = getMediaTypeWithCharset(contentType, "us-ascii"); } } }
@Override protected InputPart extractPart(BodyPart bodyPart) throws IOException { InputPart currPart = super.extractPart(bodyPart); Field disposition = bodyPart.getHeader().getField( FieldName.CONTENT_DISPOSITION); if (disposition == null) throw new RuntimeException(Messages.MESSAGES.couldFindNoContentDispositionHeader()); if (disposition instanceof ContentDispositionField) { String name = ((ContentDispositionField) disposition) .getParameter("name"); List<InputPart> list = formDataMap.get(name); if (list == null) { list = new LinkedList<InputPart>(); formData.put(name, currPart); formDataMap.put(name, list); } list.add(currPart); } else { throw new RuntimeException(Messages.MESSAGES.couldNotParseContentDisposition(disposition)); } return currPart; }
public PartImpl(BodyPart bodyPart) { this.bodyPart = bodyPart; for (Field field : bodyPart.getHeader()) { headers.add(field.getName(), field.getBody()); if (field instanceof ContentTypeField) { contentType = MediaType.valueOf(field.getBody()); } } if (contentType == null) contentType = defaultPartContentType; if (getCharset(contentType) == null) { if (defaultPartCharset != null) { contentType = getMediaTypeWithDefaultCharset(contentType); } else if (contentType.getType().equalsIgnoreCase("text")) { contentType = getMediaTypeWithCharset(contentType, "us-ascii"); } } }
public PartImpl(BodyPart bodyPart) { this.bodyPart = bodyPart; for (Field field : bodyPart.getHeader()) { headers.add(field.getName(), field.getBody()); if (field instanceof ContentTypeField) { contentType = MediaType.valueOf(field.getBody()); contentTypeFromMessage = true; } } if (contentType == null) contentType = defaultPartContentType; if (getCharset(contentType) == null) { if (defaultPartCharset != null) { contentType = getMediaTypeWithDefaultCharset(contentType); } else if (contentType.getType().equalsIgnoreCase("text")) { contentType = getMediaTypeWithCharset(contentType, "us-ascii"); } } }