Search in sources :

Example 1 with RMRealmModel

use of com.sun.identity.console.realm.model.RMRealmModel in project OpenAM by OpenRock.

the class RMRealmViewBean method handleTblDataActionHrefRequest.

/**
     * Handles edit realm request.
     *
     * @param event Request Invocation Event.
     * @throws ModelControlException if table model cannot be restored.
     */
public void handleTblDataActionHrefRequest(RequestInvocationEvent event) throws ModelControlException {
    // store the current realm name and the current selected tab
    // in the page session. Need to do this so after returning 
    // from profile object we get placed in the correct location.
    String prevRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    setPageSessionAttribute(AMAdminConstants.PREVIOUS_REALM, prevRealm);
    String newRealm = hexToString((String) getDisplayFieldValue(TBL_DATA_ACTION_HREF));
    setPageSessionAttribute(AMAdminConstants.CURRENT_REALM, newRealm);
    setCurrentLocation(newRealm);
    // store the current selected tab in the page session
    String tmp = (String) getPageSessionAttribute(getTrackingTabIDName());
    setPageSessionAttribute(AMAdminConstants.PREVIOUS_TAB_ID, tmp);
    AMViewConfig config = AMViewConfig.getInstance();
    RMRealmModel model = (RMRealmModel) getModel();
    unlockPageTrail();
    try {
        AMViewBeanBase vb = config.getTabViewBean(this, newRealm, model, "realms", -1, -1);
        passPgSessionMap(vb);
        vb.forwardTo(getRequestContext());
    } catch (AMConsoleException e) {
        setPageSessionAttribute(AMAdminConstants.CURRENT_REALM, prevRealm);
        removePageSessionAttribute(AMAdminConstants.PREVIOUS_TAB_ID);
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        forwardTo();
    }
}
Also used : AMViewConfig(com.sun.identity.console.base.AMViewConfig) AMViewBeanBase(com.sun.identity.console.base.AMViewBeanBase) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) RMRealmModel(com.sun.identity.console.realm.model.RMRealmModel)

Example 2 with RMRealmModel

use of com.sun.identity.console.realm.model.RMRealmModel in project OpenAM by OpenRock.

the class RMRealmViewBean method handleTblButtonDeleteRequest.

/**
     * Deletes realms.
     *
     * @param event Request Invocation Event.
     * @throws ModelControlException if table model cannot be restored.
     */
public void handleTblButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_SEARCH);
    table.restoreStateData();
    String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    Integer[] selected = tblModel.getSelectedRows();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    List list = (List) szCache.getSerializedObj();
    Set names = new HashSet(selected.length * 2);
    for (int i = 0; i < selected.length; i++) {
        String name = (String) list.get(selected[i].intValue());
        /* 
             * make sure the realm name starts with / to give it a
             * fully qualified look. This value will be set in the log file
             */
        if (!name.startsWith("/")) {
            name = "/" + name;
        }
        names.add(name);
    }
    try {
        RMRealmModel model = (RMRealmModel) getModel();
        model.deleteSubRealms(curRealm, names);
        if (selected.length == 1) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "realm.message.deleted");
        } else {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "realm.message.deleted.pural");
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) SerializedField(com.sun.identity.console.components.view.html.SerializedField) ArrayList(java.util.ArrayList) List(java.util.List) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) RMRealmModel(com.sun.identity.console.realm.model.RMRealmModel) HashSet(java.util.HashSet)

Example 3 with RMRealmModel

use of com.sun.identity.console.realm.model.RMRealmModel in project OpenAM by OpenRock.

the class RMRealmViewBean method populateTableModel.

private void populateTableModel(Collection realmNames) {
    tblModel.clearAll();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    RMRealmModel model = (RMRealmModel) getModel();
    tblModel.setMaxRows(model.getPageSize());
    if ((realmNames != null) && !realmNames.isEmpty()) {
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        List cache = new ArrayList(realmNames.size());
        boolean firstEntry = true;
        String startDN = model.getStartDN();
        int counter = 0;
        for (Iterator iter = realmNames.iterator(); iter.hasNext(); counter++) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblModel.appendRow();
            }
            String name = (String) iter.next();
            String fqName = null;
            String displayName = null;
            if (name.equals(startDN)) {
                tblModel.setSelectionVisible(counter, false);
                fqName = name;
                displayName = AMFormatUtils.DNToName(model, model.getStartDSDN());
            } else {
                int idx = name.lastIndexOf('/');
                displayName = (idx == -1) ? name : name.substring(idx + 1);
                tblModel.setSelectionVisible(counter, true);
                fqName = name;
            }
            /*
                 * Set name column info. Need to unescape the value as it
                 * may contain a '/' character.
                 */
            tblModel.setValue(TBL_DATA_ACTION_HREF, stringToHex(fqName));
            tblModel.setValue(TBL_DATA_NAME, SMSSchema.unescapeName(displayName));
            // set location column info
            tblModel.setValue(TBL_DATA_PATH, getPath(name));
            cache.add(name);
        }
        szCache.setValue((ArrayList) cache);
    } else {
        szCache.setValue(null);
    }
}
Also used : SerializedField(com.sun.identity.console.components.view.html.SerializedField) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) RMRealmModel(com.sun.identity.console.realm.model.RMRealmModel)

Example 4 with RMRealmModel

use of com.sun.identity.console.realm.model.RMRealmModel in project OpenAM by OpenRock.

the class RMRealmAddViewBean method handleButton1Request.

/**
     * Handles create realm request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    RMRealmModel model = (RMRealmModel) getModel();
    AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
    String realmName = (String) getDisplayFieldValue(RMRealmModel.TF_NAME);
    realmName = realmName.trim();
    String parent = (String) getDisplayFieldValue(RMRealmModel.TF_PARENT);
    if (parent != null) {
        parent = parent.trim();
    } else {
        parent = model.getStartDN();
    }
    if (realmName.length() > 0) {
        try {
            Map values = ps.getAttributeValues(model.getDataMap(), false, model);
            model.createSubRealm(parent, realmName, values);
            backTrail();
            RMRealmViewBean vb = (RMRealmViewBean) getViewBean(RMRealmViewBean.class);
            passPgSessionMap(vb);
            vb.forwardTo(getRequestContext());
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        }
    } else {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "realm.missing.realmName");
        forwardTo();
    }
}
Also used : AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) RMRealmModel(com.sun.identity.console.realm.model.RMRealmModel)

Example 5 with RMRealmModel

use of com.sun.identity.console.realm.model.RMRealmModel in project OpenAM by OpenRock.

the class RMRealmAddViewBean method setDefaultValues.

private void setDefaultValues() {
    RMRealmModel model = (RMRealmModel) getModel();
    Map defaultValues = model.getDefaultValues();
    AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
    ps.setAttributeValues(defaultValues, model);
}
Also used : AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) HashMap(java.util.HashMap) Map(java.util.Map) RMRealmModel(com.sun.identity.console.realm.model.RMRealmModel)

Aggregations

RMRealmModel (com.sun.identity.console.realm.model.RMRealmModel)11 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)9 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)4 Map (java.util.Map)4 HashMap (java.util.HashMap)3 AMPropertySheetModel (com.sun.identity.console.base.model.AMPropertySheetModel)2 SerializedField (com.sun.identity.console.components.view.html.SerializedField)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Set (java.util.Set)2 Option (com.iplanet.jato.view.html.Option)1 OptionList (com.iplanet.jato.view.html.OptionList)1 AMViewBeanBase (com.sun.identity.console.base.AMViewBeanBase)1 AMViewConfig (com.sun.identity.console.base.AMViewConfig)1 CCSelectableList (com.sun.web.ui.view.html.CCSelectableList)1 CCActionTable (com.sun.web.ui.view.table.CCActionTable)1