String nsid = user.attributeValue("nsid");
String fullname = user.attributeValue("fullname");
String token = document.selectSingleNode("rsp/auth/token/text()").getStringValue();
Connector flickrConnector = Connector.getConnector("flickr");
ApiKey apiKey;
if (request.getSession().getAttribute(FLICKR_RENEWTOKEN_APIKEYID)!=null) {
final String apiKeyIdString = (String)request.getSession().getAttribute(FLICKR_RENEWTOKEN_APIKEYID);
long apiKeyId = Long.valueOf(apiKeyIdString);
apiKey = guestService.getApiKey(apiKeyId);
} else
apiKey = guestService.createApiKey(guest.getId(), flickrConnector);
guestService.populateApiKey(apiKey.getId());
guestService.setApiKeyAttribute(apiKey, "username", username);
guestService.setApiKeyAttribute(apiKey, "token", token);
guestService.setApiKeyAttribute(apiKey, "nsid", nsid);
guestService.setApiKeyAttribute(apiKey, "fullname", fullname);
if (request.getSession().getAttribute(FLICKR_RENEWTOKEN_APIKEYID)!=null) {
request.getSession().removeAttribute(FLICKR_RENEWTOKEN_APIKEYID);
return "redirect:/app/tokenRenewed/flickr";
}
return "redirect:/app/from/"+flickrConnector.getName();
}