本文整理汇总了Java中org.springframework.social.ApiException类的典型用法代码示例。如果您正苦于以下问题:Java ApiException类的具体用法?Java ApiException怎么用?Java ApiException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApiException类属于org.springframework.social包,在下文中一共展示了ApiException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retreiveSocialAsUser
import org.springframework.social.ApiException; //导入依赖的package包/类
private User retreiveSocialAsUser(Connection<?> con) {
if (con == null) throw new IllegalStateException("No connection to social api");
// build a new User from the external provider's version of the User
UserProfile profile = con.fetchUserProfile();
String firstName = profile.getFirstName();
String lastName = profile.getLastName();
String email = profile.getEmail();
// build the UserAccountExternal from the ConnectionKey
String externalAccountProviderName = con.getKey().getProviderId();
ExternalProvider externalProvider = ExternalProvider.caseInsensitiveValueOf(externalAccountProviderName);
String externalUserId = con.getKey().getProviderUserId();
// check that we got the information we needed
if (StringUtils.isBlank(email))
throw new ApiException(externalAccountProviderName, "provider failed to return email");
User socialUser = new User(firstName, lastName, email, externalProvider, externalUserId);
log.debug("Retrieved details from {} for user '{}'", externalAccountProviderName, externalUserId);
return socialUser;
}
示例2: getDocsService
import org.springframework.social.ApiException; //导入依赖的package包/类
private DocsService getDocsService(Connection<GoogleDocs> connection)
{
DocsService docsService = null;
try
{
docsService = connection.getApi().setAuthentication(new DocsService(GoogleDocsConstants.APPLICATION_NAME));
}
catch (ApiException apie)
{
throw apie;
}
log.debug("Google Docs Client initiated");
return docsService;
}
示例3: test
import org.springframework.social.ApiException; //导入依赖的package包/类
@Override
public boolean test(Twitter twitter) {
try {
twitter.userOperations().getUserProfile();
return true;
} catch (ApiException e) {
log.error("Error during twitter API test", e);
return false;
}
}
示例4: setConnectionValues
import org.springframework.social.ApiException; //导入依赖的package包/类
@Override
public void setConnectionValues(GitlabAPI gitlab, ConnectionValues values) {
try {
GitlabUser gitlabUser = gitlab.getUser();
values.setProviderUserId(Long.toString(gitlabUser.getId()));
values.setDisplayName(gitlabUser.getUsername());
values.setImageUrl(gitlabUser.getAvatarUrl());
} catch (IOException e) {
throw new ApiException("gitlab?", "Could not fetch current user.", e);
}
}
示例5: fetchUserProfile
import org.springframework.social.ApiException; //导入依赖的package包/类
@Override
public UserProfile fetchUserProfile(GitlabAPI gitlab) {
try {
GitlabUser gitlabUser = gitlab.getUser();
return new UserProfileBuilder()
.setEmail(gitlabUser.getEmail())
.setName(gitlabUser.getName())
.setUsername(gitlabUser.getUsername())
.build();
} catch (IOException e) {
throw new ApiException("gitlab?", "Could not fetch current user.", e);
}
}
示例6: test
import org.springframework.social.ApiException; //导入依赖的package包/类
@Override
public boolean test(Yahoo2 yahoo) {
try {
return true;
} catch (ApiException e) {
return false;
}
}
示例7: test
import org.springframework.social.ApiException; //导入依赖的package包/类
@Override
public boolean test(Kakao kakao) {
try {
kakao.userOperations().isStoryUser();
return true;
} catch (ApiException e) {
return false;
}
}
示例8: test
import org.springframework.social.ApiException; //导入依赖的package包/类
@Override
public boolean test(KeyRock keyRock) {
boolean res = false;
try {
keyRock.userOperations().getUserProfile();
res = true;
} catch (ApiException e) {
}
return res;
}
示例9: test
import org.springframework.social.ApiException; //导入依赖的package包/类
public boolean test(Flickr flickr)
{
try
{
flickr.test();
return true;
}
catch (ApiException e)
{
return false;
}
}
示例10: test
import org.springframework.social.ApiException; //导入依赖的package包/类
public boolean test(TencentWeibo tencentWeibo) {
try {
return true;
} catch (ApiException e) {
return false;
}
}
示例11: test
import org.springframework.social.ApiException; //导入依赖的package包/类
@Override
public boolean test(Battlenet api) {
try {
api.accountOperations().getAccountId();
return true;
} catch (ApiException apiException) {
return false;
}
}
示例12: test
import org.springframework.social.ApiException; //导入依赖的package包/类
public boolean test(Reddit reddit) {
try {
reddit.userOperations().getUserProfile();
return true;
} catch (ApiException e) {
return false;
}
}
示例13: test
import org.springframework.social.ApiException; //导入依赖的package包/类
@Override
public boolean test(Meetup meetup) {
try {
meetup.memberOperations().getDetails();
return true;
} catch(ApiException ex) {
return false;
}
}
示例14: postConnect
import org.springframework.social.ApiException; //导入依赖的package包/类
public void postConnect(Connection<Facebook> connection, WebRequest request) {
if (request.getAttribute(POST_TO_WALL_ATTRIBUTE, WebRequest.SCOPE_SESSION) != null) {
try {
connection.updateStatus("I've connected with the Spring Social Showcase!");
} catch (ApiException e) {
// Do nothing: No need to break down if the post-connect post can't be made.
}
request.removeAttribute(POST_TO_WALL_ATTRIBUTE, WebRequest.SCOPE_SESSION);
}
}
示例15: test
import org.springframework.social.ApiException; //导入依赖的package包/类
@Override
public boolean test(Box api) {
try {
api.userOperations().getUserProfile();
return true;
} catch (ApiException e) {
return false;
}
}