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:
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.RequestInvocationEvent;
028: import com.iplanet.jato.view.html.StaticTextField;
029:
030: // iDS/AME classes
031: import com.iplanet.am.console.components.view.html.MessageBox;
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 NetFileTotalFourDotTwoUserProfileViewBean extends
038: NetFileUserProfileViewBeanBase {
039:
040: public static final String PAGE_NAME = "NetFileTotalFourDotTwoUserProfile";
041: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileTotalFourDotTwoUserProfile.jsp";
042:
043: public NetFileTotalFourDotTwoUserProfileViewBean() {
044: super (PAGE_NAME, DEFAULT_DISPLAY_URL);
045: registerChildren();
046: }
047:
048: public NetFileTotalFourDotTwoUserProfileViewBean(String pageName) {
049: super (pageName, DEFAULT_DISPLAY_URL);
050: registerChildren();
051: }
052:
053: protected void registerChildren() {
054: super .registerChildren();
055: registerChild(USER_DATA_VIEW,
056: NetFileTotalFourDotTwoUserProfileView.class);
057: }
058:
059: protected View createChild(String name) {
060: getNetFileModelMgr();
061: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
062: m.initModel(getUserDN());
063: View child = null;
064:
065: if (name.equals(CHILD_NETFILE_ATTRSFOR)) {
066: child = new StaticTextField(this , CHILD_NETFILE_ATTRSFOR,
067: modelManager.getString("props.total.four")
068: + " "
069: + modelManager.getString("for.label")
070: + " "
071: + modelManager
072: .getString("props.total.four.two")
073: + " " + modelManager.getString("for.label")
074: + " :");
075: } else if (name.equals(USER_DATA_VIEW)) {
076: child = new NetFileTotalFourDotTwoUserProfileView(this ,
077: USER_DATA_VIEW);
078: } else {
079: child = super .createChild(name);
080: }
081: return child;
082: }
083:
084: public void handleSaveButtonRequest(RequestInvocationEvent event)
085: throws ModelControlException {
086: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
087: m.initModel(getUserDN());
088: try {
089: processAttributes();
090: int size = attrValues.size();
091: Map userOnlyAttrs = new HashMap(size);
092: Map customizedAttrs = new HashMap(size);
093: Set inheritedAttrs = new HashSet(size);
094: Set nameSet = attrStatus.keySet();
095: Iterator nameIter = nameSet.iterator();
096: while (nameIter.hasNext()) {
097: String attrName = (String) nameIter.next();
098: Set values = (Set) attrValues.get(attrName);
099: String status = (String) attrStatus.get(attrName);
100: if (!m.isReadOnly(attrName)
101: && (status == null || status.trim().length() == 0)) {
102: userOnlyAttrs.put(attrName, values);
103: } else if (!m.isReadOnly(attrName)
104: && status.equals(m.getCustomizeValue())) {
105: try {
106: if (attrName
107: .equals("sunPortalNetFileMaxSearchDir")) {
108: Object currentValue = values.iterator()
109: .hasNext() ? values.iterator()
110: .next() : null;
111: if (currentValue != null) {
112: int currentIntValue = Integer
113: .parseInt(currentValue
114: .toString());
115: if (currentIntValue < 0) {
116: invalidLimitWarning();
117: forwardTo();
118: return;
119: }
120: }
121: }
122: } catch (NumberFormatException ex) {
123: invalidLimitWarning();
124: forwardTo();
125: return;
126: }
127: customizedAttrs.put(attrName, values);
128: } else if (!m.isReadOnly(attrName)
129: && status.equals(m.getInheritValue())) {
130: inheritedAttrs.add(attrName);
131: }
132: }
133:
134: m.storeAttributes(userOnlyAttrs, customizedAttrs,
135: inheritedAttrs);
136: } catch (AMConsoleException ace) {
137: }
138: forwardTo();
139: }
140:
141: private void invalidLimitWarning() {
142: MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
143: msgBox.setTitle(modelManager.getString("error.title"));
144: msgBox.setMessage(modelManager.getString("invalidlimit.error"));
145: msgBox.setType(MessageBox.TYPE_ERROR);
146: msgBox.setVisible(true);
147: }
148:
149: }
|