001: /**
002: * Copyright 2002 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: *
013: * Author: Anurag Gupta
014: */package com.sun.portal.netfile.admin;
015:
016: // JDK classes
017: import java.util.HashMap;
018: import com.sun.portal.log.common.PortalLogger;
019: import java.util.HashSet;
020: import java.util.Iterator;
021: import java.util.List;
022: import java.util.Map;
023: import java.util.Set;
024: import java.util.Vector;
025:
026: // iPlanet JATO classes
027: import com.iplanet.jato.model.ModelControlException;
028: import com.iplanet.jato.view.View;
029: import com.iplanet.jato.view.event.DisplayEvent;
030: import com.iplanet.jato.view.event.RequestInvocationEvent;
031: import com.iplanet.jato.view.html.ComboBox;
032: import com.iplanet.jato.view.html.OptionList;
033: import com.iplanet.jato.view.html.StaticTextField;
034:
035: // iDS/AME classes
036: import com.iplanet.am.console.base.model.AMAdminConstants;
037: import com.iplanet.am.console.base.model.AMConsoleException;
038: import com.iplanet.am.console.components.view.html.DynamicGUI;
039: import com.iplanet.sso.SSOException;
040:
041: // NetFile admin console classes
042: import com.sun.portal.netfile.admin.model.NetFileModel;
043:
044: public class NetFileTotalFourDotThreeViewBean extends
045: NetFileViewBeanBase implements NetFileCompressionConstants,
046: NetFileAdminService, AMAdminConstants {
047:
048: public static final String PAGE_NAME = "NetFileTotalFourDotThree";
049: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileTotalFourDotThree.jsp";
050: public static final String PAGE_LABEL = "lblTotalFour";
051:
052: public NetFileTotalFourDotThreeViewBean(String pageName) {
053: super (pageName);
054: registerChildren();
055: }
056:
057: public NetFileTotalFourDotThreeViewBean() {
058: super (PAGE_NAME);
059: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
060: registerChildren();
061: }
062:
063: protected void registerChildren() {
064: super .registerChildren();
065: registerChild(GLOBAL_DATA_VIEW,
066: NetFileTotalFourDotThreeView.class);
067: registerChild(ORG_DATA_VIEW, NetFileTotalFourDotThreeView.class);
068: registerChild(DYNAMIC_DATA_VIEW,
069: NetFileTotalFourDotThreeView.class);
070: registerChild(PAGE_LABEL, StaticTextField.class);
071: registerChild(CHILD_COMPRESSIONTYPE_LBL, StaticTextField.class);
072: registerChild(CHILD_COMPRESSIONTYPE, ComboBox.class);
073: registerChild(CHILD_COMPRESSIONLEVEL_LBL, StaticTextField.class);
074: registerChild(CHILD_COMPRESSIONLEVEL, ComboBox.class);
075: registerChild(JAVA2_ONLY, StaticTextField.class);
076: }
077:
078: /**
079: * creates child view/component
080: *
081: * @param name of view/component
082: * @return child view/component
083: */
084: protected View createChild(String name) {
085: getNetFileModelMgr();
086: View child = null;
087: int viewType = NetFileModel.DYNAMIC_TYPE;
088:
089: if (name.equals(GLOBAL_DATA_VIEW)) {
090: child = new NetFileTotalFourDotThreeView(this ,
091: GLOBAL_DATA_VIEW, NetFileModel.GLOBAL_TYPE);
092: } else if (name.equals(ORG_DATA_VIEW)) {
093: child = new NetFileTotalFourDotThreeView(this ,
094: ORG_DATA_VIEW, NetFileModel.ORG_TYPE);
095: } else if (name.equals(DYNAMIC_DATA_VIEW)) {
096: child = new NetFileTotalFourDotThreeView(this ,
097: DYNAMIC_DATA_VIEW, NetFileModel.DYNAMIC_TYPE);
098: } else if (name.equals(PAGE_LABEL)) {
099: child = new StaticTextField(this , PAGE_LABEL, modelManager
100: .getString("props.total.four")
101: + " "
102: + modelManager.getString("for.label")
103: + " "
104: + modelManager.getString("props.total.four.three"));
105: } else if (name.equals(CHILD_COMPRESSIONTYPE_LBL)) {
106: model.setCurrentRow(viewType, model
107: .getNetFileAttributeIndex(ATTR_COMPRESSION_TYPE));
108: child = new StaticTextField(this ,
109: CHILD_COMPRESSIONTYPE_LBL, model.getDynamicGUI()
110: .getLabel());
111: } else if (name.equals(CHILD_COMPRESSIONTYPE)) {
112: child = new ComboBox(this , CHILD_COMPRESSIONTYPE, "");
113: } else if (name.equals(CHILD_COMPRESSIONLEVEL_LBL)) {
114: model.setCurrentRow(viewType, model
115: .getNetFileAttributeIndex(ATTR_COMPRESSION_LEVEL));
116: child = new StaticTextField(this ,
117: CHILD_COMPRESSIONLEVEL_LBL, model.getDynamicGUI()
118: .getLabel());
119: } else if (name.equals(CHILD_COMPRESSIONLEVEL)) {
120: child = new ComboBox(this , CHILD_COMPRESSIONLEVEL, "");
121: } else if (name.equals(JAVA2_ONLY)) {
122: child = new StaticTextField(this , JAVA2_ONLY, modelManager
123: .getString("java2Only"));
124: } else {
125: child = super .createChild(name);
126: }
127: return child;
128: }
129:
130: public ComboBox setCompressionTypeOptions() {
131: OptionList optList = new OptionList();
132: String tmp;
133: for (int count = 0; count < compressionTypeOptionList.length; count++) {
134: tmp = modelManager.getString("compressionType."
135: + compressionTypeOptionList[count]);
136: optList.add(tmp, tmp);
137: }
138: ComboBox cb = (ComboBox) getDisplayField(CHILD_COMPRESSIONTYPE);
139: cb.setOptions(optList);
140: return cb;
141: }
142:
143: public ComboBox setCompressionLevelOptions() {
144: OptionList optList = new OptionList();
145: for (int count = 0; count < compressionLevelOptionListSize; count++) {
146: optList.add(compressionLevelOptionList[count],
147: compressionLevelOptionList[count]);
148: }
149: ComboBox cb = (ComboBox) getDisplayField(CHILD_COMPRESSIONLEVEL);
150: cb.setOptions(optList);
151: return cb;
152: }
153:
154: public void beginDisplay(DisplayEvent event)
155: throws ModelControlException {
156: getModel();
157: setChildValues(model);
158: model.process();
159: getNetFileModelMgr();
160: setDisplayFieldValue(PAGE_DESCRIPTION, model
161: .getServiceDisplayName());
162: setDisplayFieldValue(GLOBAL_LABEL, modelManager
163: .getString("global"));
164: setDisplayFieldValue(ORG_LABEL, modelManager
165: .getString("organization"));
166: setDisplayFieldValue(DYNAMIC_LABEL, modelManager
167: .getString("dynamic"));
168: setDisplayFieldValue(SUBMIT_BTN, modelManager
169: .getString("save.button"));
170: setDisplayFieldValue(RESET_BTN, modelManager
171: .getString("reset.button"));
172: setDisplayFieldValue(DELETE_BUTTON, modelManager
173: .getString("delete.button"));
174: setDisplayFieldValue(HELP_DOC_URL, modelManager
175: .getString(NetFileAdminService.SRA_BASE_HLP_URL));
176: setDisplayFieldValue(HELP_ANCHOR_TAG, model
177: .getHelpUrl(modelManager
178: .getString(NetFileAdminService.SRA_NF_HLP_URL)));
179:
180: int viewType = NetFileModel.DYNAMIC_TYPE;
181: ComboBox compressionTypeCB = setCompressionTypeOptions();
182: model.setCurrentRow(viewType, model
183: .getNetFileAttributeIndex(ATTR_COMPRESSION_TYPE));
184: HashSet valueSet = (HashSet) model.getAttrValues();
185: String compressionValue = null;
186: if (valueSet != null && valueSet.iterator().hasNext()) {
187: compressionValue = (String) valueSet.iterator().next();
188: }
189: compressionValue = modelManager.getString("compressionType."
190: + compressionValue);
191: compressionTypeCB.setValue(compressionValue);
192:
193: ComboBox compressionLevelCB = setCompressionLevelOptions();
194: model.setCurrentRow(viewType, model
195: .getNetFileAttributeIndex(ATTR_COMPRESSION_LEVEL));
196: valueSet = (HashSet) model.getAttrValues();
197: if (valueSet != null && valueSet.iterator().hasNext()) {
198: compressionValue = (String) valueSet.iterator().next();
199: }
200: compressionLevelCB.setValue(compressionValue);
201: model.setCurrentRow(viewType, -1);
202: }
203:
204: public void handleSubmitButtonRequest(RequestInvocationEvent event)
205: throws ModelControlException, SSOException {
206: getModel();
207: NetFileTotalFourDotThreeView view = null;
208: view = (NetFileTotalFourDotThreeView) getChild(GLOBAL_DATA_VIEW);
209: if (view != null) {
210: store(view, NetFileModel.GLOBAL_TYPE);
211: }
212: view = (NetFileTotalFourDotThreeView) getChild(ORG_DATA_VIEW);
213: if (view != null) {
214: store(view, NetFileModel.ORG_TYPE);
215: }
216: view = (NetFileTotalFourDotThreeView) getChild(DYNAMIC_DATA_VIEW);
217: if (view != null) {
218: store(view, NetFileModel.DYNAMIC_TYPE);
219: }
220: showPropertiesSavedMessageBox();
221:
222: forwardTo();
223: }
224:
225: private void store(NetFileTotalFourDotThreeView view, int type)
226: throws SSOException {
227:
228: NetFileModel m = getModel();
229: m.process();
230: Map map = new HashMap(10);
231: List dynComps = view.getDynamicCompList();
232:
233: if (dynComps != null && !dynComps.isEmpty()) {
234: Iterator it = dynComps.iterator();
235: while (it.hasNext()) {
236: DynamicGUI dGui = (DynamicGUI) it.next();
237: if (dGui != null) {
238: String dgName = dGui.getName();
239: Set dgValues = dGui.getValues();
240: if (dGui.getSyntax() == DynamicGUI.SYNTAX_DATE) {
241: try {
242: dgValues = m
243: .getDateInDefaultLocale(dgValues);
244: } catch (AMConsoleException ace) {
245: NetFileAdminModelManager
246: .debugError("Error in converting value to default locale : "
247: + ace);
248: continue;
249: }
250: }
251: map.put(dgName, dgValues);
252: }
253: }
254: }
255: if (type == NetFileModel.DYNAMIC_TYPE) {
256: ComboBox cb = (ComboBox) getDisplayField(CHILD_COMPRESSIONTYPE);
257: String compressionValue = (String) (cb.getValue());
258: String tmp;
259: for (int count = 0; count < compressionTypeOptionList.length; count++) {
260: tmp = modelManager.getString("compressionType."
261: + compressionTypeOptionList[count]);
262: if (compressionValue.equals(tmp)) {
263: compressionValue = compressionTypeOptionList[count];
264: break;
265: }
266: }
267: Vector compressionVector = new Vector(1);
268: compressionVector.add(compressionValue);
269: HashSet compressionSet = new HashSet(compressionVector);
270: map.put(ATTR_COMPRESSION_TYPE, compressionSet);
271:
272: cb = (ComboBox) getDisplayField(CHILD_COMPRESSIONLEVEL);
273: compressionValue = (String) (cb.getValue());
274: compressionVector = new Vector(1);
275: compressionVector.add(compressionValue);
276: compressionSet = new HashSet(compressionVector);
277: map.put(ATTR_COMPRESSION_LEVEL, compressionSet);
278:
279: String priority = (String) getDisplayFieldValue(PRIORITY_COMBOBOX);
280: if (!"".equals(priority))
281: map.put("priority", priority);
282: }
283:
284: if (!map.isEmpty()) {
285: m.store(type, map);
286: }
287: }
288:
289: }
|