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.*;
018: import com.sun.portal.log.common.PortalLogger;
019:
020: // iPlanet JATO classes
021: import com.iplanet.jato.model.ModelControlException;
022: import com.iplanet.jato.view.View;
023: import com.iplanet.jato.view.event.DisplayEvent;
024: import com.iplanet.jato.view.event.RequestInvocationEvent;
025: import com.iplanet.jato.view.html.StaticTextField;
026: import com.iplanet.jato.view.html.CheckBox;
027:
028: // iDS/AME classes
029: import com.iplanet.am.console.base.model.AMAdminConstants;
030: import com.iplanet.am.console.base.model.AMConsoleException;
031: import com.iplanet.am.console.components.view.html.DynamicGUI;
032: import com.iplanet.sso.SSOException;
033:
034: // NetFile admin console classes
035: import com.sun.portal.netfile.admin.model.NetFileModel;
036:
037: public class NetFileTotalTwoViewBean extends NetFileViewBeanBase
038: implements NetFileAdminService, AMAdminConstants {
039:
040: public static final String PAGE_NAME = "NetFileTotalTwo";
041: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileTotalTwo.jsp";
042: public static final String PAGE_LABEL = "lblTotalTwo";
043:
044: public static final String CHILD_FILERENAME_LBL = "allowRenameLabel";
045: public static final String CHILD_FILERENAME = "allowRename";
046:
047: public static final String CHILD_FILEDELETE_LBL = "allowDeleteLabel";
048: public static final String CHILD_FILEDELETE = "allowDelete";
049:
050: public static final String CHILD_FILEUPLOAD_LBL = "allowUploadLabel";
051: public static final String CHILD_FILEUPLOAD = "allowUpload";
052:
053: public static final String CHILD_FILEDOWNLOAD_LBL = "allowDownloadLabel";
054: public static final String CHILD_FILEDOWNLOAD = "allowDownload";
055:
056: public static final String CHILD_FILESEARCH_LBL = "allowSearchLabel";
057: public static final String CHILD_FILESEARCH = "allowSearch";
058:
059: public static final String CHILD_FILEMAIL_LBL = "allowMailLabel";
060: public static final String CHILD_FILEMAIL = "allowMail";
061:
062: public static final String CHILD_FILECOMPRESS_LBL = "allowCompressLabel";
063: public static final String CHILD_FILECOMPRESS = "allowCompress";
064:
065: public static final String CHILD_CHANGEID_LBL = "allowChangeIdLabel";
066: public static final String CHILD_CHANGEID = "allowChangeId";
067:
068: public static final String CHILD_CHANGEDOMAIN_LBL = "allowChangeDomainLabel";
069: public static final String CHILD_CHANGEDOMAIN = "allowChangeDomain";
070:
071: public static final String ATTR_ALLOWRENAME = "sunPortalNetFileAllowRename";
072: public static final String ATTR_ALLOWDELETE = "sunPortalNetFileAllowDelete";
073: public static final String ATTR_ALLOWUPLOAD = "sunPortalNetFileAllowUpload";
074: public static final String ATTR_ALLOWDOWNLOAD = "sunPortalNetFileAllowDownload";
075: public static final String ATTR_ALLOWSEARCH = "sunPortalNetFileAllowSearch";
076: public static final String ATTR_ALLOWMAIL = "sunPortalNetFileAllowMail";
077: public static final String ATTR_ALLOWCOMPRESS = "sunPortalNetFileAllowCompression";
078: public static final String ATTR_ALLOWCHANGEID = "sunPortalNetFileAllowChangeUserId";
079: public static final String ATTR_ALLOWCHANGEDOMAIN = "sunPortalNetFileAllowChangeDomain";
080:
081: public NetFileTotalTwoViewBean(String pageName) {
082: super (pageName);
083: registerChildren();
084: }
085:
086: public NetFileTotalTwoViewBean() {
087: super (PAGE_NAME);
088: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
089: registerChildren();
090: }
091:
092: protected void registerChildren() {
093: super .registerChildren();
094: registerChild(GLOBAL_DATA_VIEW, NetFileTotalTwoView.class);
095: registerChild(ORG_DATA_VIEW, NetFileTotalTwoView.class);
096: registerChild(DYNAMIC_DATA_VIEW, NetFileTotalTwoView.class);
097: registerChild(PAGE_LABEL, StaticTextField.class);
098:
099: registerChild(CHILD_FILERENAME_LBL, StaticTextField.class);
100: registerChild(CHILD_FILERENAME, CheckBox.class);
101: registerChild(CHILD_FILEDELETE_LBL, StaticTextField.class);
102: registerChild(CHILD_FILEDELETE, CheckBox.class);
103: registerChild(CHILD_FILEUPLOAD_LBL, StaticTextField.class);
104: registerChild(CHILD_FILEUPLOAD, CheckBox.class);
105: registerChild(CHILD_FILEDOWNLOAD_LBL, StaticTextField.class);
106: registerChild(CHILD_FILEDOWNLOAD, CheckBox.class);
107:
108: registerChild(CHILD_FILESEARCH_LBL, StaticTextField.class);
109: registerChild(CHILD_FILESEARCH, CheckBox.class);
110: registerChild(CHILD_FILEMAIL_LBL, StaticTextField.class);
111: registerChild(CHILD_FILEMAIL, CheckBox.class);
112: registerChild(CHILD_FILECOMPRESS_LBL, StaticTextField.class);
113: registerChild(CHILD_FILECOMPRESS, CheckBox.class);
114:
115: registerChild(CHILD_CHANGEID_LBL, StaticTextField.class);
116: registerChild(CHILD_CHANGEID, CheckBox.class);
117: registerChild(CHILD_CHANGEDOMAIN_LBL, StaticTextField.class);
118: registerChild(CHILD_CHANGEDOMAIN, CheckBox.class);
119:
120: registerChild(JAVA2_ONLY, StaticTextField.class);
121: }
122:
123: /**
124: * creates child view/component
125: *
126: * @param name of view/component
127: * @return child view/component
128: */
129: protected View createChild(String name) {
130: /* get the model manager and model ready*/
131: getNetFileModelMgr();
132: View child = null;
133:
134: int viewType = NetFileModel.DYNAMIC_TYPE;
135:
136: if (name.equals(GLOBAL_DATA_VIEW)) {
137: child = new NetFileTotalTwoView(this , GLOBAL_DATA_VIEW,
138: NetFileModel.GLOBAL_TYPE);
139: } else if (name.equals(ORG_DATA_VIEW)) {
140: child = new NetFileTotalTwoView(this , ORG_DATA_VIEW,
141: NetFileModel.ORG_TYPE);
142: } else if (name.equals(DYNAMIC_DATA_VIEW)) {
143: child = new NetFileTotalTwoView(this , DYNAMIC_DATA_VIEW,
144: NetFileModel.DYNAMIC_TYPE);
145: } else if (name.equals(PAGE_LABEL)) {
146: child = new StaticTextField(this , PAGE_LABEL, modelManager
147: .getString("props.total.two"));
148:
149: } else if (name.equals(CHILD_FILERENAME_LBL)) {
150: model.setCurrentRow(viewType, model
151: .getNetFileAttributeIndex(ATTR_ALLOWRENAME));
152: child = new StaticTextField(this , CHILD_FILERENAME_LBL,
153: model.getDynamicGUI().getLabel());
154: } else if (name.equals(CHILD_FILERENAME)) {
155: child = new CheckBox(this , CHILD_FILERENAME, "true",
156: "false", true);
157:
158: } else if (name.equals(CHILD_FILEDELETE_LBL)) {
159: model.setCurrentRow(viewType, model
160: .getNetFileAttributeIndex(ATTR_ALLOWDELETE));
161: child = new StaticTextField(this , CHILD_FILEDELETE_LBL,
162: model.getDynamicGUI().getLabel());
163: } else if (name.equals(CHILD_FILEDELETE)) {
164: child = new CheckBox(this , CHILD_FILEDELETE, "true",
165: "false", true);
166:
167: } else if (name.equals(CHILD_FILEUPLOAD_LBL)) {
168: model.setCurrentRow(viewType, model
169: .getNetFileAttributeIndex(ATTR_ALLOWUPLOAD));
170: child = new StaticTextField(this , CHILD_FILEUPLOAD_LBL,
171: model.getDynamicGUI().getLabel());
172: } else if (name.equals(CHILD_FILEUPLOAD)) {
173: child = new CheckBox(this , CHILD_FILEUPLOAD, "true",
174: "false", true);
175:
176: } else if (name.equals(CHILD_FILEDOWNLOAD_LBL)) {
177: model.setCurrentRow(viewType, model
178: .getNetFileAttributeIndex(ATTR_ALLOWDOWNLOAD));
179: child = new StaticTextField(this , CHILD_FILEDOWNLOAD_LBL,
180: model.getDynamicGUI().getLabel());
181: } else if (name.equals(CHILD_FILEDOWNLOAD)) {
182: child = new CheckBox(this , CHILD_FILEDOWNLOAD, "true",
183: "false", true);
184:
185: } else if (name.equals(CHILD_FILESEARCH_LBL)) {
186: model.setCurrentRow(viewType, model
187: .getNetFileAttributeIndex(ATTR_ALLOWSEARCH));
188: child = new StaticTextField(this , CHILD_FILESEARCH_LBL,
189: model.getDynamicGUI().getLabel());
190: } else if (name.equals(CHILD_FILESEARCH)) {
191: child = new CheckBox(this , CHILD_FILESEARCH, "true",
192: "false", true);
193:
194: } else if (name.equals(CHILD_FILEMAIL_LBL)) {
195: model.setCurrentRow(viewType, model
196: .getNetFileAttributeIndex(ATTR_ALLOWMAIL));
197: child = new StaticTextField(this , CHILD_FILEMAIL_LBL, model
198: .getDynamicGUI().getLabel());
199: } else if (name.equals(CHILD_FILEMAIL)) {
200: child = new CheckBox(this , CHILD_FILEMAIL, "true", "false",
201: true);
202:
203: } else if (name.equals(CHILD_FILECOMPRESS_LBL)) {
204: model.setCurrentRow(viewType, model
205: .getNetFileAttributeIndex(ATTR_ALLOWCOMPRESS));
206: child = new StaticTextField(this , CHILD_FILECOMPRESS_LBL,
207: model.getDynamicGUI().getLabel());
208: } else if (name.equals(CHILD_FILECOMPRESS)) {
209: child = new CheckBox(this , CHILD_FILECOMPRESS, "true",
210: "false", true);
211:
212: } else if (name.equals(CHILD_CHANGEID_LBL)) {
213: model.setCurrentRow(viewType, model
214: .getNetFileAttributeIndex(ATTR_ALLOWCHANGEID));
215: child = new StaticTextField(this , CHILD_CHANGEID_LBL, model
216: .getDynamicGUI().getLabel());
217: } else if (name.equals(CHILD_CHANGEID)) {
218: child = new CheckBox(this , CHILD_CHANGEID, "true", "false",
219: true);
220:
221: } else if (name.equals(CHILD_CHANGEDOMAIN_LBL)) {
222: model.setCurrentRow(viewType, model
223: .getNetFileAttributeIndex(ATTR_ALLOWCHANGEDOMAIN));
224: child = new StaticTextField(this , CHILD_CHANGEDOMAIN_LBL,
225: model.getDynamicGUI().getLabel());
226: } else if (name.equals(CHILD_CHANGEDOMAIN)) {
227: child = new CheckBox(this , CHILD_CHANGEDOMAIN, "true",
228: "false", true);
229:
230: } else if (name.equals(JAVA2_ONLY)) {
231: child = new StaticTextField(this , JAVA2_ONLY, modelManager
232: .getString("java2Only"));
233: } else {
234: child = super .createChild(name);
235: }
236: return child;
237: }
238:
239: private void setInitialValue(String attributeName, String childName) {
240: int viewType = NetFileModel.DYNAMIC_TYPE;
241: model.setCurrentRow(viewType, model
242: .getNetFileAttributeIndex(attributeName));
243: CheckBox checkBox = (CheckBox) getDisplayField(childName);
244: HashSet valueSet = (HashSet) model.getAttrValues();
245: String value = null;
246: if (valueSet != null && valueSet.iterator().hasNext()) {
247: value = (String) valueSet.iterator().next();
248: }
249: checkBox.setValue(value);
250: }
251:
252: public void beginDisplay(DisplayEvent event)
253: throws ModelControlException {
254: getModel();
255: setChildValues(model);
256: model.process();
257: getNetFileModelMgr();
258:
259: setDisplayFieldValue(PAGE_DESCRIPTION, model
260: .getServiceDisplayName());
261: setDisplayFieldValue(GLOBAL_LABEL, modelManager
262: .getString("global"));
263: setDisplayFieldValue(ORG_LABEL, modelManager
264: .getString("organization"));
265: setDisplayFieldValue(DYNAMIC_LABEL, modelManager
266: .getString("dynamic"));
267: setDisplayFieldValue(SUBMIT_BTN, modelManager
268: .getString("save.button"));
269: setDisplayFieldValue(RESET_BTN, modelManager
270: .getString("reset.button"));
271: setDisplayFieldValue(DELETE_BUTTON, modelManager
272: .getString("delete.button"));
273: setDisplayFieldValue(HELP_DOC_URL, modelManager
274: .getString(NetFileAdminService.SRA_BASE_HLP_URL));
275: setDisplayFieldValue(HELP_ANCHOR_TAG, model
276: .getHelpUrl(modelManager
277: .getString(NetFileAdminService.SRA_NF_HLP_URL)));
278:
279: setInitialValue(ATTR_ALLOWRENAME, CHILD_FILERENAME);
280: setInitialValue(ATTR_ALLOWDELETE, CHILD_FILEDELETE);
281: setInitialValue(ATTR_ALLOWUPLOAD, CHILD_FILEUPLOAD);
282: setInitialValue(ATTR_ALLOWDOWNLOAD, CHILD_FILEDOWNLOAD);
283:
284: setInitialValue(ATTR_ALLOWSEARCH, CHILD_FILESEARCH);
285: setInitialValue(ATTR_ALLOWMAIL, CHILD_FILEMAIL);
286: setInitialValue(ATTR_ALLOWCOMPRESS, CHILD_FILECOMPRESS);
287:
288: setInitialValue(ATTR_ALLOWCHANGEID, CHILD_CHANGEID);
289: setInitialValue(ATTR_ALLOWCHANGEDOMAIN, CHILD_CHANGEDOMAIN);
290: }
291:
292: public void handleSubmitButtonRequest(RequestInvocationEvent event)
293: throws ModelControlException, SSOException {
294: getModel();
295: NetFileTotalTwoView view = null;
296: view = (NetFileTotalTwoView) getChild(GLOBAL_DATA_VIEW);
297: if (view != null) {
298: store(view, NetFileModel.GLOBAL_TYPE);
299: }
300: view = (NetFileTotalTwoView) getChild(ORG_DATA_VIEW);
301: if (view != null) {
302: store(view, NetFileModel.ORG_TYPE);
303: }
304: view = (NetFileTotalTwoView) getChild(DYNAMIC_DATA_VIEW);
305: if (view != null) {
306: store(view, NetFileModel.DYNAMIC_TYPE);
307: }
308: showPropertiesSavedMessageBox();
309:
310: forwardTo();
311: }
312:
313: private HashSet getCheckedValue(String childName) {
314: CheckBox checkBox = (CheckBox) getDisplayField(childName);
315: String checkBoxValue = (String) checkBox.getValue();
316:
317: Vector valueVector = new Vector(1);
318: valueVector.add(checkBoxValue);
319: return new HashSet(valueVector);
320: }
321:
322: private void store(NetFileTotalTwoView view, int type)
323: throws SSOException {
324: NetFileModel m = getModel();
325: m.process();
326: Map map = new HashMap(10);
327: List dynComps = view.getDynamicCompList();
328:
329: if (dynComps != null && !dynComps.isEmpty()) {
330: Iterator it = dynComps.iterator();
331: while (it.hasNext()) {
332: DynamicGUI dGui = (DynamicGUI) it.next();
333: if (dGui != null) {
334: Set dgValues = dGui.getValues();
335: if (dGui.getSyntax() == DynamicGUI.SYNTAX_DATE) {
336: try {
337: dgValues = m
338: .getDateInDefaultLocale(dgValues);
339: } catch (AMConsoleException ace) {
340: NetFileAdminModelManager
341: .debugError("Error in converting value to default locale : "
342: + ace);
343: // showMessage(MessageBox.TYPE_ERROR,
344: // m.getErrorTitle(),
345: // ace.getMessage());
346: continue;
347: }
348: }
349: map.put(dGui.getName(), dgValues);
350: }
351: }
352: }
353:
354: if (type == NetFileModel.DYNAMIC_TYPE) {
355: map
356: .put(ATTR_ALLOWRENAME,
357: getCheckedValue(CHILD_FILERENAME));
358: map
359: .put(ATTR_ALLOWDELETE,
360: getCheckedValue(CHILD_FILEDELETE));
361: map
362: .put(ATTR_ALLOWUPLOAD,
363: getCheckedValue(CHILD_FILEUPLOAD));
364: map.put(ATTR_ALLOWDOWNLOAD,
365: getCheckedValue(CHILD_FILEDOWNLOAD));
366:
367: map
368: .put(ATTR_ALLOWSEARCH,
369: getCheckedValue(CHILD_FILESEARCH));
370: map.put(ATTR_ALLOWMAIL, getCheckedValue(CHILD_FILEMAIL));
371: map.put(ATTR_ALLOWCOMPRESS,
372: getCheckedValue(CHILD_FILECOMPRESS));
373:
374: map
375: .put(ATTR_ALLOWCHANGEID,
376: getCheckedValue(CHILD_CHANGEID));
377: map.put(ATTR_ALLOWCHANGEDOMAIN,
378: getCheckedValue(CHILD_CHANGEDOMAIN));
379:
380: String priority = (String) getDisplayFieldValue(PRIORITY_COMBOBOX);
381: if (!"".equals(priority))
382: map.put("priority", priority);
383: }
384:
385: if (!map.isEmpty()) {
386: m.store(type, map);
387: }
388: }
389: }
|