Search in sources :

Example 1 with QueryResults

use of com.sun.identity.console.base.model.QueryResults in project OpenAM by OpenRock.

the class SubjectOpViewBeanBase method beginDisplay.

public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    String subjectType = (String) getPageSessionAttribute(SubjectOpViewBeanBase.PG_SESSION_SUBJECT_TYPE);
    PolicyModel model = (PolicyModel) getModel();
    Syntax syntax = model.getSubjectSyntax(realmName, subjectType);
    int intSyntax = AMDisplayType.getDisplaySyntax(syntax);
    if (!submitCycle) {
        String subjectName = (String) getPageSessionAttribute(SubjectOpViewBeanBase.PG_SESSION_SUBJECT_NAME);
        propertySheetModel.setValue(SYNTAX, Integer.toString(intSyntax));
        propertySheetModel.setValue(SUBJECT_NAME, subjectName);
        propertySheetModel.setValue(SUBJECT_TYPE, subjectType);
        QueryResults qr = model.getActiveSubjectTypes(realmName);
        Map map = (Map) qr.getResults();
        String i18nName = (String) map.get(subjectType);
        propertySheetModel.setValue(SUBJECT_TYPE_NAME, i18nName);
        propertySheetModel.setValue(EXCLUSIVE, isSubjectExclusive() ? "true" : "false");
    }
    if (intSyntax == AMDisplayType.SYNTAX_MULTIPLE_CHOICE) {
        setAddRemoveModel();
    }
}
Also used : PolicyModel(com.sun.identity.console.policy.model.PolicyModel) Syntax(com.sun.identity.policy.Syntax) Map(java.util.Map) QueryResults(com.sun.identity.console.base.model.QueryResults)

Example 2 with QueryResults

use of com.sun.identity.console.base.model.QueryResults in project OpenAM by OpenRock.

the class SelectSubjectTypeViewBean method getTypeOptions.

protected OptionList getTypeOptions() {
    PolicyModel model = (PolicyModel) getModel();
    String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    QueryResults qr = model.getActiveSubjectTypes(curRealm);
    String strError = qr.getStrError();
    if ((strError != null) && (strError.length() > 0)) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", strError);
    }
    return createOptionList((Map) qr.getResults(), model.getUserLocale());
}
Also used : PolicyModel(com.sun.identity.console.policy.model.PolicyModel) QueryResults(com.sun.identity.console.base.model.QueryResults)

Example 3 with QueryResults

use of com.sun.identity.console.base.model.QueryResults in project OpenAM by OpenRock.

the class PolicyNormalViewBeanBase method beginDisplay.

public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    try {
        populateAttributes();
    } catch (AMConsoleException e) {
    //NO-OP
    /* attribute values will not be populated if cached policy
             * cannot be located.
             */
    }
    CCButton btn = (CCButton) getChild("tblSubjectsButtonDelete");
    btn.setDisabled(true);
    btn = (CCButton) getChild("tblResponseProvidersButtonDelete");
    btn.setDisabled(true);
    btn = (CCButton) getChild("tblConditionsButtonDelete");
    btn.setDisabled(true);
    PolicyModel model = (PolicyModel) getModel();
    String realm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    QueryResults subjectsQuery = model.getActiveSubjectTypes(realm);
    Map subjects = (Map) subjectsQuery.getResults();
    if ((subjects == null) || subjects.isEmpty()) {
        ((CCButton) getChild("tblSubjectsButtonAdd")).setDisabled(true);
        setDisplayFieldValue("tblSubjectsNote", model.getLocalizedString("policy.no.subject.types"));
    } else {
        setDisplayFieldValue("tblSubjectsNote", "");
    }
    Map conditions = model.getActiveConditionTypes(realm);
    if ((conditions == null) || conditions.isEmpty()) {
        ((CCButton) getChild("tblConditionsButtonAdd")).setDisabled(true);
        setDisplayFieldValue("tblConditionsNote", model.getLocalizedString("policy.no.condition.types"));
    } else {
        setDisplayFieldValue("tblConditionsNote", "");
    }
    Map responseProviders = model.getActiveResponseProviderTypes(realm);
    if ((responseProviders == null) || responseProviders.isEmpty()) {
        ((CCButton) getChild("tblResponseProvidersButtonAdd")).setDisabled(true);
        setDisplayFieldValue("tblResponseProvidersNote", model.getLocalizedString("policy.no.response.providers.types"));
    } else {
        setDisplayFieldValue("tblResponseProvidersNote", "");
    }
}
Also used : CCButton(com.sun.web.ui.view.html.CCButton) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) QueryResults(com.sun.identity.console.base.model.QueryResults)

Example 4 with QueryResults

use of com.sun.identity.console.base.model.QueryResults in project OpenAM by OpenRock.

the class PolicyOpViewBeanBase method populateSubjectsTable.

protected void populateSubjectsTable() throws AMConsoleException {
    tblSubjectsModel.clearAll();
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    Set subjectsNames = policy.getSubjectNames();
    if ((subjectsNames != null) && !subjectsNames.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        QueryResults queryResults = model.getActiveSubjectTypes(realmName);
        Map localizedSbjTypeNames = (Map) queryResults.getResults();
        boolean firstEntry = true;
        for (Iterator iter = subjectsNames.iterator(); iter.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblSubjectsModel.appendRow();
            }
            try {
                String name = (String) iter.next();
                Subject subject = policy.getSubject(name);
                tblSubjectsModel.setValue(TBL_SUBJECTS_DATA_NAME, name);
                String sbjTypeName = model.getSubjectTypeName(realmName, subject);
                String displayName = (String) localizedSbjTypeNames.get(sbjTypeName);
                if (displayName == null) {
                    displayName = sbjTypeName;
                }
                tblSubjectsModel.setValue(TBL_SUBJECTS_DATA_TYPE, displayName);
                tblSubjectsModel.setValue(TBL_SUBJECTS_ACTION_HREF, stringToHex(name));
            } catch (NameNotFoundException e) {
                debug.warning("PolicyOpViewBeanBase.populateSubjectsTable", e);
            }
        }
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Set(java.util.Set) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Iterator(java.util.Iterator) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) HashMap(java.util.HashMap) Map(java.util.Map) QueryResults(com.sun.identity.console.base.model.QueryResults) Subject(com.sun.identity.policy.interfaces.Subject)

Example 5 with QueryResults

use of com.sun.identity.console.base.model.QueryResults in project OpenAM by OpenRock.

the class PolicyOpViewBeanBase method handleTblSubjectsButtonAddRequest.

public void handleTblSubjectsButtonAddRequest(RequestInvocationEvent event) throws ModelControlException {
    String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    PolicyModel model = (PolicyModel) getModel();
    try {
        if (!reconstructPolicy()) {
            QueryResults queryResults = model.getActiveSubjectTypes(curRealm);
            Map activeSubjectTypes = (Map) queryResults.getResults();
            unlockPageTrail();
            if (activeSubjectTypes.size() == 1) {
                String subjectType = (String) activeSubjectTypes.keySet().iterator().next();
                String viewBeanURL = model.getSubjectViewBeanURL(curRealm, subjectType);
                removePageSessionAttribute(WIZARD);
                setPageSessionAttribute(SubjectOpViewBeanBase.CALLING_VIEW_BEAN, getClass().getName());
                if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
                    forwardToSubjectURL(viewBeanURL, "", subjectType, curRealm, "add");
                } else {
                    forwardToSubjectAddViewBean(curRealm, subjectType);
                }
            } else {
                setPageSessionAttribute(SelectSubjectTypeViewBean.CALLING_VIEW_BEAN, getClass().getName());
                SelectSubjectTypeViewBean vb = (SelectSubjectTypeViewBean) getViewBean(SelectSubjectTypeViewBean.class);
                setPageSessionAttribute(WIZARD, "true");
                passPgSessionMap(vb);
                vb.forwardTo(getRequestContext());
            }
        } else {
            forwardTo();
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblSubjectsButtonAddRequest", e);
        redirectToStartURL();
    }
}
Also used : PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) QueryResults(com.sun.identity.console.base.model.QueryResults)

Aggregations

QueryResults (com.sun.identity.console.base.model.QueryResults)6 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)5 Map (java.util.Map)5 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)3 HashMap (java.util.HashMap)3 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)2 Syntax (com.sun.identity.policy.Syntax)2 Subject (com.sun.identity.policy.interfaces.Subject)2 Iterator (java.util.Iterator)2 Set (java.util.Set)2 SSOException (com.iplanet.sso.SSOException)1 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)1 Policy (com.sun.identity.policy.Policy)1 PolicyException (com.sun.identity.policy.PolicyException)1 PolicyManager (com.sun.identity.policy.PolicyManager)1 SubjectTypeManager (com.sun.identity.policy.SubjectTypeManager)1 CCButton (com.sun.web.ui.view.html.CCButton)1 HashSet (java.util.HashSet)1