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);
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");
Related
org.eclipse.egit.github.core.client.RequestException: Invalid request. "base", "head" weren't supplied. (422)
Source code
pullRequestService = new PullRequestService(gitHubClient);
PullRequest request=new PullRequest();
request.setTitle("a fix");
request.setBody("this is a fix");
request.setHead(new PullRequestMarker().setRef("testBranch"));
request.setBase(new PullRequestMarker().setRef("master"));
pullRequestService.createPullRequest(repo,request);
testBranch Branch is created in my repo.
not able to create pull request through java api
I am not an expert of github api, but by checking the code, I suspect you should call setLabel() instead of setRef(), as the PullRequestService works with the label value as base and head:
String base = baseMarker.getLabel();
if (base != null)
params.put(PR_BASE, base);
Repo
I encoutered same error when tried creating pull request using egit.github.core api. Finally below code worked for me.
PullRequestService pullRequestService = new PullRequestService(client);
pullRequestService.getClient().setCredentials("<userid>", "<password>");
RepositoryId repo = RepositoryId.createFromId("<owenerName>" + "/" + "repoName");
PullRequest request = new PullRequest();
request.setTitle("Please merge");
request.setBody("Please merge");
request.setHead(new PullRequestMarker().setRef("<branchName>").setLabel("< branchName >"));
request.setBase(new PullRequestMarker().setRef("master").setLabel("master"));
pullRequestService.createPullRequest(repo,request);
Just make sure branch exists and has commit pushed to it.
I am trying to call the API QtocRtvTCPA in /QSYS.LIB/QTOCNETSTS.SRVPGM in v7r3 via jtOpen/jt400. parameter[3] is defined as ErrorCode in the API
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/apis/qtocrtvtcpa.htm
Every attempt I have made to call the service program has resulted in the error at the bottom. I have tried all the items that are commented out below. I could use some help in determining how to pass the error code parameter.
private byte[] receiverVariable = new byte[1000];
parameters[0].setOutputDataLength(receiverVariable.length);
parameters[1].setInputData(bin4.toBytes(receiverVariable.length));
parameters[2].setInputData(new AS400Text(8).toBytes("TCPA0200"));
//parameters[3] = new ErrorCodeParameter();
//parameters[3] = new ProgramParameter(BinaryConverter.intToByteArray(0));
//parameters[3] = new ProgramParameter(new AS400Text(8).toBytes("ERRC0100"), 0);
//parameters[3] = new ProgramParameter(new AS400Text(8).toBytes("ERRC0200"), 0);
//parameters[3] = new ProgramParameter(0);
ServiceProgramCall sPGMCall = new ServiceProgramCall(as400);
sPGMCall.setProgram("/QSYS.LIB/QTOCNETSTS.SRVPGM", parameters);
sPGMCall.setProcedureName("QtocRtvTCPA");
sPGMCall.setReturnValueFormat(ServiceProgramCall.NO_RETURN_VALUE);
Error code parameter not valid.
CPF3CF1
AS400Message (ID: CPF3CF1 text: Error code parameter not valid.):com.ibm.as400.access.AS400Message#1536d79
Cause . . . . . : The format of the error code parameter is not correct. Recovery . . . : Correct the error code parameter and try the request again. If you do not know the correct format for the error code parameter, see the APIs topic collection in the Programming category in the IBM i Information Center, http://www.ibm.com/systems/i/infocenter/.
The solution
parameters[3].setInputData(bin4.toBytes(0));
parameters[0].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
parameters[1].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
parameters[2].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
parameters[3].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
We are trying to automate the project migration from one Rally workspace to other. Everything seems to work fine like we are able to migrate project and related releases/iterations/userstories/tasks from one workspace to another workspace.
But while trying to migrate BE Initiative/BE Feature/CPM Feature we are getting some exception related to Null Pointer exception but the error we are getting in Response doesn't seem to give much info.
A sample of code is -
String oldProjectObjectId = "12345";
String newProjectObjectId = "67890";
String oldRallyWorkspaceObjectId = "32145";
String newRallyWorkspaceObjectId = "67894";
QueryResponse beInitiativeResponse = queryRally("portfolioitem/beinitiative", "/project/"+this.oldProjectObjectId, "/workspace/"+this.oldRallyWorkspaceObjectId);
int beInitiativeCount = beInitiativeResponse.getTotalResultCount();
if(beInitiativeCount >0){
JsonArray initiativeArray = beInitiativeResponse.getResults();
for(int i=0; i< initiativeArray.size();i++){
JsonObject beInitiativeObject = initiativeArray.get(i).getAsJsonObject();
String oldBeInitiativeObjectId = beInitiativeObject.get("ObjectID").getAsString();
String oldBeInitiativeName = beInitiativeObject.get("_refObjectName").getAsString();
String owner = getObjectId(beInitiativeObject, "Owner");
JsonObject BeInitiativeCreateObject = getJsonObject(oldBeInitiativeName, "/project/"+this.newProjectObjectId, "/workspace/"+this.newRallyWorkspaceObjectId, owner);
CreateResponse beInitiativeCreateResponse = createInRally("portfolioitem/beinitiative", BeInitiativeCreateObject);
if(beInitiativeCreateResponse.wasSuccessful()){
String newBeInitiativeObjectId = beInitiativeCreateResponse.getObject().get("ObjectID").getAsString();
String mapKey = oldBeInitiativeObjectId;
String mapValue= newBeInitiativeObjectId;
this.beInitiativesHashMap.put(mapKey, mapValue);
}
else{
String[] errorList;
errorList = beInitiativeCreateResponse.getErrors();
for (int j = 0; j < errorList.length; j++) {
System.out.println(errorList[j]);
}
}
}
}
queryRally and createInRally functions use Rally rest client to fetch and create the required projects and associated attributes like releases, iterations etc.
After executing CreateResponse beInitiativeCreateResponse = createInRally("portfolioitem/beinitiative", BeInitiativeCreateObject); when it's trying to execute if(beInitiativeCreateResponse.wasSuccessful()) it is instead going to else block and thus printing the below mentioned error.
An unexpected error has occurred.We have recorded this error and will begin to investigate it. In the meantime, if you would like to speak with our Support Team, please reference the information below:java.lang.NullPointerException2017-12-05 11:01 AM PST America/Los_Angeles
But the important point that is when trying to migrate projects and it's related attributes like release/iterations etc. withing same Rally workspace the above piece of code works just fine.
Update1:
While analysing the issue I made the following observations -
The workspace in which I am trying to create the BeInitiative doesn't have BEinitiative, Be Feature, CPM Feature options in Portfolio items dropdown. Rather it has Theme, Initiative and Feature options in it.
Therefore, I think I was getting the previouly mentioned error. Now I made the following changes to the code.
CreateResponse beInitiativeCreateResponse = createInRally("portfolioitem/theme", themeCreateObject);
So now instead of creating the BEInitiative I am trying to create the theme only in new workspace but getting the following error -
Requested type name \"/portfolioitem/theme\" is unknown.
The object that i am passing to CreateResponse function is -
{"Name":"xyz","Project":"/project/1804","Workspace":"/workspace/139"}
Also code for createInRally function is as mentioned below -
public CreateResponse createInRally( String query, JsonObject object) throws IOException{
CreateRequest createRequest = new CreateRequest(query, object);
CreateResponse createResponse = restApi.create(createRequest);
return createResponse;
}
The Unknown Type error was occurring as a result of not passing the workspace's object id in which we were trying to create the portfolio item.
So after modifying the createInRally function to include the workspace object id we were able to create the initiative portfolio item.
The modified createInRally function is as shown below-
CreateRequest createRequest = new CreateRequest(query, object);
createRequest.addParam("workspace", "/workspace/1333333333");
CreateResponse createResponse = restApi.create(createRequest);
return createResponse;
So this is definitely an error in the web services api. You should never get 500 responses with an unhandled nullpointer. My initial guess is that when you're creating your new object some field on it is still referencing an object in the old workspace, and when we try to correctly hook up all the associations it fails to read one of those objects in the new workspace. Can you provide some more information about what your actual object you're sending to create looks like? Specifically what object relationships are you including (that may not be valid in the new workspace)?
I have been assigned to clean up a project for a client that uses BIRT reporting. I have fixed most of the issues but I still have one report that is not working and is returning an error. The error is:
Row (id = 1467):
+ There are errors evaluating script "var fileName = row["Attached_File"];
params["HyperlinkParameter"].value = ImageDecoder.decodeDocs(row["Ecrash_Attach"],fileName);":
Wrapped java.lang.NullPointerException (/report/body/table[#id="61"]/detail/row[#id="70"]/cell[#id="71"]/grid[#id="1460"]/row[#id="1462"]/cell[#id="1463"]/table[#id="1464"]/detail/row[#id="1467"]/method[#name="onCreate"]#2)
I can post the full stack trace if someone wants it but for now I will omit it since it is very long.
Here is the source of the decodeDocs method:
public static String decodeDocs(byte[] source, String fileName) {
String randName = "";
byte[] docSource = null;
if ( Base64.isArrayByteBase64(source) ){
docSource = Base64.decodeBase64(source);
}
documentZipPath = writeByteStreamToFile(source);
randName = writeByteStreamToFile(docSource, fileName);
return randName;
}
I am pretty well lost on this one. The error looks to be telling me there is an error on line two of the script which is:
var fileName = row["Attached_File"];
params["HyperlinkParameter"].value = ImageDecoder.decodeDocs(row["Ecrash_Attach"],fileName);
This is written in the OnCreate method of the report. Any help, even clues would be greatly appreciated. If you would like to see the report just ask and I will post the xml for it.
A common mistake I make in BIRT is to access the value of a null report parameter.
In your case, could params["HyperlinkParameter"] be null?
My Problem: I write an automated system that needs to read .doc and .odt, performs some operation on it and exports it to pdf again.
Currently that works fine for everything I need, I could solve all problems until this one:
If a user provides a Document that had recorded changes (Redlines) I need to automatically accept all that changes or hide them.
I could solve that one with the code below as long as the OOo is showing on screen. When I launch it hidden, my calls do nothing at all.
So, here is what I do currently:
// DO NOT try to cast this to Desktop as com.sun.star.frame.Desktop is NOT a valid class!
// keep it as Object and cast it to XDesktop later (via queryInterface)
Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
XMultiServiceFactory xFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(
XMultiServiceFactory.class, xMCF);
// what goes for desktop above is valid for DispatchHelper as well.
Object dispatchHelper = xFactory.createInstance("com.sun.star.frame.DispatchHelper");
// the DispatchHelper is the class that handles the interaction with dialogs.
XDispatchHelper helper = (XDispatchHelper) UnoRuntime.queryInterface(
XDispatchHelper.class, dispatchHelper);
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, desktop);
XFrame xFrame = xDesktop.getCurrentFrame();
XDispatchProvider xDispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, xFrame);
// We issute the Track Changes Dialog (Bearbeiten - Ă„nderungen // Edit - Changes) and tell it
// to ACCEPT all changes.
PropertyValue[] acceptChanges = new PropertyValue[1];
acceptChanges[0] = new PropertyValue();
acceptChanges[0].Name = "AcceptTrackedChanges";
acceptChanges[0].Value = Boolean.TRUE;
helper.executeDispatch(xDispatchProvider, ".uno:AcceptTrackedChanges", "", 0, acceptChanges);
// We issue it again to tell it to stop showing changes.
PropertyValue[] showChanges = new PropertyValue[1];
showChanges[0] = new PropertyValue();
showChanges[0].Name = "ShowTrackedChanges";
showChanges[0].Value = Boolean.FALSE;
helper.executeDispatch(xDispatchProvider, ".uno:ShowTrackedChanges", "", 0, showChanges);
My current guess is that I cannot call this because being hidden, I have no Frame to call any dispatcher to. But I could not find a way to get the Dispatcher for the Component.
I already tried to dispatch TrackChanges as well (to FALSE) but that didn't do it either.
After spending two days understanding the OOo API, I realized that the document isn't loaded in the frontend which is why this approach fails. However, you can modify the document's property directly:
XPropertySet docProperties = UnoRuntime.queryInterface(XPropertySet.class, document);
docProperties.setPropertyValue("RedlineDisplayType", RedlineDisplayType.NONE);
The property name "RedlineDisplayType" can be found in the RedlinePortion documentation