Package org.brickred.socialauth.util

Examples of org.brickred.socialauth.util.Response


  @Override
  public Response api(final String url, final String methodType,
      final Map<String, String> params,
      final Map<String, String> headerParams, final String body)
      throws Exception {
    Response response = null;
    LOG.debug("Calling URL : " + url);
    try {
      response = authenticationStrategy.executeFeed(url, methodType,
          params, headerParams, body);
    } catch (Exception e) {
View Full Code Here


   */

  @Override
  public List<Contact> getContactList() throws Exception {
    LOG.info("Fetching contacts from " + CONNECTION_URL);
    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(CONNECTION_URL
          + authenticationStrategy.getAccessGrant().getKey());
    } catch (Exception ie) {
      throw new SocialAuthException(
          "Failed to retrieve the contacts from " + CONNECTION_URL,
          ie);
    }
    Element root;
    try {
      root = XMLParseUtil.loadXmlResource(serviceResponse
          .getInputStream());
    } catch (Exception e) {
      throw new ServerDataException(
          "Failed to parse the contacts from response."
              + CONNECTION_URL, e);
View Full Code Here

    message = message.replace("&", "&amp;");
    LOG.info("Updating status " + message + " on " + UPDATE_STATUS_URL);
    Map<String, String> headerParams = new HashMap<String, String>();
    headerParams.put("Content-Type", "text/xml;charset=UTF-8");
    String msgBody = String.format(STATUS_BODY, message);
    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(
          UPDATE_STATUS_URL
              + authenticationStrategy.getAccessGrant().getKey(),
          MethodType.POST.toString(), null, headerParams, msgBody);
    } catch (Exception ie) {
      throw new SocialAuthException("Failed to update status on "
          + UPDATE_STATUS_URL, ie);
    }
    LOG.debug("Status Updated and return status code is : "
        + serviceResponse.getStatus());
    // return 201
    return serviceResponse;
  }
View Full Code Here

  }

  private Profile getProfile() throws Exception {
    LOG.debug("Obtaining user profile");
    Profile profile = new Profile();
    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(PROFILE_URL
          + authenticationStrategy.getAccessGrant().getKey());
    } catch (Exception e) {
      throw new SocialAuthException(
          "Failed to retrieve the user profile from  " + PROFILE_URL,
          e);
    }
    if (serviceResponse.getStatus() != 200) {
      throw new SocialAuthException(
          "Failed to retrieve the user profile from  " + PROFILE_URL
              + ". Staus :" + serviceResponse.getStatus());
    }

    Element root;
    try {
      root = XMLParseUtil.loadXmlResource(serviceResponse
          .getInputStream());
    } catch (Exception e) {
      throw new ServerDataException(
          "Failed to parse the profile from response." + PROFILE_URL,
          e);
View Full Code Here

   * @return List of feed
   * @throws Exception
   */
  @Override
  public List<Feed> getFeeds() throws Exception {
    Response response = null;
    List<Feed> list = new ArrayList<Feed>();
    LOG.info("Getting feeds from URL : " + FEED_URL);
    try {
      response = providerSupport.api(FEED_URL);
      String respStr = response
          .getResponseBodyAsString(Constants.ENCODING);
      LOG.debug("Feeds json string :: " + respStr);
      JSONArray jarr = new JSONArray(respStr);
      LOG.debug("Feeds count :: " + jarr.length());
      for (int i = 0; i < jarr.length(); i++) {
View Full Code Here

    String profileUrl = String
        .format(PROFILE_URL, accessToken.getAttribute("user_nsid"),
            config.get_consumerKey());

    LOG.info("Obtaining user profile. Profile URL : " + profileUrl);
    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(profileUrl);
    } catch (Exception e) {
      throw new SocialAuthException(
          "Failed to retrieve the user profile from  " + profileUrl,
          e);
    }
    if (serviceResponse.getStatus() != 200) {
      throw new SocialAuthException(
          "Failed to retrieve the user profile from  " + profileUrl
              + ". Status :" + serviceResponse.getStatus());
    }

    Element root;
    try {
      root = XMLParseUtil.loadXmlResource(serviceResponse
          .getInputStream());
    } catch (Exception e) {
      throw new ServerDataException(
          "Failed to parse the profile from response." + profileUrl,
          e);
View Full Code Here

    String contactUrl = String
        .format(CONTACT_URL, accessToken.getAttribute("user_nsid"),
            config.get_consumerKey());

    LOG.info("Obtaining user contacts. Contact URL : " + contactUrl);
    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(contactUrl);
    } catch (Exception e) {
      throw new SocialAuthException("Failed to retrieve contacts from  "
          + contactUrl, e);
    }
    if (serviceResponse.getStatus() != 200) {
      throw new SocialAuthException("Failed to retrieve contacts from  "
          + contactUrl + ". Status :" + serviceResponse.getStatus());
    }
    String result;
    try {
      result = serviceResponse
          .getResponseBodyAsString(Constants.ENCODING);
    } catch (Exception exc) {
      throw new SocialAuthException("Failed to read response from  "
          + contactUrl, exc);
    }
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

    LOG.info("Fetching contacts from " + CONTACTS_FEED_URL);
    if (Permission.AUTHENTICATE_ONLY.equals(this.scope)) {
      throw new SocialAuthException(
          "You have not set Permission to get contacts.");
    }
    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy
          .executeFeed(CONTACTS_FEED_URL);
    } catch (Exception ie) {
      throw new SocialAuthException(
          "Failed to retrieve the contacts from " + CONTACTS_FEED_URL,
          ie);
    }
    List<Contact> plist = new ArrayList<Contact>();
    Element root;

    try {
      root = XMLParseUtil.loadXmlResource(serviceResponse
          .getInputStream());
    } catch (Exception e) {
      throw new ServerDataException(
          "Failed to parse the contacts from response."
              + CONTACTS_FEED_URL, e);
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 {

    Response serviceResponse = null;
    if (!MethodType.GET.toString().equals(methodType)) {
      throw new SocialAuthException(
          "Only GET method is implemented in Google API function");
    }
    LOG.debug("Calling URL : " + url);
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.