gpt4 book ai didi

java - 使用 Java 中的 Rally Rest Client 创建 BE Initiative、BE Feature 和 CPM Feature

转载 作者:行者123 更新时间:2023-12-02 11:55:01 25 4
gpt4 key购买 nike

我们正在尝试自动将项目从一个 Rally 工作区迁移到另一个工作区。一切似乎都工作正常,就像我们能够将项目和相关版本/迭代/用户故事/任务从一个工作区迁移到另一个工作区一样。但是,在尝试迁移 BE Initiative/BE 功能/CPM 功能时,我们收到了一些与空指针异常相关的异常,但我们在响应中收到的错误似乎没有提供太多信息。

代码示例是 -

    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 和 createInRally 函数使用 Rally Rest 客户端来获取和创建所需的项目以及相关属性,例如发布、迭代等。

执行CreateResponse beInitiativeCreateResponse = createInRally("portfolioitem/beinitiative", BeInitiativeCreateObject);后当它尝试执行if(beInitiativeCreateResponse.wasSuccessful())时相反,它会转到 else block ,从而打印下面提到的错误。

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.NullPointerException

2017-12-05 11:01 AM PST America/Los_Angeles

但是重要一点是,当尝试迁移项目及其相关属性(例如发布/迭代等)时,在相同的 Rally 工作区中,上述代码可以正常工作。

更新1:

在分析这个问题时,我做出了以下观察 -

我尝试在其中创建 BeInitiative 的工作区在“投资组合”项目下拉列表中没有“BEinitiative”、“Be 功能”、“CPM 功能”选项。相反,它有主题、倡议和功能选项。因此,我认为我遇到了前面提到的错误。现在我对代码进行了以下更改。

CreateResponse beInitiativeCreateResponse = createInRally("portfolioitem/theme", themeCreateObject);

所以现在我不再创建 BEInitiative,而是尝试仅在新工作区中创建主题,但出现以下错误 -

Requested type name \"/portfolioitem/theme\" is unknown.

我传递给 CreateResponse 函数的对象是 -

{"Name":"xyz","Project":"/project/1804","Workspace":"/workspace/139"}

createInRally 函数的代码如下 -

public CreateResponse createInRally( String query, JsonObject object) throws IOException{

CreateRequest createRequest = new CreateRequest(query, object);

CreateResponse createResponse = restApi.create(createRequest);

return createResponse;
}

最佳答案

由于未传递我们尝试在其中创建投资组合项目的工作区的对象 ID,因此发生了未知类型错误。因此,在修改 createInRally 函数以包含工作区对象 ID 后,我们能够创建计划组合项目。修改后的createInRally函数如下图-

    CreateRequest createRequest = new CreateRequest(query, object);

createRequest.addParam("workspace", "/workspace/1333333333");

CreateResponse createResponse = restApi.create(createRequest);

return createResponse;

关于java - 使用 Java 中的 Rally Rest Client 创建 BE Initiative、BE Feature 和 CPM Feature,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47661102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com