001: /**
002: * $Id: Gateway1ViewBean.java,v 1.6 2005/11/30 11:27:08 ss150821 Exp $
003: * Copyright 2001 Sun Microsystems, Inc. Some preexisting
004: * portions Copyright 2001 Netscape Communications Corp.
005: * All rights reserved. Use of this product is subject to
006: * license terms. Federal Acquisitions: Commercial Software --
007: * Government Users Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and iPlanet are
011: * trademarks or registered trademarks of Sun Microsystems, Inc.
012: * in the United States and other countries. Netscape and the
013: * Netscape N logo are registered trademarks of Netscape
014: * Communications Corporation in the U.S. and other countries.
015: * Other Netscape logos, product names, and service names are
016: * also trademarks of Netscape Communications Corporation,
017: * which may be registered in other countries.
018: */package com.sun.portal.rproxy.admin;
019:
020: // JDK classes
021: import java.util.HashMap;
022: import java.util.Iterator;
023: import java.util.List;
024: import java.util.Map;
025: import java.util.Set;
026:
027: import com.iplanet.am.console.base.model.AMConsoleException;
028: import com.iplanet.am.console.components.view.html.DynamicGUI;
029: import com.iplanet.jato.model.ModelControlException;
030: import com.iplanet.jato.view.View;
031: import com.iplanet.jato.view.event.RequestInvocationEvent;
032: import com.iplanet.jato.view.html.StaticTextField;
033: import com.iplanet.sso.SSOException;
034: import com.sun.portal.rproxy.admin.model.GatewayModel;
035:
036: public class Gateway1ViewBean extends GatewayViewBeanBase implements
037: GatewayAdminService {
038:
039: public static final String PAGE_NAME = "Gateway1";
040:
041: public static final String DEFAULT_DISPLAY_URL = "/ps/gwadmin/Gateway1.jsp";
042:
043: public Gateway1ViewBean(String pageName) {
044: super (pageName);
045: registerChildren();
046: }
047:
048: public Gateway1ViewBean() {
049: super (PAGE_NAME);
050: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
051: registerChildren();
052: }
053:
054: protected void registerChildren() {
055: super .registerChildren();
056: registerChild(GLOBAL_DATA_VIEW, Gateway1View.class);
057: }
058:
059: protected View createChild(String name) {
060: getGWModelMgr();
061: View child = null;
062:
063: if (name.equals(GLOBAL_DATA_VIEW)) {
064: child = new Gateway1View(this , GLOBAL_DATA_VIEW);
065: } else if (name.equals(CHILD_GWPROFILEFOR)) {
066: child = new StaticTextField(this , CHILD_GWPROFILEFOR,
067: modelManager.getString("props.1") + " "
068: + modelManager.getString("for.label"));
069: } else {
070: child = super .createChild(name);
071: }
072: return child;
073: }
074:
075: public void handleSubmitButtonRequest(RequestInvocationEvent event)
076: throws ModelControlException, SSOException {
077: getModel();
078: Gateway1View view = null;
079: view = (Gateway1View) getChild(GLOBAL_DATA_VIEW);
080: if (view != null) {
081: store(view);
082: }
083: forwardTo();
084: }
085:
086: private void store(Gateway1View view) throws SSOException {
087:
088: String configName = (String) getDisplayFieldValue(HIDDEN_CONFIG_NAME);
089: GatewayModel m = getModel();
090: m.process(configName);
091: Map map = new HashMap(10);
092: List dynComps = view.getDynamicCompList();
093:
094: if (dynComps != null && !dynComps.isEmpty()) {
095: Iterator it = dynComps.iterator();
096: while (it.hasNext()) {
097: DynamicGUI dGui = (DynamicGUI) it.next();
098: if (dGui != null) {
099: Set dgValues = dGui.getValues();
100: if (dGui.getSyntax() == DynamicGUI.SYNTAX_DATE) {
101: try {
102: dgValues = m
103: .getDateInDefaultLocale(dgValues);
104: } catch (AMConsoleException ace) {
105: GatewayAdminModelManager
106: .debugError("Error in converting value to default locale : "
107: + ace);
108: continue;
109: }
110: }
111: try {
112: if (dGui.getSyntax() == DynamicGUI.SYNTAX_STRING) {
113: // To fix RFE Id 5044474
114: String value = "";
115: String name = dGui.getName();
116: if (dgValues != null) {
117: if (dgValues.iterator().hasNext())
118: value = (String) dgValues
119: .iterator().next();
120: }
121: if (value.trim().equals("")) {
122: dgValues.clear();
123: dgValues.add(value);
124: }
125:
126: if (name
127: .equals("sunPortalGatewayRProxyPortTimeout")
128: || name
129: .equals("sunPortalGatewayBlockedSocketTimeout")) {
130: if (value != null
131: && !value.trim().equals("")) {// Converting
132: // seconds
133: // values to
134: // milliseconds
135: // to store
136: value = String.valueOf(Integer
137: .parseInt(value) * 1000);
138: dgValues.clear();
139: dgValues.add(value);
140: }
141: }
142:
143: }
144:
145: map.put(dGui.getName(), dgValues);
146: } catch (NumberFormatException nfe) {
147: // Dont store the new values
148: }
149:
150: }
151: }
152: }
153: if (!map.isEmpty()) {
154: m.store(configName, map);
155: }
156: }
157:
158: }
|