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.List;
022: import java.util.LinkedList;
023: import java.util.Map;
024: import java.util.Set;
025: import java.util.StringTokenizer;
026: import java.util.Vector;
027:
028: // iPlanet JATO classes
029: import com.iplanet.jato.model.ModelControlException;
030: import com.iplanet.jato.view.View;
031: import com.iplanet.jato.view.event.ChildDisplayEvent;
032: import com.iplanet.jato.view.event.DisplayEvent;
033: import com.iplanet.jato.view.event.RequestInvocationEvent;
034: import com.iplanet.jato.view.html.ComboBox;
035: import com.iplanet.jato.view.html.HiddenField;
036: import com.iplanet.jato.view.html.OptionList;
037: import com.iplanet.jato.view.html.StaticTextField;
038:
039: // iDS/AME classes
040: import com.iplanet.am.console.components.view.html.DynamicGUI;
041: import com.iplanet.am.console.components.view.html.IPlanetButton;
042: import com.iplanet.am.console.components.view.html.MessageBox;
043: import com.iplanet.am.console.base.model.AMConsoleException;
044:
045: // NetFile admin console classes
046: import com.sun.portal.netfile.admin.model.NetFileUserProfileModelImpl;
047:
048: public class NetFileDataUserProfileViewBean extends
049: NetFileUserProfileViewBeanBase {
050:
051: public static final String PAGE_NAME = "NetFileDataUserProfile";
052: public static final String DEFAULT_DISPLAY_URL = "/ps/netfileadmin/NetFileDataUserProfile.jsp";
053: public static final String CHILD_TILEDVIEW = "NetFileHostsTiledView";
054:
055: public NetFileDataUserProfileViewBean() {
056: super (PAGE_NAME, DEFAULT_DISPLAY_URL);
057: registerChildren();
058: }
059:
060: public NetFileDataUserProfileViewBean(String pageName) {
061: super (pageName, DEFAULT_DISPLAY_URL);
062: registerChildren();
063: }
064:
065: protected void registerChildren() {
066: super .registerChildren();
067: registerChild(USER_DATA_VIEW, NetFileDataUserProfileView.class);
068: }
069:
070: protected View createChild(String name) {
071: getNetFileModelMgr();
072: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
073: m.initModel(getUserDN());
074: View child = null;
075:
076: if (name.equals(CHILD_NETFILE_ATTRSFOR)) {
077: child = new StaticTextField(this , CHILD_NETFILE_ATTRSFOR,
078: modelManager.getString("service.name")
079: + " "
080: + modelManager
081: .getString("attributes.label")
082: + " " + modelManager.getString("for.label")
083: + " :");
084: } else if (name.equals(USER_DATA_VIEW)) {
085: child = new NetFileDataUserProfileView(this , USER_DATA_VIEW);
086: } else {
087: child = super .createChild(name);
088: }
089: return child;
090: }
091:
092: public void handleSaveButtonRequest(RequestInvocationEvent event)
093: throws ModelControlException {
094: NetFileUserProfileModelImpl m = (NetFileUserProfileModelImpl) getModel();
095: m.initModel(getUserDN());
096: try {
097: int netfilehostsIndex = m.getNetFileHostsIndex();
098: processAttributes(netfilehostsIndex);
099: int size = attrValues.size();
100: Map userOnlyAttrs = new HashMap(size);
101: Map customizedAttrs = new HashMap(size);
102: Set inheritedAttrs = new HashSet(size);
103: Set nameSet = attrStatus.keySet();
104: Iterator nameIter = nameSet.iterator();
105: while (nameIter.hasNext()) {
106: String attrName = (String) nameIter.next();
107: Set values = (Set) attrValues.get(attrName);
108: String status = (String) attrStatus.get(attrName);
109: if (!m.isReadOnly(attrName)
110: && (status == null || status.trim().length() == 0)) {
111: userOnlyAttrs.put(attrName, values);
112: } else if (!m.isReadOnly(attrName)
113: && status.equals(m.getCustomizeValue())) {
114: customizedAttrs.put(attrName, values);
115: } else if (!m.isReadOnly(attrName)
116: && status.equals(m.getInheritValue())) {
117: inheritedAttrs.add(attrName);
118: }
119: }
120: m.storeAttributes(userOnlyAttrs, customizedAttrs,
121: inheritedAttrs);
122: } catch (AMConsoleException ace) {
123: }
124: forwardTo();
125: }
126:
127: public void processAttributes(int netFileHostsIndex)
128: throws AMConsoleException {
129: if (attrValues == null) {
130: attrValues = new HashMap();
131: }
132: if (attrStatus == null) {
133: attrStatus = new HashMap();
134: }
135: NetFileDataUserProfileView view = (NetFileDataUserProfileView) getChild(USER_DATA_VIEW);
136: List dynComps = view.getDynamicCompList(netFileHostsIndex);
137: if (dynComps != null && !dynComps.isEmpty()) {
138: Iterator it = dynComps.iterator();
139: while (it.hasNext()) {
140: DynamicGUI dGui = (DynamicGUI) it.next();
141: if (dGui != null) {
142: attrValues.put(dGui.getName(), dGui.getValues());
143: attrStatus.put(dGui.getName(), dGui
144: .getStatusValue());
145: }
146: }
147: }
148: }
149:
150: }
|