Search in sources :

Example 1 with ServicesModel

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

the class ServicesSelectViewBean method handleButton2Request.

/**
     * Handles next button request.
     *
     * @param event Request invocation event.
     */
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
    ServicesModel model = (ServicesModel) getModel();
    String serviceName = (String) getDisplayFieldValue(ATTR_SERVICE_LIST);
    serviceName = serviceName.trim();
    if (serviceName.length() > 0) {
        SCUtils utils = new SCUtils(serviceName, model);
        String propertiesViewBeanURL = utils.getServiceDisplayURL();
        if ((propertiesViewBeanURL != null) && (propertiesViewBeanURL.trim().length() > 0)) {
            String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
            if (curRealm == null) {
                curRealm = AMModelBase.getStartDN(getRequestContext().getRequest());
            }
            try {
                String pageTrailID = (String) getPageSessionAttribute(PG_SESSION_PAGE_TRAIL_ID);
                propertiesViewBeanURL += "?ServiceName=" + serviceName + "&Location=" + stringToHex(curRealm) + "&Template=true&Op=" + AMAdminConstants.OPERATION_ADD + "&" + PG_SESSION_PAGE_TRAIL_ID + "=" + pageTrailID;
                HttpServletResponse response = getRequestContext().getResponse();
                backTrail();
                response.sendRedirect(propertiesViewBeanURL);
            } catch (UnsupportedEncodingException e) {
                setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
                forwardTo();
            } catch (IOException e) {
                setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
                forwardTo();
            }
        } else {
            ServicesAddViewBean vb = (ServicesAddViewBean) getViewBean(ServicesAddViewBean.class);
            setPageSessionAttribute(ServicesAddViewBean.SERVICE_NAME, serviceName);
            unlockPageTrailForSwapping();
            passPgSessionMap(vb);
            vb.forwardTo(getRequestContext());
        }
    } else {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "services.missing.servicename");
        forwardTo();
    }
}
Also used : ServicesModel(com.sun.identity.console.realm.model.ServicesModel) HttpServletResponse(javax.servlet.http.HttpServletResponse) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) SCUtils(com.sun.identity.console.service.model.SCUtils)

Example 2 with ServicesModel

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

the class ServicesViewBean method getServiceNames.

private void getServiceNames() {
    ServicesModel model = (ServicesModel) getModel();
    try {
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        populateTableModel(model.getAssignedServiceNames(curRealm));
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : ServicesModel(com.sun.identity.console.realm.model.ServicesModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 3 with ServicesModel

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

the class ServicesViewBean method beginDisplay.

public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    resetButtonState(TBL_BUTTON_DELETE);
    getServiceNames();
    setPageTitle(getModel(), "page.title.realms.services");
    ServicesModel model = (ServicesModel) getModel();
    String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    try {
        if (model.getAssignableServiceNames(curRealm).isEmpty()) {
            CCButton btnAdd = (CCButton) getChild(TBL_BUTTON_ADD);
            btnAdd.setDisabled(true);
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "services.noservices.for.assignment.message");
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        CCButton btnAdd = (CCButton) getChild(TBL_BUTTON_ADD);
        btnAdd.setDisabled(true);
    }
}
Also used : CCButton(com.sun.web.ui.view.html.CCButton) ServicesModel(com.sun.identity.console.realm.model.ServicesModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 4 with ServicesModel

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

the class ServicesViewBean method populateTableModel.

private void populateTableModel(Map nameToDisplayNames) {
    tblModel.clearAll();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    if ((nameToDisplayNames != null) && !nameToDisplayNames.isEmpty()) {
        Map reverseMap = AMFormatUtils.reverseStringMap(nameToDisplayNames);
        ServicesModel model = (ServicesModel) getModel();
        List list = AMFormatUtils.sortKeyInMap(reverseMap, model.getUserLocale());
        boolean firstEntry = true;
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblModel.appendRow();
            }
            String displayName = (String) iter.next();
            String name = (String) reverseMap.get(displayName);
            tblModel.setValue(TF_DATA_NAME, name);
            tblModel.setValue(TBL_DATA_NAME, displayName);
            tblModel.setValue(TBL_DATA_ACTION_HREF, name);
            tblModel.setValue(TBL_DATA_ACTION_LABEL, "table.services.action.edit");
        }
        szCache.setValue((Serializable) nameToDisplayNames);
    } else {
        szCache.setValue(null);
    }
}
Also used : SerializedField(com.sun.identity.console.components.view.html.SerializedField) ServicesModel(com.sun.identity.console.realm.model.ServicesModel) Iterator(java.util.Iterator) List(java.util.List) Map(java.util.Map)

Example 5 with ServicesModel

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

the class ServicesViewBean method handleTblButtonDeleteRequest.

/**
     * Deletes ID Repo.
     *
     * @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();
    Integer[] selected = tblModel.getSelectedRows();
    Set names = new HashSet(selected.length * 2);
    for (int i = 0; i < selected.length; i++) {
        tblModel.setRowIndex(selected[i].intValue());
        names.add((String) tblModel.getValue(TF_DATA_NAME));
    }
    try {
        ServicesModel model = (ServicesModel) getModel();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        model.unassignServices(curRealm, names);
        if (selected.length == 1) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "services.message.deleted");
        } else {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "services.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) ServicesModel(com.sun.identity.console.realm.model.ServicesModel) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashSet(java.util.HashSet)

Aggregations

ServicesModel (com.sun.identity.console.realm.model.ServicesModel)7 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)4 SCUtils (com.sun.identity.console.service.model.SCUtils)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Map (java.util.Map)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 OptionList (com.iplanet.jato.view.html.OptionList)1 SerializedField (com.sun.identity.console.components.view.html.SerializedField)1 CCButton (com.sun.web.ui.view.html.CCButton)1 CCRadioButton (com.sun.web.ui.view.html.CCRadioButton)1 CCActionTable (com.sun.web.ui.view.table.CCActionTable)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1