Search in sources :

Example 21 with CachedPolicy

use of com.sun.identity.console.policy.model.CachedPolicy 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)

Example 22 with CachedPolicy

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

the class PolicyNormalEditViewBean 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("PolicyNormalEditViewBean.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 23 with CachedPolicy

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

the class PolicyNormalEditViewBean method getBreadCrumbDisplayName.

protected String getBreadCrumbDisplayName() {
    try {
        PolicyModel model = (PolicyModel) getModel();
        CachedPolicy cachedPolicy = getCachedPolicy();
        String[] arg = { cachedPolicy.getTrackPolicyName() };
        return MessageFormat.format(model.getLocalizedString("breadcrumbs.editPolicy"), (Object[]) arg);
    } catch (AMConsoleException e) {
        debug.warning("PolicyNormalEditViewBean.getBreadCrumbDisplayName", e);
        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 24 with CachedPolicy

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

the class PolicyOpViewBeanBase method handleTblReferralsEditLinkRequest.

public void handleTblReferralsEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String name = hexToString((String) getDisplayFieldValue(TBL_REFERRALS_ACTION_HREF));
    setPageSessionAttribute(ReferralEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
    setPageSessionAttribute(ReferralEditViewBean.EDIT_REFERRAL_NAME, name);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Referral referral = policy.getReferral(name);
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String referralType = referral.getReferralTypeName();
        String viewBeanURL = model.getReferralViewBeanURL(realmName, referralType);
        unlockPageTrail();
        if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
            forwardToReferralURL(viewBeanURL, name, referralType, realmName, "edit");
        } else {
            forwardToReferralEditViewBean(model, realmName, name, referralType);
        }
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblReferralsEditLinkRequest", e);
        redirectToStartURL();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Referral(com.sun.identity.policy.interfaces.Referral) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) 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 25 with CachedPolicy

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

the class PolicyOpViewBeanBase method handleTblResponseProvidersButtonDeleteRequest.

/**
     * Handles delete response attribute request.
     *
     * @param event Request Invocation Event.
     */
public void handleTblResponseProvidersButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_RESPONSE_ATTRIBUTES);
    table.restoreStateData();
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Integer[] selected = tblResponseProvidersModel.getSelectedRows();
        for (int i = 0; i < selected.length; i++) {
            tblResponseProvidersModel.setRowIndex(selected[i].intValue());
            String responseProviderName = (String) tblResponseProvidersModel.getValue(TBL_RESPONSE_ATTRIBUTES_DATA_NAME);
            policy.removeResponseProvider(responseProviderName);
        }
        cachedPolicy.setPolicyModified(true);
        populateResponseProvidersTable();
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblResponseProvidersButtonDeleteRequest", e);
        redirectToStartURL();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)53 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)38 Policy (com.sun.identity.policy.Policy)37 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)26 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)21 NameAlreadyExistsException (com.sun.identity.policy.NameAlreadyExistsException)10 InvalidNameException (com.sun.identity.policy.InvalidNameException)9 Map (java.util.Map)9 Set (java.util.Set)9 PolicyCache (com.sun.identity.console.policy.model.PolicyCache)6 Condition (com.sun.identity.policy.interfaces.Condition)6 Subject (com.sun.identity.policy.interfaces.Subject)6 HashMap (java.util.HashMap)6 Iterator (java.util.Iterator)6 Referral (com.sun.identity.policy.interfaces.Referral)5 ResponseProvider (com.sun.identity.policy.interfaces.ResponseProvider)5 CCActionTable (com.sun.web.ui.view.table.CCActionTable)5 Rule (com.sun.identity.policy.Rule)4 QueryResults (com.sun.identity.console.base.model.QueryResults)1 SimpleTimeCondition (com.sun.identity.policy.plugins.SimpleTimeCondition)1