8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: ServicesViewBean.java,v 1.2 2008/06/25 05:43:12 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.model.ModelControlException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.view.event.DisplayEvent;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.view.event.RequestInvocationEvent;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.console.base.model.AMAdminConstants;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.console.base.model.AMConsoleException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.console.base.model.AMFormatUtils;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.console.base.model.AMModel;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.console.base.model.AMModelBase;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.console.components.view.html.SerializedField;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.console.realm.model.ServicesModel;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.console.realm.model.ServicesModelImpl;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.console.service.model.SCUtils;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.web.ui.view.pagetitle.CCPageTitle;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String DEFAULT_DISPLAY_URL =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String CHILD_TBL_TILED_VIEW = "tableTiledView";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String TBL_SEARCH = "tblSearch";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String TBL_BUTTON_ADD = "tblButtonAdd";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String TBL_BUTTON_DELETE = "tblButtonDelete";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String TBL_COL_NAME = "tblColName";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String TBL_DATA_NAME = "tblDataName";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String TF_DATA_NAME = "tfDataName";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String TBL_COL_ACTION = "tblColAction";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String TBL_DATA_ACTION_LABEL = "tblDataActionLabel";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String PAGETITLE = "pgtitle";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String TBL_DATA_ACTION_HREF = "tblDataActionHref";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Creates a services view bean.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super("Services");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChild(TBL_SEARCH, CCActionTable.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChild(CHILD_TBL_TILED_VIEW, ServicesTiledView.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SerializedField szCache = (SerializedField)getChild(SZ_CACHE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster populateTableModel((Map)szCache.getSerializedObj());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster view = new ServicesTiledView(this, tblModel, name);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ServicesTiledView tView = (ServicesTiledView)getChild(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster CCActionTable child = new CCActionTable(this, tblModel, name);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setPageTitle(getModel(), "page.title.realms.services");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ServicesModel model = (ServicesModel)getModel();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String curRealm = (String)getPageSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (model.getAssignableServiceNames(curRealm).isEmpty()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster CCButton btnAdd = (CCButton)getChild(TBL_BUTTON_ADD);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "services.noservices.for.assignment.message");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster CCButton btnAdd = (CCButton)getChild(TBL_BUTTON_ADD);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RequestContext rc = RequestManager.getRequestContext();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return new ServicesModelImpl(req, getPageSessionAttributes());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getClass().getClassLoader().getResourceAsStream(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "com/sun/identity/console/oneBtnPageTitle.xml"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ptModel.setValue("button1", getBackButtonLabel());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getClass().getClassLoader().getResourceAsStream(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "com/sun/identity/console/tblRMServices.xml"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tblModel.setActionValue(TBL_BUTTON_ADD, "table.services.button.new");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "table.services.button.delete");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "table.services.name.column.name");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "table.services.action.column.name");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ServicesModel model = (ServicesModel)getModel();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String curRealm = (String)getPageSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster populateTableModel(model.getAssignedServiceNames(curRealm));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private void populateTableModel(Map nameToDisplayNames) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SerializedField szCache = (SerializedField)getChild(SZ_CACHE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((nameToDisplayNames != null) && !nameToDisplayNames.isEmpty()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Map reverseMap = AMFormatUtils.reverseStringMap(nameToDisplayNames);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ServicesModel model = (ServicesModel)getModel();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster List list = AMFormatUtils.sortKeyInMap(reverseMap,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean firstEntry = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (Iterator iter = list.iterator(); iter.hasNext(); ) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String name = (String)reverseMap.get(displayName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "table.services.action.edit");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster szCache.setValue((Serializable)nameToDisplayNames);
ServicesSelectViewBean.class);
} catch (UnsupportedEncodingException e) {
e.getMessage());
forwardTo();
} catch (IOException e) {
e.getMessage());
forwardTo();
ServicesEditViewBean.class);
throws ModelControlException
} catch (AMConsoleException e) {
e.getMessage());
forwardTo();
backTrail();