1

I am getting started with jelastic API which I intend to use to automatically deploy applications. Everyting about calling the api seems straight forward, and I am able to authenticate without problems.

Then I ran into problems trying to get list of environments from which I hope to get ENV_APPID to use for deployment:

String PLATFORM_APPID = "1dd8d191d38fff45e62564fcf67fdcd6";
String HOSTER_URL = "https://app.jelastic.dogado.eu";
String USER_EMAIL = "??";
String USER_PASSWORD = "??";

AuthenticationResponse authenticationResponse = authenticationService.signin(USER_EMAIL, USER_PASSWORD);
System.out.println("Signin response: " + authenticationResponse);
if (!authenticationResponse.isOK()) {
   System.exit(authenticationResponse.getResult());
}

final String session = authenticationResponse.getSession();

System.out.println("Getting environments list...");
EnvironmentInfoResponses environmentInfoResponses = environmentService.getEnvs(PLATFORM_APPID, session);
System.out.println("GetEnvs response: " + environmentInfoResponses);

The code completes with following output (sensitive information is replaced with question mark)

Authenticate user...
Signin response: {"uid":??,"result":0,"session":"5935x8f7c158de1f65562015a09f1aa0c99fd","email":"??","data":{"lang":"en"}}
Getting environments list...
GetEnvs response: {"result":15,"source":"hx-core","error":"system application is not allowed"}

This is obviously not what I expect. The code is easy; Am I having problem with constants ? (I reuse PLATFORM_APPID from sample code) Am I missing some kind of permission?

Thanks for any input.

4

1 回答 1

1

此示例适用于我:输出:

登录响应:{"uid":uid,"result":0,"session":"73aax79fe1592910526ab550395de436e176e","email":"","data":{"lang":"en"}} 获取环境列表.. .GetEnvs 响应:{"result":0,"infos":[{"result":0,"nodes":[],"env":{"uid":uid,"ishaenabled":false,"extdomains" :[],"engine":{"id":2,"keyword":"java7","name":"Java 7","vcsSupport":false,"type":"java","version": "1.7.0_51"},"status":6,"isTransferring":false,"domain":"domain.jelastic.dogado.eu","pricingType":"HYBRID","appid":"appid","上下文":[],"sslstate":false,"shortdomain":"domain"},"right":"OWNER"}]}

代码:

public class GetEnvList {
private final static String USER_AGENT = "Environment Lifecycle Example";
private final static String USER_AGENT_PARAM = "User-Agent";
private final static String PLATFORM_APPID = "1dd8d191d38fff45e62564fcf67fdcd6";
private final static String HOSTER_URL = "https://app.jelastic.dogado.eu"; // hoster's url, see http://docs.jelastic.com/en/jelastic-hoster-info
private final static String USER_EMAIL = ""; // your email
private final static String USER_PASSWORD = ""; // your password

private static Map<String, String> headers;
private static Authentication authenticationService;
private static Environment environmentService;

static {
    headers = new HashMap<>();
    headers.put(USER_AGENT_PARAM, USER_AGENT);

    authenticationService = new Authentication(PLATFORM_APPID);
    authenticationService.setServerUrl(HOSTER_URL + "/1.0/");

    environmentService = new Environment(PLATFORM_APPID);
    environmentService.setServerUrl(HOSTER_URL + "/1.0/");
}

public static void main(String[] args) {

    System.out.println("Authenticate user...");
    AuthenticationResponse authenticationResponse = authenticationService.signin(USER_EMAIL, USER_PASSWORD, headers);
    System.out.println("Signin response: " + authenticationResponse);
    if (!authenticationResponse.isOK()) {
        System.exit(authenticationResponse.getResult());
    }

    final String session = authenticationResponse.getSession();

    /**
     * Gets the information about all environments of a user.
     */
    System.out.println("Getting environments list...");
    EnvironmentInfoResponses environmentInfoResponses = environmentService.getEnvs(PLATFORM_APPID, session, headers);
    System.out.println("GetEnvs response: " + environmentInfoResponses);
}

}

于 2014-07-04T13:13:15.083 回答