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.model;
015:
016: // JDK classes
017: import java.util.Iterator;
018: import com.sun.portal.log.common.PortalLogger;
019: import java.util.Map;
020: import java.util.Set;
021: import java.util.HashSet;
022: import java.util.ArrayList;
023: import java.security.AccessController;
024:
025: import com.sun.identity.security.DecryptAction;
026:
027: // Servlet classes
028: import javax.servlet.http.HttpServletRequest;
029:
030: // iDS/AME classes
031: import com.iplanet.sso.SSOException;
032: import com.iplanet.am.console.service.model.SMDataModelImpl;
033: import com.iplanet.am.console.base.model.AMConsoleException; //import com.iplanet.sm.ServiceSchemaManager;
034: //import com.iplanet.sm.SMSException;
035: import com.sun.identity.sm.ServiceSchemaManager;
036: import com.sun.identity.sm.SMSException;
037:
038: // NetFile admin console classes
039: import com.sun.portal.netfile.admin.NetFileAdminModelManager;
040:
041: public class NetFileModelImpl extends SMDataModelImpl implements
042: NetFileModel {
043:
044: private String propsURL = "";
045:
046: public NetFileModelImpl(HttpServletRequest req, String rbName,
047: Map map, String svcName, boolean processTemplate) {
048: super (req, rbName, map, svcName, processTemplate);
049: try {
050: ServiceSchemaManager svcSchemaMgr = new ServiceSchemaManager(
051: svcName, ssoToken);
052: if (svcSchemaMgr != null) {
053: propsURL = svcSchemaMgr.getPropertiesViewBeanURL();
054: }
055: NetFileAdminModelManager
056: .debugMessage("NetFileModelImpl: Properties view bean URL -> "
057: + propsURL);
058: } catch (SSOException ssoe) {
059: NetFileAdminModelManager.debugError(
060: "NetFileModelImpl: Error retrieving view bean URL",
061: ssoe);
062: } catch (SMSException smse) {
063: NetFileAdminModelManager.debugError(
064: "NetFileModelImpl: Error retrieving view bean URL",
065: smse);
066: }
067: }
068:
069: public int getNetFileAttributeIndex(String attr) {
070: String aName = "";
071: int attrIndex = -1;
072:
073: for (int i = 0; i < dynSize; i++) {
074: setCurrentRow(DYNAMIC_TYPE, i);
075: aName = getAttrName();
076:
077: if (aName.equals(attr)) {
078: attrIndex = i;
079: break;
080: }
081: }
082: return attrIndex;
083: }
084:
085: public int getNetFileHostsIndex() {
086: String aName = "";
087: int hostsIndex = -1;
088:
089: for (int i = 0; i < dynSize; i++) {
090: setCurrentRow(DYNAMIC_TYPE, i);
091: aName = getAttrName();
092: NetFileAdminModelManager.debugMessage("hostname[" + i
093: + "] = " + aName);
094: if (aName.equals("sunPortalNetFileCommonHostData")) {
095: hostsIndex = i;
096: break;
097: }
098: }
099: NetFileAdminModelManager.debugMessage("netfile hosts index = "
100: + hostsIndex);
101: return hostsIndex;
102: }
103:
104: public Set getNetFileHosts() {
105: int NetFileHostsIndex = getNetFileHostsIndex();
106: setCurrentRow(DYNAMIC_TYPE, NetFileHostsIndex);
107: Set value = getAttrValues();
108: Set netFileHosts = new HashSet();
109: if (value != null) {
110: ArrayList encryptedNetFileHosts = new ArrayList(value);
111: if (!encryptedNetFileHosts.isEmpty()) {
112: Iterator hosts = encryptedNetFileHosts.iterator();
113: while (hosts.hasNext()) {
114: netFileHosts
115: .add(getDecryptedHostInfo((String) hosts
116: .next()));
117: }
118: }
119: }
120:
121: return netFileHosts;
122: }
123:
124: public int getNetFileHostsCount() {
125: Set s = getNetFileHosts();
126: return s == null ? 0 : s.size();
127: }
128:
129: public String getNetFileHostsI18NKey() {
130: int index = getNetFileHostsIndex();
131: setCurrentRow(DYNAMIC_TYPE, index);
132: return getDynamicGUI().getLabel();
133: }
134:
135: public String getHelpAnchorTag(String docName) {
136: return super .getHelpAnchorTag(docName);
137: }
138:
139: public String getPropsUrl() {
140: return propsURL;
141: }
142:
143: public void process() {
144: try {
145: super .process();
146: } catch (Exception ex) {
147: }
148: }
149:
150: public void store(int viewType, Map newMap) {
151: try {
152: super .store(viewType, newMap);
153: } catch (Exception ex) {
154: NetFileAdminModelManager.debugError("Exception : ", ex);
155: }
156: }
157:
158: public String getHelpUrl(String docName) {
159: return getHelpURL(docName);
160: }
161:
162: String getDecryptedHostInfo(String szEncryptedHostInfo) {
163: return (String) AccessController
164: .doPrivileged(new DecryptAction(szEncryptedHostInfo));
165: }
166:
167: public String getHelpDocURL() {
168: return super.getHelpDocURL(resBundle);
169: }
170:
171: }
|