List of usage examples for javax.activation DataHandler getInputStream
public InputStream getInputStream() throws IOException
From source file:de.kp.ames.web.function.comm.CommDQM.java
/** * Get either single chat message or all registered * products//from ww w.ja v a 2 s. c om * * @param item * @return * @throws Exception */ public JSONArray getChatMessages(String item) throws Exception { if (item == null) { /* * Determine chat messages (metadata) */ List<RegistryObjectImpl> messages = getRegistryObjects_ByClasNode(item, ClassificationConstants.FNC_ID_Chat); /* * Build JSON representation */ return JsonBusinessProvider.getChatMessages(jaxrHandle, messages); } else { /* * Determine content of chat message */ ExtrinsicObjectImpl eo = (ExtrinsicObjectImpl) getRegistryObjectById(item); if (eo == null) throw new JAXRException("[CommDQM] RegistryObject with id <" + item + "> not found."); DataHandler handler = eo.getRepositoryItem(); InputStream stream = handler.getInputStream(); byte[] bytes = FileUtil.getByteArrayFromInputStream(stream); JSONObject jChatMessage = new JSONObject(new String(bytes)); return new JSONArray().put(jChatMessage); } }
From source file:de.kp.ames.web.function.comm.CommDQM.java
/** * Get either single mail message or all registered * products// ww w.java2 s.c o m * * @param item * @return * @throws Exception */ public JSONArray getMailMessages(String item) throws Exception { if (item == null) { /* * Determine mail messages (metadata) */ List<RegistryObjectImpl> messages = getRegistryObjects_ByClasNode(item, ClassificationConstants.FNC_ID_Mail); /* * Build JSON representation */ return JsonBusinessProvider.getMailMessages(jaxrHandle, messages); } else { /* * Determine content of mail message */ ExtrinsicObjectImpl eo = (ExtrinsicObjectImpl) getRegistryObjectById(item); if (eo == null) throw new JAXRException("[CommDQM] RegistryObject with id <" + item + "> not found."); DataHandler handler = eo.getRepositoryItem(); InputStream stream = handler.getInputStream(); byte[] bytes = FileUtil.getByteArrayFromInputStream(stream); JSONObject jMailMessage = new JSONObject(new String(bytes)); return new JSONArray().put(jMailMessage); } }
From source file:org.mule.module.http.functional.requester.HttpRequestInboundAttachmentsTestCase.java
private void assertAttachment(MuleMessage message, String attachmentName, String attachmentContents, String contentType) throws IOException { assertTrue(message.getInboundAttachmentNames().contains(attachmentName)); DataHandler handler = message.getInboundAttachment(attachmentName); assertThat(handler.getContentType(), equalTo(contentType)); assertThat(IOUtils.toString(handler.getInputStream()), equalTo(attachmentContents)); }
From source file:org.wso2.am.admin.clients.tasks.TaskAdminClient.java
public void addTask(DataHandler dh) throws TaskManagementException, IOException, XMLStreamException { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); //create the builder StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement scheduleTaskElem = builder.getDocumentElement(); // scheduleTaskElem.setText("test"); taskAdminStub.addTaskDescription(scheduleTaskElem); }
From source file:com.vangent.hieos.xutil.soap.Mtom.java
public void decode(OMElement document) throws XdsIOException, IOException { this.document = document; OMText binaryNode = (OMText) document.getFirstOMChild(); //System.out.println("isOptimized: " + binaryNode.isOptimized()); xop = binaryNode.isOptimized();//from ww w. j a v a 2 s.c om if (xop) { javax.activation.DataHandler datahandler = (javax.activation.DataHandler) binaryNode.getDataHandler(); InputStream is = null; try { is = datahandler.getInputStream(); contents = Io.getBytesFromInputStream(is); } catch (IOException e) { throw new XdsIOException("Error accessing XOP encoded document content from message"); } this.content_type = datahandler.getContentType(); } else { String base64 = binaryNode.getText(); contents = Base64.decodeBase64(base64.getBytes()); /* BHT: REMOVED (and replaced with above line). BASE64Decoder d = new BASE6decoded.toString();4Decoder(); contents = d.decodeBuffer(base64); */ this.content_type = null; } }
From source file:org.wso2.esb.integration.common.clients.prioroty.executor.PriorityMediationAdminClient.java
public void addPriorityMediator(String name, DataHandler dh) throws IOException, XMLStreamException { priorityMediationAdmin = this.setPriorityExecutorStub(); XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement messageProcessorElem = builder.getDocumentElement(); priorityMediationAdmin.add(name, messageProcessorElem); }
From source file:org.openehealth.ipf.platform.camel.lbs.cxf.process.CxfPojoResourceHandler.java
private ResourceDataSource extractFromDataHandler(String subUnit, DataHandler handler, int paramIdx) throws IOException { InputStream inputStream = handler.getInputStream(); try {/* w w w. ja v a2 s. c o m*/ String contentType = handler.getContentType(); String id = RESOURCE_ID_PARAM_PREFIX + paramIdx; return resourceFactory.createResource(subUnit, contentType, null, id, inputStream); } finally { inputStream.close(); } }
From source file:mitm.application.djigzo.ws.impl.BackupWSImpl.java
@Override public void restore(BinaryDTO backup, String password) throws WebServiceCheckedException { try {//w ww . ja v a 2 s.co m if (backup == null) { throw new WebServiceCheckedException("backup is null."); } DataHandler dataHandler = backup.getDataHandler(); InputStream input = dataHandler.getInputStream(); backupMaker.restore(input, password); } catch (IOException e) { logger.error("restore failed.", e); throw new WebServiceCheckedException(ExceptionUtils.getRootCauseMessage(e)); } catch (BackupException e) { logger.error("restore failed.", e); throw new WebServiceCheckedException(ExceptionUtils.getRootCauseMessage(e)); } catch (RuntimeException e) { logger.error("restore failed.", e); throw new WebServiceCheckedException(WSExceptionUtils.getExceptionMessage(e)); } }
From source file:org.shredzone.cilla.admin.AbstractImageBean.java
/** * Creates a {@link StreamedContent} for the given {@link DataHandler}. * * @param dh/*from ww w.jav a 2 s . c o m*/ * {@link DataHandler} to stream * @return {@link StreamedContent} containing that image */ protected StreamedContent createStreamedContent(DataHandler dh) { if (dh != null) { try { return new DefaultStreamedContent(dh.getInputStream(), dh.getContentType()); } catch (IOException ex) { log.error("Exception while streaming content", ex); } } return createEmptyStreamedContent(); }
From source file:org.wso2.am.admin.clients.mediation.MessageStoreAdminClient.java
public void addMessageStore(DataHandler dh) throws IOException, XMLStreamException, org.wso2.carbon.message.store.stub.Exception { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream()); StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement messageStore = builder.getDocumentElement(); messageStoreAdminServiceStub.addMessageStore(messageStore.toString()); }