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

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

Best Java code snippets using org.apache.camel.converter.stream.OutputStreamBuilder.withExchange (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

protected OutputStreamBuilder getOutputStream(CMSSignedDataParser sp, Exchange exchange) throws Exception {
  // get the InputStream with the plain data
  InputStream data;
  try {
    data = sp.getSignedContent().getContentStream();
  } catch (NullPointerException e) { // nullpointer exception is
                    // thrown when the signed content
                    // is missing
    throw getContentMissingException(e);
  }
  // the input stream must be completely read, otherwise the signer
  // info is not available!
  OutputStreamBuilder osb = OutputStreamBuilder.withExchange(exchange);
  try {
    // data can be null in the case of explicit Signed Data
    if (data != null) {
      try {
        IOHelper.copy(data, osb);
      } finally {
        IOHelper.close(data);
      }
    }
  } catch (IOException e) {
    throw new CryptoCmsException("Error during reading the signed content of the signed data object", e);
  }
  return osb;
}
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

osb = OutputStreamBuilder.withExchange(exchange);
org.apache.camel.converter.streamOutputStreamBuilderwithExchange

Popular methods of OutputStreamBuilder

  • build
  • flush
  • write

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (ScheduledExecutorService)
  • compareTo (BigDecimal)
  • getExternalFilesDir (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top PhpStorm 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