use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class ServerSiteModelImpl method createServer.
/**
* Creates a server.
*
* @param name Name of Server.
* @throws AMConsoleException if error occurs when creating server.
*/
public void createServer(String name) throws AMConsoleException {
SSOToken ssoToken = getUserSSOToken();
String[] param = { name };
logEvent("ATTEMPT_CREATE_SERVER", param);
try {
String svrConfigXML = ServerConfiguration.getServerConfigXML(ssoToken, SystemProperties.getServerInstanceName());
ServerConfiguration.createServerInstance(ssoToken, name, Collections.EMPTY_MAP, svrConfigXML);
logEvent("SUCCEED_CREATE_SERVER", param);
} catch (UnknownPropertyNameException e) {
// this will not happen because we do not set any property during
// creation.
} catch (SSOException e) {
String[] params = { name, e.getMessage() };
logEvent("SSO_EXCEPTION_CREATE_SERVER", params);
throw new AMConsoleException(getErrorString(e));
} catch (ConfigurationException e) {
String[] params = { name, e.getMessage() };
logEvent("CONFIGURATION_EXCEPTION_CREATE_SERVER", params);
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
String[] params = { name, e.getMessage() };
logEvent("SMS_EXCEPTION_CREATE_SITE", params);
throw new AMConsoleException(getErrorString(e));
} catch (IOException e) {
String[] params = { name, e.getMessage() };
logEvent("IO_EXCEPTION_CREATE_SERVER", params);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class ServerSiteModelImpl method deleteSites.
/**
* Deletes a set of sites.
*
* @param sites Set of of sites to be deleted.
* @throws AMConsoleException if error occurs when getting the site name.
*/
public void deleteSites(Set sites) throws AMConsoleException {
String siteName = null;
try {
if ((sites != null) && !sites.isEmpty()) {
SSOToken token = getUserSSOToken();
for (Iterator i = sites.iterator(); i.hasNext(); ) {
siteName = (String) i.next();
String[] param = { siteName };
logEvent("ATTEMPT_DELETE_SITE", param);
SiteConfiguration.deleteSite(token, siteName);
logEvent("SUCCEED_DELETE_SITE", param);
}
}
} catch (ConfigurationException e) {
String[] params = { siteName, e.getMessage() };
logEvent("SMS_EXCEPTION_DELETE_SITE", params);
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
String[] params = { siteName, e.getMessage() };
logEvent("SMS_EXCEPTION_DELETE_SITE", params);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] params = { siteName, e.getMessage() };
logEvent("SSO_EXCEPTION_DELETE_SITE", params);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class ServerSiteModelImpl method updateServerConfigInheritance.
/**
* Updates server property inheritance settings.
*
* @param serverName Name of server.
* @param toInherit Properties to inherit.
* @param notToInherit Properties not to inherit.
* @throws AMConsoleException if server profile cannot be updated.
*/
public void updateServerConfigInheritance(String serverName, Set toInherit, Set notToInherit) throws AMConsoleException {
String[] param = { serverName };
logEvent("ATTEMPT_MODIFY_SERVER_INHERITANCE", param);
try {
SSOToken ssoToken = getUserSSOToken();
Map defaultValues = ServerConfiguration.getDefaults(ssoToken);
Map svrProperties = ServerConfiguration.getServerInstance(ssoToken, serverName);
if ((toInherit != null) && !toInherit.isEmpty()) {
Set toRemove = new HashSet();
for (Iterator i = toInherit.iterator(); i.hasNext(); ) {
String name = (String) i.next();
if (svrProperties.containsKey(name)) {
toRemove.add(name);
}
}
if (!toRemove.isEmpty()) {
ServerConfiguration.removeServerConfiguration(ssoToken, serverName, toRemove);
}
}
if ((notToInherit != null) && !notToInherit.isEmpty()) {
Map toAdd = new HashMap();
for (Iterator i = notToInherit.iterator(); i.hasNext(); ) {
String name = (String) i.next();
if (!svrProperties.containsKey(name)) {
toAdd.put(name, defaultValues.get(name));
}
}
if (!toAdd.isEmpty()) {
try {
ServerConfiguration.setServerInstance(ssoToken, serverName, toAdd);
} catch (UnknownPropertyNameException ex) {
// ignore, this cannot happen because default values
// would have all valid property names
}
}
}
logEvent("SUCCEED_MODIFY_SERVER_INHERITANCE", param);
} catch (ConfigurationException e) {
String[] params = { serverName, e.getMessage() };
logEvent("CONFIGURATION_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
throw new AMConsoleException(getErrorString(e));
} catch (IOException e) {
String[] params = { serverName, e.getMessage() };
logEvent("IO_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
String[] params = { serverName, e.getMessage() };
logEvent("SMS_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] params = { serverName, e.getMessage() };
logEvent("SSO_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class ServerSiteModelImpl method modifySite.
/**
* Modifies site profile.
*
* @param siteName name of site.
* @param primaryURL Primary URL.
* @param failoverURLs Failover URLs.
* @throws AMConsoleException if site profile cannot be modified.
*/
public void modifySite(String siteName, String primaryURL, Set failoverURLs) throws AMConsoleException {
try {
SSOToken ssoToken = getUserSSOToken();
String[] param = { siteName };
logEvent("ATTEMPT_MODIFY_SITE", param);
SiteConfiguration.setSitePrimaryURL(ssoToken, siteName, primaryURL);
SiteConfiguration.setSiteSecondaryURLs(ssoToken, siteName, failoverURLs);
logEvent("SUCCEED_MODIFY_SITE", param);
} catch (ConfigurationException e) {
String[] params = { siteName, e.getMessage() };
logEvent("CONFIGURATION_EXCEPTION_MODIFY_SITE", params);
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
String[] params = { siteName, e.getMessage() };
logEvent("SMS_EXCEPTION_MODIFY_SITE", params);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] params = { siteName, e.getMessage() };
logEvent("SSO_EXCEPTION_MODIFY_SITE", params);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class AgentsModelImpl method createAgentLocal.
/**
* Creates localized agent.
*
* @param realmName Realm where agent resides.
* @param name Name of agent.
* @param type Type of agent.
* @param password Password of agent.
* @param agentURL Agent URL.
* @throws AMConsoleException if agent cannot be created.
*/
public void createAgentLocal(String realmName, String name, String type, String password, String agentURL) throws AMConsoleException {
String[] params = { realmName, name, type };
try {
logEvent("ATTEMPT_CREATE_AGENT", params);
Map map = AgentConfiguration.getDefaultValues(type, false);
Set set = new HashSet(2);
map.put(AgentConfiguration.ATTR_NAME_PWD, set);
set.add(password);
Set newset = new HashSet(2);
newset.add(AgentConfiguration.VAL_CONFIG_REPO_LOCAL);
map.put(AgentConfiguration.ATTR_CONFIG_REPO, newset);
AgentConfiguration.createAgentLocal(getUserSSOToken(), realmName, name, type, map, agentURL);
logEvent("SUCCEED_CREATE_AGENT", params);
} catch (ConfigurationException e) {
String[] paramsEx = { realmName, name, type, getErrorString(e) };
logEvent("EXCEPTION_CREATE_AGENT", paramsEx);
debug.warning("AgentsModelImpl.createAgent", e);
throw new AMConsoleException(getErrorString(e));
} catch (MalformedURLException e) {
String[] paramsEx = { realmName, name, type, getErrorString(e) };
logEvent("EXCEPTION_CREATE_AGENT", paramsEx);
debug.warning("AgentsModelImpl.createAgent", e);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] paramsEx = { realmName, name, type, getErrorString(e) };
logEvent("EXCEPTION_CREATE_AGENT", paramsEx);
debug.warning("AgentsModelImpl.createAgent", e);
throw new AMConsoleException(getErrorString(e));
} catch (IdRepoException e) {
String[] paramsEx = { realmName, name, type, getErrorString(e) };
logEvent("EXCEPTION_CREATE_AGENT", paramsEx);
debug.warning("AgentsModelImpl.createAgent", e);
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
String[] paramsEx = { realmName, name, type, getErrorString(e) };
logEvent("EXCEPTION_CREATE_AGENT", paramsEx);
debug.warning("AgentsModelImpl.createAgent", e);
throw new AMConsoleException(getErrorString(e));
}
}
Aggregations