Search in sources :

Example 26 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PolicyReferralEditViewBean method getBreadCrumbDisplayName.

protected String getBreadCrumbDisplayName() {
    PolicyModel model = (PolicyModel) getModel();
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        String[] arg = { cachedPolicy.getTrackPolicyName() };
        return MessageFormat.format(model.getLocalizedString("breadcrumbs.editPolicy"), (Object[]) arg);
    } catch (AMConsoleException e) {
        debug.warning("PolicyReferralEditViewBean.getBreadCrumbDisplayName", e);
        // Bread Crumb will not be set if cached policy cannot be located.
        return "";
    }
}
Also used : CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 27 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PolicyReferralEditViewBean 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
        } else {
            CachedPolicy cachedPolicy = getCachedPolicy();
            PolicyModel model = (PolicyModel) getModel();
            try {
                model.replacePolicy(currentRealm, cachedPolicy.getPolicy());
                setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.modified.message");
                cachedPolicy.setPolicyModified(false);
            } catch (AMConsoleException e) {
                setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            }
        }
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyReferralEditViewBean.handleButton1Request", e);
        redirectToStartURL();
    }
}
Also used : CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 28 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PolicyReferralEditViewBean method handleButton2Request.

/**
     * Handles reset request.
     *
     * @param event Request invocation event
     */
public void handleButton2Request(RequestInvocationEvent event) {
    PolicyModel model = (PolicyModel) getModel();
    String cacheID = (String) getPageSessionAttribute(ProfileViewBeanBase.PG_SESSION_POLICY_CACHE_ID);
    try {
        CachedPolicy cachedPolicy = model.getCachedPolicy(cacheID);
        String policyName = cachedPolicy.getTrackPolicyName();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        try {
            cacheID = model.cachePolicy(curRealm, policyName);
            setPageSessionAttribute(PolicyOpViewBeanBase.PG_SESSION_POLICY_CACHE_ID, cacheID);
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyReferralEditViewBean.handleButton2Request", e);
        redirectToStartURL();
    }
}
Also used : CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 29 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PolicyNormalAddViewBean 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 {
        reconstructPolicy();
        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();
    }
}
Also used : CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 30 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PolicyNormalEditViewBean method handleButton2Request.

/**
     * Handles reset request.
     *
     * @param event Request invocation event
     */
public void handleButton2Request(RequestInvocationEvent event) {
    PolicyModel model = (PolicyModel) getModel();
    String cacheID = (String) getPageSessionAttribute(ProfileViewBeanBase.PG_SESSION_POLICY_CACHE_ID);
    try {
        CachedPolicy cachedPolicy = model.getCachedPolicy(cacheID);
        String policyName = cachedPolicy.getTrackPolicyName();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        try {
            cacheID = model.cachePolicy(curRealm, policyName);
            setPageSessionAttribute(PolicyOpViewBeanBase.PG_SESSION_POLICY_CACHE_ID, cacheID);
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyNormalEditViewBean.handleButton2Request", e);
        redirectToStartURL();
    }
}
Also used : CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

PolicyModel (com.sun.identity.console.policy.model.PolicyModel)84 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)28 Map (java.util.Map)27 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)26 HashMap (java.util.HashMap)14 Policy (com.sun.identity.policy.Policy)12 Set (java.util.Set)12 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)11 Iterator (java.util.Iterator)8 OptionList (com.iplanet.jato.view.html.OptionList)7 PolicyCache (com.sun.identity.console.policy.model.PolicyCache)6 QueryResults (com.sun.identity.console.base.model.QueryResults)5 Syntax (com.sun.identity.policy.Syntax)5 Rule (com.sun.identity.policy.Rule)3 Referral (com.sun.identity.policy.interfaces.Referral)3 CCButton (com.sun.web.ui.view.html.CCButton)3 List (java.util.List)3 IdentitySubjectModel (com.sun.identity.console.policy.model.IdentitySubjectModel)2 ActionSchema (com.sun.identity.policy.ActionSchema)2 ValidValues (com.sun.identity.policy.ValidValues)2