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.view.View;
022: import com.iplanet.jato.view.html.StaticTextField;
023: import com.iplanet.jato.view.html.ComboBox;
024: import com.iplanet.jato.view.html.CheckBox;
025: import com.iplanet.jato.view.html.OptionList;
026: import com.iplanet.jato.view.event.DisplayEvent;
027: import com.iplanet.jato.view.event.RequestInvocationEvent;
028: import com.iplanet.jato.model.ModelControlException;
029:
030: // iDS/AME classes
031: import com.iplanet.am.console.components.view.html.DynamicGUI;
032: import com.iplanet.am.console.base.model.AMConsoleException;
033:
034: // NetFile admin console classes
035: import com.sun.portal.netfile.admin.model.NetFileUserProfileModelImpl;
036:
037: public class NetFileTotalTwoUserProfileViewBean extends
038: NetFileUserProfileViewBeanBase {
039:
040: public static final String PAGE_NAME = "NetFileTotalTwoUserProfile";
041: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileTotalTwoUserProfile.jsp";
042:
043: public static final String CHILD_FILERENAME_LBL = "allowRenameLabel";
044: public static final String CHILD_FILERENAME = "allowRename";
045: public static final String FILERENAME_STATUS = "allowRenameStatus";
046:
047: public static final String CHILD_FILEDELETE_LBL = "allowDeleteLabel";
048: public static final String CHILD_FILEDELETE = "allowDelete";
049: public static final String FILEDELETE_STATUS = "allowDeleteStatus";
050:
051: public static final String CHILD_FILEUPLOAD_LBL = "allowUploadLabel";
052: public static final String CHILD_FILEUPLOAD = "allowUpload";
053: public static final String FILEUPLOAD_STATUS = "allowUploadStatus";
054:
055: public static final String CHILD_FILEDOWNLOAD_LBL = "allowDownloadLabel";
056: public static final String CHILD_FILEDOWNLOAD = "allowDownload";
057: public static final String FILEDOWNLOAD_STATUS = "allowDownloadStatus";
058:
059: public static final String CHILD_FILESEARCH_LBL = "allowSearchLabel";
060: public static final String CHILD_FILESEARCH = "allowSearch";
061: public static final String FILESEARCH_STATUS = "allowSearchStatus";
062:
063: public static final String CHILD_FILEMAIL_LBL = "allowMailLabel";
064: public static final String CHILD_FILEMAIL = "allowMail";
065: public static final String FILEMAIL_STATUS = "allowMailStatus";
066:
067: public static final String CHILD_FILECOMPRESS_LBL = "allowCompressLabel";
068: public static final String CHILD_FILECOMPRESS = "allowCompress";
069: public static final String FILECOMPRESS_STATUS = "allowCompressStatus";
070:
071: public static final String CHILD_CHANGEID_LBL = "allowChangeIdLabel";
072: public static final String CHILD_CHANGEID = "allowChangeId";
073: public static final String CHANGEID_STATUS = "allowChangeIdStatus";
074:
075: public static final String CHILD_CHANGEDOMAIN_LBL = "allowChangeDomainLabel";
076: public static final String CHILD_CHANGEDOMAIN = "allowChangeDomain";
077: public static final String CHANGEDOMAIN_STATUS = "allowChangeDomainStatus";
078:
079: public static final String ATTR_ALLOWRENAME = "sunPortalNetFileAllowRename";
080: public static final String ATTR_ALLOWDELETE = "sunPortalNetFileAllowDelete";
081: public static final String ATTR_ALLOWUPLOAD = "sunPortalNetFileAllowUpload";
082: public static final String ATTR_ALLOWDOWNLOAD = "sunPortalNetFileAllowDownload";
083: public static final String ATTR_ALLOWSEARCH = "sunPortalNetFileAllowSearch";
084: public static final String ATTR_ALLOWMAIL = "sunPortalNetFileAllowMail";
085: public static final String ATTR_ALLOWCOMPRESS = "sunPortalNetFileAllowCompression";
086: public static final String ATTR_ALLOWCHANGEID = "sunPortalNetFileAllowChangeUserId";
087: public static final String ATTR_ALLOWCHANGEDOMAIN = "sunPortalNetFileAllowChangeDomain";
088:
089: public NetFileTotalTwoUserProfileViewBean() {
090: super (PAGE_NAME, DEFAULT_DISPLAY_URL);
091: registerChildren();
092: }
093:
094: public NetFileTotalTwoUserProfileViewBean(String pageName) {
095: super (pageName, DEFAULT_DISPLAY_URL);
096: registerChildren();
097: }
098:
099: protected void registerChildren() {
100: super .registerChildren();
101: registerChild(USER_DATA_VIEW,
102: NetFileTotalTwoUserProfileView.class);
103:
104: registerChild(CHILD_FILERENAME_LBL, StaticTextField.class);
105: registerChild(CHILD_FILERENAME, CheckBox.class);
106: registerChild(FILERENAME_STATUS, ComboBox.class);
107:
108: registerChild(CHILD_FILEDELETE_LBL, StaticTextField.class);
109: registerChild(CHILD_FILEDELETE, CheckBox.class);
110: registerChild(FILEDELETE_STATUS, ComboBox.class);
111:
112: registerChild(CHILD_FILEUPLOAD_LBL, StaticTextField.class);
113: registerChild(CHILD_FILEUPLOAD, CheckBox.class);
114: registerChild(FILEUPLOAD_STATUS, ComboBox.class);
115:
116: registerChild(CHILD_FILEDOWNLOAD_LBL, StaticTextField.class);
117: registerChild(CHILD_FILEDOWNLOAD, CheckBox.class);
118: registerChild(FILEDOWNLOAD_STATUS, ComboBox.class);
119:
120: registerChild(CHILD_FILESEARCH_LBL, StaticTextField.class);
121: registerChild(CHILD_FILESEARCH, CheckBox.class);
122: registerChild(FILESEARCH_STATUS, ComboBox.class);
123:
124: registerChild(CHILD_FILEMAIL_LBL, StaticTextField.class);
125: registerChild(CHILD_FILEMAIL, CheckBox.class);
126: registerChild(FILEMAIL_STATUS, ComboBox.class);
127:
128: registerChild(CHILD_FILECOMPRESS_LBL, StaticTextField.class);
129: registerChild(CHILD_FILECOMPRESS, CheckBox.class);
130: registerChild(FILECOMPRESS_STATUS, ComboBox.class);
131:
132: registerChild(CHILD_CHANGEID_LBL, StaticTextField.class);
133: registerChild(CHILD_CHANGEID, CheckBox.class);
134: registerChild(CHANGEID_STATUS, ComboBox.class);
135:
136: registerChild(CHILD_CHANGEDOMAIN_LBL, StaticTextField.class);
137: registerChild(CHILD_CHANGEDOMAIN, CheckBox.class);
138: registerChild(CHANGEDOMAIN_STATUS, ComboBox.class);
139:
140: registerChild(JAVA2_ONLY, StaticTextField.class);
141: }
142:
143: protected View createChild(String name) {
144: getNetFileModelMgr();
145: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
146: m.initModel(getUserDN());
147: View child = null;
148:
149: if (name.equals(CHILD_NETFILE_ATTRSFOR)) {
150: child = new StaticTextField(this , CHILD_NETFILE_ATTRSFOR,
151: modelManager.getString("props.total.two") + " "
152: + modelManager.getString("for.label")
153: + " :");
154: } else if (name.equals(USER_DATA_VIEW)) {
155: child = new NetFileTotalTwoUserProfileView(this ,
156: USER_DATA_VIEW);
157:
158: } else if (name.equals(CHILD_FILERENAME_LBL)) {
159: child = new StaticTextField(this , CHILD_FILERENAME_LBL, m
160: .getAttrLabel(ATTR_ALLOWRENAME));
161: } else if (name.equals(CHILD_FILERENAME)) {
162: child = new CheckBox(this , CHILD_FILERENAME, "true",
163: "false", true);
164: } else if (name.equals(FILERENAME_STATUS)) {
165: child = new ComboBox(this , FILERENAME_STATUS, "");
166:
167: } else if (name.equals(CHILD_FILEDELETE_LBL)) {
168: child = new StaticTextField(this , CHILD_FILEDELETE_LBL, m
169: .getAttrLabel(ATTR_ALLOWDELETE));
170: } else if (name.equals(CHILD_FILEDELETE)) {
171: child = new CheckBox(this , CHILD_FILEDELETE, "true",
172: "false", true);
173: } else if (name.equals(FILEDELETE_STATUS)) {
174: child = new ComboBox(this , FILEDELETE_STATUS, "");
175:
176: } else if (name.equals(CHILD_FILEUPLOAD_LBL)) {
177: child = new StaticTextField(this , CHILD_FILEUPLOAD_LBL, m
178: .getAttrLabel(ATTR_ALLOWUPLOAD));
179: } else if (name.equals(CHILD_FILEUPLOAD)) {
180: child = new CheckBox(this , CHILD_FILEUPLOAD, "true",
181: "false", true);
182: } else if (name.equals(FILEUPLOAD_STATUS)) {
183: child = new ComboBox(this , FILEUPLOAD_STATUS, "");
184:
185: } else if (name.equals(CHILD_FILEDOWNLOAD_LBL)) {
186: child = new StaticTextField(this , CHILD_FILEDOWNLOAD_LBL, m
187: .getAttrLabel(ATTR_ALLOWDOWNLOAD));
188: } else if (name.equals(CHILD_FILEDOWNLOAD)) {
189: child = new CheckBox(this , CHILD_FILEDOWNLOAD, "true",
190: "false", true);
191: } else if (name.equals(FILEDOWNLOAD_STATUS)) {
192: child = new ComboBox(this , FILEDOWNLOAD_STATUS, "");
193:
194: } else if (name.equals(CHILD_FILESEARCH_LBL)) {
195: child = new StaticTextField(this , CHILD_FILESEARCH_LBL, m
196: .getAttrLabel(ATTR_ALLOWSEARCH));
197: } else if (name.equals(CHILD_FILESEARCH)) {
198: child = new CheckBox(this , CHILD_FILESEARCH, "true",
199: "false", true);
200: } else if (name.equals(FILESEARCH_STATUS)) {
201: child = new ComboBox(this , FILESEARCH_STATUS, "");
202:
203: } else if (name.equals(CHILD_FILEMAIL_LBL)) {
204: child = new StaticTextField(this , CHILD_FILEMAIL_LBL, m
205: .getAttrLabel(ATTR_ALLOWMAIL));
206: } else if (name.equals(CHILD_FILEMAIL)) {
207: child = new CheckBox(this , CHILD_FILEMAIL, "true", "false",
208: true);
209: } else if (name.equals(FILEMAIL_STATUS)) {
210: child = new ComboBox(this , FILEMAIL_STATUS, "");
211:
212: } else if (name.equals(CHILD_FILECOMPRESS_LBL)) {
213: child = new StaticTextField(this , CHILD_FILECOMPRESS_LBL, m
214: .getAttrLabel(ATTR_ALLOWCOMPRESS));
215: } else if (name.equals(CHILD_FILECOMPRESS)) {
216: child = new CheckBox(this , CHILD_FILECOMPRESS, "true",
217: "false", true);
218: } else if (name.equals(FILECOMPRESS_STATUS)) {
219: child = new ComboBox(this , FILECOMPRESS_STATUS, "");
220:
221: } else if (name.equals(CHILD_CHANGEID_LBL)) {
222: child = new StaticTextField(this , CHILD_CHANGEID_LBL, m
223: .getAttrLabel(ATTR_ALLOWCHANGEID));
224: } else if (name.equals(CHILD_CHANGEID)) {
225: child = new CheckBox(this , CHILD_CHANGEID, "true", "false",
226: true);
227: } else if (name.equals(CHANGEID_STATUS)) {
228: child = new ComboBox(this , CHANGEID_STATUS, "");
229:
230: } else if (name.equals(CHILD_CHANGEDOMAIN_LBL)) {
231: child = new StaticTextField(this , CHILD_CHANGEDOMAIN_LBL, m
232: .getAttrLabel(ATTR_ALLOWCHANGEDOMAIN));
233: } else if (name.equals(CHILD_CHANGEDOMAIN)) {
234: child = new CheckBox(this , CHILD_CHANGEDOMAIN, "true",
235: "false", true);
236: } else if (name.equals(CHANGEDOMAIN_STATUS)) {
237: child = new ComboBox(this , CHANGEDOMAIN_STATUS, "");
238:
239: } else if (name.equals(JAVA2_ONLY)) {
240: child = new StaticTextField(this , JAVA2_ONLY, modelManager
241: .getString("java2Only"));
242: } else {
243: child = super .createChild(name);
244: }
245: return child;
246: }
247:
248: private void setInitialValue(NetFileUserProfileModelImpl m,
249: String attributeName, String childName) {
250: CheckBox checkBox = (CheckBox) getDisplayField(childName);
251: HashSet valueSet = (HashSet) m.getAttrValues(attributeName);
252: String value = null;
253: if (valueSet != null && valueSet.iterator().hasNext()) {
254: value = (String) valueSet.iterator().next();
255: }
256: checkBox.setValue(value);
257: }
258:
259: public void beginDisplay(DisplayEvent event)
260: throws ModelControlException {
261: getNetFileModelMgr();
262: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
263: setChildValues(model);
264: m.initModel(getUserDN());
265: setDisplayFieldValue(PAGE_DESCRIPTION, m
266: .getServiceDescription());
267: setDisplayFieldValue(SAVE_BTN, modelManager
268: .getString("save.button"));
269: setDisplayFieldValue(RESET_BTN, modelManager
270: .getString("reset.button"));
271: setDisplayFieldValue(CHILD_USERID, m.getUserID());
272:
273: setInitialValue(m, ATTR_ALLOWRENAME, CHILD_FILERENAME);
274: setInitialValue(m, ATTR_ALLOWDELETE, CHILD_FILEDELETE);
275: setInitialValue(m, ATTR_ALLOWUPLOAD, CHILD_FILEUPLOAD);
276: setInitialValue(m, ATTR_ALLOWDOWNLOAD, CHILD_FILEDOWNLOAD);
277:
278: setInitialValue(m, ATTR_ALLOWSEARCH, CHILD_FILESEARCH);
279: setInitialValue(m, ATTR_ALLOWMAIL, CHILD_FILEMAIL);
280: setInitialValue(m, ATTR_ALLOWCOMPRESS, CHILD_FILECOMPRESS);
281:
282: setInitialValue(m, ATTR_ALLOWCHANGEID, CHILD_CHANGEID);
283: setInitialValue(m, ATTR_ALLOWCHANGEDOMAIN, CHILD_CHANGEDOMAIN);
284:
285: if (!m.isReadOnly(ATTR_ALLOWRENAME)) {
286: setStatusOptions(m, FILERENAME_STATUS);
287: }
288: if (!m.isReadOnly(ATTR_ALLOWDELETE)) {
289: setStatusOptions(m, FILEDELETE_STATUS);
290: }
291: if (!m.isReadOnly(ATTR_ALLOWUPLOAD)) {
292: setStatusOptions(m, FILEUPLOAD_STATUS);
293: }
294: if (!m.isReadOnly(ATTR_ALLOWDOWNLOAD)) {
295: setStatusOptions(m, FILEDOWNLOAD_STATUS);
296: }
297: if (!m.isReadOnly(ATTR_ALLOWSEARCH)) {
298: setStatusOptions(m, FILESEARCH_STATUS);
299: }
300: if (!m.isReadOnly(ATTR_ALLOWMAIL)) {
301: setStatusOptions(m, FILEMAIL_STATUS);
302: }
303: if (!m.isReadOnly(ATTR_ALLOWCOMPRESS)) {
304: setStatusOptions(m, FILECOMPRESS_STATUS);
305: }
306: if (!m.isReadOnly(ATTR_ALLOWCHANGEID)) {
307: setStatusOptions(m, CHANGEID_STATUS);
308: }
309: if (!m.isReadOnly(ATTR_ALLOWCHANGEDOMAIN)) {
310: setStatusOptions(m, CHANGEDOMAIN_STATUS);
311: }
312: }
313:
314: private HashSet getCheckedValue(String childName) {
315: CheckBox checkBox = (CheckBox) getDisplayField(childName);
316: String checkBoxValue = (String) checkBox.getValue();
317:
318: Vector valueVector = new Vector(1);
319: valueVector.add(checkBoxValue);
320: return new HashSet(valueVector);
321: }
322:
323: public void handleSaveButtonRequest(RequestInvocationEvent event)
324: throws ModelControlException {
325: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
326: m.initModel(getUserDN());
327: getNetFileModelMgr();
328: try {
329: processAttributes();
330: int size = attrValues.size();
331: Map userOnlyAttrs = new HashMap(size);
332: Map customizedAttrs = new HashMap(size);
333: Set inheritedAttrs = new HashSet(size);
334: Set nameSet = attrStatus.keySet();
335: Iterator nameIter = nameSet.iterator();
336: while (nameIter.hasNext()) {
337: String attrName = (String) nameIter.next();
338: Set values = (Set) attrValues.get(attrName);
339: String status = (String) attrStatus.get(attrName);
340: if (!m.isReadOnly(attrName)
341: && (status == null || status.trim().length() == 0)) {
342: userOnlyAttrs.put(attrName, values);
343: } else if (!m.isReadOnly(attrName)
344: && status.equals(m.getCustomizeValue())) {
345: customizedAttrs.put(attrName, values);
346: } else if (!m.isReadOnly(attrName)
347: && status.equals(m.getInheritValue())) {
348: inheritedAttrs.add(attrName);
349: } else if (!m.isReadOnly(attrName)
350: && status.equals(m.getSkipValue())) {
351: userOnlyAttrs.put(attrName, values);
352: }
353: }
354:
355: String fieldStatus = (String) getDisplayFieldValue(FILERENAME_STATUS);
356: if (fieldStatus.equals(m.getCustomizeValue())) {
357: customizedAttrs.put(ATTR_ALLOWRENAME,
358: getCheckedValue(CHILD_FILERENAME));
359: } else if (fieldStatus.equals(m.getInheritValue())) {
360: inheritedAttrs.add(ATTR_ALLOWRENAME);
361: }
362:
363: fieldStatus = (String) getDisplayFieldValue(FILEDELETE_STATUS);
364: if (fieldStatus.equals(m.getCustomizeValue())) {
365: customizedAttrs.put(ATTR_ALLOWDELETE,
366: getCheckedValue(CHILD_FILEDELETE));
367: } else if (fieldStatus.equals(m.getInheritValue())) {
368: inheritedAttrs.add(ATTR_ALLOWDELETE);
369: }
370:
371: fieldStatus = (String) getDisplayFieldValue(FILEUPLOAD_STATUS);
372: if (fieldStatus.equals(m.getCustomizeValue())) {
373: customizedAttrs.put(ATTR_ALLOWUPLOAD,
374: getCheckedValue(CHILD_FILEUPLOAD));
375: } else if (fieldStatus.equals(m.getInheritValue())) {
376: inheritedAttrs.add(ATTR_ALLOWUPLOAD);
377: }
378:
379: fieldStatus = (String) getDisplayFieldValue(FILEDOWNLOAD_STATUS);
380: if (fieldStatus.equals(m.getCustomizeValue())) {
381: customizedAttrs.put(ATTR_ALLOWDOWNLOAD,
382: getCheckedValue(CHILD_FILEDOWNLOAD));
383: } else if (fieldStatus.equals(m.getInheritValue())) {
384: inheritedAttrs.add(ATTR_ALLOWDOWNLOAD);
385: }
386:
387: fieldStatus = (String) getDisplayFieldValue(FILESEARCH_STATUS);
388: if (fieldStatus.equals(m.getCustomizeValue())) {
389: customizedAttrs.put(ATTR_ALLOWSEARCH,
390: getCheckedValue(CHILD_FILESEARCH));
391: } else if (fieldStatus.equals(m.getInheritValue())) {
392: inheritedAttrs.add(ATTR_ALLOWSEARCH);
393: }
394:
395: fieldStatus = (String) getDisplayFieldValue(FILEMAIL_STATUS);
396: if (fieldStatus.equals(m.getCustomizeValue())) {
397: customizedAttrs.put(ATTR_ALLOWMAIL,
398: getCheckedValue(CHILD_FILEMAIL));
399: } else if (fieldStatus.equals(m.getInheritValue())) {
400: inheritedAttrs.add(ATTR_ALLOWMAIL);
401: }
402:
403: fieldStatus = (String) getDisplayFieldValue(FILECOMPRESS_STATUS);
404: if (fieldStatus.equals(m.getCustomizeValue())) {
405: customizedAttrs.put(ATTR_ALLOWCOMPRESS,
406: getCheckedValue(CHILD_FILECOMPRESS));
407: } else if (fieldStatus.equals(m.getInheritValue())) {
408: inheritedAttrs.add(ATTR_ALLOWCOMPRESS);
409: }
410:
411: fieldStatus = (String) getDisplayFieldValue(CHANGEID_STATUS);
412: if (fieldStatus.equals(m.getCustomizeValue())) {
413: customizedAttrs.put(ATTR_ALLOWCHANGEID,
414: getCheckedValue(CHILD_CHANGEID));
415: } else if (fieldStatus.equals(m.getInheritValue())) {
416: inheritedAttrs.add(ATTR_ALLOWCHANGEID);
417: }
418:
419: fieldStatus = (String) getDisplayFieldValue(CHANGEDOMAIN_STATUS);
420: if (fieldStatus.equals(m.getCustomizeValue())) {
421: customizedAttrs.put(ATTR_ALLOWCHANGEDOMAIN,
422: getCheckedValue(CHILD_CHANGEDOMAIN));
423: } else if (fieldStatus.equals(m.getInheritValue())) {
424: inheritedAttrs.add(ATTR_ALLOWCHANGEDOMAIN);
425: }
426:
427: m.storeAttributes(userOnlyAttrs, customizedAttrs,
428: inheritedAttrs);
429: } catch (AMConsoleException ace) {
430: }
431: forwardTo();
432: }
433:
434: public void processAttributes() throws AMConsoleException {
435: if (attrValues == null) {
436: attrValues = new HashMap();
437: }
438: if (attrStatus == null) {
439: attrStatus = new HashMap();
440: }
441: NetFileTotalTwoUserProfileView view = (NetFileTotalTwoUserProfileView) getChild(USER_DATA_VIEW);
442: List dynComps = view.getDynamicCompList();
443: if (dynComps != null && !dynComps.isEmpty()) {
444: Iterator it = dynComps.iterator();
445: while (it.hasNext()) {
446: DynamicGUI dGui = (DynamicGUI) it.next();
447: if (dGui != null) {
448: attrValues.put(dGui.getName(), dGui.getValues());
449: attrStatus.put(dGui.getName(), dGui
450: .getStatusValue());
451: }
452: }
453: }
454: }
455:
456: private void setStatusOptions(NetFileUserProfileModelImpl model,
457: String attrStatus) {
458: OptionList optionList = new OptionList();
459: optionList.add(model.getCustomizeLabel(), model
460: .getCustomizeValue());
461: optionList
462: .add(model.getInheritLabel(), model.getInheritValue());
463: optionList.add(model.getSkipLabel(), model.getSkipValue());
464: ComboBox cb = (ComboBox) getChild(attrStatus);
465: cb.setOptions(optionList);
466: cb.setValue(model.getSkipValue());
467: }
468:
469: }
|