public void writeTo(List<Object> list, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { PartType partType = FindAnnotation.findAnnotation(annotations, PartType.class); MediaType partMediaType = MediaType.valueOf(partType.value()); MultipartOutput output = new MultipartOutput(); for (Object obj : list) { output.addPart(obj, partMediaType); } write(output, mediaType, httpHeaders, entityStream); } }
protected void write(MultipartOutput multipartOutput, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { String boundary = mediaType.getParameters().get("boundary"); if (boundary == null) boundary = multipartOutput.getBoundary(); httpHeaders.putSingle(HttpHeaderNames.CONTENT_TYPE, mediaType.toString() + "; boundary=" + multipartOutput.getBoundary()); byte[] boundaryBytes = ("--" + boundary).getBytes(); writeParts(multipartOutput, entityStream, boundaryBytes); entityStream.write(boundaryBytes); entityStream.write("--".getBytes()); }
protected void writeParts(MultipartOutput multipartOutput, OutputStream entityStream, byte[] boundaryBytes) throws IOException { for (OutputPart part : multipartOutput.getParts()) { MultivaluedMap<String, Object> headers = new MultivaluedMapImpl<String, Object>(); writePart(entityStream, boundaryBytes, part, headers); } }
public OutputPart addFormData(String key, Object entity, GenericType<?> type, MediaType mediaType) { OutputPart part = super.addPart(entity, type, mediaType); formData.put(key, part); addFormDataMap(key, part); return part; }
public OutputPart addFormData(String key, Object entity, GenericType<?> type, MediaType mediaType, String filename) { OutputPart part = super.addPart(entity, type, mediaType, filename); formData.put(key, part); addFormDataMap(key, part); return part; }
public OutputPart addFormData(String key, Object entity, MediaType mediaType, String filename) { OutputPart part = super.addPart(entity, mediaType, filename); formData.put(key, part); addFormDataMap(key, part); return part; }
public void writeTo(List<Object> list, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { PartType partType = FindAnnotation.findAnnotation(annotations, PartType.class); MediaType partMediaType = MediaType.valueOf(partType.value()); MultipartOutput output = new MultipartOutput(); for (Object obj : list) { output.addPart(obj, partMediaType); } write(output, mediaType, httpHeaders, entityStream); } }
protected void write(MultipartOutput multipartOutput, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { String boundary = mediaType.getParameters().get("boundary"); if (boundary == null) boundary = multipartOutput.getBoundary(); httpHeaders.putSingle(HttpHeaderNames.CONTENT_TYPE, mediaType.toString() + "; boundary=" + multipartOutput.getBoundary()); byte[] boundaryBytes = ("--" + boundary).getBytes(); writeParts(multipartOutput, entityStream, boundaryBytes); entityStream.write(boundaryBytes); entityStream.write("--".getBytes()); }
protected void writeParts(MultipartOutput multipartOutput, OutputStream entityStream, byte[] boundaryBytes) throws IOException { for (OutputPart part : multipartOutput.getParts()) { MultivaluedMap<String, Object> headers = new MultivaluedMapImpl<String, Object>(); writePart(entityStream, boundaryBytes, part, headers); } }
public OutputPart addFormData(String key, Object entity, Class<?> type, Type genericType, MediaType mediaType) { OutputPart part = super.addPart(entity, type, genericType, mediaType); formData.put(key, part); addFormDataMap(key, part); return part; }
public OutputPart addFormData(String key, Object entity, Class<?> type, Type genericType, MediaType mediaType, String filename) { OutputPart part = super.addPart(entity, type, genericType, mediaType, filename); formData.put(key, part); addFormDataMap(key, part); return part; }
public OutputPart addFormData(String key, Object entity, MediaType mediaType) { OutputPart part = super.addPart(entity, mediaType); formData.put(key, part); addFormDataMap(key, part); return part; }
/** * Used to add parts to the multipart output message. * * @param entity * the object representing the part's body * @param mediaType * the Content-Type of the part * @param contentId * the Content-ID to be used as identification for the current * part, optional, if null one will be generated * @param contentTransferEncoding * The value to be used for the Content-Transfer-Encoding header * field of the part. It's optional, if you don't want to set * this pass null. Example values are: "7bit", * "quoted-printable", "base64", "8bit", "binary" * @return {@link OutputPart} */ public OutputPart addPart(Object entity, MediaType mediaType, String contentId, String contentTransferEncoding) { OutputPart outputPart = super.addPart(entity, mediaType); if (contentTransferEncoding != null) outputPart.getHeaders().putSingle("Content-Transfer-Encoding", contentTransferEncoding); if (contentId != null) outputPart.getHeaders().putSingle("Content-ID", contentId); return outputPart; }
public OutputPart addFormData(String key, Object entity, Class<?> type, Type genericType, MediaType mediaType, String filename) { OutputPart part = super.addPart(entity, type, genericType, mediaType, filename); formData.put(key, part); addFormDataMap(key, part); return part; }
public OutputPart addFormData(String key, Object entity, MediaType mediaType) { OutputPart part = super.addPart(entity, mediaType); formData.put(key, part); addFormDataMap(key, part); return part; }
public OutputPart addFormData(String key, Object entity, MediaType mediaType, String filename) { OutputPart part = super.addPart(entity, mediaType, filename); formData.put(key, part); addFormDataMap(key, part); return part; }
public OutputPart addFormData(String key, Object entity, GenericType<?> type, MediaType mediaType) { OutputPart part = super.addPart(entity, type, mediaType); formData.put(key, part); addFormDataMap(key, part); return part; }
public OutputPart addFormData(String key, Object entity, GenericType<?> type, MediaType mediaType, String filename) { OutputPart part = super.addPart(entity, type, mediaType, filename); formData.put(key, part); addFormDataMap(key, part); return part; }
public OutputPart addFormData(String key, Object entity, Class<?> type, Type genericType, MediaType mediaType) { OutputPart part = super.addPart(entity, type, genericType, mediaType); formData.put(key, part); addFormDataMap(key, part); return part; }
/** * Used to add parts to the multipart output message. * * @param entity * the object representing the part's body * @param mediaType * the Content-Type of the part * @param contentId * the Content-ID to be used as identification for the current * part, optional, if null one will be generated * @param contentTransferEncoding * The value to be used for the Content-Transfer-Encoding header * field of the part. It's optional, if you don't want to set * this pass null. Example values are: "7bit", * "quoted-printable", "base64", "8bit", "binary" * @return {@link OutputPart} */ public OutputPart addPart(Object entity, MediaType mediaType, String contentId, String contentTransferEncoding) { OutputPart outputPart = super.addPart(entity, mediaType); if (contentTransferEncoding != null) outputPart.getHeaders().putSingle("Content-Transfer-Encoding", contentTransferEncoding); if (contentId != null) outputPart.getHeaders().putSingle("Content-ID", contentId); return outputPart; }