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 NetFileTotalFourUserProfileViewBean extends
038: NetFileUserProfileViewBeanBase {
039:
040: public static final String PAGE_NAME = "NetFileTotalFourUserProfile";
041: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileTotalFourUserProfile.jsp";
042:
043: public NetFileTotalFourUserProfileViewBean() {
044: super (PAGE_NAME, DEFAULT_DISPLAY_URL);
045: registerChildren();
046: }
047:
048: public NetFileTotalFourUserProfileViewBean(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: NetFileTotalFourUserProfileView.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.one")
073: + " " + modelManager.getString("for.label")
074: + " :");
075: } else if (name.equals(USER_DATA_VIEW)) {
076: child = new NetFileTotalFourUserProfileView(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("sunPortalNetFileFileUploadLimit")
108: || attrName
109: .equals("sunPortalNetFileFileStorageLimit")) {
110: Object currentValue = values.iterator()
111: .hasNext() ? values.iterator()
112: .next() : null;
113: if (currentValue != null) {
114: int currentIntValue = Integer
115: .parseInt(currentValue
116: .toString());
117: if (currentIntValue < 0) {
118: invalidLimitWarning();
119: forwardTo();
120: return;
121: }
122: }
123: }
124: } catch (NumberFormatException ex) {
125: invalidLimitWarning();
126: forwardTo();
127: return;
128: }
129: customizedAttrs.put(attrName, values);
130: } else if (!m.isReadOnly(attrName)
131: && status.equals(m.getInheritValue())) {
132: inheritedAttrs.add(attrName);
133: }
134: }
135:
136: m.storeAttributes(userOnlyAttrs, customizedAttrs,
137: inheritedAttrs);
138: } catch (AMConsoleException ace) {
139: }
140: forwardTo();
141: }
142:
143: private void invalidLimitWarning() {
144: MessageBox msgBox = (MessageBox) getDisplayField(CHILD_CC_MSGBOX);
145: msgBox.setTitle(modelManager.getString("error.title"));
146: msgBox.setMessage(modelManager.getString("invalidlimit.error"));
147: msgBox.setType(MessageBox.TYPE_ERROR);
148: msgBox.setVisible(true);
149: }
150:
151: }
|