public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream, final MultipartRelatedInput xopPackage) throws IOException { try { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); InputPart rootPart = xopPackage.getRootPart(); JAXBContext jaxb = findJAXBContext(type, annotations, rootPart .getMediaType(), true); Unmarshaller unmarshaller = jaxb.createUnmarshaller(); unmarshaller .setAttachmentUnmarshaller(new XopAttachmentUnmarshaller( xopPackage)); return unmarshaller.unmarshal(new StreamSource(rootPart.getBody( InputStream.class, null))); } catch (JAXBException e) { Response response = Response.serverError().build(); throw new WebApplicationException(e, response); } }
@Override public DataHandler getAttachmentAsDataHandler(final String cid) { final InputPart inputPart = getInputPart(cid); return new DataHandler( new InputPartBackedDataSource(cid, inputPart)); }
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream, final MultipartRelatedInput xopPackage) throws IOException { try { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); InputPart rootPart = xopPackage.getRootPart(); JAXBContext jaxb = findJAXBContext(type, annotations, rootPart .getMediaType(), true); Unmarshaller unmarshaller = jaxb.createUnmarshaller(); unmarshaller .setAttachmentUnmarshaller(new XopAttachmentUnmarshaller( xopPackage)); return unmarshaller.unmarshal(new StreamSource(rootPart.getBody( InputStream.class, null))); } catch (JAXBException e) { Response response = Response.serverError().build(); throw new WebApplicationException(e, response); } }
@Override public DataHandler getAttachmentAsDataHandler(final String cid) { final InputPart inputPart = getInputPart(cid); return new DataHandler( new InputPartBackedDataSource(cid, inputPart)); }
@Override public byte[] getAttachmentAsByteArray(String cid) { InputPart inputPart = getInputPart(cid); try { return inputPart.getBody(byte[].class, null); } catch (IOException e) { throw new IllegalArgumentException(Messages.MESSAGES.exceptionWhileExtractionAttachment(cid), e); } }
@Override public byte[] getAttachmentAsByteArray(String cid) { InputPart inputPart = getInputPart(cid); try { return inputPart.getBody(byte[].class, null); } catch (IOException e) { throw new IllegalArgumentException(Messages.MESSAGES.exceptionWhileExtractionAttachment(cid), e); } }