Question

Bank of Nova Scotia
CA
Last activity: 17 Nov 2020 15:44 EST
Repository API - pyStream Property - Got InvalidJavaObjectClass Message
I am trying to build a Custom Repository with the 7.4+ Repository API. I am calling a REST services that returns a application-octet stream. With that, I have mapped the response to a property of Java Object type.
In the Response Data Transform ( of class Embed-Repository-File), I have something like the following:
.pyStream = @MyFunction(.mySourceJavaObjectProperty)
My Functions looks something like this:
byte[] byteArray = null;
try { byteArray = (byte[]) object; } catch (Exception e) { byteArray = ((String)object).getBytes(); }
java.io.InputStream is = (java.io.InputStream) (new java.io.ByteArrayInputStream(byteArray)); return is;
With the line in the Data Transform, I was getting a warning message like this in the Tracer:
(Embed-Repository-File)InvalidJavaObjectClass java.io.ByteArrayInputStream java.io.InputStream
If I use the ClipboardPage putObject Engine API method, I won't get this warning.
Is there something that I did wrong here? I have already casted the object as an InputStream in the function. Alternatively, is there a better way to create an InputStream object from a byte array?
I am on Pega 7.4.