Search in sources :

Example 6 with NameAlreadyExistsException

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();
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) InvalidNameException(com.sun.identity.policy.InvalidNameException) Referral(com.sun.identity.policy.interfaces.Referral) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 7 with NameAlreadyExistsException

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();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) InvalidNameException(com.sun.identity.policy.InvalidNameException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) Rule(com.sun.identity.policy.Rule) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 8 with NameAlreadyExistsException

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();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) InvalidNameException(com.sun.identity.policy.InvalidNameException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) Rule(com.sun.identity.policy.Rule) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 9 with NameAlreadyExistsException

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();
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 10 with NameAlreadyExistsException

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();
        }
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) InvalidNameException(com.sun.identity.policy.InvalidNameException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

Aggregations

AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)10 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)10 NameAlreadyExistsException (com.sun.identity.policy.NameAlreadyExistsException)10 Policy (com.sun.identity.policy.Policy)10 InvalidNameException (com.sun.identity.policy.InvalidNameException)8 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)4 Rule (com.sun.identity.policy.Rule)2 Condition (com.sun.identity.policy.interfaces.Condition)2 Referral (com.sun.identity.policy.interfaces.Referral)2 ResponseProvider (com.sun.identity.policy.interfaces.ResponseProvider)2 Subject (com.sun.identity.policy.interfaces.Subject)2