1

アプリケーションを自動的にデプロイするために使用する jelastic API を使い始めています。API の呼び出しに関するすべてが簡単に思え、問題なく認証できます。

次に、展開に使用する ENV_APPID を取得したい環境のリストを取得しようとして問題に遭遇しました。

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);

コードは次の出力で完了します (機密情報は疑問符に置き換えられます)

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"}

これは明らかに私が期待するものではありません。コードは簡単です。定数に問題がありますか? (サンプル コードの PLATFORM_APPID を再利用します) 何か権限がありませんか?

ご意見ありがとうございます。

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","contexts":[],"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 に答える