Example usage for javax.activation DataHandler getInputStream

List of usage examples for javax.activation DataHandler getInputStream

Introduction

In this page you can find the example usage for javax.activation DataHandler getInputStream.

Prototype

public InputStream getInputStream() throws IOException 

Source Link

Document

Get the InputStream for this object.

Usage

From source file:sernet.verinice.server.vna.VnaServiceImpl.java

protected void doImport(Vna request, Response response)
        throws IOException, CommandException, SyncParameterException {
    if (request != null && request.getData() != null) {
        DataHandler handler = request.getData();
        InputStream is = handler.getInputStream();
        byte[] bytes = IOUtils.toByteArray(is);

        String message = "File recieved: " + request.getName() + ", type: " + request.getType().toString()
                + ", size: " + bytes.length + " bytes.";
        if (LOG.isInfoEnabled()) {
            LOG.info(message);/*from   w w  w. j  a  v a 2  s  .  com*/
        }
        response.getMessage().add(message);
        SyncParameter parameter = getParameterForRequest(request);
        SyncCommand command = doImport(parameter, bytes);
        createResponse(command, response);
    }
}

From source file:org.wso2.am.admin.clients.mediation.PriorityMediationAdminClient.java

public void addPriorityMediator(String name, DataHandler dh) throws IOException, XMLStreamException {
    XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream());
    StAXOMBuilder builder = new StAXOMBuilder(parser);
    OMElement messageProcessorElem = builder.getDocumentElement();
    priorityMediationAdmin.add(name, messageProcessorElem);
}

From source file:org.wso2.am.admin.clients.mediation.MessageProcessorClient.java

public void addMessageProcessor(DataHandler dh) throws IOException, XMLStreamException {
    XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(dh.getInputStream());
    StAXOMBuilder builder = new StAXOMBuilder(parser);
    OMElement messageProcessorElem = builder.getDocumentElement();
    messageProcessorAdminServiceStub.addMessageProcessor(messageProcessorElem.toString());
}

From source file:TextViewer.java

public void setCommandContext(String verb, DataHandler dh) throws IOException {

    this.verb = verb;
    this.dh = dh;

    this.setInputStream(dh.getInputStream());
}

From source file:org.wso2.carbon.registry.jira.issues.test.LogDownloadPathTraversalTestCase.java

private String downloadLogFile(String logFileName) throws LogViewerException, IOException {
    LogViewerClient logViewerClient = new LogViewerClient(backendURL, sessionCookie);
    DataHandler logFileDataHandler = logViewerClient.downloadArchivedLogFiles(logFileName, "", "");
    InputStream logFileInputStream = logFileDataHandler.getInputStream();
    return IOUtils.toString(logFileInputStream);
}

From source file:org.wso2.carbon.dataservices.core.admin.DataServiceFileUploader.java

public String uploadService(String fileName, String serviceHierarchy, DataHandler dataHandler)
        throws Exception {
    try {/*from  w w w. jav  a2  s .c  om*/
        byte[] data = this.getByteArrayFromInputStream(dataHandler.getInputStream());
        String serviceContents = new String(data);
        String serviceName = fileName;
        int index = fileName.lastIndexOf("." + this.getDataServiceFileExtension());
        if (index != -1) {
            serviceName = serviceName.substring(0, index);
        }
        this.saveDataService(serviceName, serviceHierarchy, serviceContents);
    } catch (Exception e) {
        String msg = "Error occured while uploading the service " + fileName;
        log.error(msg, e);
        throw new Exception("Failed to upload the service archive " + fileName, e);
    }

    return DBConstants.LABEL_SUCESSFULL;
}

From source file:org.apereo.portal.portlets.account.EmailPasswordResetNotificationImplTest.java

private String getBodyHtml(Multipart msg) throws Exception {
    for (int i = 0; i < msg.getCount(); i++) {
        BodyPart part = msg.getBodyPart(i);
        String type = part.getContentType();

        if ("text/plain".equals(type) || "text/html".equals(type)) {
            DataHandler handler = part.getDataHandler();
            String val = IOUtils.toString(handler.getInputStream());
            return val;
        }//from   ww  w  .  ja  v a  2 s .c  o  m
    }

    return null;
}

From source file:es.caib.sgtsic.xml.XmlManager.java

public T generateItem(DataHandler document) throws JAXBException, IOException {
    return unmarshal(document.getInputStream());
}

From source file:org.wso2.carbon.dataservices.core.admin.DataServiceFileUploader.java

public String uploadWSDL(String fileName, DataHandler dataHandler) throws Exception {
    WSDLToDataService.deployDataService(this.getAxisConfig(),
            this.getByteArrayFromInputStream(dataHandler.getInputStream()));
    return DBConstants.LABEL_SUCESSFULL;
}

From source file:de.kp.ames.web.function.domain.model.JsonChat.java

public void set(RegistryObjectImpl ro, Locale locale) throws JSONException, JAXRException {

    /*// w  w  w .ja  v  a  2  s.c om
     * Convert extrinsic object
     */
    super.set(ro, locale);

    /*
     * Convert "subject" and "from"
     */
    String from = "";
    String subject = "";

    String message = "";

    try {

        ExtrinsicObjectImpl eo = (ExtrinsicObjectImpl) ro;
        DataHandler dataHandler = eo.getRepositoryItem();

        InputStream stream = dataHandler.getInputStream();
        byte[] bytes = FileUtil.getByteArrayFromInputStream(stream);

        JSONObject jChat = new JSONObject(new String(bytes, GlobalConstants.UTF_8));

        from = jChat.getString(JaxrConstants.RIM_FROM);
        subject = jChat.getString(JaxrConstants.RIM_SUBJECT);

        message = jChat.getString(JaxrConstants.RIM_MESSAGE);

    } catch (Exception e) {
        e.printStackTrace();

    }

    put(JaxrConstants.RIM_FROM, from);
    put(JaxrConstants.RIM_SUBJECT, subject);

    put(JaxrConstants.RIM_MESSAGE, message);

    /*
     * Convert icon
     */
    put(JaxrConstants.RIM_ICON, IconConstants.CHAT);

}