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.Iterator;
020: import java.util.List;
021: import java.util.Map;
022: import java.util.Set;
023:
024: // iPlanet JATO classes
025: import com.iplanet.jato.model.ModelControlException;
026: import com.iplanet.jato.view.View;
027: import com.iplanet.jato.view.event.DisplayEvent;
028: import com.iplanet.jato.view.event.RequestInvocationEvent;
029: import com.iplanet.jato.view.html.StaticTextField;
030:
031: // iDS/AME classes
032: import com.iplanet.am.console.base.model.AMAdminConstants;
033: import com.iplanet.am.console.base.model.AMConsoleException;
034: import com.iplanet.am.console.components.view.html.DynamicGUI;
035: import com.iplanet.am.console.components.view.html.MessageBox;
036: import com.iplanet.sso.SSOException;
037:
038: // NetFile admin console classes
039: import com.sun.portal.netfile.admin.model.NetFileModel;
040:
041: public class NetFileTotalFourDotTwoViewBean extends NetFileViewBeanBase
042: implements NetFileAdminService, AMAdminConstants {
043:
044: public static final String PAGE_NAME = "NetFileTotalFourDotTwo";
045: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileTotalFourDotTwo.jsp";
046: public static final String PAGE_LABEL = "lblTotalFour";
047:
048: public NetFileTotalFourDotTwoViewBean(String pageName) {
049: super (pageName);
050: registerChildren();
051: }
052:
053: public NetFileTotalFourDotTwoViewBean() {
054: super (PAGE_NAME);
055: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
056: registerChildren();
057: }
058:
059: protected void registerChildren() {
060: super .registerChildren();
061: registerChild(GLOBAL_DATA_VIEW,
062: NetFileTotalFourDotTwoView.class);
063: registerChild(ORG_DATA_VIEW, NetFileTotalFourDotTwoView.class);
064: registerChild(DYNAMIC_DATA_VIEW,
065: NetFileTotalFourDotTwoView.class);
066: registerChild(PAGE_LABEL, StaticTextField.class);
067: }
068:
069: /**
070: * creates child view/component
071: *
072: * @param name of view/component
073: * @return child view/component
074: */
075: protected View createChild(String name) {
076: getNetFileModelMgr();
077: View child = null;
078:
079: if (name.equals(GLOBAL_DATA_VIEW)) {
080: child = new NetFileTotalFourDotTwoView(this ,
081: GLOBAL_DATA_VIEW, NetFileModel.GLOBAL_TYPE);
082: } else if (name.equals(ORG_DATA_VIEW)) {
083: child = new NetFileTotalFourDotTwoView(this , ORG_DATA_VIEW,
084: NetFileModel.ORG_TYPE);
085: } else if (name.equals(DYNAMIC_DATA_VIEW)) {
086: child = new NetFileTotalFourDotTwoView(this ,
087: DYNAMIC_DATA_VIEW, NetFileModel.DYNAMIC_TYPE);
088: } else if (name.equals(PAGE_LABEL)) {
089: child = new StaticTextField(this , PAGE_LABEL, modelManager
090: .getString("props.total.four")
091: + " "
092: + modelManager.getString("for.label")
093: + " "
094: + modelManager.getString("props.total.four.two"));
095: } else {
096: child = super .createChild(name);
097: }
098: return child;
099: }
100:
101: public void handleSubmitButtonRequest(RequestInvocationEvent event)
102: throws ModelControlException, SSOException {
103: getModel();
104: NetFileTotalFourDotTwoView view = null;
105: view = (NetFileTotalFourDotTwoView) getChild(GLOBAL_DATA_VIEW);
106: if (view != null) {
107: store(view, NetFileModel.GLOBAL_TYPE);
108: }
109: view = (NetFileTotalFourDotTwoView) getChild(ORG_DATA_VIEW);
110: if (view != null) {
111: store(view, NetFileModel.ORG_TYPE);
112: }
113: view = (NetFileTotalFourDotTwoView) getChild(DYNAMIC_DATA_VIEW);
114: if (view != null) {
115: store(view, NetFileModel.DYNAMIC_TYPE);
116: }
117: showPropertiesSavedMessageBox();
118:
119: forwardTo();
120: }
121:
122: public void beginDisplay(DisplayEvent event)
123: throws ModelControlException {
124: super .beginDisplay(event);
125: }
126:
127: private void store(NetFileTotalFourDotTwoView view, int type)
128: throws SSOException {
129:
130: NetFileModel m = getModel();
131: m.process();
132: Map map = new HashMap(10);
133: List dynComps = view.getDynamicCompList();
134:
135: if (dynComps != null && !dynComps.isEmpty()) {
136: Iterator it = dynComps.iterator();
137: while (it.hasNext()) {
138: DynamicGUI dGui = (DynamicGUI) it.next();
139: if (dGui != null) {
140: String dgName = dGui.getName();
141: Set dgValues = dGui.getValues();
142: if (dGui.getSyntax() == DynamicGUI.SYNTAX_DATE) {
143: try {
144: dgValues = m
145: .getDateInDefaultLocale(dgValues);
146: } catch (AMConsoleException ace) {
147: NetFileAdminModelManager
148: .debugError("Error in converting value to default locale : "
149: + ace);
150: // showMessage(MessageBox.TYPE_ERROR,
151: // m.getErrorTitle(),
152: // ace.getMessage());
153: continue;
154: }
155: }
156: map.put(dgName, dgValues);
157: try {
158: if (dgName
159: .equals("sunPortalNetFileMaxSearchDir")) {
160: Object currentValue = (dgValues.iterator())
161: .next();
162: if (currentValue != null) {
163: int currentIntValue = Integer
164: .parseInt(currentValue
165: .toString());
166: if (currentIntValue < 0) {
167: invalidLimitWarning();
168: return;
169: }
170: }
171: }
172: } catch (NumberFormatException ex) {
173: invalidLimitWarning();
174: return;
175: }
176: }
177: }
178: }
179: if (type == NetFileModel.DYNAMIC_TYPE) {
180: String priority = (String) getDisplayFieldValue(PRIORITY_COMBOBOX);
181: if (!"".equals(priority))
182: map.put("priority", priority);
183: }
184:
185: if (!map.isEmpty()) {
186: m.store(type, map);
187: }
188: }
189:
190: private void invalidLimitWarning() {
191: MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
192: msgBox.setTitle(modelManager.getString("error.title"));
193: msgBox.setMessage(modelManager.getString("invalidlimit.error"));
194: msgBox.setType(MessageBox.TYPE_ERROR);
195: msgBox.setVisible(true);
196: }
197:
198: }
|