Package com.kii.cloud.storage
Class Kii
- java.lang.Object
-
- com.kii.cloud.storage.Kii
-
public final class Kii extends java.lang.Object
This class provides:- Manages application key and application id. Call
initialize(String, String, String)
prior to use SDK.- Cancel async task by
cancelTask(int)
- Provides SDK information.
- Manages application key and application id. Call
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Kii.Site
Represent server location of the app.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static KiiBucket
bucket(java.lang.String bucketName)
Returns the KiiBucket which is open for application user.static boolean
cancelTask(int token)
Cancel the background task.static KiiEncryptedBucket
encryptedBucket(java.lang.String bucketName)
Returns the KiiEncryptedBucket which is open for application user.static long
getAccessTokenExpiration()
Returns access token lifetime.static java.lang.String
getAppId()
Application IDstatic java.lang.String
getAppKey()
Application Keystatic java.lang.String
getBaseURL()
URL for KiiCloudStorage Serverstatic java.lang.String
getBuildNumber()
KiiCloudStorage SDK Build Numberstatic java.lang.String
getKiiAppsBaseURL()
URL of KiiApps Server.static java.lang.String
getReservedProvider1()
Internal use only.static java.lang.String
getSDKVersion()
KiiCloudStorage SDK Version Numberstatic Kii.Site
getSite()
Get the site for KiiCloudStorage Server.static KiiGroup
group(java.lang.String groupName)
Create a group own by current user.
No other member will be added to the group.: Group owner(current log-in user) will be added as a group member by default. static KiiGroup
group(java.lang.String groupName, java.util.List<KiiUser> groupMembers)
Create a group own by current user assigning the specified users as group members.: Group owner will be added as a group member also by default. static void
initialize(android.content.Context context, java.lang.String appId, java.lang.String appKey)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call.static void
initialize(android.content.Context context, java.lang.String appId, java.lang.String appKey, boolean enableKiiAnalytics)
Initialize KiiCloudStorage SDK with the option to enable KiiAnalytics and this must be call prior to all APIs call.static void
initialize(android.content.Context context, java.lang.String appId, java.lang.String appKey, Kii.Site site)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call.static void
initialize(android.content.Context context, java.lang.String appId, java.lang.String appKey, Kii.Site site, boolean enableKiiAnalytics)
Initialize KiiCloudStorage SDK with option to enable KiiAnalytics and this must be call prior to all APIs call.static void
initialize(android.content.Context context, java.lang.String appId, java.lang.String appKey, java.lang.String serverUrl)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call.static void
initialize(android.content.Context context, java.lang.String appId, java.lang.String appKey, java.lang.String serverUrl, boolean enableKiiAnalytics)
Initialize KiiCloudStorage SDK with option to enable KiiAnalytics and this must be call prior to all APIs call.static void
initialize(java.lang.String appId, java.lang.String appKey)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call.static void
initialize(java.lang.String appId, java.lang.String appKey, Kii.Site site)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call.static void
initialize(java.lang.String appId, java.lang.String appKey, java.lang.String serverUrl)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call.static KiiListResult<KiiTopic>
listTopics()
Returns the list of topics in app scope.static void
listTopics(KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics()
.static KiiListResult<KiiTopic>
listTopics(java.lang.String paginationKey)
Returns the next page of list of topics in app scope.static void
listTopics(java.lang.String paginationKey, KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics(String)
.static void
onRestoreInstanceState(android.content.Context context, android.os.Bundle savedInstanceState)
Restore saved Kii state given inonSaveInstanceState(Bundle)
.static void
onRestoreInstanceState(android.os.Bundle savedInstanceState)
Restore saved Kii state given inonSaveInstanceState(Bundle)
.static void
onSaveInstanceState(android.os.Bundle outState)
Save Kii state to outState bundle which is provided by android.app.Activity#onSaveInstanceState(android.os.Bundle outState).static KiiServerCodeEntry
serverCodeEntry(java.lang.String entryName)
Instantiate KiiServerCodeEntry with specified entry name.static KiiServerCodeEntry
serverCodeEntry(java.lang.String entryName, KiiServerCodeEnvironmentVersion environmentVersion)
Instantiate KiiServerCodeEntry with specified entry name and environmentVersion.static KiiServerCodeEntry
serverCodeEntry(java.lang.String entryName, java.lang.String version)
Instantiate KiiServerCodeEntry with specified entry name and version.static KiiServerCodeEntry
serverCodeEntry(java.lang.String entryName, java.lang.String version, KiiServerCodeEnvironmentVersion environmentVersion)
Instantiate KiiServerCodeEntry with specified entry name and version and environmentVersion.static void
setAccessTokenExpiration(long expiresIn)
Set the access token lifetime in seconds.static KiiSocialConnect
socialConnect(KiiSocialConnect.SocialNetwork network)
Return an instance of the KiiSocialConnect.static KiiTopic
topic(java.lang.String name)
Get instance of app scope topic.static KiiUser
user()
Returns logged in user.
-
-
-
Method Detail
-
getBaseURL
@Nullable public static java.lang.String getBaseURL()
URL for KiiCloudStorage Server
-
getSite
@Nullable public static Kii.Site getSite()
Get the site for KiiCloudStorage Server. Note : This method returns null when initialized with URL for private/dedicated location.- Returns:
- Site
-
getAccessTokenExpiration
public static long getAccessTokenExpiration()
Returns access token lifetime. If access token lifetime has not set explicitly bysetAccessTokenExpiration(long)
, returns 0.- Returns:
- access token lifetime in seconds.
- Throws:
java.lang.IllegalStateException
- Thrown if SDK has not initialized yet.
-
getAppId
@Nullable public static java.lang.String getAppId()
Application ID
-
getAppKey
@Nullable public static java.lang.String getAppKey()
Application Key
-
getKiiAppsBaseURL
@Nullable public static java.lang.String getKiiAppsBaseURL()
URL of KiiApps Server.- Returns:
- URL of KiiApps Server.
-
cancelTask
public static boolean cancelTask(int token)
Cancel the background task.- Parameters:
token
- is a unique id given when an asynchronous task is called- Returns:
- true if cancel is successful else false. Cancel can fail if token is not found.
-
initialize
public static void initialize(@NonNull java.lang.String appId, @NonNull java.lang.String appKey)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call. It is pointing to the Default Development KiiCloud Server.- Parameters:
appId
- application ID found in your Kii developer consoleappKey
- application key found in your Kii developer console- Throws:
java.lang.IllegalArgumentException
- Thrown if specified appId/appKey is null or empty.
-
initialize
public static void initialize(@NonNull java.lang.String appId, @NonNull java.lang.String appKey, @NonNull Kii.Site site)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call.- Parameters:
appId
- application ID found in your Kii developer console.appKey
- application key found in your Kii developer console.site
- KiiCloud site.- Throws:
java.lang.IllegalArgumentException
- Thrown specified appId/appKey/site is null or empty.
-
initialize
public static void initialize(@NonNull java.lang.String appId, @NonNull java.lang.String appKey, @NonNull java.lang.String serverUrl)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call.- Parameters:
appId
- application ID found in your Kii developer consoleappKey
- application key found in your Kii developer consoleserverUrl
- the KiiCloud base URL- Throws:
java.lang.IllegalArgumentException
- Thrown if specified appId/appKey/serverUrl is null or empty.
-
initialize
public static void initialize(@Nullable android.content.Context context, @NonNull java.lang.String appId, @NonNull java.lang.String appKey)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call. It is pointing to the Default Development KiiCloud Server.- Parameters:
context
-appId
- application ID found in your Kii developer consoleappKey
- application key found in your Kii developer console- Throws:
java.lang.IllegalArgumentException
- Thrown if specified appId/appKey is null or empty.
-
initialize
public static void initialize(@Nullable android.content.Context context, @NonNull java.lang.String appId, @NonNull java.lang.String appKey, @NonNull Kii.Site site)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call.- Parameters:
context
-appId
- application ID found in your Kii developer console.appKey
- application key found in your Kii developer console.site
- KiiCloud site.- Throws:
java.lang.IllegalArgumentException
- Thrown specified appId/appKey/site is null or empty.
-
initialize
public static void initialize(@Nullable android.content.Context context, @NonNull java.lang.String appId, @NonNull java.lang.String appKey, @NonNull java.lang.String serverUrl)
Initialize KiiCloudStorage SDK and this must be call prior to all APIs call.- Parameters:
context
-appId
- application ID found in your Kii developer consoleappKey
- application key found in your Kii developer consoleserverUrl
- the KiiCloud base URL- Throws:
java.lang.IllegalArgumentException
- Thrown if specified appId/appKey/serverUrl is null or empty.
-
initialize
public static void initialize(@Nullable android.content.Context context, @NonNull java.lang.String appId, @NonNull java.lang.String appKey, boolean enableKiiAnalytics)
Initialize KiiCloudStorage SDK with the option to enable KiiAnalytics and this must be call prior to all APIs call. It is pointing to the Default Development KiiCloud Server.Note that you can disable Kii Analytics at the beginning, and enable it later by calling this method. However, once you enable Kii Aanlytics, you can't disable it until the application is finished. - Parameters:
context
-appId
- application ID found in your Kii developer consoleappKey
- application key found in your Kii developer consoleenableKiiAnalytics
- true to init KiiAnalytics- Throws:
java.lang.IllegalArgumentException
- Thrown if specified appId/appKey is null or empty.
-
initialize
public static void initialize(@Nullable android.content.Context context, @NonNull java.lang.String appId, @NonNull java.lang.String appKey, @NonNull Kii.Site site, boolean enableKiiAnalytics)
Initialize KiiCloudStorage SDK with option to enable KiiAnalytics and this must be call prior to all APIs call.Note that you can disable Kii Analytics at the beginning, and enable it later by calling this method. However, once you enable Kii Aanlytics, you can't disable it until the application is finished. - Parameters:
context
-appId
- application ID found in your Kii developer console.appKey
- application key found in your Kii developer console.site
- KiiCloud site.enableKiiAnalytics
- true to init KiiAnalytics- Throws:
java.lang.IllegalArgumentException
- Thrown specified appId/appKey/site is null or empty.
-
initialize
public static void initialize(@NonNull android.content.Context context, @NonNull java.lang.String appId, @NonNull java.lang.String appKey, @NonNull java.lang.String serverUrl, boolean enableKiiAnalytics)
Initialize KiiCloudStorage SDK with option to enable KiiAnalytics and this must be call prior to all APIs call.Note that you can disable Kii Analytics at the beginning, and enable it later by calling this method. However, once you enable Kii Aanlytics, you can't disable it until the application is finished. - Parameters:
context
-appId
- application ID found in your Kii developer consoleappKey
- application key found in your Kii developer consoleserverUrl
- the KiiCloud base URLenableKiiAnalytics
- true to init KiiAnalytics- Throws:
java.lang.IllegalArgumentException
- Thrown if specified appId/appKey/serverUrl is null or empty.
-
setAccessTokenExpiration
public static void setAccessTokenExpiration(long expiresIn)
Set the access token lifetime in seconds. If you don't call this method or call it with 0, token won't be expired. Call this method if you like the access token to be expired after assigned period. Once called, token retrieved by each future authentication will have the specified lifetime. Note that, it will not update the lifetime of token received prior calling this method. Once expired, you have to login again to renew the token.- Parameters:
expiresIn
- The life time of access token in seconds.- Throws:
java.lang.IllegalStateException
- Thrown if SDK has not initialized.java.lang.IllegalArgumentException
- If the specified expiresIn is negative.
-
getSDKVersion
@NonNull public static java.lang.String getSDKVersion()
KiiCloudStorage SDK Version Number
-
user
@Nullable public static KiiUser user()
Returns logged in user.- Returns:
- user logged in. null if no user logged in.
-
bucket
@NonNull public static KiiBucket bucket(@NonNull java.lang.String bucketName)
Returns the KiiBucket which is open for application user.- Parameters:
bucketName
- is a name of KiiBucket.- Returns:
- KiiBucket open for application user.
- Throws:
java.lang.IllegalArgumentException
- when bucketName is not acceptable format. For details please refer toKiiBucket.isValidBucketName(String)
-
encryptedBucket
@NonNull public static KiiEncryptedBucket encryptedBucket(@NonNull java.lang.String bucketName)
Returns the KiiEncryptedBucket which is open for application user.- Parameters:
bucketName
- name of the bucket- Returns:
- encrypted bucket instance.
- Throws:
java.lang.IllegalArgumentException
- when bucketName is not acceptable format. For details please refer toKiiBucket.isValidBucketName(String)
-
getBuildNumber
@NonNull public static java.lang.String getBuildNumber()
KiiCloudStorage SDK Build Number
-
group
@NonNull public static KiiGroup group(@Nullable java.lang.String groupName, @Nullable java.util.List<KiiUser> groupMembers)
Create a group own by current user assigning the specified users as group members.: Group owner will be added as a group member also by default. This api will NOT access to server immediately. After call this api, call save()
to save the group to the cloud.- Parameters:
groupName
- Name of the group.groupMembers
- Members of the group. Group owner will be added as a group member no matter owner is in the list or not.- Returns:
- KiiGroup instance.
-
group
@NonNull public static KiiGroup group(@Nullable java.lang.String groupName)
Create a group own by current user.
No other member will be added to the group.: Group owner(current log-in user) will be added as a group member by default. This api will NOT access to server immediately. After call this api, call save()
to save the group to the cloud.- Parameters:
groupName
- Name of the group.- Returns:
- KiiGroup instance.
-
socialConnect
@NonNull public static KiiSocialConnect socialConnect(@NonNull KiiSocialConnect.SocialNetwork network)
Return an instance of the KiiSocialConnect. This API needs specified social network service name.- Parameters:
network
- Social network service name.- Returns:
- KiiSocialConnect instance.
- Throws:
java.lang.IllegalArgumentException
- if specified network is null.
-
topic
@NonNull public static KiiTopic topic(@NonNull java.lang.String name)
Get instance of app scope topic. The topic bound to the application.- Parameters:
name
-- Returns:
- KiiTopic bound to the application.
-
listTopics
@NonNull public static KiiListResult<KiiTopic> listTopics() throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Returns the list of topics in app scope.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Returns:
- a list of the topics in app scope.
Call
KiiListResult.hasNext()
to check if there are any more result. - Throws:
java.io.IOException
UnauthorizedException
ForbiddenException
BadRequestException
ConflictException
NotFoundException
UndefinedException
-
listTopics
@WorkerThread @NonNull public static KiiListResult<KiiTopic> listTopics(@Nullable java.lang.String paginationKey) throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Returns the next page of list of topics in app scope.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
paginationKey
- Specifies the pagination key that is obtained byKiiListResult.getPaginationKey()
. If specified null or empty, it's same as thelistTopics()
.- Returns:
- a list of the topics in app scope.
KiiListResult.hasNext()
to check if there are any more result. - Throws:
java.io.IOException
UnauthorizedException
ForbiddenException
BadRequestException
ConflictException
NotFoundException
UndefinedException
-
listTopics
public static void listTopics(@NonNull KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics()
. A background task will be initiated to execute the task.- Parameters:
callback
- notifies events.
-
listTopics
public static void listTopics(@Nullable java.lang.String paginationKey, @NonNull KiiCallback<KiiListResult<KiiTopic>> callback)
Asynchronous call forlistTopics(String)
. A background task will be initiated to execute the task.- Parameters:
paginationKey
- Specifies the pagination key that is obtained byKiiListResult.getPaginationKey()
. If specified null or empty, it's same as thelistTopics(KiiCallback)
.callback
- notifies events.
-
serverCodeEntry
@NonNull public static KiiServerCodeEntry serverCodeEntry(@NonNull java.lang.String entryName)
Instantiate KiiServerCodeEntry with specified entry name.- Parameters:
entryName
- name of the entry.- Returns:
- KiiServerCodeEntry instance.
- Throws:
java.lang.IllegalArgumentException
- when entryName is null, empty or invalid. Valid entryName pattern is "[a-zA-Z][_a-zA-Z0-9]*$".
-
serverCodeEntry
@NonNull public static KiiServerCodeEntry serverCodeEntry(@NonNull java.lang.String entryName, @NonNull java.lang.String version)
Instantiate KiiServerCodeEntry with specified entry name and version.- Parameters:
entryName
- name of the entry.version
- of the entry.- Returns:
- KiiServerCodeEntry instance.
- Throws:
java.lang.IllegalArgumentException
- Thrown if- entryName is null, empty or invalid. Valid entryName pattern is "[a-zA-Z][_a-zA-Z0-9]*$".
- version is null or empty.
-
serverCodeEntry
@NonNull public static KiiServerCodeEntry serverCodeEntry(@NonNull java.lang.String entryName, @NonNull KiiServerCodeEnvironmentVersion environmentVersion)
Instantiate KiiServerCodeEntry with specified entry name and environmentVersion.- Parameters:
entryName
- name of the entry.environmentVersion
- the version of Node.js to run.- Returns:
- KiiServerCodeEntry instance.
- Throws:
java.lang.IllegalArgumentException
- Thrown if- entryName is null, empty or invalid. Valid entryName pattern is "[a-zA-Z][_a-zA-Z0-9]*$".
- version is null or empty.
-
serverCodeEntry
@NonNull public static KiiServerCodeEntry serverCodeEntry(@NonNull java.lang.String entryName, @NonNull java.lang.String version, @NonNull KiiServerCodeEnvironmentVersion environmentVersion)
Instantiate KiiServerCodeEntry with specified entry name and version and environmentVersion.- Parameters:
entryName
- name of the entry.version
- of the entry.environmentVersion
- the version of Node.js to run.- Returns:
- KiiServerCodeEntry instance.
- Throws:
java.lang.IllegalArgumentException
- Thrown if- entryName is null, empty or invalid. Valid entryName pattern is "[a-zA-Z][_a-zA-Z0-9]*$".
- version is null or empty.
-
onSaveInstanceState
public static void onSaveInstanceState(@Nullable android.os.Bundle outState)
Save Kii state to outState bundle which is provided by android.app.Activity#onSaveInstanceState(android.os.Bundle outState).
Note:- In this feature, "com.kii.cloud.storage.*" string is used for bundle key.
If you want to save states in android.app.Activity#onSaveInstanceState(android.os.Bundle outState), do not use "com.kii.cloud.storage.*" string for bundle key. - This method should be called in android.app.Activity#onSaveInstanceState(android.os.Bundle outState).
- Parameters:
outState
- Bundle in which to place your saved state.- See Also:
onRestoreInstanceState(Bundle)
- In this feature, "com.kii.cloud.storage.*" string is used for bundle key.
-
onRestoreInstanceState
public static void onRestoreInstanceState(@Nullable android.os.Bundle savedInstanceState)
Restore saved Kii state given inonSaveInstanceState(Bundle)
.
Specifically, initialize KiiCloudStorage SDK and set KiiUser as current user if exists.
Note: This method should be called in android.app.Activity#onCreate(android.os.Bundle outState) or android.app.Activity#onRestoreInstanceState(android.os.Bundle outState)- Parameters:
savedInstanceState
- Bundle data most recently supplied in android.app.Activity#onSaveInstanceState(android.os.Bundle outState).- See Also:
onSaveInstanceState(Bundle)
-
onRestoreInstanceState
public static void onRestoreInstanceState(@Nullable android.content.Context context, @Nullable android.os.Bundle savedInstanceState)
Restore saved Kii state given inonSaveInstanceState(Bundle)
.
Specifically, initialize KiiCloudStorage SDK and set KiiUser as current user if exists.
Note: This method should be called in android.app.Activity#onCreate(android.os.Bundle outState) or android.app.Activity#onRestoreInstanceState(android.os.Bundle outState)- Parameters:
context
-savedInstanceState
- Bundle data most recently supplied in android.app.Activity#onSaveInstanceState(android.os.Bundle outState).- See Also:
onSaveInstanceState(Bundle)
-
getReservedProvider1
public static java.lang.String getReservedProvider1()
Internal use only.- Returns:
- Reserved provider string.
-
-