SessionHAPropertiesViewBean.java revision aee26cce86cd7acccbcd94284b027d11cb9ac327
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff/**
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff *
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff *
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * The contents of this file are subject to the terms
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * of the Common Development and Distribution License
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * (the License). You may not use this file except in
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * compliance with the License.
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac *
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * You can obtain a copy of the License at
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * https://opensso.dev.java.net/public/CDDLv1.0.html or
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * opensso/legal/CDDLv1.0.txt
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * See the License for the specific language governing
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * permission and limitations under the License.
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac *
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * When distributing Covered Code, include this CDDL
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * Header Notice in each file and include the License file
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * at opensso/legal/CDDLv1.0.txt.
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * If applicable, add the following below the CDDL Header,
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * with the fields enclosed by brackets [] replaced by
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * your own identifying information:
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * "Portions Copyrighted [year] [name of copyright owner]"
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff *
4323400c50c6c6f278c473544883e91ac4c0e781ludo * $Id: SessionHAPropertiesViewBean.java,v 1.2 2008/06/25 05:43:12 qcheng Exp $
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff *
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff */
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffpackage com.sun.identity.console.session;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.iplanet.jato.RequestContext;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.iplanet.jato.RequestManager;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.iplanet.jato.model.ModelControlException;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.iplanet.jato.view.View;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.iplanet.jato.view.event.DisplayEvent;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.iplanet.jato.view.event.RequestInvocationEvent;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.sun.web.ui.model.CCPageTitleModel;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.sun.web.ui.view.alert.CCAlert;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.sun.web.ui.view.pagetitle.CCPageTitle;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport javax.servlet.http.HttpServletRequest;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swiftimport java.util.Map;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.sun.identity.console.base.AMPropertySheet;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.sun.identity.console.base.model.AMConsoleException;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.sun.identity.console.base.model.AMModel;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.sun.identity.console.base.model.AMPropertySheetModel;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.sun.identity.console.session.model.SMProfileModel;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffimport com.sun.identity.console.session.model.SMProfileModelImpl;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoffpublic class SessionHAPropertiesViewBean
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff extends SessionHAPropertiesBase {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff public static final String DEFAULT_DISPLAY_URL =
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift "/console/session/SessionHAProperties.jsp";
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff protected AMPropertySheetModel psModel;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift private static final String PAGETITLE = "pgtitle";
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff private boolean initialized;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff /**
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * Creates a authentication domains view bean.
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff */
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff public SessionHAPropertiesViewBean() {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff super(SESSION_HA_PROPERTIES);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift protected void initialize() {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift if (!initialized) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff String sessionAttribute = (String) getPageSessionAttribute(SESSION_HA_PROPERTIES);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff if (sessionAttribute != null) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff initialized = true;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift createPropertyModel(sessionAttribute);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift createPageTitleModel();
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff registerChildren();
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift super.initialize();
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift super.registerChildren();
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff protected void registerChildren() {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff registerChild(SESSION_HA_PROPERTIES, AMPropertySheet.class);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift if (psModel != null) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff psModel.registerChildren(this);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift if (ptModel != null) {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ptModel.registerChildren(this);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift protected View createChild(String name) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff View view = null;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff if (psModel == null) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff createPropertyModel(SESSION_HA_PROPERTIES);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff if (ptModel == null) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff createPageTitleModel();
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift if (name.equals(PAGETITLE)) {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift view = new CCPageTitle(this, ptModel, name);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff } else if (name.equals(SESSION_HA_PROPERTIES)) {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift view = new AMPropertySheet(this, psModel, name);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift } else if ((psModel != null) && psModel.isChildSupported(name)) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff view = psModel.createChild(this, name, getModel());
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff } else if ((ptModel != null) && ptModel.isChildSupported(name)) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff view = ptModel.createChild(this, name);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff } else {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff view = super.createChild(name);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff return view;
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff public void beginDisplay(DisplayEvent event)
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff throws ModelControlException {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift super.beginDisplay(event);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift SMProfileModel model = (SMProfileModel) getModel();
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff if (model != null) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff String sessionAttribute = (String) getPageSessionAttribute(SESSION_HA_PROPERTIES);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff AMPropertySheet ps =
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift (AMPropertySheet) getChild(SESSION_HA_PROPERTIES);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff psModel.clear();
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff //try {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff //ps.setAttributeValues(
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff // model.getAttributeValues(sessionAttribute), model);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift //} catch (AMConsoleException a) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff // setInlineAlertMessage(CCAlert.TYPE_ERROR,
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff // "message.error", "no.properties");
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff //}
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff // Set our Sub-Tabs and current position, relative to one.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift addSessionsTab(model, 2);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff private void createPageTitleModel() {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff ptModel = new CCPageTitleModel(
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff getClass().getClassLoader().getResourceAsStream(
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff "com/sun/identity/console/twoBtnsPageTitle.xml"));
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff ptModel.setValue("button1", "button.save");
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff ptModel.setValue("button2", "button.reset");
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff protected AMModel getModelInternal() {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff RequestContext rc = RequestManager.getRequestContext();
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift HttpServletRequest req = rc.getRequest();
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff return new SMProfileModelImpl(req, getPageSessionAttributes());
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift protected void createPropertyModel(String modelName) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff SMProfileModel model = (SMProfileModel) getModel();
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift try {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift psModel = new AMPropertySheetModel(
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff model.getSessionProfilePropertyXML(modelName,
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff getClass().getName()));
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff psModel.clear();
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff } catch (AMConsoleException e) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error",
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff e.getMessage() + ", File Not Found for ModelName:[" + modelName + "].");
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /**
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * Handles save button request.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift *
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * @param event Request invocation event
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff */
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift public void handleButton1Request(RequestInvocationEvent event)
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift throws ModelControlException {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift SMProfileModel model = (SMProfileModel) getModel();
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff String name =
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff (String) getPageSessionAttribute(SESSION_HA_PROPERTIES);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff //AMPropertySheet ps = (AMPropertySheet) getChild(SESSION_HA_PROPERTIES);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff //try {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff //Map orig = model.getAttributeValues(name);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift //Map values = ps.getAttributeValues(orig, true, true, model);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff //model.setAttributeValues(name, values);
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information",
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff "message.updated");
4323400c50c6c6f278c473544883e91ac4c0e781ludo //} catch (AMConsoleException e) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff // setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error",
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff // e.getMessage());
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff //}
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff forwardTo();
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /**
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * Handles reset request.
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff *
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff * @param event Request invocation event
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff */
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff public void handleButton2Request(RequestInvocationEvent event) {
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff forwardTo();
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff }
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff}
9448ac32f12d59ed3d29eaf65703f4abe866c3eblutoff