Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

Requirements for custom stream processing in File data sets

Updated on March 11, 2021

Standard File data sets support reading or writing compressed .zip and .gzip files. To extend these capabilities to support encryption, decryption, and other compression methods for files in repositories, implement custom stream processing as Java classes on the Pega Platform server classpath.

To implement custom stream processing, ensure that:

  • The input stream processing class implements java.util.function.Function<InputStream, InputStream>.
  • The output stream processing class implements java.util.function.Function<OutputStream, OutputStream>.
  • The classes are present on the Pega Platform server classpath on every node that uses the data set, for example, by importing the .jar file to pega-enginecode codeset. The codeset version must be the same as the release version.
  • For custom stream processing with ZIP compression, the java.util.function.Function<OutputStream, OutputStream> function does not replace the original stream.
  • The classes are public.
  • The classes expose a public constructor with no arguments.
  • You restart the application server after importing the new classes.
For example: See the following code for a sample custom stream processing implementation (output and input streams):
public class OutputStreamShiftingProcessing implements Function<OutputStream, OutputStream> {  
  
  
private static final int SHIFT = 2;  
  
  
 @Override  
 public OutputStream apply(OutputStream outputStream) {  
   return new ShiftingOutputStream(outputStream);  
 }  
  
  
 public static class ShiftingOutputStream extends OutputStream {  
  
  
 private final OutputStream outputStream;  
  
  
 public ShiftingOutputStream(OutputStream outputStream) {  
   this.outputStream = outputStream;  
 }  
  
  
 @Override  
 public void write(int b) throws IOException {  
   if (b != -1) {  
     outputStream.write(b + SHIFT);  
   } else {  
     outputStream.write(b);  
   }  
 }  
  
  
 @Override  
 public void close() throws IOException {  
   outputStream.close();  
 }  
 }  
}  
 public class InputStreamShiftingProcessing implements Function<InputStream, InputStream> {  
  
  
 private static final int SHIFT = 2;  
  
  
 @Override  
 public InputStream apply(InputStream inputStream) {  
   return new ShiftingInputStream(inputStream);  
 }  
  
 public static class ShiftingInputStream extends InputStream {  
  
 private final InputStream inputStream;  
  
 public ShiftingInputStream(InputStream inputStream) {  
   this.inputStream = inputStream;  
 }  
  
 @Override  
 public int read() throws IOException {  
   int read = inputStream.read();  
   if (read != -1) {  
     return read - SHIFT;  
   } else {  
     return read;  
   }  
 }  
  
  
 @Override  
 public void close() throws IOException {  
   inputStream.close();  
 }  
 }  
}  

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us