use of com.sun.identity.policy.NameAlreadyExistsException in project OpenAM by OpenRock.
the class ReferralEditViewBean method handleButton1Request.
private void handleButton1Request(CachedPolicy cachedPolicy) throws ModelControlException {
Referral deleted = null;
String origName = (String) getPageSessionAttribute(EDIT_REFERRAL_NAME);
Policy policy = cachedPolicy.getPolicy();
try {
Referral referral = createReferral();
if (referral != null) {
String name = (String) propertySheetModel.getValue(REFERRAL_NAME);
if (origName.equals(name)) {
policy.replaceReferral(name, referral);
} else {
deleted = policy.removeReferral(origName);
policy.addReferral(name, referral);
}
deleted = null;
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.referral.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 (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.addReferral(origName, deleted);
} catch (NameAlreadyExistsException e) {
debug.warning("ReferralEditViewBean.handleButton1Request", e);
} catch (InvalidNameException e) {
debug.warning("ReferralEditViewBean.handleButton1Request", e);
}
}
}
forwardTo();
}
use of com.sun.identity.policy.NameAlreadyExistsException 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.policy.NameAlreadyExistsException 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.policy.NameAlreadyExistsException 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.NameAlreadyExistsException in project OpenAM by OpenRock.
the class SubjectAddViewBean method handleButton2Request.
/**
* Handles create policy's subject request.
*
* @param event Request invocation event
*/
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
boolean forwarded = false;
submitCycle = true;
bFilter = true;
try {
Subject subject = createSubject();
if (subject != null) {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
String name = (String) propertySheetModel.getValue(SUBJECT_NAME);
policy.addSubject(name, subject, isExclusive());
backTrail();
forwardToPolicyViewBean();
forwarded = 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) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
} finally {
if (!forwarded) {
forwardTo();
}
}
}
Aggregations