本文整理匯總了Java中org.apache.usergrid.java.client.UsergridClient類的典型用法代碼示例。如果您正苦於以下問題:Java UsergridClient類的具體用法?Java UsergridClient怎麽用?Java UsergridClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
UsergridClient類屬於org.apache.usergrid.java.client包,在下文中一共展示了UsergridClient類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: save
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
@NotNull
public UsergridResponse save(@NotNull final UsergridClient client) {
UsergridResponse response;
if( this.getUuid() != null ) {
response = client.PUT(this);
} else {
response = client.POST(this);
}
if( response.ok() ) {
UsergridEntity responseEntity = response.first();
if( responseEntity != null ) {
this.copyAllProperties(responseEntity);
}
}
return response;
}
示例2: checkAvailable
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
public static void checkAvailable(@NotNull final UsergridClient client, @Nullable final String email, @Nullable final String username, @NotNull final UsergridCheckAvailabilityCallback checkAvailabilityCallback) {
if (email == null && username == null) {
checkAvailabilityCallback.onResponse(false);
return;
}
UsergridQuery query = new UsergridQuery(UsergridUser.USER_ENTITY_TYPE);
if (username != null) {
query.eq(UsergridUserProperties.USERNAME.toString(), username);
}
if (email != null) {
query.or().eq(UsergridUserProperties.EMAIL.toString(), email);
}
UsergridAsync.GET(client, query, new UsergridResponseCallback() {
@Override
public void onResponse(@NotNull UsergridResponse response) {
checkAvailabilityCallback.onResponse((response.ok() && response.first() != null));
}
});
}
示例3: saveSharedDeviceRemotelyAndToDisk
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
private static void saveSharedDeviceRemotelyAndToDisk(@NotNull final UsergridClient client, @NotNull final Context context, @NotNull final UsergridResponseCallback responseCallback) {
UsergridDevice sharedDevice = UsergridSharedDevice.getSharedDevice(context);
String sharedDeviceUUID = sharedDevice.getUuid() != null ? sharedDevice.getUuid() : sharedDevice.getStringProperty("uuid");
UsergridRequest request = new UsergridRequest(UsergridHttpMethod.PUT, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE, client.clientAppUrl(), null, sharedDevice, client.authForRequests(), "devices", sharedDeviceUUID);
UsergridAsync.sendRequest(client, request, new UsergridResponseCallback() {
@Override
public void onResponse(@NotNull UsergridResponse response) {
UsergridEntity responseEntity = response.entity();
if (response.ok() && responseEntity != null && responseEntity instanceof UsergridDevice) {
UsergridSharedDevice.sharedDevice = (UsergridDevice) responseEntity;
UsergridSharedDevice.saveSharedDeviceToDisk(context);
}
responseCallback.onResponse(response);
}
});
}
示例4: fromException
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
@NotNull
public static UsergridResponse fromException(@Nullable final UsergridClient client, @NotNull final Exception ex) {
final UsergridResponse response = new UsergridResponse();
response.client = client;
final UsergridResponseError responseError = new UsergridResponseError();
responseError.setErrorDescription(ex.getMessage());
if( ex.getClass() != null ) {
responseError.setErrorName(ex.getClass().toString());
}
if( ex.getCause() != null ) {
responseError.setErrorException(ex.getCause().toString());
}
response.responseError = responseError;
return response;
}
示例5: loadNextPage
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
@NotNull
public UsergridResponse loadNextPage() {
UsergridClient client = this.client;
UsergridEntity entity = this.first();
if( this.hasNextPage() && client != null && entity != null ) {
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("cursor", getCursor());
UsergridRequest request = new UsergridRequest(UsergridEnums.UsergridHttpMethod.GET, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE, client.clientAppUrl(), paramsMap, null, null, this.getQuery(), client.authForRequests() , entity.getType());
return client.sendRequest(request);
} else {
return UsergridResponse.fromError(client,"Error Loading Next Page.","Unable to load next page.");
}
}
示例6: fromError
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
@NotNull
public static UsergridResponse fromError(@Nullable final UsergridClient client, @NotNull final String errorName, @NotNull final String errorDescription) {
UsergridResponse response = new UsergridResponse();
response.client = client;
response.responseError = new UsergridResponseError(errorName,errorDescription);
return response;
}
示例7: reload
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
@NotNull
public UsergridResponse reload(@NotNull final UsergridClient client) {
String uuidOrName = this.uuidOrName();
if( uuidOrName == null ) {
return UsergridResponse.fromError(client, "No UUID or name found.", "The entity object must have a `uuid` or `name` assigned.");
}
UsergridResponse response = client.GET(this.getType(), uuidOrName);
if( response.ok() ) {
UsergridEntity responseEntity = response.first();
if( responseEntity != null ) {
this.copyAllProperties(responseEntity);
}
}
return response;
}
示例8: checkAvailable
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
public static boolean checkAvailable(@NotNull final UsergridClient client, @Nullable final String email, @Nullable final String username) {
if (email == null && username == null) {
throw new IllegalArgumentException("email and username both are null ");
}
UsergridQuery query = new UsergridQuery(USER_ENTITY_TYPE);
if (username != null) {
query.eq(UsergridUserProperties.USERNAME.toString(), username);
}
if (email != null) {
query.or().eq(UsergridUserProperties.EMAIL.toString(), email);
}
return client.GET(query).first() != null;
}
示例9: create
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
@NotNull
public UsergridResponse create(@NotNull final UsergridClient client) {
UsergridResponse response = client.POST(this);
UsergridUser createdUser = response.user();
if( createdUser != null ) {
this.copyAllProperties(createdUser);
}
return response;
}
示例10: login
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
@NotNull
public UsergridResponse login(@NotNull final UsergridClient client, @NotNull final String username, @NotNull final String password) {
UsergridUserAuth userAuth = new UsergridUserAuth(username,password);
UsergridResponse response = client.authenticateUser(userAuth,false);
if( response.ok() ) {
this.userAuth = userAuth;
}
return response;
}
示例11: logout
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
@NotNull
public UsergridResponse logout(@NotNull final UsergridClient client) {
UsergridResponse response;
String uuidOrUsername = this.uuidOrUsername();
String accessToken = (this.userAuth != null) ? this.userAuth.getAccessToken() : null;
if (uuidOrUsername == null || accessToken == null ) {
response = UsergridResponse.fromError(client, "Logout Failed.", "UUID or Access Token not found on UsergridUser object.");
} else {
response = client.logoutUser(uuidOrUsername, accessToken);
if( response.ok() ) {
this.userAuth = null;
}
}
return response;
}
示例12: clientAppInit
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
@Test
public void clientAppInit() {
Usergrid.initSharedInstance(SDKTestConfiguration.ORG_NAME, SDKTestConfiguration.APP_NAME, SDKTestConfiguration.USERGRID_URL, SDKTestConfiguration.authFallBack);
Usergrid.authenticateApp(new UsergridAppAuth(SDKTestConfiguration.APP_CLIENT_ID, SDKTestConfiguration.APP_CLIENT_SECRET));
//should fall back to using no authentication when currentUser is not authenticated and authFallback is set to NONE
UsergridClient client = Usergrid.getInstance();
// client.config.authMode = UsergridEnums.UsergridAuthMode.NONE;
String[] segments = {client.getOrgId(), client.getAppId(), "users"};
UsergridRequest request = new UsergridRequest(UsergridEnums.UsergridHttpMethod.GET, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE,
client.getBaseUrl(), null, null, null, null, client.authForRequests(), segments);
client.sendRequest(request);
}
示例13: authenticateApp
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
public static void authenticateApp(@NotNull final UsergridClient client, @NotNull final UsergridResponseCallback responseCallback) {
(new UsergridAsyncTask(responseCallback) {
@Override
public UsergridResponse doTask() {
return client.authenticateApp();
}
}).execute();
}
示例14: authenticateUser
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
public static void authenticateUser(@NotNull final UsergridClient client, @NotNull final UsergridUserAuth userAuth, final boolean setAsCurrentUser, @NotNull final UsergridResponseCallback responseCallback) {
(new UsergridAsyncTask(responseCallback) {
@Override
public UsergridResponse doTask() {
return client.authenticateUser(userAuth,setAsCurrentUser);
}
}).execute();
}
示例15: resetPassword
import org.apache.usergrid.java.client.UsergridClient; //導入依賴的package包/類
public static void resetPassword(@NotNull final UsergridClient client, @NotNull final UsergridUser user, @NotNull final String oldPassword, @NotNull final String newPassword, @NotNull final UsergridResponseCallback responseCallback) {
(new UsergridAsyncTask(responseCallback) {
@Override
public UsergridResponse doTask() {
return client.resetPassword(user,oldPassword,newPassword);
}
}).execute();
}