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.event.DisplayEvent;
027: import com.iplanet.jato.view.View;
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.sso.SSOException;
036:
037: // NetFile admin console classes
038: import com.sun.portal.netfile.admin.model.NetFileModel;
039:
040: public class NetFileTotalFiveViewBean extends NetFileViewBeanBase
041: implements NetFileAdminService, AMAdminConstants {
042:
043: public static final String PAGE_NAME = "NetFileTotalFive";
044: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileTotalFive.jsp";
045: public static final String PAGE_LABEL = "lblTotalFive";
046:
047: public NetFileTotalFiveViewBean(String pageName) {
048: super (pageName);
049: registerChildren();
050: }
051:
052: public NetFileTotalFiveViewBean() {
053: super (PAGE_NAME);
054: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
055: registerChildren();
056: }
057:
058: protected void registerChildren() {
059: super .registerChildren();
060: registerChild(GLOBAL_DATA_VIEW, NetFileTotalFiveView.class);
061: registerChild(ORG_DATA_VIEW, NetFileTotalFiveView.class);
062: registerChild(DYNAMIC_DATA_VIEW, NetFileTotalFiveView.class);
063: registerChild(PAGE_LABEL, StaticTextField.class);
064: }
065:
066: /**
067: * creates child view/component
068: *
069: * @param name of view/component
070: * @return child view/component
071: */
072: protected View createChild(String name) {
073: /* get the model manager and model ready*/
074: getNetFileModelMgr();
075: View child = null;
076:
077: if (name.equals(GLOBAL_DATA_VIEW)) {
078: child = new NetFileTotalFiveView(this , GLOBAL_DATA_VIEW,
079: NetFileModel.GLOBAL_TYPE);
080: } else if (name.equals(ORG_DATA_VIEW)) {
081: child = new NetFileTotalFiveView(this , ORG_DATA_VIEW,
082: NetFileModel.ORG_TYPE);
083: } else if (name.equals(DYNAMIC_DATA_VIEW)) {
084: child = new NetFileTotalFiveView(this , DYNAMIC_DATA_VIEW,
085: NetFileModel.DYNAMIC_TYPE);
086: } else if (name.equals(PAGE_LABEL)) {
087: child = new StaticTextField(this , PAGE_LABEL, modelManager
088: .getString("props.total.five"));
089: } else {
090: child = super .createChild(name);
091: }
092: return child;
093: }
094:
095: public void beginDisplay(DisplayEvent event)
096: throws ModelControlException {
097: super .beginDisplay(event);
098: }
099:
100: public void handleSubmitButtonRequest(RequestInvocationEvent event)
101: throws ModelControlException, SSOException {
102: getModel();
103: NetFileTotalFiveView view = null;
104: view = (NetFileTotalFiveView) getChild(GLOBAL_DATA_VIEW);
105: if (view != null) {
106: store(view, NetFileModel.GLOBAL_TYPE);
107: }
108: view = (NetFileTotalFiveView) getChild(ORG_DATA_VIEW);
109: if (view != null) {
110: store(view, NetFileModel.ORG_TYPE);
111: }
112: view = (NetFileTotalFiveView) getChild(DYNAMIC_DATA_VIEW);
113: if (view != null) {
114: store(view, NetFileModel.DYNAMIC_TYPE);
115: }
116: showPropertiesSavedMessageBox();
117:
118: forwardTo();
119: }
120:
121: private void store(NetFileTotalFiveView view, int type)
122: throws SSOException {
123: NetFileModel m = getModel();
124: m.process();
125: Map map = new HashMap(10);
126: List dynComps = view.getDynamicCompList();//m.getNetFileHostsIndex());
127: NetFileAdminModelManager.debugError("\n Dynamic comps -> "
128: + dynComps);
129: if (dynComps != null && !dynComps.isEmpty()) {
130: Iterator it = dynComps.iterator();
131: while (it.hasNext()) {
132: Object o = it.next();
133: NetFileAdminModelManager.debugError("\n Next element "
134: + o);
135: DynamicGUI dGui = (DynamicGUI) o;
136:
137: if (dGui != null) {
138: Set dgValues = dGui.getValues();
139: if (dGui.getSyntax() == DynamicGUI.SYNTAX_DATE) {
140: try {
141: dgValues = m
142: .getDateInDefaultLocale(dgValues);
143: } catch (AMConsoleException ace) {
144: NetFileAdminModelManager
145: .debugError("Error in converting value to default locale : "
146: + ace);
147: // showMessage(MessageBox.TYPE_ERROR,
148: // m.getErrorTitle(),
149: // ace.getMessage());
150: continue;
151: }
152: }
153: NetFileAdminModelManager
154: .debugError("\nAttr name -> "
155: + dGui.getName() + " value -> "
156: + dgValues);
157: map.put(dGui.getName(), dgValues);
158: }
159: }
160: }
161: if (type == NetFileModel.DYNAMIC_TYPE) {
162: String priority = (String) getDisplayFieldValue(PRIORITY_COMBOBOX);
163: if (!"".equals(priority))
164: map.put("priority", priority);
165: }
166: NetFileAdminModelManager.debugError("Global -> "
167: + NetFileModel.GLOBAL_TYPE + " Dynamic -> "
168: + NetFileModel.DYNAMIC_TYPE + " Org -> "
169: + NetFileModel.ORG_TYPE);
170: NetFileAdminModelManager.debugError("Type -> " + type
171: + " Map -> " + map);
172: if (!map.isEmpty()) {
173: m.store(type, map);
174: }
175: }
176:
177: }
|