Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Java中向Rally添加新用户_Java_Rally - Fatal编程技术网

在Java中向Rally添加新用户

在Java中向Rally添加新用户,java,rally,Java,Rally,我正在寻找任何可用的代码,以添加新的用户在拉力用Java编写?如果它已经在那里的某个地方,我想得到同样的。感谢您的帮助 使用Java REST toolkit在技术上是可行的,因为它使用的WS-API与Ruby REST toolkit相同。以下是创建用户的示例代码: import com.google.gson.JsonObject; import com.rallydev.rest.RallyRestApi; import com.rallydev.rest.request.CreateRe

我正在寻找任何可用的代码,以添加新的用户在拉力用Java编写?如果它已经在那里的某个地方,我想得到同样的。感谢您的帮助

使用Java REST toolkit在技术上是可行的,因为它使用的WS-API与Ruby REST toolkit相同。以下是创建用户的示例代码:

import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.CreateRequest;
import com.rallydev.rest.request.GetRequest;
import com.rallydev.rest.response.CreateResponse;
import com.rallydev.rest.response.GetResponse;
import com.rallydev.rest.util.Ref;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class aRestcreateUser {

    public static void main(String[] args) throws URISyntaxException, IOException {

        //Create and configure a new instance of RallyRestApi
        String myRallyURL = "https://rally1.rallydev.com";
        String myRallyUser = "administrator@company.com"; //must have admin rights
        String myRallyPassword = "adminPassword";

        String wsapiVersion = "1.43";
        RallyRestApi restApi = new RallyRestApi(
            new URI(myRallyURL),
            myRallyUser,
            myRallyPassword);
        restApi.setWsapiVersion(wsapiVersion);
        System.out.println(restApi.getWsapiVersion()); 


        try {

            System.out.println("Creating User...");
            JsonObject newUser = new JsonObject();
            newUser.addProperty("UserName", "nick002@test.com");
            newUser.addProperty("EmailAddress", "nmusaelian@rallydev.com");

            CreateRequest createRequest = new CreateRequest("User", newUser);
            CreateResponse createResponse = restApi.create(createRequest);

            if (createResponse.wasSuccessful()) {
                System.out.println(String.format("Created User %s", createResponse.getObject().get("_ref").getAsString()));

                String ref = Ref.getRelativeRef(createResponse.getObject().get("_ref").getAsString());
                System.out.println(String.format("\nReading User %s...", ref));
                GetRequest getRequest = new GetRequest(ref);
                GetResponse getResponse = restApi.get(getRequest);
                JsonObject obj = getResponse.getObject();
                System.out.println(String.format("Read User. Name = %s, State = %s",
                        obj.get("UserName").getAsString(), obj.get("EmailAddress").getAsString()));

            } else {
                String[] errorList;
                errorList = createResponse.getErrors();
                for (int i=0;i<errorList.length;i++) {
                    System.out.println(errorList[i]);
                }
            }

        } finally {
            //Release all resources
            restApi.close();
        }
    }
}
import com.google.gson.JsonObject;
导入com.rallydev.rest.RallyRestApi;
导入com.rallydev.rest.request.CreateRequest;
导入com.rallydev.rest.request.GetRequest;
导入com.rallydev.rest.response.CreateResponse;
导入com.rallydev.rest.response.GetResponse;
导入com.rallydev.rest.util.Ref;
导入java.io.IOException;
导入java.net.URI;
导入java.net.URISyntaxException;
公共类AresCreateUser{
公共静态void main(字符串[]args)抛出URISyntaxException、IOException{
//创建并配置RallyRestApi的新实例
字符串myRallyURL=”https://rally1.rallydev.com";
字符串myRallyUser=”administrator@company.com“;//必须具有管理员权限
字符串myRallyPassword=“adminPassword”;
字符串wsapiVersion=“1.43”;
RallyRestApi restApi=新的RallyRestApi(
新URI(myRallyURL),
迈拉卢瑟,
myRallyPassword);
restApi.setWsapiVersion(wsapiVersion);
System.out.println(restApi.getWsapiVersion());
试一试{
System.out.println(“创建用户…”);
JsonObject newUser=新JsonObject();
newUser.addProperty(“用户名”nick002@test.com");
newUser.addProperty(“电子邮件地址”nmusaelian@rallydev.com");
CreateRequest CreateRequest=新的CreateRequest(“用户”,新用户);
CreateResponse CreateResponse=restApi.create(createRequest);
if(createResponse.wasSuccessful()){
System.out.println(String.format(“创建的用户%s”,createResponse.getObject().get(“\u ref”).getAsString());
字符串ref=ref.getRelativeRef(createResponse.getObject().get(“\u ref”).getAsString());
System.out.println(String.format(“\n读取用户%s…”,ref));
GetRequest GetRequest=新的GetRequest(参考);
GetResponse GetResponse=restApi.get(getRequest);
JsonObject obj=getResponse.getObject();
System.out.println(String.format(“读取用户名=%s,状态=%s”),
obj.get(“用户名”).getAsString(),obj.get(“电子邮件地址”).getAsString();
}否则{
字符串[]错误列表;
errorList=createResponse.getErrors();

对于(inti=0;iI)用户管理参见Ruby周围的代码,但不是Java。Java在技术上是否可行?