Package org.brickred.socialauth.exception

Examples of org.brickred.socialauth.exception.SocialAuthException


   */
  @Override
  public List<Contact> getContactList() throws Exception {
    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;
View Full Code Here


      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);
    try {
      serviceResponse = authenticationStrategy.executeFeed(url,
          methodType, params, headerParams, body);
    } catch (Exception ie) {
      throw new SocialAuthException(
          "Error while making request to URL : " + url, ie);
    }
    return serviceResponse;
  }
View Full Code Here

  @Override
  public Response uploadImage(final String message, final String fileName,
      final InputStream inputStream) throws Exception {
    LOG.warn("WARNING: Not implemented for Google");
    throw new SocialAuthException(
        "Update Status is not implemented for Google");
  }
View Full Code Here

    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
View Full Code Here

    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);
    }
    try {
      JSONObject pObj = new JSONObject(result);
      if (pObj.has("id_str")) {
View Full Code Here

   */
  @Override
  public Response updateStatus(final String msg) throws Exception {
    LOG.info("Updatting status " + msg);
    if (!isVerify) {
      throw new SocialAuthException(
          "Please call verifyResponse function first to get Access Token");
    }
    if (msg == null || msg.trim().length() == 0) {
      throw new ServerDataException("Status cannot be blank");
    }
    String message = msg;
    if (message.length() > 140) {
      LOG.debug("Truncating message up to 140 characters");
      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

   *         name and profile URL will be available
   */
  @Override
  public List<Contact> getContactList() throws Exception {
    if (!isVerify) {
      throw new SocialAuthException(
          "Please call verifyResponse function first to get Access Token");
    }
    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
View Full Code Here

    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
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 {
    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,
View Full Code Here

  @Override
  public Response uploadImage(final String message, final String fileName,
      final InputStream inputStream) throws Exception {
    LOG.info("Uploading Image :: " + fileName + ", message :: " + message);
    if (!IMAGE_FILE_PATTERN.matcher(fileName).find()) {
      throw new SocialAuthException(
          "Twitter supports only PNG, JPG and GIF image formats");
    }
    String fileNameParam = "media[]";
    Map<String, String> map = new HashMap<String, String>();
    map.put("status", message);
View Full Code Here

TOP

Related Classes of org.brickred.socialauth.exception.SocialAuthException

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.