OSEOAuth2Store.LOG.entering(OSEOAuth2Store.LOG_CLASS, "getToken", new Object[] {
gadgetUri, serviceName, user, scope, type });
}
final String processedGadgetUri = this.getGadgetUri(user, gadgetUri, serviceName);
OAuth2Token token = this.cache.getToken(processedGadgetUri, serviceName, user, scope, type);
if (token == null) {
try {
token = this.persister.findToken(processedGadgetUri, serviceName, user, scope, type);
if (token != null) {
synchronized (token) {
try {
token.setGadgetUri(processedGadgetUri);
this.cache.storeToken(token);
} finally {
token.setGadgetUri(gadgetUri);
}
}
}
} catch (final OAuth2PersistenceException e) {
throw new GadgetException(Code.OAUTH_STORAGE_ERROR, "Error loading OAuth2 token", e);