use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class ServerConfigXMLAddServerViewBean method handleButton1Request.
/**
* Handles create server to server configuration XML request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
ServerSiteModel model = (ServerSiteModel) getModel();
String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
String serverGroupType = (String) getPageSessionAttribute(PG_ATTR_SERVER_GROUP_TYPE);
String name = (String) getDisplayFieldValue(TF_NAME);
name = name.trim();
String host = (String) getDisplayFieldValue(TF_HOST);
host = host.trim();
String port = (String) getDisplayFieldValue(TF_PORT);
port = port.trim();
String type = (String) getDisplayFieldValue(CHOICE_TYPE);
if ((name.length() > 0) && (port.length() > 0) && (host.length() > 0)) {
try {
ServerConfigXML xmlObj = model.getServerConfigObject(serverName);
ServerConfigXML.ServerGroup serverGroup = (serverGroupType.equals(DSConfigMgr.DEFAULT)) ? xmlObj.getDefaultServerGroup() : xmlObj.getSMSServerGroup();
serverGroup.addHost(name, host, port, type);
model.setServerConfigXML(serverName, xmlObj.toXML());
backTrail();
ServerConfigXMLViewBean vb = (ServerConfigXMLViewBean) getViewBean(ServerConfigXMLViewBean.class);
removePageSessionAttribute(PG_ATTR_SERVER_GROUP_TYPE);
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
} catch (ConfigurationException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
} else {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "serverconfig.create.server.missing.atributes");
forwardTo();
}
}
use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class AgentsModelImpl method setAttributeValues.
/**
* Modifies agent or agent group attribute values.
*
* @param universalId Universal ID of the agent/agent group.
* @param values attribute values of an agent or agent group.
* @throws AMConsoleException if object cannot located.
*/
public void setAttributeValues(String universalId, Map values) throws AMConsoleException {
String[] param = { universalId };
logEvent("ATTEMPT_SET_AGENT_ATTRIBUTE_VALUE", param);
try {
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
values.remove(IdConstants.AGENT_TYPE);
if (!isAgentGroup(universalId)) {
AgentConfiguration.validateAgentRootURLs(values);
}
amid.setAttributes(values);
amid.store();
logEvent("SUCCEED_SET_AGENT_ATTRIBUTE_VALUE", param);
} catch (ConfigurationException e) {
String[] paramsEx = { universalId, getErrorString(e) };
logEvent("EXCEPTION_SET_AGENT_ATTRIBUTE_VALUE", paramsEx);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] paramsEx = { universalId, getErrorString(e) };
logEvent("EXCEPTION_SET_AGENT_ATTRIBUTE_VALUE", paramsEx);
throw new AMConsoleException(getErrorString(e));
} catch (IdRepoException e) {
String[] paramsEx = { universalId, getErrorString(e) };
logEvent("EXCEPTION_SET_AGENT_ATTRIBUTE_VALUE", paramsEx);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class SitesResourceProvider method createInstance.
@Override
public Promise<ResourceResponse, ResourceException> createInstance(Context context, CreateRequest request) {
JsonValue content = request.getContent();
String id = request.getNewResourceId();
try {
id = validWriteOperation(content, id);
} catch (BadRequestException e) {
return e.asPromise();
}
String url = content.get(PRIMARY_URL).asString();
try {
SSOToken token = getSsoToken(context);
if (SiteConfiguration.isSiteExist(token, id)) {
return new ConflictException("Site with id already exists: " + id).asPromise();
}
SiteConfiguration.createSite(token, id, url, content.get(SECONDARY_URLS).asSet());
debug.message("Site created: {}", id);
return newResultPromise(getSite(token, id));
} catch (SMSException | SSOException | ConfigurationException e) {
debug.error("Could not create site", e);
return new InternalServerErrorException("Could not create site").asPromise();
} catch (NotFoundException e) {
return new InternalServerErrorException("Could not read site just created").asPromise();
}
}
use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class SitesResourceProvider method queryCollection.
@Override
public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler handler) {
if (!"true".equals(request.getQueryFilter().toString())) {
return new BadRequestException("Query only supports 'true' filter").asPromise();
}
try {
SSOToken token = getSsoToken(context);
Set<String> siteNames = SiteConfiguration.getSites(token);
for (String siteName : siteNames) {
handler.handleResource(getSite(token, siteName));
}
return newResultPromise(newQueryResponse());
} catch (SSOException | SMSException | ConfigurationException e) {
debug.error("Could not read sites", e);
return new InternalServerErrorException("Could not read sites").asPromise();
} catch (NotFoundException e) {
debug.error("Could not read site", e);
return new InternalServerErrorException("Could not read site we've just got name for").asPromise();
}
}
use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class SitesResourceProvider method readInstance.
@Override
public Promise<ResourceResponse, ResourceException> readInstance(Context context, String id, ReadRequest request) {
try {
SSOToken token = getSsoToken(context);
ResourceResponse site = getSite(token, id);
return newResultPromise(site);
} catch (SMSException | SSOException | ConfigurationException e) {
debug.error("Could not read site {}", id, e);
return new InternalServerErrorException("Could not read site").asPromise();
} catch (NotFoundException e) {
return e.asPromise();
}
}
Aggregations