domainStorageManager.addDomain(sd);
} catch(SecurityException sx){
log.error("Could not add remote security domain with name "+site.getName()+" for owner domain "+ownerDomainId);
throw new SSOException(SSOException.SITE_COULD_NOT_BE_CREATED,sx);
}
SecurityDomain storedDomain = domainAccessManager.getDomainByName(site.getName());
if (storedDomain == null || storedDomain.getDomainId() == null){
throw new SSOException(SSOException.SITE_COULD_NOT_BE_CREATED);
}
site.setSecurityDomainId(storedDomain.getDomainId());
try{
return ssoSiteManagerSPI.add(site);
} catch (SSOException se){
// catch SSO Exception to remove already stored domain.