0001: package com.sun.portal.community.admin.mbeans;
0002:
0003: import java.io.*;
0004: import java.util.*;
0005: import java.util.logging.*;
0006: import java.net.*;
0007: import java.lang.*;
0008: import java.text.*;
0009:
0010: import javax.management.MBeanServer;
0011: import javax.management.MBeanServerConnection;
0012: import javax.management.remote.JMXConnector;
0013: import javax.management.ObjectName;
0014:
0015: import javax.xml.rpc.Stub;
0016:
0017: import com.iplanet.sso.SSOTokenManager;
0018: import com.iplanet.sso.SSOToken;
0019: import com.iplanet.sso.SSOException;
0020:
0021: import com.sun.portal.util.SSOUtil;
0022:
0023: import com.sun.portal.log.common.*;
0024: import com.sun.portal.log.common.PortalLogger;
0025:
0026: import com.sun.portal.search.util.*;
0027: import com.sun.portal.search.soif.*;
0028: import com.sun.portal.search.rdm.*;
0029: import com.sun.portal.search.rdmserver.*;
0030: import com.sun.portal.search.db.*;
0031: import com.sun.portal.search.rdmgr.*;
0032:
0033: import com.sun.portal.admin.server.PASModule;
0034: import com.sun.portal.admin.server.AdminServerUtil;
0035: import com.sun.portal.admin.server.mbeans.PSResource;
0036: import com.sun.portal.admin.common.util.AdminUtil;
0037: import com.sun.portal.admin.common.context.PortalDomainContext;
0038: import com.sun.portal.admin.common.context.PSConfigContext;
0039: import com.sun.portal.admin.common.InstanceAttributes;
0040: import com.sun.portal.admin.common.PSMBeanException;
0041:
0042: import com.sun.portal.community.stubs.*;
0043:
0044: public class CommunityManager extends PSResource implements
0045: CommunityManagerMBean {
0046:
0047: private PSConfigContext cc = null;
0048: private PortalDomainContext pdc = null;
0049: private String portalID = null;
0050: private static Logger logger = PortalLogger
0051: .getLogger(CommunityManager.class);
0052:
0053: public void init(PSConfigContext cc, PortalDomainContext pdc,
0054: List path) {
0055: super .init(cc, pdc, path);
0056: this .cc = cc;
0057: this .pdc = pdc;
0058:
0059: try {
0060: portalID = pdc.getAttributeValue(TYPE, path, "PortalID");
0061:
0062: if (pdc.getAttributeValue(TYPE, path,
0063: "UserCommunityManagerWSURL").equals("")) {
0064: pdc.setAttributeValue(TYPE, path,
0065: "CommunityManagerWSURL",
0066: findCommunityManagerWSURL());
0067: }
0068: } catch (Exception e) {
0069: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0003", e);
0070: }
0071: }
0072:
0073: /*
0074: ** retrieveCommunityManagerWSURL
0075: **
0076: ** Output:
0077: ** data (String)
0078: */
0079: public String retrieveCommunityManagerWSURL()
0080: throws PSMBeanException {
0081: String url = "";
0082: try {
0083: url = pdc.getAttributeValue(TYPE, path,
0084: "UserCommunityManagerWSURL");
0085: } catch (Exception e) {
0086: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0003", e);
0087: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0088: .toString(), e);
0089: }
0090: return url;
0091: }
0092:
0093: /*
0094: ** modifyCommunityManagerWSURL
0095: */
0096: public void modifyCommunityManagerWSURL(String url)
0097: throws PSMBeanException {
0098: if (url == null) {
0099: String message = "No URL specified";
0100: Object[] o = { message };
0101: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0102: throw new PSMBeanException(
0103: "CommunityManager:modifyCommunityManagerWSURL",
0104: message);
0105: }
0106:
0107: try {
0108: pdc.setAttributeValue(TYPE, path,
0109: "UserCommunityManagerWSURL", url);
0110: if (!url.equals("")) {
0111: pdc
0112: .setAttributeValue(
0113: TYPE,
0114: path,
0115: "CommunityManagerWSURL",
0116: url
0117: + "/communitymanagerwebservices/communitymanagerwebservices");
0118: } else {
0119: pdc.setAttributeValue(TYPE, path,
0120: "CommunityManagerWSURL",
0121: findCommunityManagerWSURL());
0122: }
0123: } catch (Exception e) {
0124: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0003", e);
0125: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0126: .toString(), e);
0127: }
0128: }
0129:
0130: /*
0131: ** retrieveEffectiveCommunityManagerWSURL
0132: **
0133: ** Output:
0134: ** data (String)
0135: */
0136: public String retrieveEffectiveCommunityManagerWSURL()
0137: throws PSMBeanException {
0138: String url = "";
0139: try {
0140: url = pdc.getAttributeValue(TYPE, path,
0141: "CommunityManagerWSURL");
0142: if (pdc.getAttributeValue(TYPE, path,
0143: "UserCommunityManagerWSURL").equals("")
0144: && !validateCommunityManagerWSURL(url)) {
0145: url = findCommunityManagerWSURL();
0146: pdc.setAttributeValue(TYPE, path,
0147: "CommunityManagerWSURL", url);
0148: }
0149: } catch (Exception e) {
0150: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0003", e);
0151: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0152: .toString(), e);
0153: }
0154: return url;
0155: }
0156:
0157: /*
0158: ** retrieveSearchServerID
0159: **
0160: ** Output:
0161: ** data (String)
0162: */
0163: public String retrieveSearchServerID() throws PSMBeanException,
0164: UnknownHostException {
0165: try {
0166: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0167: return cmwsi.getSearchServerID(AdminServerUtil
0168: .getSSOToken().getTokenID().toString());
0169: } catch (Exception e) {
0170: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0171: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0172: .toString(), e);
0173: }
0174: }
0175:
0176: /*
0177: ** getAvailableCommunityTemplates
0178: **
0179: ** Output:
0180: ** data (ArrayList) - [attributes] (Properties) - id (String)
0181: ** name (String)
0182: ** description (String)
0183: */
0184: public ArrayList getAvailableCommunityTemplates(String locale)
0185: throws PSMBeanException, UnknownHostException {
0186: if (locale == null) {
0187: String message = "No locale specified";
0188: Object[] o = { message };
0189: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0190: throw new PSMBeanException(
0191: "CommunityManager:getAvailableCommunityTemplates",
0192: message);
0193: }
0194:
0195: try {
0196: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0197: return (ArrayList) cmwsi.getAvailableTemplates(
0198: AdminServerUtil.getSSOToken().getTokenID()
0199: .toString(), locale);
0200: } catch (Exception e) {
0201: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0202: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0203: .toString(), e);
0204: }
0205: }
0206:
0207: /*
0208: ** retrieveAvailableCommunityDPs
0209: **
0210: ** Output:
0211: ** data (ArrayList) - [names] (String)
0212: */
0213: public ArrayList retrieveAvailableCommunityDPs()
0214: throws PSMBeanException, UnknownHostException {
0215: try {
0216: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0217: return (ArrayList) cmwsi.getAvailableDPs(AdminServerUtil
0218: .getSSOToken().getTokenID().toString());
0219: } catch (Exception e) {
0220: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0221: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0222: .toString(), e);
0223: }
0224: }
0225:
0226: /*
0227: ** searchForCommunities
0228: **
0229: ** Output:
0230: ** data (ArrayList) - [attributes] (Properties) - id (String)
0231: ** name (String)
0232: ** description (String)
0233: ** category (String)
0234: ** unlisted (String)
0235: ** membershiprestricted (String)
0236: ** secured (String)
0237: ** disabled (String)
0238: ** users (String)
0239: ** pendingusers (String)
0240: */
0241: public ArrayList searchForCommunities(String query)
0242: throws PSMBeanException, UnknownHostException {
0243: if (query == null) {
0244: String message = "No query specified";
0245: Object[] o = { message };
0246: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0247: throw new PSMBeanException(
0248: "CommunityManager:searchForCommunities", message);
0249: }
0250:
0251: try {
0252: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0253: return (ArrayList) cmwsi.search(AdminServerUtil
0254: .getSSOToken().getTokenID().toString(), query);
0255: } catch (Exception e) {
0256: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0257: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0258: .toString(), e);
0259: }
0260: }
0261:
0262: /*
0263: ** getCommunity
0264: **
0265: ** Output:
0266: ** data (Properties) - id (String)
0267: ** name (String)
0268: ** description (String)
0269: ** category (String)
0270: ** unlisted (String)
0271: ** membershiprestricted (String)
0272: ** secured (String)
0273: ** disabled (String)
0274: ** deleted (String)
0275: ** users (String)
0276: */
0277: public Properties getCommunity(String name)
0278: throws PSMBeanException, UnknownHostException {
0279: if (name == null) {
0280: String message = "No community name specified";
0281: Object[] o = { message };
0282: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0283: throw new PSMBeanException("CommunityManager:getCommunity",
0284: message);
0285: }
0286:
0287: try {
0288: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0289: return cmwsi.getCommunityProperties(AdminServerUtil
0290: .getSSOToken().getTokenID().toString(), name);
0291: } catch (Exception e) {
0292: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0003", e);
0293: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0294: .toString(), e);
0295: }
0296: }
0297:
0298: /*
0299: ** getCommunityDP
0300: **
0301: ** Output:
0302: ** data (byte[])
0303: */
0304: public byte[] getCommunityDP(String name, String dp)
0305: throws PSMBeanException, UnknownHostException {
0306: if (name == null) {
0307: String message = "No community name specified";
0308: Object[] o = { message };
0309: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0310: throw new PSMBeanException(
0311: "CommunityManager:getCommunityDP", message);
0312: }
0313: if (dp == null) {
0314: String message = "No community dp specified";
0315: Object[] o = { message };
0316: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0317: throw new PSMBeanException(
0318: "CommunityManager:getCommunityDP", message);
0319: }
0320:
0321: try {
0322: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0323: return cmwsi.getCommunityDP(AdminServerUtil.getSSOToken()
0324: .getTokenID().toString(), name, dp);
0325: } catch (Exception e) {
0326: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0003", e);
0327: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0328: .toString(), e);
0329: }
0330: }
0331:
0332: /*
0333: ** setCommunity
0334: */
0335: public void setCommunity(String name, Properties p)
0336: throws PSMBeanException, UnknownHostException {
0337: if (name == null) {
0338: String message = "No community name specified";
0339: Object[] o = { message };
0340: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0341: throw new PSMBeanException("CommunityManager:setCommunity",
0342: message);
0343: }
0344: if (p == null) {
0345: String message = "No community properties specified";
0346: Object[] o = { message };
0347: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0348: throw new PSMBeanException("CommunityManager:setCommunity",
0349: message);
0350: }
0351:
0352: try {
0353: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0354: cmwsi.setCommunityProperties(AdminServerUtil.getSSOToken()
0355: .getTokenID().toString(), name, p);
0356: } catch (Exception e) {
0357: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0003", e);
0358: throw new PSMBeanException("PSALI_CSPACCSH0001", e
0359: .toString(), e);
0360: }
0361: }
0362:
0363: /*
0364: ** createCommunity
0365: */
0366: public void createCommunity(String name, String description,
0367: String owner, String category, String template,
0368: String unlisted, String membershipRestricted, String secured)
0369: throws PSMBeanException, UnknownHostException {
0370: if (name == null) {
0371: String message = "No community name specified";
0372: Object[] o = { message };
0373: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0374: throw new PSMBeanException(
0375: "CommunityManager:createCommunity", message);
0376: }
0377: if (description == null) {
0378: String message = "No community description specified";
0379: Object[] o = { message };
0380: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0381: throw new PSMBeanException(
0382: "CommunityManager:createCommunity", message);
0383: }
0384: if (owner == null) {
0385: String message = "No community owner specified";
0386: Object[] o = { message };
0387: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0388: throw new PSMBeanException(
0389: "CommunityManager:createCommunity", message);
0390: }
0391: if (category == null) {
0392: String message = "No community category specified";
0393: Object[] o = { message };
0394: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0395: throw new PSMBeanException(
0396: "CommunityManager:createCommunity", message);
0397: }
0398: if (template == null) {
0399: String message = "No community template specified";
0400: Object[] o = { message };
0401: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0402: throw new PSMBeanException(
0403: "CommunityManager:createCommunity", message);
0404: }
0405: if (unlisted == null) {
0406: String message = "Community unlisted attribute not specified";
0407: Object[] o = { message };
0408: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0409: throw new PSMBeanException(
0410: "CommunityManager:createCommunity", message);
0411: }
0412: if (membershipRestricted == null) {
0413: String message = "Community membership restricted attribute not specified";
0414: Object[] o = { message };
0415: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0416: throw new PSMBeanException(
0417: "CommunityManager:createCommunity", message);
0418: }
0419: if (secured == null) {
0420: String message = "Community secured attribute not specified";
0421: Object[] o = { message };
0422: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0423: throw new PSMBeanException(
0424: "CommunityManager:createCommunity", message);
0425: }
0426:
0427: try {
0428: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0429: cmwsi.createCommunity(AdminServerUtil.getSSOToken()
0430: .getTokenID().toString(), name, description, owner,
0431: category, template, unlisted, membershipRestricted,
0432: secured);
0433: } catch (Exception e) {
0434: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0435: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0436: .toString(), e);
0437: }
0438: }
0439:
0440: /*
0441: ** enableCommunity
0442: */
0443: public void enableCommunity(String name) throws PSMBeanException,
0444: UnknownHostException {
0445: if (name == null) {
0446: String message = "No community name specified";
0447: Object[] o = { message };
0448: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0449: throw new PSMBeanException(
0450: "CommunityManager:enableCommunity", message);
0451: }
0452:
0453: try {
0454: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0455: cmwsi.enableCommunity(AdminServerUtil.getSSOToken()
0456: .getTokenID().toString(), name);
0457: } catch (Exception e) {
0458: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0459: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0460: .toString(), e);
0461: }
0462: }
0463:
0464: /*
0465: ** disableCommunity
0466: */
0467: public void disableCommunity(String name) throws PSMBeanException,
0468: UnknownHostException {
0469: if (name == null) {
0470: String message = "No community name specified";
0471: Object[] o = { message };
0472: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0473: throw new PSMBeanException(
0474: "CommunityManager:disableCommunity", message);
0475: }
0476:
0477: try {
0478: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0479: cmwsi.disableCommunity(AdminServerUtil.getSSOToken()
0480: .getTokenID().toString(), name);
0481: } catch (Exception e) {
0482: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0483: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0484: .toString(), e);
0485: }
0486: }
0487:
0488: /*
0489: ** deleteCommunity
0490: */
0491: public void deleteCommunity(String name) throws PSMBeanException,
0492: UnknownHostException {
0493: if (name == null) {
0494: String message = "No community name specified";
0495: Object[] o = { message };
0496: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0497: throw new PSMBeanException(
0498: "CommunityManager:deleteCommunity", message);
0499: }
0500:
0501: try {
0502: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0503: cmwsi.deleteCommunity(AdminServerUtil.getSSOToken()
0504: .getTokenID().toString(), name);
0505: } catch (Exception e) {
0506: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0507: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0508: .toString(), e);
0509: }
0510: }
0511:
0512: /*
0513: ** undeleteCommunity
0514: */
0515: public void undeleteCommunity(String name) throws PSMBeanException,
0516: UnknownHostException {
0517: if (name == null) {
0518: String message = "No community name specified";
0519: Object[] o = { message };
0520: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0521: throw new PSMBeanException(
0522: "CommunityManager:undeleteCommunity", message);
0523: }
0524:
0525: try {
0526: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0527: cmwsi.undeleteCommunity(AdminServerUtil.getSSOToken()
0528: .getTokenID().toString(), name);
0529: } catch (Exception e) {
0530: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0531: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0532: .toString(), e);
0533: }
0534: }
0535:
0536: /*
0537: ** destroyCommunity
0538: */
0539: public void destroyCommunity(String name) throws PSMBeanException,
0540: UnknownHostException {
0541: if (name == null) {
0542: String message = "No community name specified";
0543: Object[] o = { message };
0544: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0545: throw new PSMBeanException(
0546: "CommunityManager:destroyCommunity", message);
0547: }
0548:
0549: try {
0550: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0551: cmwsi.destroyCommunity(AdminServerUtil.getSSOToken()
0552: .getTokenID().toString(), name);
0553: } catch (Exception e) {
0554: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0555: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0556: .toString(), e);
0557: }
0558: }
0559:
0560: /*
0561: ** addUser
0562: **
0563: */
0564: public void addUser(String name, String user)
0565: throws PSMBeanException, UnknownHostException {
0566: if (name == null) {
0567: String message = "No community name specified";
0568: Object[] o = { message };
0569: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0570: throw new PSMBeanException("CommunityManager:addUser",
0571: message);
0572: }
0573: if (user == null) {
0574: String message = "No user specified";
0575: Object[] o = { message };
0576: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0577: throw new PSMBeanException("CommunityManager:addUser",
0578: message);
0579: }
0580:
0581: try {
0582: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0583: cmwsi.addUser(AdminServerUtil.getSSOToken().getTokenID()
0584: .toString(), name, user);
0585: } catch (Exception e) {
0586: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0587: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0588: .toString(), e);
0589: }
0590: }
0591:
0592: /*
0593: ** removeCommunityUser
0594: **
0595: */
0596: public void removeCommunityUser(String name, String user)
0597: throws PSMBeanException, UnknownHostException {
0598: if (name == null) {
0599: String message = "No community name specified";
0600: Object[] o = { message };
0601: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0602: throw new PSMBeanException(
0603: "CommunityManager:removeCommunityUser", message);
0604: }
0605: if (user == null) {
0606: String message = "No community user specified";
0607: Object[] o = { message };
0608: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0609: throw new PSMBeanException(
0610: "CommunityManager:removeCommunityUser", message);
0611: }
0612:
0613: try {
0614: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0615: cmwsi.removeUser(AdminServerUtil.getSSOToken().getTokenID()
0616: .toString(), name, user);
0617: } catch (Exception e) {
0618: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0619: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0620: .toString(), e);
0621: }
0622: }
0623:
0624: /*
0625: ** approveUser
0626: **
0627: */
0628: public void approveUser(String name, String user)
0629: throws PSMBeanException, UnknownHostException {
0630: if (name == null) {
0631: String message = "No community name specified";
0632: Object[] o = { message };
0633: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0634: throw new PSMBeanException("CommunityManager:approveUser",
0635: message);
0636: }
0637: if (user == null) {
0638: String message = "No user specified";
0639: Object[] o = { message };
0640: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0641: throw new PSMBeanException("CommunityManager:approveUser",
0642: message);
0643: }
0644:
0645: try {
0646: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0647: cmwsi.approveUser(AdminServerUtil.getSSOToken()
0648: .getTokenID().toString(), name, user);
0649: } catch (Exception e) {
0650: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0651: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0652: .toString(), e);
0653: }
0654: }
0655:
0656: /*
0657: ** denyUser
0658: **
0659: */
0660: public void denyUser(String name, String user)
0661: throws PSMBeanException, UnknownHostException {
0662: if (name == null) {
0663: String message = "No community name specified";
0664: Object[] o = { message };
0665: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0666: throw new PSMBeanException("CommunityManager:denyUser",
0667: message);
0668: }
0669: if (user == null) {
0670: String message = "No user specified";
0671: Object[] o = { message };
0672: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0673: throw new PSMBeanException("CommunityManager:denyUser",
0674: message);
0675: }
0676:
0677: try {
0678: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0679: cmwsi.denyUser(AdminServerUtil.getSSOToken().getTokenID()
0680: .toString(), name, user);
0681: } catch (Exception e) {
0682: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0683: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0684: .toString(), e);
0685: }
0686: }
0687:
0688: /*
0689: ** banCommunityUser
0690: **
0691: */
0692: public void banCommunityUser(String name, String user)
0693: throws PSMBeanException, UnknownHostException {
0694: if (name == null) {
0695: String message = "No community name specified";
0696: Object[] o = { message };
0697: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0698: throw new PSMBeanException(
0699: "CommunityManager:banCommunityUser", message);
0700: }
0701: if (user == null) {
0702: String message = "No community user specified";
0703: Object[] o = { message };
0704: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0705: throw new PSMBeanException(
0706: "CommunityManager:banCommunityUser", message);
0707: }
0708:
0709: try {
0710: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0711: cmwsi.banUser(AdminServerUtil.getSSOToken().getTokenID()
0712: .toString(), name, user);
0713: } catch (Exception e) {
0714: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0715: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0716: .toString(), e);
0717: }
0718: }
0719:
0720: /*
0721: ** unbanCommunityUser
0722: **
0723: */
0724: public void unbanCommunityUser(String name, String user)
0725: throws PSMBeanException, UnknownHostException {
0726: if (name == null) {
0727: String message = "No community name specified";
0728: Object[] o = { message };
0729: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0730: throw new PSMBeanException(
0731: "CommunityManager:unbanCommunityUser", message);
0732: }
0733: if (user == null) {
0734: String message = "No community user specified";
0735: Object[] o = { message };
0736: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0737: throw new PSMBeanException(
0738: "CommunityManager:unbanCommunityUser", message);
0739: }
0740:
0741: try {
0742: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0743: cmwsi.unbanUser(AdminServerUtil.getSSOToken().getTokenID()
0744: .toString(), name, user);
0745: } catch (Exception e) {
0746: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0747: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0748: .toString(), e);
0749: }
0750: }
0751:
0752: /*
0753: ** addCommunityOwner
0754: **
0755: */
0756: public void addCommunityOwner(String name, String user)
0757: throws PSMBeanException, UnknownHostException {
0758: if (name == null) {
0759: String message = "No community name specified";
0760: Object[] o = { message };
0761: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0762: throw new PSMBeanException(
0763: "CommunityManager:addCommunityOwner", message);
0764: }
0765: if (user == null) {
0766: String message = "No community user specified";
0767: Object[] o = { message };
0768: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0769: throw new PSMBeanException(
0770: "CommunityManager:addCommunityOwner", message);
0771: }
0772:
0773: try {
0774: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0775: cmwsi.addOwner(AdminServerUtil.getSSOToken().getTokenID()
0776: .toString(), name, user);
0777: } catch (Exception e) {
0778: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0779: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0780: .toString(), e);
0781: }
0782: }
0783:
0784: /*
0785: ** removeCommunityOwner
0786: **
0787: */
0788: public void removeCommunityOwner(String name, String user)
0789: throws PSMBeanException, UnknownHostException {
0790: if (name == null) {
0791: String message = "No community name specified";
0792: Object[] o = { message };
0793: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0794: throw new PSMBeanException(
0795: "CommunityManager:removeCommunityOwner", message);
0796: }
0797: if (user == null) {
0798: String message = "No community user specified";
0799: Object[] o = { message };
0800: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0801: throw new PSMBeanException(
0802: "CommunityManager:removeCommunityOwner", message);
0803: }
0804:
0805: try {
0806: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0807: cmwsi.removeOwner(AdminServerUtil.getSSOToken()
0808: .getTokenID().toString(), name, user);
0809: } catch (Exception e) {
0810: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0811: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0812: .toString(), e);
0813: }
0814: }
0815:
0816: /*
0817: ** getCommunityUsers
0818: **
0819: ** Output:
0820: ** data (ArrayList) - [attributes] (Properties) - dn (String)
0821: ** role (String)
0822: */
0823: public ArrayList getCommunityUsers(String name)
0824: throws PSMBeanException, UnknownHostException {
0825: if (name == null) {
0826: String message = "No community name specified";
0827: Object[] o = { message };
0828: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0829: throw new PSMBeanException(
0830: "CommunityManager:getCommunityUsers", message);
0831: }
0832:
0833: try {
0834: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0835: return (ArrayList) cmwsi.getUsers(AdminServerUtil
0836: .getSSOToken().getTokenID().toString(), name);
0837: } catch (Exception e) {
0838: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0839: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0840: .toString(), e);
0841: }
0842: }
0843:
0844: /*
0845: ** getPendingUsers
0846: **
0847: ** Output:
0848: ** data (ArrayList) - [attributes] (Properties) - dn (String)
0849: ** role (String)
0850: */
0851: public ArrayList getPendingUsers(String name)
0852: throws PSMBeanException, UnknownHostException {
0853: if (name == null) {
0854: String message = "No community name specified";
0855: Object[] o = { message };
0856: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0857: throw new PSMBeanException(
0858: "CommunityManager:getPendingUsers", message);
0859: }
0860:
0861: try {
0862: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0863: return (ArrayList) cmwsi.getPendingUsers(AdminServerUtil
0864: .getSSOToken().getTokenID().toString(), name);
0865: } catch (Exception e) {
0866: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0867: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0868: .toString(), e);
0869: }
0870: }
0871:
0872: /*
0873: ** getCommunityUserRoles
0874: **
0875: ** Output:
0876: ** roles (String)
0877: */
0878: public String getCommunityUserRoles(String name, String user)
0879: throws PSMBeanException, UnknownHostException {
0880: if (name == null) {
0881: String message = "No community name specified";
0882: Object[] o = { message };
0883: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0884: throw new PSMBeanException(
0885: "CommunityManager:getCommunityUserRoles", message);
0886: }
0887: if (user == null) {
0888: String message = "No community user specified";
0889: Object[] o = { message };
0890: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0891: throw new PSMBeanException(
0892: "CommunityManager:getCommunityUserRoles", message);
0893: }
0894:
0895: String roles = new String();
0896: try {
0897: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0898: List l = cmwsi.getUserRoles(AdminServerUtil.getSSOToken()
0899: .getTokenID().toString(), name, user);
0900: for (int index = 0; index < l.size(); index++) {
0901: if (index == 0) {
0902: roles = (String) l.get(index);
0903: } else {
0904: roles = roles + "," + (String) l.get(index);
0905: }
0906: }
0907: } catch (Exception e) {
0908: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0909: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0910: .toString(), e);
0911: }
0912: return roles;
0913: }
0914:
0915: /*
0916: ** isCommunityUser
0917: **
0918: ** Output:
0919: ** has (Boolean)
0920: */
0921: public Boolean isCommunityUser(String name, String user)
0922: throws PSMBeanException, UnknownHostException {
0923: if (name == null) {
0924: String message = "No community name specified";
0925: Object[] o = { message };
0926: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0927: throw new PSMBeanException(
0928: "CommunityManager:isCommunityUser", message);
0929: }
0930: if (user == null) {
0931: String message = "No user specified";
0932: Object[] o = { message };
0933: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0934: throw new PSMBeanException(
0935: "CommunityManager:isCommunityUser", message);
0936: }
0937:
0938: try {
0939: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0940: return new Boolean(cmwsi.hasUser(AdminServerUtil
0941: .getSSOToken().getTokenID().toString(), name, user));
0942: } catch (Exception e) {
0943: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0944: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0945: .toString(), e);
0946: }
0947: }
0948:
0949: /*
0950: ** isCommunityOwner
0951: **
0952: ** Output:
0953: ** isOwner (Boolean)
0954: */
0955: public Boolean isCommunityOwner(String name, String user)
0956: throws PSMBeanException, UnknownHostException {
0957: if (name == null) {
0958: String message = "No community name specified";
0959: Object[] o = { message };
0960: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0961: throw new PSMBeanException(
0962: "CommunityManager:isCommunityOwner", message);
0963: }
0964: if (user == null) {
0965: String message = "No community user specified";
0966: Object[] o = { message };
0967: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0968: throw new PSMBeanException(
0969: "CommunityManager:isCommunityOwner", message);
0970: }
0971:
0972: try {
0973: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
0974: return new Boolean(cmwsi.isOwner(AdminServerUtil
0975: .getSSOToken().getTokenID().toString(), name, user));
0976: } catch (Exception e) {
0977: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
0978: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
0979: .toString(), e);
0980: }
0981: }
0982:
0983: /*
0984: ** isCommunityUserBanned
0985: **
0986: ** Output:
0987: ** isBanned (Boolean)
0988: */
0989: public Boolean isCommunityUserBanned(String name, String user)
0990: throws PSMBeanException, UnknownHostException {
0991: if (name == null) {
0992: String message = "No community name specified";
0993: Object[] o = { message };
0994: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
0995: throw new PSMBeanException(
0996: "CommunityManager:isCommunityUserBanned", message);
0997: }
0998: if (user == null) {
0999: String message = "No community user specified";
1000: Object[] o = { message };
1001: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
1002: throw new PSMBeanException(
1003: "CommunityManager:isCommunityUserBanned", message);
1004: }
1005:
1006: try {
1007: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
1008: return new Boolean(cmwsi.isUserBanned(AdminServerUtil
1009: .getSSOToken().getTokenID().toString(), name, user));
1010: } catch (Exception e) {
1011: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
1012: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
1013: .toString(), e);
1014: }
1015: }
1016:
1017: /*
1018: ** isUserPending
1019: **
1020: ** Output:
1021: ** isPending (Boolean)
1022: */
1023: public Boolean isUserPending(String name, String user)
1024: throws PSMBeanException, UnknownHostException {
1025: if (name == null) {
1026: String message = "No community name specified";
1027: Object[] o = { message };
1028: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
1029: throw new PSMBeanException(
1030: "CommunityManager:isUserPending", message);
1031: }
1032: if (user == null) {
1033: String message = "No user specified";
1034: Object[] o = { message };
1035: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
1036: throw new PSMBeanException(
1037: "CommunityManager:isUserPending", message);
1038: }
1039:
1040: try {
1041: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
1042: return new Boolean(cmwsi.isUserPending(AdminServerUtil
1043: .getSSOToken().getTokenID().toString(), name, user));
1044: } catch (Exception e) {
1045: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
1046: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
1047: .toString(), e);
1048: }
1049: }
1050:
1051: /*
1052: ** For testing!
1053: ** requestCommunityMembership
1054: */
1055: public void requestCommunityMembership(String name, String user)
1056: throws PSMBeanException, UnknownHostException {
1057: if (name == null) {
1058: String message = "No community name specified";
1059: Object[] o = { message };
1060: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
1061: throw new PSMBeanException(
1062: "CommunityManager:requestCommunityMembership",
1063: message);
1064: }
1065: if (user == null) {
1066: String message = "No user specified";
1067: Object[] o = { message };
1068: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", o);
1069: throw new PSMBeanException(
1070: "CommunityManager:requestCommunityMembership",
1071: message);
1072: }
1073:
1074: try {
1075: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(retrieveEffectiveCommunityManagerWSURL());
1076: cmwsi.requestMembership(AdminServerUtil.getSSOToken()
1077: .getTokenID().toString(), name, user);
1078: } catch (Exception e) {
1079: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0002", e.toString());
1080: throw new PSMBeanException("PSSH_CSPCAMCM0002", e
1081: .toString(), e);
1082: }
1083: }
1084:
1085: private CommunityManagerWSInterface getCommunityManagerWSInterface(
1086: String url) throws Exception {
1087: Stub s = (Stub) (new CommunityManagerWebServices_Impl()
1088: .getCommunityManagerWSInterfacePort());
1089: s._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,
1090: url);
1091: CommunityManagerWSInterface cmwsi = (CommunityManagerWSInterface) s;
1092: return cmwsi;
1093: }
1094:
1095: private boolean validateCommunityManagerWSURL(String url) {
1096: try {
1097: CommunityManagerWSInterface cmwsi = getCommunityManagerWSInterface(url);
1098: return cmwsi.validate();
1099: } catch (Exception e) {
1100: return false;
1101: }
1102: }
1103:
1104: private String findCommunityManagerWSURL() {
1105: String url = "";
1106: try {
1107: LinkedList path1 = new LinkedList();
1108: path1.addFirst(AdminUtil.DEFAULT_DOMAIN);
1109: path1.addFirst(portalID);
1110: Set objects = pdc.getResourceIDs(
1111: AdminUtil.PORTAL_SERVER_INSTANCE_MBEAN_TYPE, path1);
1112: Iterator i = objects.iterator();
1113: while (i.hasNext()) {
1114: LinkedList path2 = new LinkedList();
1115: path2.addFirst(AdminUtil.DEFAULT_DOMAIN);
1116: path2.addFirst(portalID);
1117: path2.addFirst((String) i.next());
1118:
1119: String protocol = pdc.getAttributeValue(
1120: AdminUtil.PORTAL_SERVER_INSTANCE_MBEAN_TYPE,
1121: path2, "Scheme");
1122: String host = pdc.getAttributeValue(
1123: AdminUtil.PORTAL_SERVER_INSTANCE_MBEAN_TYPE,
1124: path2, "Host");
1125: String port = pdc.getAttributeValue(
1126: AdminUtil.PORTAL_SERVER_INSTANCE_MBEAN_TYPE,
1127: path2, "Port");
1128:
1129: url = protocol
1130: + "://"
1131: + host
1132: + ":"
1133: + port
1134: + "/communitymanagerwebservices/communitymanagerwebservices";
1135: if (validateCommunityManagerWSURL(url)) {
1136: break;
1137: }
1138: }
1139: } catch (Exception e) {
1140: logger.log(Level.SEVERE, "PSSH_CSPCAMCM0003", e);
1141: }
1142: return url;
1143: }
1144:
1145: }
|