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.HashSet;
018: import com.sun.portal.log.common.PortalLogger;
019: import java.util.HashMap;
020: import java.util.Iterator;
021: import java.util.Map;
022: import java.util.Set;
023: import java.util.Vector;
024:
025: // iPlanet JATO classes
026: import com.iplanet.jato.model.ModelControlException;
027: import com.iplanet.jato.view.View;
028: import com.iplanet.jato.view.event.ChildDisplayEvent;
029: import com.iplanet.jato.view.event.DisplayEvent;
030: import com.iplanet.jato.view.event.RequestInvocationEvent;
031: import com.iplanet.jato.view.html.ComboBox;
032: import com.iplanet.jato.view.html.OptionList;
033: import com.iplanet.jato.view.html.StaticTextField;
034:
035: // iDS/AME classes
036: import com.iplanet.am.console.base.model.AMConsoleException;
037:
038: // NetFile admin console classes
039: import com.sun.portal.netfile.admin.model.NetFileUserProfileModelImpl;
040:
041: public class NetFileTotalFourDotThreeUserProfileViewBean extends
042: NetFileUserProfileViewBeanBase implements
043: NetFileCompressionConstants {
044:
045: public static final String PAGE_NAME = "NetFileTotalFourDotThreeUserProfile";
046: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileTotalFourDotThreeUserProfile.jsp";
047:
048: public static final String COMPRESSIONTYPE_STATUS = "compressionTypeStatus";
049: public static final String COMPRESSIONLEVEL_STATUS = "compressionLevelStatus";
050:
051: public NetFileTotalFourDotThreeUserProfileViewBean() {
052: super (PAGE_NAME, DEFAULT_DISPLAY_URL);
053: registerChildren();
054: }
055:
056: public NetFileTotalFourDotThreeUserProfileViewBean(String pageName) {
057: super (pageName, DEFAULT_DISPLAY_URL);
058: registerChildren();
059: }
060:
061: protected void registerChildren() {
062: super .registerChildren();
063: registerChild(USER_DATA_VIEW,
064: NetFileTotalFourDotThreeUserProfileView.class);
065: registerChild(CHILD_COMPRESSIONTYPE_LBL, StaticTextField.class);
066: registerChild(CHILD_COMPRESSIONTYPE, ComboBox.class);
067: registerChild(COMPRESSIONTYPE_STATUS, ComboBox.class);
068: registerChild(CHILD_COMPRESSIONLEVEL_LBL, StaticTextField.class);
069: registerChild(CHILD_COMPRESSIONLEVEL, ComboBox.class);
070: registerChild(COMPRESSIONLEVEL_STATUS, ComboBox.class);
071: registerChild(JAVA2_ONLY, StaticTextField.class);
072: }
073:
074: protected View createChild(String name) {
075: getNetFileModelMgr();
076: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
077: m.initModel(getUserDN());
078: View child = null;
079:
080: if (name.equals(CHILD_NETFILE_ATTRSFOR)) {
081: child = new StaticTextField(
082: this ,
083: CHILD_NETFILE_ATTRSFOR,
084: modelManager.getString("props.total.four")
085: + " "
086: + modelManager.getString("for.label")
087: + " "
088: + modelManager
089: .getString("props.total.four.three")
090: + " " + modelManager.getString("for.label")
091: + " :");
092: } else if (name.equals(USER_DATA_VIEW)) {
093: child = new NetFileTotalFourDotThreeUserProfileView(this ,
094: USER_DATA_VIEW);
095: } else if (name.equals(CHILD_COMPRESSIONTYPE_LBL)) {
096: child = new StaticTextField(this ,
097: CHILD_COMPRESSIONTYPE_LBL, m
098: .getAttrLabel(ATTR_COMPRESSION_TYPE));
099: } else if (name.equals(CHILD_COMPRESSIONTYPE)) {
100: child = new ComboBox(this , CHILD_COMPRESSIONTYPE, "");
101: } else if (name.equals(COMPRESSIONTYPE_STATUS)) {
102: child = new ComboBox(this , COMPRESSIONTYPE_STATUS, "");
103: } else if (name.equals(CHILD_COMPRESSIONLEVEL_LBL)) {
104: child = new StaticTextField(this ,
105: CHILD_COMPRESSIONLEVEL_LBL, m
106: .getAttrLabel(ATTR_COMPRESSION_LEVEL));
107: } else if (name.equals(CHILD_COMPRESSIONLEVEL)) {
108: child = new ComboBox(this , CHILD_COMPRESSIONLEVEL, "");
109: } else if (name.equals(COMPRESSIONLEVEL_STATUS)) {
110: child = new ComboBox(this , COMPRESSIONLEVEL_STATUS, "");
111: } else if (name.equals(JAVA2_ONLY)) {
112: child = new StaticTextField(this , JAVA2_ONLY, modelManager
113: .getString("java2Only"));
114: } else {
115: child = super .createChild(name);
116: }
117: return child;
118: }
119:
120: public ComboBox setCompressionTypeOptions() {
121: OptionList optList = new OptionList();
122: String tmp;
123: for (int count = 0; count < compressionTypeOptionList.length; count++) {
124: tmp = modelManager.getString("compressionType."
125: + compressionTypeOptionList[count]);
126: optList.add(tmp, tmp);
127: }
128: ComboBox cb = (ComboBox) getDisplayField(CHILD_COMPRESSIONTYPE);
129: cb.setOptions(optList);
130: return cb;
131: }
132:
133: public ComboBox setCompressionLevelOptions() {
134: OptionList optList = new OptionList();
135: for (int count = 0; count < compressionLevelOptionListSize; count++) {
136: optList.add(compressionLevelOptionList[count],
137: compressionLevelOptionList[count]);
138: }
139: ComboBox cb = (ComboBox) getDisplayField(CHILD_COMPRESSIONLEVEL);
140: cb.setOptions(optList);
141: return cb;
142: }
143:
144: public void beginDisplay(DisplayEvent event)
145: throws ModelControlException {
146: getNetFileModelMgr();
147: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
148: setChildValues(model);
149: m.initModel(getUserDN());
150: setDisplayFieldValue(PAGE_DESCRIPTION, m
151: .getServiceDescription());
152: setDisplayFieldValue(SAVE_BTN, modelManager
153: .getString("save.button"));
154: setDisplayFieldValue(RESET_BTN, modelManager
155: .getString("reset.button"));
156: setDisplayFieldValue(CHILD_USERID, m.getUserID());
157:
158: ComboBox compressionTypeCB = setCompressionTypeOptions();
159: HashSet valueSet = (HashSet) m
160: .getAttrValues(ATTR_COMPRESSION_TYPE);
161: String compressionValue = null;
162: if (valueSet != null && valueSet.iterator().hasNext()) {
163: compressionValue = (String) valueSet.iterator().next();
164: }
165: compressionValue = modelManager.getString("compressionType."
166: + compressionValue);
167: compressionTypeCB.setValue(compressionValue);
168:
169: ComboBox compressionLevelCB = setCompressionLevelOptions();
170: valueSet = (HashSet) m.getAttrValues(ATTR_COMPRESSION_LEVEL);
171: if (valueSet != null && valueSet.iterator().hasNext()) {
172: compressionValue = (String) valueSet.iterator().next();
173: }
174: compressionLevelCB.setValue(compressionValue);
175:
176: if (!m.isReadOnly(ATTR_COMPRESSION_TYPE)) {
177: setCompressionTypeStatusOptions(m);
178: }
179:
180: if (!m.isReadOnly(ATTR_COMPRESSION_LEVEL)) {
181: setCompressionLevelStatusOptions(m);
182: }
183: }
184:
185: public void handleSaveButtonRequest(RequestInvocationEvent event)
186: throws ModelControlException {
187: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
188: m.initModel(getUserDN());
189: try {
190: processAttributes();
191: int size = attrValues.size();
192: Map userOnlyAttrs = new HashMap(size);
193: Map customizedAttrs = new HashMap(size);
194: Set inheritedAttrs = new HashSet(size);
195: Set nameSet = attrStatus.keySet();
196: Iterator nameIter = nameSet.iterator();
197: while (nameIter.hasNext()) {
198: String attrName = (String) nameIter.next();
199: Set values = (Set) attrValues.get(attrName);
200: String status = (String) attrStatus.get(attrName);
201: if (!m.isReadOnly(attrName)
202: && (status == null || status.trim().length() == 0)) {
203: userOnlyAttrs.put(attrName, values);
204: } else if (!m.isReadOnly(attrName)
205: && status.equals(m.getCustomizeValue())) {
206: customizedAttrs.put(attrName, values);
207: } else if (!m.isReadOnly(attrName)
208: && status.equals(m.getInheritValue())) {
209: inheritedAttrs.add(attrName);
210: } else if (!m.isReadOnly(attrName)
211: && status.equals(m.getSkipValue())) {
212: userOnlyAttrs.put(attrName, values);
213: }
214: }
215:
216: String netFileCompressionTypeStatus = (String) getDisplayFieldValue(COMPRESSIONTYPE_STATUS);
217: String netFileCompressionLevelStatus = (String) getDisplayFieldValue(COMPRESSIONLEVEL_STATUS);
218:
219: if (netFileCompressionTypeStatus.equals(m
220: .getCustomizeValue())) {
221: ComboBox cb = (ComboBox) getDisplayField(CHILD_COMPRESSIONTYPE);
222: String compressionTypeValue = (String) (cb.getValue());
223: String tmp;
224: for (int count = 0; count < compressionTypeOptionList.length; count++) {
225: tmp = modelManager.getString("compressionType."
226: + compressionTypeOptionList[count]);
227: if (compressionTypeValue.equals(tmp)) {
228: compressionTypeValue = compressionTypeOptionList[count];
229: break;
230: }
231: }
232: Vector compressionTypeVector = new Vector(1);
233: compressionTypeVector.add(compressionTypeValue);
234: HashSet compressionTypeSet = new HashSet(
235: compressionTypeVector);
236: customizedAttrs.put(ATTR_COMPRESSION_TYPE,
237: compressionTypeSet);
238: } else if (netFileCompressionTypeStatus.equals(m
239: .getInheritValue())) {
240: inheritedAttrs.add(ATTR_COMPRESSION_TYPE);
241: }
242:
243: if (netFileCompressionLevelStatus.equals(m
244: .getCustomizeValue())) {
245: ComboBox cb = (ComboBox) getDisplayField(CHILD_COMPRESSIONLEVEL);
246: String compressionLevelValue = (String) (cb.getValue());
247: Vector compressionLevelVector = new Vector(1);
248: compressionLevelVector.add(compressionLevelValue);
249: HashSet compressionLevelSet = new HashSet(
250: compressionLevelVector);
251: customizedAttrs.put(ATTR_COMPRESSION_LEVEL,
252: compressionLevelSet);
253: } else if (netFileCompressionLevelStatus.equals(m
254: .getInheritValue())) {
255: inheritedAttrs.add(ATTR_COMPRESSION_LEVEL);
256: }
257:
258: m.storeAttributes(userOnlyAttrs, customizedAttrs,
259: inheritedAttrs);
260: } catch (AMConsoleException ace) {
261: }
262: forwardTo();
263: }
264:
265: public boolean beginCompressionTypeStatusDisplay(
266: ChildDisplayEvent event) {
267: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
268: m.initModel(getUserDN());
269: return !m.isReadOnly(ATTR_COMPRESSION_TYPE);
270: }
271:
272: public boolean beginCompressionLevelStatusDisplay(
273: ChildDisplayEvent event) {
274: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
275: m.initModel(getUserDN());
276: return !m.isReadOnly(ATTR_COMPRESSION_LEVEL);
277: }
278:
279: private void setCompressionTypeStatusOptions(
280: NetFileUserProfileModelImpl model) {
281: OptionList optionList = new OptionList();
282: optionList.add(model.getCustomizeLabel(), model
283: .getCustomizeValue());
284: optionList
285: .add(model.getInheritLabel(), model.getInheritValue());
286: optionList.add(model.getSkipLabel(), model.getSkipValue());
287: ComboBox cb = (ComboBox) getChild(COMPRESSIONTYPE_STATUS);
288: cb.setOptions(optionList);
289: cb.setValue(model.getSkipValue());
290: }
291:
292: private void setCompressionLevelStatusOptions(
293: NetFileUserProfileModelImpl model) {
294: OptionList optionList = new OptionList();
295: optionList.add(model.getCustomizeLabel(), model
296: .getCustomizeValue());
297: optionList
298: .add(model.getInheritLabel(), model.getInheritValue());
299: optionList.add(model.getSkipLabel(), model.getSkipValue());
300: ComboBox cb = (ComboBox) getChild(COMPRESSIONLEVEL_STATUS);
301: cb.setOptions(optionList);
302: cb.setValue(model.getSkipValue());
303: }
304:
305: }
|