本文整理汇总了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);
}
}
示例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);
}