package com.kii.thingif;

import android.text.TextUtils;

import org.w3c.dom.Text;

/** Represents Application on Kii Cloud */
public class KiiApp {
    private String appID;
    private String appKey;
    private String hostName;
    private String baseUrl;


    /** Instantiate Kii App with App Location.
     * If you haven't created Kii Cloud App yet,
     * Please visit https://developer.kii.com and create your app.
     * @param appID ID of the app.
     * @param appKey Key of the app.
     * @param site Site of the app.
     * @throws  IllegalArgumentException when appID, appKey and site is null or empty string.
     */
    public KiiApp(String appID, String appKey, Site site) {
        if (TextUtils.isEmpty(appID)) {
            throw new IllegalArgumentException("appID is null or empty.");
        }
        if (TextUtils.isEmpty(appKey)) {
            throw new IllegalArgumentException("appKey is null or empty.");
        }
        if (site == null) {
            throw new IllegalArgumentException("site is null.");
        }
        this.appID = appID;
        this.appKey = appKey;
        this.hostName = site.getHostName();
        this.baseUrl = "https://" + this.hostName;
    }

    /** Instantiate Kii App with Host Name.
     * Who host Kii Cloud in private/ dedicated location
     * Will use this constructor to instantiate KiiApp.
     * (Private/ Dedicated location is only available in Enterprise subscription.)
     * If you're using public Kii Cloud, please use {@link KiiApp(String, String, Site)}
     * @param appID ID of the app.
     * @param appKey Key of the app.
     * @param hostName Host Name of the app.
     * @throws  IllegalArgumentException when appID, appKey and hostName is null or empty string.
     */
    public KiiApp(String appID, String appKey, String hostName) {
        if (TextUtils.isEmpty(appID)) {
            throw new IllegalArgumentException("appID is null or empty.");
        }
        if (TextUtils.isEmpty(appKey)) {
            throw new IllegalArgumentException("appKey is null or empty.");
        }
        if (TextUtils.isEmpty(hostName)) {
            throw new IllegalArgumentException("hostName is null or empty.");
        }
        this.appID = appID;
        this.appKey = appKey;
        this.hostName = hostName;
        this.baseUrl = "https://" + hostName;
    }

    public String getAppID() {
        return this.appID;
    }

    public String getAppKey() {
        return  this.appKey;
    }

    public String getHostName() {
        return this.hostName;
    }

    public String getBaseUrl() {
        return this.baseUrl;
    }

}

@@ -252,16 +252,45 @@
 aseUrl;%0A
+    private String siteName;%0A
 %0A%0A    /*
@@ -1216,32 +1216,69 @@
  this.hostName;%0A
+        this.siteName = site.name();%0A
     %7D%0A%0A    /** I
@@ -1597,16 +1597,100 @@
  Site)%7D%0A
+     * With this constructor, %7B@link #getSiteName()%7D returns fixed string %22CUSTOM%22.%0A
      * @
@@ -2483,32 +2483,1404 @@
 //%22 + hostName;%0A
+        this.siteName = %22CUSTOM%22;%0A    %7D%0A%0A    /** Instantiate Kii App with Host Name and Site Name.%0A     * Who host Kii Cloud in private/ dedicated location%0A     * Will use this constructor to instantiate KiiApp.%0A     * (Private/ Dedicated location is only available in Enterprise subscription.)%0A     * If you're using public Kii Cloud, please use %7B@link KiiApp(String, String, Site)%7D%0A     * siteName is used by Gateway Agent to resolve the server location stored with the siteName%0A     * in the Gateway configuration.%0A     * @param appID ID of the app.%0A     * @param appKey Key of the app.%0A     * @param hostName Host name of the app.%0A     * @param siteName Site name of the app. (Corresponds to Gateway Agent configuration.)%0A     */%0A    public KiiApp(String appID, String appKey, String hostName, String siteName) %7B%0A        if (TextUtils.isEmpty(appID)) %7B%0A            throw new IllegalArgumentException(%22appID is null or empty.%22);%0A        %7D%0A        if (TextUtils.isEmpty(appKey)) %7B%0A            throw new IllegalArgumentException(%22appKey is null or empty.%22);%0A        %7D%0A        if (TextUtils.isEmpty(hostName)) %7B%0A            throw new IllegalArgumentException(%22hostName is null or empty.%22);%0A        %7D%0A        this.appID = appID;%0A        this.appKey = appKey;%0A        this.hostName = hostName;%0A        this.baseUrl = %22https://%22 + hostName;%0A        this.siteName = siteName;%0A
     %7D%0A%0A    publi
@@ -4103,24 +4103,24 @@
 BaseUrl() %7B%0A
-
         retu
@@ -4143,10 +4143,81 @@
 %0A    %7D%0A%0A
+    public String getSiteName() %7B%0A        return this.siteName;%0A    %7D%0A%0A
 %7D%0A

Add site name in KiiApp.