/*
 * Copyright 2015 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.idolutils.processors;

import com.autonomy.aci.client.services.Processor;
import com.autonomy.aci.client.services.ProcessorException;
import com.autonomy.aci.client.transport.AciResponseInputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;

public class CopyResponseProcessor implements Processor<Boolean> {

    private static final long serialVersionUID = 8869650394998971739L;

    private final transient OutputStream outputStream;

    public CopyResponseProcessor(final OutputStream outputStream) {
        this.outputStream = outputStream;
    }

    @Override
    public Boolean process(final AciResponseInputStream aciResponse) {
        try {
            IOUtils.copy(aciResponse, outputStream);

            outputStream.flush();

            return true;
        }
        catch(final IOException e) {
            throw new ProcessorException(e);
        }
    }
}

@@ -496,16 +496,148 @@
 Utils;%0A%0A
+/**%0A * Processor which copies the entire response stream into the given %7B@link OutputStream%7D before flushing the output stream.%0A */%0A
 public c
@@ -832,120 +832,553 @@
     
-public CopyResponseProcessor(final OutputStream outputStream) %7B%0A        this.outputStream = outputStream;%0A    %7D%0A
+/**%0A     * Creates a new CopyResponseProcessor which writes to the given OutputStream.%0A     * @param outputStream The OutputStream to write to%0A     */%0A    public CopyResponseProcessor(final OutputStream outputStream) %7B%0A        this.outputStream = outputStream;%0A    %7D%0A%0A    /**%0A     * Copies the given AciResponseInputStream into the OutputStream.%0A     * @param aciResponse The AciResponseInputStream to read%0A     * @return true If the method completes successfully%0A     * @throws ProcessorException If an IOException is thrown internally.%0A     */
 %0A   

Add Javadoc