}
if (domainUser == null) {
// Registration
RegistrationToken token = null;
// 5 cases:
// - token is ready with both OAUTH + SIGNED - send registration url
// - token is ready for SIGNED and only SIGNED is needed - send
// registration url
// - token is already SIGNED created - send do to OAUTH
// - token is OAUTH created and id in the session - update SIGNED and
// send registration url
// - token is null. send request failed
String tokenId = null;
if (platformRequestWrapper.getRegistrationTokenId() != null) {
tokenId = platformRequestWrapper.getRegistrationTokenId();
try {
token = RegistrationTokenUtils.updateTokenForOpenSocial(
tokenId,
platformRequestWrapper.getOpenSocialViewerId(),
platformRequestWrapper.getOpenSocialConsumerKey());
} catch (Exception e) {
printStackTrace(e);
}
}
if (token == null) {
try {
token = RegistrationTokenUtils
.createNew(platformRequestWrapper);
platformRequestWrapper.getSession().setAttribute(SharedConstants.registrationTokenParamName,token.getTokenID());
} catch (Exception e) {
log.warning(e.getMessage());
}
}
if(token ==null)
log.warning("token is null we have a problem");
else if (token.isTokenReady())
jsonResponse.addCustomFieldError(
SharedConstants.registrationTokenParamName,
token.getTokenID());
else if (token.isOpenSocialReady() && userRegistrationMethod.equalsIgnoreCase(SharedConstants.registrationMethodSigned))
jsonResponse.addCustomFieldError(
SharedConstants.registrationTokenParamName,
token.getTokenID());
else if (!token.isOauthReady()){
jsonResponse.addCustomFieldError(
SharedConstants.registrationTokenParamName,
token.getTokenID());
jsonResponse.addCustomFieldError(SharedConstants.registrationProcessParamName, SharedConstants.registrationDoOAuth);
}
else
token =null;