当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionClass.COMMUNICATION属性代码示例

本文整理汇总了Java中com.vangav.backend.exceptions.VangavException.ExceptionClass.COMMUNICATION属性的典型用法代码示例。如果您正苦于以下问题:Java ExceptionClass.COMMUNICATION属性的具体用法?Java ExceptionClass.COMMUNICATION怎么用?Java ExceptionClass.COMMUNICATION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.vangav.backend.exceptions.VangavException.ExceptionClass的用法示例。


在下文中一共展示了ExceptionClass.COMMUNICATION属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProfilePictureAsync

/**
 * getProfilePictureAsync
 * BLOCKING method
 * gets a facebook user's profile picture from a previously issued async
 *   request
 * @param requestTrackingUuid
 * @return user's facebook profile picture in String format
 * @throws Exception
 */
public String getProfilePictureAsync (
  String requestTrackingUuid) throws Exception {
  
  if (this.futureDownloadResponses.containsKey(
        requestTrackingUuid) == false) {
    
    throw new CodeException(
      153,
      8,
      "Invalid request tracking id ["
      + requestTrackingUuid
      + "]",
      ExceptionClass.INVALID);
  }
  
  RestAsync restAsync =
    this.futureDownloadResponses.remove(requestTrackingUuid).get();
  
  if (restAsync.isResponseStatusSuccess() == true) {
    
    return restAsync.getRawResponseString();
  } else {
    
    throw new BadRequestException(
      153,
      9,
      "Couldn't get profile picture for user wit facebook user id ["
        + this.userId
        + "] and fb_access_token ["
        + this.accessToken
        + "], got http status code ["
        + restAsync.getResponseStatusCode()
        + "] and raw response ["
        + restAsync.getRawResponseString()
        + "]",
      ExceptionClass.COMMUNICATION);
  }
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:47,代码来源:FacebookGraph.java

示例2: getProfilePicture

/**
 * getProfilePicture
 * @param requestType - SYNC or ASYNC
 * @param pictureWidth
 * @return profile picture for SYNC requests and future response tracking id
 *           for ASYNC requests
 * @throws Exception
 */
private String getProfilePicture (
  RequestType requestType,
  int pictureWidth) throws Exception {
  
  CountDownLatch countDownLatch = new CountDownLatch(1);
  
  RestAsync restAsync =
    new RestAsync(
      countDownLatch,
      String.format(
        kGetUserProfilePicture,
        this.version,
        this.userId,
        pictureWidth) );
  
  ThreadPool.i().executeInRestClientPool(restAsync);
  
  if (requestType == RequestType.SYNC) {
    
    countDownLatch.await();
    
    if (restAsync.isResponseStatusSuccess() == true) {
      
      return restAsync.getRawResponseString();
    } else {
      
      throw new BadRequestException(
        153,
        10,
        "Couldn't get profile picture for user wit facebook user id ["
          + this.userId
          + "]",
        ExceptionClass.COMMUNICATION);
    }
  } else if (requestType == RequestType.ASYNC) {
    
    String uuid = UUID.randomUUID().toString();
    
    this.futureDownloadResponses.put(
      uuid,
      new FutureResponse<String>(countDownLatch, restAsync) );
    
    return uuid;
  }
  
  throw new CodeException(
    153,
    11,
    "Unhandled RequestType ["
      + requestType.toString()
      + "]",
    ExceptionClass.TYPE);
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:61,代码来源:FacebookGraph.java


注:本文中的com.vangav.backend.exceptions.VangavException.ExceptionClass.COMMUNICATION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。