Skip to content

add the Data Service anyDocument data type #1296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ehennum opened this issue May 4, 2021 · 1 comment
Closed

add the Data Service anyDocument data type #1296

ehennum opened this issue May 4, 2021 · 1 comment

Comments

@ehennum
Copy link
Contributor

ehennum commented May 4, 2021

Document values for the anyDocument data type can have any of the four document formats (binary, JSON, text, or XML).

When calling a Data Service endpoint with a parameter having the anyDocument data type, the caller must specify the format of each document value so the Java API can set the Content Type header that communicates the format of the document value to the appserver.

Similarly, when a Data Service endpoint returns document values with the anyDocument data type, the appserver must communicate the format of the document value to the Java API. The appserver sets the Content Type header for the document value. In turn, the Java API must set the equivalent format when returning the document value to the caller.

In both cases, the Java API associates a document value with a format by wrapping the document value with a handle, which has a getter and setter for the format. In particular, the document value are represented with any subclass that implements the BufferableContentHandle interface (which includes most of the out-of-the-box handles provided by the Java API). Additional considerations:

When generating a Data Service interface using the Gradle plugin provided by the ml-development-tools, the $javaClass annotation for an anyDocument type can specify a BufferableContentHandle subclass. If no $javaClass is provided, the default is InputStreamHandle. (An invalid $javaClass annotation throws an error at the start of code generation.)

The predefined IO Data Service classes (InputCaller, OutputCaller, and InputOutputCaller) must also be able to support anyDocument for either input or output. These classes can each add a static factory that takes handles for the input and / or output similar to:

static <IC,IR,OC,OR> InputOutputCaller<BufferableContentHandle<IC,IR>,BufferableContentHandle<OC,OR>> onHandles(
        DatabaseClient client, JSONWriteHandle apiDecl,
        BufferableContentHandle<IC,IR> inputHandle, BufferableContentHandle<OC,OR> outputHandle
) {
    return new InputOutputEndpointImpl<>(client, apiDecl, new HandleProvider.DirectHandleProvider<>(inputHandle, outputHandle));
}
@ehennum
Copy link
Contributor Author

ehennum commented Jul 16, 2021

@llinggit , I've merged the refactoring into develop which also implements the changes in the generated interfaces.

I believe the remaining task is to add the new factories from the description to the Input, Output, and InputOutput callers and one unit test each with an anyDocument type.

@llinggit llinggit added fix and removed new labels Sep 20, 2021
llinggit pushed a commit to llinggit/java-client-api that referenced this issue Sep 24, 2021
llinggit pushed a commit that referenced this issue Sep 24, 2021
@llinggit llinggit assigned georgeajit and unassigned llinggit Sep 24, 2021
@llinggit llinggit added test and removed fix labels Sep 24, 2021
@georgeajit georgeajit removed the test label Oct 1, 2021
@georgeajit georgeajit added this to the java-client-api-NEXT milestone Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants