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