use of com.sun.identity.console.policy.model.CachedPolicy in project OpenAM by OpenRock.
the class RuleAddViewBean method handleButton2Request.
/**
* Handles create policy request.
*
* @param event Request invocation event
*/
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
Rule rule = createRule();
if (rule != null) {
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
policy.addRule(rule);
backTrail();
cachedPolicy.setPolicyModified(true);
forwardToPolicyViewBean();
} catch (NameAlreadyExistsException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
forwardTo();
} catch (InvalidNameException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
forwardTo();
} catch (AMConsoleException e) {
debug.warning("RuleAddViewBean.handleButton2Request", e);
redirectToStartURL();
}
} else {
forwardTo();
}
}
use of com.sun.identity.console.policy.model.CachedPolicy in project OpenAM by OpenRock.
the class RuleOpViewBeanBase method initialize.
protected void initialize() {
if (!initialized) {
try {
CachedPolicy cachedPolicy = getCachedPolicy();
if (cachedPolicy != null) {
super.initialize();
createPropertyModel();
createTableModels();
registerChildren();
initialized = true;
}
} catch (AMConsoleException e) {
debug.warning("RuleOpViewBeanBase.initialize", e);
//NO-OP
}
}
}
use of com.sun.identity.console.policy.model.CachedPolicy in project OpenAM by OpenRock.
the class RuleEditViewBean method handleButton1Request.
/**
* Handles create policy request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
boolean forwarded = false;
Rule rule = createRule();
if (rule != null) {
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
String origRuleName = (String) getPageSessionAttribute(EDIT_RULE_NAME);
policy.removeRule(origRuleName);
policy.addRule(rule);
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.rule.updated");
cachedPolicy.setPolicyModified(true);
} catch (NameAlreadyExistsException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (InvalidNameException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (AMConsoleException e) {
debug.warning("RuleEditViewBean.handleButton1Request", e);
redirectToStartURL();
forwarded = true;
}
}
if (!forwarded) {
forwardTo();
}
}
use of com.sun.identity.console.policy.model.CachedPolicy 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.console.policy.model.CachedPolicy in project OpenAM by OpenRock.
the class PolicyReferralAddViewBean method handleButton1Request.
/**
* Handles create policy request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
String currentRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
try {
if (reconstructPolicy()) {
// error message set in PolicyOpViewBeanBase
forwardTo();
} else {
CachedPolicy cachedPolicy = getCachedPolicy();
PolicyModel model = (PolicyModel) getModel();
String name = cachedPolicy.getPolicy().getName();
if (name.equals(model.getLocalizedString("policy.create.name"))) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getLocalizedString("policy.name.change"));
forwardTo();
} else {
try {
model.createPolicy(currentRealm, cachedPolicy.getPolicy());
backTrail();
forwardToPolicyViewBean();
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
}
}
} catch (AMConsoleException e) {
redirectToStartURL();
}
}
Aggregations