public void downloadBAMTool(String toolName, HttpServletResponse response)
     throws BAMToolboxDepolyerServiceBAMToolboxDeploymentExceptionException {
   try {
     ServletOutputStream out = response.getOutputStream();
     DataHandler downloadData = stub.downloadToolBox(toolName);
     if (downloadData != null) {
       String fileName = "";
       if (!toolName.endsWith(".tbox")) {
         fileName = toolName + ".tbox";
       } else fileName = toolName;
       response.setHeader("Content-Disposition", "fileName=" + fileName);
       response.setContentType(downloadData.getContentType());
       InputStream in = downloadData.getDataSource().getInputStream();
       int nextChar;
       while ((nextChar = in.read()) != -1) {
         out.write((char) nextChar);
       }
       out.flush();
       in.close();
     } else {
       out.write("The requested service archive was not found on the server".getBytes());
     }
   } catch (RemoteException e) {
     log.error(e.getMessage(), e);
     throw new BAMToolboxDepolyerServiceBAMToolboxDeploymentExceptionException(e);
   } catch (IOException e) {
     log.error(e.getMessage(), e);
     throw new BAMToolboxDepolyerServiceBAMToolboxDeploymentExceptionException(e);
   }
 }
Exemplo n.º 2
0
  /**
   * Parses the MimePart to create a DataSource.
   *
   * @param parent the parent multi-part
   * @param part the current part to be processed
   * @return the DataSource
   * @throws MessagingException creating the DataSource failed
   * @throws IOException creating the DataSource failed
   */
  protected DataSource createDataSource(final Multipart parent, final MimePart part)
      throws MessagingException, IOException {
    final DataHandler dataHandler = part.getDataHandler();
    final DataSource dataSource = dataHandler.getDataSource();
    final String contentType = getBaseMimeType(dataSource.getContentType());
    final byte[] content = this.getContent(dataSource.getInputStream());
    final ByteArrayDataSource result = new ByteArrayDataSource(content, contentType);
    final String dataSourceName = getDataSourceName(part, dataSource);

    result.setName(dataSourceName);
    return result;
  }
Exemplo n.º 3
0
 public java.io.InputStream getInputStream() throws OMException {
   if (isBinary) {
     if (dataHandlerObject == null) {
       getDataHandler();
     }
     InputStream inStream;
     javax.activation.DataHandler dataHandler = (javax.activation.DataHandler) dataHandlerObject;
     try {
       inStream = dataHandler.getDataSource().getInputStream();
     } catch (IOException e) {
       throw new OMException("Cannot get InputStream from DataHandler.", e);
     }
     return inStream;
   } else {
     throw new OMException("Unsupported Operation");
   }
 }
Exemplo n.º 4
0
 public DataSourceSource(DataHandler dh) throws MimeTypeParseException {
   this(dh.getDataSource());
 }