Request parameters not recognised by DropletInvoker.invokeDroplet

542 views Asked by At

I'm trying to invoke RQLQueryForEach droplet from using DUST's DropletInvoker by using below code.

HeadPipelineServlet dynamoHandler = (HeadPipelineServlet) Nucleus.getGlobalNucleus().resolveName("/atg/dynamo/servlet/dafpipeline/DynamoHandler");
DynamoHttpServletRequest request = dynamoHandler.getRequest(null); 

ByteBuffer buffer = ByteBuffer.allocate(1024);
TestingDynamoHttpServletRequest wrappedRequest = new TestingDynamoHttpServletRequest(request, buffer);
TestingDynamoHttpServletResponse wrappedResponce = new TestingDynamoHttpServletResponse(request.getResponse());

DynamoServlet droplet = (DynamoServlet) wrappedRequest.resolveName("/atg/dynamo/droplet/RQLQueryForEach");

wrappedRequest.setParameter("repository", "/atg/userprofiling/ProfileAdapterRepository");
wrappedRequest.setParameter("itemDescriptor", "user");
wrappedRequest.setParameter("transactionManager", "/atg/dynamo/transaction/TransactionManager");
wrappedRequest.setParameter("queryRQL", "ALL");

DropletInvoker mDropletInvoker = new DropletInvoker(Nucleus.getGlobalNucleus());
DropletResult result = mDropletInvoker.invokeDroplet(droplet, null, wrappedRequest, wrappedResponce);

assertNotNull("Check that output got rendered",result.getRenderedOutputParameter("output"));

invokeDroplet method is failing with exception "javax.servlet.ServletException: required parameter 'repository' not passed to droplet." Can any one point me in the right direction, what is that I'm doing incorrectly?

Here is the full stack trace...

javax.servlet.ServletException: required parameter 'repository' not passed to droplet
    at atg.repository.servlet.RQLQueryForEach.getRangeResults(RQLQueryForEach.java:254)
    at atg.repository.servlet.RQLQueryForEach.getResults(RQLQueryForEach.java:220)
    at atg.repository.servlet.RQLQueryForEach.service(RQLQueryForEach.java:179)
    at atg.servlet.DynamoServlet.service(DynamoServlet.java:152)

I could solve the problem using additional parameters. However the i still couldn't figure out why my original code isn't working.

Workaround I found

HeadPipelineServlet dynamoHandler = (HeadPipelineServlet) Nucleus.getGlobalNucleus().resolveName("/atg/dynamo/servlet/dafpipeline/DynamoHandler");
Map<String,Object> additionalParams = new HashMap<>();
additionalParams.put("repository", "/atg/userprofiling/ProfileAdapterRepository");
additionalParams.put("itemDescriptor", "user");
additionalParams.put("queryRQL", "ALL");
DropletInvoker mDropletInvoker = new DropletInvoker(Nucleus.getGlobalNucleus());
DropletResult result = mDropletInvoker.invokeDroplet("/atg/dynamo/droplet/RQLQueryForEach",additionalParams); 
1

There are 1 answers

3
boyintello On

Are you building your dust code properly? The error only suggests that the input parameter repository is not sent in the request.

Was there a point when the below line was not in your code. If you have added it, probably your changes have not been built. Could you clean your project and try again. Other than this I don't see any thing wrong with your code. Also if you are using eclipse, probably your Build Automatically under Projects menu is not checked.

wrappedRequest.setParameter("repository", "/atg/userprofiling/ProfileAdapterRepository");