Package org.brickred.socialauth.util

Examples of org.brickred.socialauth.util.Response


  private Profile getProfile() throws Exception {
    String presp;
    try {
      Map<String, String> hmap = new HashMap<String, String>();
      hmap.put("Accept", "application/vnd.com.runkeeper.Profile+json");
      Response response = authenticationStrategy.executeFeed(PROFILE_URL,
          MethodType.GET.toString(), null, hmap, null);
      presp = response.getResponseBodyAsString(Constants.ENCODING);
    } catch (Exception e) {
      throw new SocialAuthException("Error while getting profile from "
          + PROFILE_URL, e);
    }
    try {
View Full Code Here


  public Response api(final String url, final String methodType,
      final Map<String, String> params,
      final Map<String, String> headerParams, final String body)
      throws Exception {
    LOG.info("Calling api function for url  :  " + url);
    Response response = null;
    try {
      response = authenticationStrategy.executeFeed(url, methodType,
          params, headerParams, body);
    } catch (Exception e) {
      throw new SocialAuthException(
View Full Code Here

   * @throws Exception
   */
  @Override
  public List<Feed> getFeeds() throws Exception {
    LOG.info("Getting feeds from URL : " + FEED_URL);
    Response serviceResponse = null;
    List<Feed> list;
    try {
      serviceResponse = providerSupport.api(FEED_URL
          + providerSupport.getAccessGrant().getKey());
    } catch (Exception ie) {
      throw new SocialAuthException("Failed to retrieve the feeds from "
          + FEED_URL, ie);
    }

    if (serviceResponse.getStatus() != 200) {
      throw new SocialAuthException("Failed to retrieve the feeds from  "
          + FEED_URL + ". Staus :" + serviceResponse.getStatus());
    }
    Element root;
    try {
      root = XMLParseUtil.loadXmlResource(serviceResponse
          .getInputStream());
      list = getStatusFeed(root);

    } catch (Exception e) {
      throw new ServerDataException(
View Full Code Here

  private Profile getProfile() throws Exception {
    Profile profile = new Profile();
    String url = PROFILE_URL + accessToken.getAttribute("screen_name");
    LOG.debug("Obtaining user profile. Profile URL : " + url);
    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(url);
    } catch (Exception e) {
      throw new SocialAuthException(
          "Failed to retrieve the user profile from  " + url, e);
    }
    if (serviceResponse.getStatus() != 200) {
      throw new SocialAuthException(
          "Failed to retrieve the user profile from  " + url
              + ". Status :" + serviceResponse.getStatus());
    }
    String result;
    try {
      result = serviceResponse
          .getResponseBodyAsString(Constants.ENCODING);
      LOG.debug("User Profile :" + result);
    } catch (Exception exc) {
      throw new SocialAuthException("Failed to read response from  "
          + url, exc);
View Full Code Here

      message = message.substring(0, 140);
    }

    String url = UPDATE_STATUS_URL
        + URLEncoder.encode(message, Constants.ENCODING);
    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(url,
          MethodType.POST.toString(), null, null, null);
    } catch (Exception e) {
      throw new SocialAuthException("Failed to update status on " + url,
          e);
    }
    if (serviceResponse.getStatus() != 200) {
      throw new SocialAuthException("Failed to update status on " + url
          + ". Status :" + serviceResponse.getStatus());
    }
    return serviceResponse;
  }
View Full Code Here

    }
    String url = String.format(CONTACTS_URL,
        accessToken.getAttribute("screen_name"));
    List<Contact> plist = new ArrayList<Contact>();
    LOG.info("Fetching contacts from " + url);
    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(url);
    } catch (Exception ie) {
      throw new SocialAuthException(
          "Failed to retrieve the contacts from " + url, ie);
    }
    String result;
    try {
      result = serviceResponse
          .getResponseBodyAsString(Constants.ENCODING);
    } catch (Exception e) {
      throw new ServerDataException("Failed to get response from " + url);
    }
    LOG.debug("User friends ids : " + result);
View Full Code Here

      }
      strb.append(value);
    }
    String url = LOOKUP_URL + strb.toString();
    LOG.debug("Fetching info of following users : " + url);
    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(url);
    } catch (Exception ie) {
      throw new SocialAuthException(
          "Failed to retrieve the contacts from " + url, ie);
    }
    String result;
    try {
      result = serviceResponse
          .getResponseBodyAsString(Constants.ENCODING);
    } catch (Exception e) {
      throw new ServerDataException("Failed to get response from " + url,
          e);
    }
View Full Code Here

      throws Exception {
    if (!isVerify) {
      throw new SocialAuthException(
          "Please call verifyResponse function first to get Access Token");
    }
    Response response = null;
    LOG.debug("Calling URL : " + url);
    response = authenticationStrategy.executeFeed(url, methodType, params,
        headerParams, body);
    return response;
  }
View Full Code Here

          "Twitter supports only PNG, JPG and GIF image formats");
    }
    String fileNameParam = "media[]";
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", message);
    Response response = authenticationStrategy.uploadImage(
        IMAGE_UPLOAD_URL, MethodType.POST.toString(), map, null,
        fileName, inputStream, fileNameParam);
    LOG.info("Upload Image status::" + response.getStatus());
    return response;
  }
View Full Code Here

  public void setAccessGrant(final AccessGrant accessGrant)
      throws AccessTokenExpireException, SocialAuthException {
    this.accessGrant = accessGrant;
    authenticationStrategy.setAccessGrant(accessGrant);
    LOG.debug("Checking for token expiry");
    Response response = null;
    try {
      response = authenticationStrategy.executeFeed(PROFILE_URL);
    } catch (Exception e) {
      LOG.error("Unable to check token expire");
      LOG.error(e.getMessage());
View Full Code Here

TOP

Related Classes of org.brickred.socialauth.util.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.