001: /**
002: * $Id: CMCNodeImplBase.java,v 1.2 2007/01/26 03:47:48 portalbld Exp $
003: * Copyright 2005 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.community.mc.impl.am;
014:
015: import com.iplanet.am.sdk.AMException;
016: import com.iplanet.am.sdk.AMFilteredRole;
017: import com.iplanet.am.sdk.AMObject;
018: import com.iplanet.am.sdk.AMOrganization;
019: import com.iplanet.am.sdk.AMRole;
020: import com.iplanet.am.sdk.AMPeopleContainer;
021: import com.iplanet.sso.SSOException;
022: import com.sun.portal.community.mc.CMCException;
023: import com.sun.portal.community.mc.CMCNode;
024: import com.sun.portal.community.mc.CMCPrincipal;
025: import com.sun.portal.community.mc.ConfigTable;
026: import com.sun.portal.community.mc.ConfigTable.ConfigKey;
027: import com.sun.portal.community.mc.CMCRolePrincipal;
028: import java.util.Collections;
029: import java.util.HashSet;
030: import java.util.Iterator;
031: import java.util.Properties;
032: import java.util.Set;
033:
034: /**
035: * AM community node contributor, base class
036: *
037: * This class is extended by all AM community node
038: * contributors.
039: */
040: public abstract class CMCNodeImplBase extends CMCImplBase implements
041: CMCNode {
042: private CMCPrincipal communityPrincipal;
043:
044: public void init(Properties p, CMCPrincipal cp) throws CMCException {
045: this .communityPrincipal = cp;
046: }
047:
048: public CMCPrincipal getCMCPrincipal() {
049: return communityPrincipal;
050: }
051:
052: public abstract Set getUsers() throws CMCException;
053:
054: public Set getRoles() throws CMCException {
055: throw new UnsupportedOperationException(
056: "not supported: getRoles");
057: }
058:
059: public boolean supportsGetRoles() {
060: return false;
061: }
062:
063: public Set getUsers(Set rolePrincipals) throws CMCException {
064: // only one role
065: return getUsers();
066: }
067:
068: public void addUsers(Set newUsers, CMCRolePrincipal rolePrincipal) {
069: throw new UnsupportedOperationException(
070: "not supported: addUsers");
071: }
072:
073: public void addRole(CMCRolePrincipal rolePrincipal) {
074: throw new UnsupportedOperationException(
075: "not supported: addRole");
076: }
077:
078: public boolean supportsAddUsers() {
079: return false;
080: }
081:
082: public boolean supportsAddRole() {
083: return false;
084: }
085:
086: public void removeUsers(Set oldUsers, Set rolePrincipals) {
087: throw new UnsupportedOperationException(
088: "not supported: removeUsers");
089: }
090:
091: public boolean supportsRemoveUsers() {
092: return false;
093: }
094:
095: public void removeRole(CMCRolePrincipal rolePrincipal) {
096: throw new UnsupportedOperationException(
097: "not supported: removeRole");
098: }
099:
100: public boolean supportsRemoveRole() {
101: return false;
102: }
103:
104: public boolean supportsRole(CMCRolePrincipal rolePrincipal) {
105: if (rolePrincipal.equals(CMCRolePrincipal.MEMBER_ROLE)) {
106: return true;
107: }
108: return false;
109: }
110:
111: public void create() {
112: throw new UnsupportedOperationException("not supported: create");
113: }
114:
115: public boolean supportsCreate() {
116: return false;
117: }
118:
119: public void remove() {
120: throw new UnsupportedOperationException("not supported: remove");
121: }
122:
123: public boolean supportsRemove() {
124: return false;
125: }
126:
127: public abstract boolean exists() throws CMCException;
128:
129: public abstract ConfigTable getDPDocuments() throws CMCException;
130:
131: public ConfigTable getDPDocuments(Set rolePrincipals)
132: throws CMCException {
133: // one role
134: return getDPDocuments();
135: }
136:
137: public abstract ConfigTable getDPDocumentsLastModified()
138: throws CMCException;
139:
140: public ConfigTable getDPDocumentsLastModified(Set rolePrincipals)
141: throws CMCException {
142: // one role
143: return getDPDocumentsLastModified();
144: }
145:
146: public void setDPDocuments(ConfigTable dpDocuments) {
147: throw new UnsupportedOperationException(
148: "not supported: setDPDocuments");
149: }
150:
151: public boolean supportsSetDPDocuments() {
152: return false;
153: }
154:
155: protected Set getOrganizationUsers(String orgDn, int levels)
156: throws SSOException, AMException {
157: AMOrganization amOrg = adminConnection.getOrganization(orgDn);
158: Set pcs = amOrg.getPeopleContainers(levels);
159: Set users = new HashSet();
160: for (Iterator i = pcs.iterator(); i.hasNext();) {
161: String pcDn = (String) i.next();
162: AMPeopleContainer ampc = adminConnection
163: .getPeopleContainer(pcDn);
164: users.addAll(ampc.getUserDNs());
165: }
166: //Debug.log("CommunityNodeImplBase", "getOrganizationUsers", "orgDn=" + orgDn + ", users=" + users);
167: return users;
168: }
169:
170: protected ConfigTable getTemplateDPDocuments(String dn)
171: throws AMException, SSOException, CMCException {
172: ConfigTable dpDocuments = new ConfigTable();
173: byte[] dp = getTemplateStringAttributeByteArray(dn,
174: dmpc.MP_SUN_DESKTOP_SERVICE, dmpc.ATTR_DP_DOCUMENT);
175: if (dp != null && dp.length > 0) {
176: ConfigKey ck = new ConfigKey(getCMCPrincipal(),
177: CMCRolePrincipal.MEMBER_ROLE);
178: dpDocuments.put(ck, dp);
179: }
180: return dpDocuments;
181: }
182:
183: protected ConfigTable getTemplateDPDocumentsLastModified(String dn)
184: throws AMException, SSOException, CMCException {
185: ConfigTable lastModifieds = new ConfigTable();
186: String lm = getTemplateStringAttribute(dn,
187: dmpc.MP_SUN_DESKTOP_SERVICE, dmpc.ATTR_DP_LAST_MODIFIED);
188: if (lm != null && lm.length() > 0) {
189: Long lastModified;
190: try {
191: lastModified = Long.valueOf(lm);
192: } catch (NumberFormatException nfe) {
193: lastModified = new Long(-1);
194: }
195: ConfigKey ck = new ConfigKey(getCMCPrincipal(),
196: CMCRolePrincipal.MEMBER_ROLE);
197: lastModifieds.put(ck, lastModified);
198: }
199:
200: return lastModifieds;
201: }
202:
203: //
204: // Description related Methods
205: //
206:
207: public String getDescription() throws CMCException {
208: throw new UnsupportedOperationException(
209: "not supported: getDescription");
210: }
211:
212: public void setDescription(String description) throws CMCException {
213: throw new UnsupportedOperationException(
214: "not supported: setDescription");
215: }
216:
217: public boolean supportsDescription() throws CMCException {
218: return false;
219: }
220:
221: //
222: // Category related Methods
223: //
224: public String getCategory() throws CMCException {
225: throw new UnsupportedOperationException(
226: "not supported: getCategory");
227: }
228:
229: public void setCategory(String category) throws CMCException {
230: throw new UnsupportedOperationException(
231: "not supported: setCategory");
232: }
233:
234: public boolean supportsCategory() throws CMCException {
235: return false;
236: }
237:
238: //
239: // Community creation time related Methods
240: //
241: public long getCommunityCreationTime() throws CMCException {
242: throw new UnsupportedOperationException(
243: "not supported: getCommunityCreationTime");
244: }
245:
246: public boolean supportsCommunityCreationTime() throws CMCException {
247: return false;
248: }
249:
250: //
251: // Membership restriction related methods
252: //
253: public boolean isMembershipRestricted() throws CMCException {
254: throw new UnsupportedOperationException(
255: "not supported: isMembershipRestricted");
256: }
257:
258: public void setMembershipRestricted(boolean isMembershipRestricted)
259: throws CMCException {
260: throw new UnsupportedOperationException(
261: "not supported: setMembershipRestricted");
262: }
263:
264: public boolean supportsMembershipRestriction() throws CMCException {
265: return false;
266: }
267:
268: //
269: // Security related methods
270: //
271:
272: public boolean isSecure() throws CMCException {
273: throw new UnsupportedOperationException(
274: "not supported: isSecure");
275: }
276:
277: public void setSecure(boolean isSecure) throws CMCException {
278: throw new UnsupportedOperationException(
279: "not supported: setSecure");
280: }
281:
282: public boolean supportsSecuring() throws CMCException {
283: return false;
284: }
285:
286: //
287: // Listing related methods
288: //
289: public boolean isListed() throws CMCException {
290: throw new UnsupportedOperationException(
291: "not supported: isListed");
292: }
293:
294: public void setListed(boolean isListed) throws CMCException {
295: throw new UnsupportedOperationException(
296: "not supported: setListed");
297: }
298:
299: public boolean supportsListing() throws CMCException {
300: return false;
301: }
302:
303: public boolean supportsRoleCreationTime() throws CMCException {
304: return false;
305: }
306:
307: }
|