use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class ResponseProviderEditViewBean method handleButton1Request.
private void handleButton1Request(CachedPolicy cachedPolicy) throws ModelControlException {
ResponseProvider deleted = null;
submitCycle = true;
String origName = (String) getPageSessionAttribute(EDIT_RESPONSEPROVIDER_NAME);
Policy policy = cachedPolicy.getPolicy();
try {
ResponseProvider provider = createResponseProvider();
if (provider != null) {
String name = (String) propertySheetModel.getValue(RESPONSEPROVIDER_NAME);
if (origName.equals(name)) {
policy.replaceResponseProvider(name, provider);
} else {
deleted = policy.removeResponseProvider(origName);
policy.addResponseProvider(name, provider);
}
deleted = null;
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.responseProvider.updated");
cachedPolicy.setPolicyModified(true);
}
} catch (NameAlreadyExistsException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (NameNotFoundException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
} finally {
if (deleted != null) {
try {
policy.addResponseProvider(origName, deleted);
} catch (NameAlreadyExistsException e) {
debug.warning("ResponseProviderEditViewBean.handleButton1Request", e);
}
}
}
forwardTo();
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class ResponseProviderOpViewBeanBase method createResponseProvider.
protected ResponseProvider createResponseProvider() throws ModelControlException, AMConsoleException {
ResponseProvider provider = null;
String providerType = (String) propertySheetModel.getValue(RESPONSEPROVIDER_TYPE);
String providerName = getResponseProviderName();
if (providerName != null) {
Map values = getValues(providerType);
if (values != null) {
provider = createResponseProvider(providerType, values);
}
}
return provider;
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class ResponseProviderTypeManager method getResponseProvider.
/**
* Returns an instance of the <code>ResponseProvider</code>
* given the response provider type name.
*
* @param responseProviderTypeName response provider type name.
* @return an instance of the <code>ResponseProvider</code>
* given the response provider type name.
* @throws NameNotFoundException if the <code>ResponseProvider</code>
* not found
* @throws PolicyException for any other abnormal condition
*/
public ResponseProvider getResponseProvider(String responseProviderTypeName) throws NameNotFoundException, PolicyException {
PluginSchema ps = PolicyManager.getPluginSchema(RESPONSE_PROVIDER, responseProviderTypeName);
if (ps == null) {
throw (new NameNotFoundException(ResBundleUtils.rbName, "invalid_response_provider", null, responseProviderTypeName, PolicyException.RESPONSE_PROVIDER_COLLECTION));
}
// Construct the object
ResponseProvider respProvider = null;
try {
String className = ps.getClassName();
respProvider = (ResponseProvider) Class.forName(className).newInstance();
} catch (Exception e) {
throw (new PolicyException(e));
}
respProvider.initialize(pm.getPolicyConfig());
return respProvider;
}
use of com.sun.identity.policy.interfaces.ResponseProvider in project OpenAM by OpenRock.
the class ResponseProviders method clone.
/**
* Returns a deep copy of this object with the identical
* set of <code>ResponseProvider</code> objects
*
* @return a deep copy of this object
*/
public Object clone() {
ResponseProviders answer = null;
try {
answer = (ResponseProviders) super.clone();
} catch (CloneNotSupportedException se) {
answer = new ResponseProviders();
}
answer.name = name;
answer.description = description;
answer.providers = new HashMap();
Iterator items = providers.keySet().iterator();
while (items.hasNext()) {
Object item = items.next();
ResponseProvider responseProvider = (ResponseProvider) providers.get(item);
answer.providers.put(item, responseProvider.clone());
}
return (answer);
}
Aggregations