* @throws Exception, RegistryException.
*/
public void proceedUpdateContact(String domain, String email, String confirmationKey)
throws Exception {
TenantManager tenantManager = Util.getTenantManager();
int tenantId;
try {
tenantId = tenantManager.getTenantId(domain);
} catch (UserStoreException e) {
String msg = "Error in adding tenant, tenant domain: " + domain + ".";
log.error(msg);
throw new RegistryException(msg, e);
}
UserRegistry superTenantSystemRegistry = Util.getGovernanceSystemRegistry(
MultitenantConstants.SUPER_TENANT_ID);
String emailVerificationPath =
StratosConstants.ADMIN_EMAIL_VERIFICATION_FLAG_PATH +
RegistryConstants.PATH_SEPARATOR + tenantId;
if (!superTenantSystemRegistry.resourceExists(emailVerificationPath)) {
// the confirmation key should exist,otherwise fail registraion
String msg = "The confirmationKey doesn't exist in service.";
log.error(msg);
throw new RegistryException(msg);
}
Resource resource = superTenantSystemRegistry.get(emailVerificationPath);
String actualConfirmationKey = null;
Object content = resource.getContent();
if (content instanceof String) {
actualConfirmationKey = (String) content;
} else if (content instanceof byte[]) {
actualConfirmationKey = new String((byte[]) content);
}
if (actualConfirmationKey == null || !actualConfirmationKey.equals(confirmationKey)) {
// validation will fail.
String msg = "The email confirmation key is not matching";
log.error(msg);
throw new RegistryException(msg);
}
resource.setProperty(email, "true");
// now we will really update the tenant email
Tenant tenant;
try {
tenant = tenantManager.getTenant(tenantId);
} catch (UserStoreException e) {
String msg =
"Error in retrieving the tenant information for the tenant id: " + tenantId +
".";
log.error(msg, e);
throw new RegistryException(msg, e);
}
// If TenantActivation is moderated, the mail address associated with the validation link
// would not be the tenant email. Otherwise, the validation mail would be the tenant email.
if (!CommonUtil.isTenantActivationModerated()) {
tenant.setEmail(email);
}
try {
tenantManager.updateTenant(tenant);
} catch (UserStoreException e) {
String msg =
"Error in updating the tenant information for the tenant id: " + tenantId + ".";
log.error(msg, e);
throw new RegistryException(msg, e);
}
// activate the tenant on successful validation of the email, if it is not already activated.
if ("false".equals(resource.getProperty(StratosConstants.IS_EMAIL_VALIDATED))) {
tenantManager.activateTenant(tenantId);
// set the registry flag
resource.editPropertyValue(StratosConstants.IS_EMAIL_VALIDATED, "false", "true");
if (log.isDebugEnabled()) {
log.debug("Tenant : " + tenantId + " is activated after validating the " +