Android Open Source - uppidy-android-sdk User Template






From Project

Back to project page uppidy-android-sdk.

License

The source code is released under:

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...

If you think the Android project uppidy-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.uppidy.android.sdk.api.impl;
//from   w  ww.  j  av  a2s.co m
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.codehaus.jackson.JsonNode;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import com.uppidy.android.sdk.api.ApiContactInfo;
import com.uppidy.android.sdk.api.ApiProfile;
import com.uppidy.android.sdk.api.UppidyApi;
import com.uppidy.android.sdk.api.UserOperations;

class UserTemplate extends AbstractUppidyOperations implements UserOperations {

  private final UppidyApi uppidyApi;
  
  public UserTemplate(UppidyApi uppidyApi, boolean isAuthorizedForUser) {
    super(isAuthorizedForUser);
    this.uppidyApi = uppidyApi;
  }

  public ApiProfile getUserProfile() {
    requireAuthorization();
    return getUserProfile("me");
  }

  public ApiProfile getUserProfile(String userId) {
    return uppidyApi.fetchObject(userId + "/profile", ApiProfile.class);
  }
  
  public byte[] getUserProfileImage(String imageType) {
    requireAuthorization();
    return getUserProfileImage("me", imageType);
  }
  
  public byte[] getUserProfileImage(String userId, String imageType) {
    return uppidyApi.fetchImage(userId, "picture", imageType);
  }

  public List<String> getUserPermissions() {
    JsonNode responseNode = uppidyApi.fetchObject("me/permissions", JsonNode.class);    
    return deserializePermissionsNodeToList(responseNode);
  }

  public List<ApiContactInfo> search(String query) {
    requireAuthorization();
    MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
    queryParams.add("query", query);
    return uppidyApi.fetchConnections("search", "user", ApiContactInfo.class, queryParams);
  }

  private List<String> deserializePermissionsNodeToList(JsonNode jsonNode) {
    JsonNode dataNode = jsonNode.get("data");      
    List<String> permissions = new ArrayList<String>();
    for (Iterator<JsonNode> elementIt = dataNode.getElements(); elementIt.hasNext(); ) {
      JsonNode permissionsElement = elementIt.next();
      for (Iterator<String> fieldNamesIt = permissionsElement.getFieldNames(); fieldNamesIt.hasNext(); ) {
        permissions.add(fieldNamesIt.next());
      }
    }      
    return permissions;
  }
}




Java Source Code List

com.uppidy.android.sdk.api.ApiAppInfo.java
com.uppidy.android.sdk.api.ApiBodyPartResource.java
com.uppidy.android.sdk.api.ApiBodyPart.java
com.uppidy.android.sdk.api.ApiContactInfo.java
com.uppidy.android.sdk.api.ApiContact.java
com.uppidy.android.sdk.api.ApiContainer.java
com.uppidy.android.sdk.api.ApiConversation.java
com.uppidy.android.sdk.api.ApiEntity.java
com.uppidy.android.sdk.api.ApiLocation.java
com.uppidy.android.sdk.api.ApiMessage.java
com.uppidy.android.sdk.api.ApiModifications.java
com.uppidy.android.sdk.api.ApiObject.java
com.uppidy.android.sdk.api.ApiProfile.java
com.uppidy.android.sdk.api.ApiSync.java
com.uppidy.android.sdk.api.BackupOperations.java
com.uppidy.android.sdk.api.FeedOperations.java
com.uppidy.android.sdk.api.UppidyApi.java
com.uppidy.android.sdk.api.Uppidy.java
com.uppidy.android.sdk.api.UserOperations.java
com.uppidy.android.sdk.api.impl.AbstractUppidyOperations.java
com.uppidy.android.sdk.api.impl.BackupTemplate.java
com.uppidy.android.sdk.api.impl.FeedTemplate.java
com.uppidy.android.sdk.api.impl.UppidyErrorHandler.java
com.uppidy.android.sdk.api.impl.UppidyTemplate.java
com.uppidy.android.sdk.api.impl.UserTemplate.java
com.uppidy.android.sdk.backup.BackupService.java
com.uppidy.android.sdk.backup.MessageProvider.java
com.uppidy.android.sdk.backup.NetworkStateListener.java
com.uppidy.android.sdk.connect.UppidyAdapter.java
com.uppidy.android.sdk.connect.UppidyConnectionFactory.java
com.uppidy.android.sdk.connect.UppidyOAuth2Template.java
com.uppidy.android.sdk.connect.UppidyServiceProvider.java
com.uppidy.android.util.StringUtil.java