Tabnine Logo
OutputStreamBuilder.build
Code IndexAdd Tabnine to your IDE (free)

How to use
build
method
in
org.apache.camel.converter.stream.OutputStreamBuilder

Best Java code snippets using org.apache.camel.converter.stream.OutputStreamBuilder.build (Showing top 8 results out of 315)

origin: org.apache.camel/camel-zipfile

@Override
public Object unmarshal(final Exchange exchange, final InputStream inputStream) throws Exception {
  if (usingIterator) {
    ZipIterator zipIterator = new ZipIterator(exchange, inputStream);
    zipIterator.setAllowEmptyDirectory(allowEmptyDirectory);
    return zipIterator;
  } else {
    ZipInputStream zis = new ZipInputStream(inputStream);
    OutputStreamBuilder osb = OutputStreamBuilder.withExchange(exchange);
    try {
      ZipEntry entry = zis.getNextEntry();
      if (entry != null) {
        exchange.getOut().setHeader(FILE_NAME, entry.getName());
        IOHelper.copy(zis, osb);
      }
      entry = zis.getNextEntry();
      if (entry != null) {
        throw new IllegalStateException("Zip file has more than 1 entry.");
      }
      return osb.build();
    } finally {
      IOHelper.close(zis, osb);
    }
  }
}
origin: org.apache.camel/camel-dropbox

  private Map.Entry<String, Object> downloadSingleFile(String path) throws DropboxException {
    try {
      OutputStreamBuilder target = OutputStreamBuilder.withExchange(exchange);
      DbxDownloader<FileMetadata> downloadedFile = client.files().download(path);
      if (downloadedFile != null) {
        downloadedFile.download(target);
        LOG.debug("downloaded path={}", path);
        return new AbstractMap.SimpleEntry<>(path, target.build());
      } else {
        return null;
      }
    } catch (DbxException e) {
      throw new DropboxException(path + " does not exist or cannot obtain metadata", e);
    } catch (IOException e) {
      throw new DropboxException(path + " cannot obtain a stream", e);
    }
  }
}
origin: org.apache.camel/camel-crypto-cms

private Object transformToStreamCacheOrByteArray(Exchange exchange, InputStream is) throws CryptoCmsException {
  // the input stream must be completely read, outherwise you will get
  // errors when your use as next component the file adapter.
  OutputStreamBuilder output = OutputStreamBuilder.withExchange(exchange);
  try {
    // data can be null in the case of explicit Signed Data
    if (is != null) {
      try {
        IOHelper.copy(is, output);
      } finally {
        IOHelper.close(is);
      }
    }
    LOG.debug("CMS Enveloped Data decryption successful");
    return output.build();
  } catch (IOException e) {
    throw new CryptoCmsException("Error during reading the unencrypted content of the enveloped data object", e);
  } finally {
    IOHelper.close(output);
  }
}
origin: org.apache.camel/camel-tarfile

@Override
public Object unmarshal(final Exchange exchange, final InputStream stream) throws Exception {
  if (usingIterator) {
    TarIterator tarIterator = new TarIterator(exchange, stream);
    tarIterator.setAllowEmptyDirectory(allowEmptyDirectory);
    return tarIterator;
  } else {
    BufferedInputStream bis = new BufferedInputStream(stream);
    TarArchiveInputStream tis = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, bis);
    OutputStreamBuilder osb = OutputStreamBuilder.withExchange(exchange);
    try {
      TarArchiveEntry entry = tis.getNextTarEntry();
      if (entry != null) {
        exchange.getOut().setHeader(FILE_NAME, entry.getName());
        IOHelper.copy(tis, osb);
      }
      entry = tis.getNextTarEntry();
      if (entry != null) {
        throw new IllegalStateException("Tar file has more than 1 entry.");
      }
      return osb.build();
    } finally {
      IOHelper.close(osb, tis, bis);
    }
  }
}
origin: org.apache.camel/camel-crypto-cms

@Override
public void process(Exchange exchange) throws Exception { // NOPMD all
  // exceptions must be caught to react on exception case and re-thrown,
  // see code below
  OutputStreamBuilder output = OutputStreamBuilder.withExchange(exchange);
  OutputStream outStream;
  if (config.getToBase64()) {
    outStream = new Base64OutputStream(output);
  } else {
    outStream = output;
  }
  InputStream body = exchange.getIn().getMandatoryBody(InputStream.class);
  // lets setup the out message before we invoke the processing
  // so that it can mutate it if necessary
  Message out = exchange.getOut();
  out.copyFrom(exchange.getIn());
  try {
    try {
      marshalInternal(body, outStream, exchange);
    } finally {
      IOHelper.close(outStream); // base64 stream must be closed,
                    // before we fetch the bytes
    }
    setBodyAndHeader(out, output.build());
  } catch (Throwable e) {
    // remove OUT message, as an exception occurred
    exchange.setOut(null);
    throw e;
  }
}
origin: org.apache.camel/camel-crypto-cms

@Override
protected Object unmarshalInternal(InputStream is, Exchange exchange) throws Exception {
  CMSSignedDataParser sp;
  try {
    sp = new CMSSignedDataParser(new JcaDigestCalculatorProviderBuilder().setProvider(BouncyCastleProvider.PROVIDER_NAME).build(), is);
  } catch (CMSException e) {
    throw new CryptoCmsFormatException(getFormatErrorMessage(), e);
  }
  OutputStreamBuilder output = getOutputStream(sp, exchange);
  debugLog(sp);
  verify(sp, exchange);
  return output.build();
}
origin: org.apache.camel/camel-crypto

public Object unmarshal(final Exchange exchange, final InputStream encryptedStream) throws Exception {
  if (encryptedStream != null) {
    byte[] iv = getInlinedInitializationVector(exchange, encryptedStream);
    Key key = getKey(exchange);
    CipherInputStream cipherStream = null;
    OutputStreamBuilder osb = null;
    try {
      cipherStream = new CipherInputStream(encryptedStream, initializeCipher(DECRYPT_MODE, key, iv));
      osb = OutputStreamBuilder.withExchange(exchange);
      HMACAccumulator hmac = getMessageAuthenticationCode(key);
      byte[] buffer = new byte[bufferSize];
      hmac.attachStream(osb);
      int read;
      while ((read = cipherStream.read(buffer)) >= 0) {
        hmac.decryptUpdate(buffer, read);
      }
      hmac.validate();
      return osb.build();
    } finally {
      IOHelper.close(cipherStream, "cipher", LOG);
      IOHelper.close(osb, "plaintext", LOG);
    }
  }
  return null;
}
origin: org.apache.camel/camel-crypto

return osb.build();
org.apache.camel.converter.streamOutputStreamBuilderbuild

Popular methods of OutputStreamBuilder

  • withExchange
  • flush
  • write

Popular in Java

  • Making http post requests using okhttp
  • startActivity (Activity)
  • findViewById (Activity)
  • setScale (BigDecimal)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Runner (org.openjdk.jmh.runner)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now