ATG 11.3 JAX-RS API – DropletInvoker
The
DropletInvoker is used to invoke droplets and returns output data for each
oparam. The droplet result gets filled up for each output of oparam using the
call back mechanism.
- Droplet Invoker object can be created using the constructor as below
DropletInvoker dropletInvoker = new DropletInvoker(“path to your droplet”);
- Adding inputs to the invoker [addInput(String pKey, Object pObject)]
dropletInvoker.addInput("pParamName1", pParamVal1);
dropletInvoker.addInput("pParamName2", pParamVal2);
dropletInvoker.addInput("pParamName3", pParamVal3);
- Adding open parameter to the invoker
- Adding output parameter to the invoker
oParamOutput.addOutput("outputObj",
" outputObj ");
- Executing the droplet
dropletInvoker.invoke();
- Getting the response from the execution
OParam oParamOutputResponse = dropletInvoker.getOParam("output");
if(oParamOutputResponse!=null){
Object responseObj
= oParamOutputResponse.getOutput("outputObj ");
…
}
Example code to invoke droplet
to get the user details based on email id.
@GET
...
public RepresentationModel
getUser(@QueryParam("email") String email,@QueryParam("token") String authtoken) throws RestException {
...
RepresentationModel.Builder
builder = null;
//Adds Input and
output parameter to RestProfileDisplayWarningsDroplet
DropletInvoker
dropletInvoker = new DropletInvoker("/com/../YourUserLookupDroplet");
dropletInvoker.addInput("token", token);
dropletInvoker.addInput("email", email);
OParam
oParamOutput = dropletInvoker.addOParam("output");
oParamOutput.addOutput("users", "users");
dropletInvoker.invoke();
OParam
oParamOutputResponse = dropletInvoker.getOParam("output");
List
usersRepItem = null;
ResponsePayload
responsePayload = getResponsePayload();
//Your
custom Response Payload
if(oParamOutputResponse!=null){
Output
users = oParamOutputResponse.getOutput("users");
usersRepItem = (List)users.getObject();
RepositoryItem
userItem = (RepositoryItem)usersRepItem.get(0);
builder =
getRepresentationModelProfileBuilder(responsePayload, userItem);
}
return builder.build();
}
API Ref doc
: http://docs.oracle.com/cd/E69533_01/Platform.11-3/apidoc/atg/service/jaxrs/DropletInvoker.html
No comments
Post a Comment