001: /**
002: * Copyright 2005 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: */package com.sun.portal.admin.console.communities;
013:
014: import java.util.*;
015: import java.util.logging.Level;
016: import java.io.*;
017: import java.text.*;
018:
019: import javax.faces.context.FacesContext;
020: import javax.faces.application.FacesMessage;
021: import javax.faces.component.UIComponent;
022: import javax.faces.validator.*;
023: import javax.faces.el.ValueBinding;
024: import javax.servlet.http.HttpServletRequest;
025: import javax.management.*;
026:
027: import com.sun.web.ui.model.*;
028: import com.sun.web.ui.event.*;
029: import com.sun.web.ui.component.*;
030:
031: import com.sun.data.provider.*;
032: import com.sun.data.provider.impl.ObjectListDataProvider;
033:
034: import com.sun.cacao.agent.JmxClient;
035:
036: import com.sun.portal.admin.common.util.AdminClientUtil;
037: import com.sun.portal.admin.console.common.PSBaseBean;
038:
039: public class CommunityPendingUsersHomeBean extends PSBaseBean {
040:
041: public String communityName = "";
042: private ObjectListDataProvider communityPendingUsers = null;
043:
044: public CommunityPendingUsersHomeBean() {
045: communityName = (String) getSessionAttribute("communitypendingusershome.community.selected");
046:
047: retrieveCommunityPendingUsers();
048: }
049:
050: public String getPageTitle() {
051: MessageFormat mf = new MessageFormat("");
052: mf.applyPattern(getLocalizedString("communities",
053: "communitypendingusershome.pagetitle"));
054: return mf.format(new Object[] { communityName });
055: }
056:
057: public boolean getShowError() {
058: String value = (String) getSessionAttribute("communitypendingusershome.showerror");
059: if (value == null || value.equals("false")) {
060: return false;
061: } else {
062: return true;
063: }
064: }
065:
066: public ObjectListDataProvider getCommunityPendingUsers() {
067: return communityPendingUsers;
068: }
069:
070: public void setPendingCommunityUsers(
071: ObjectListDataProvider communityPendingUsers) {
072: this .communityPendingUsers = communityPendingUsers;
073: }
074:
075: public String approve() {
076: try {
077: LinkedList path = new LinkedList();
078: path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
079: path
080: .addFirst((String) getSessionAttribute(ATTR_SELECTED_PORTAL));
081: path.addFirst("CommunityManager");
082: ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
083: AdminClientUtil.COMMUNITYMANAGER_MBEAN_TYPE, path);
084:
085: List l = Checkbox.getSelected("checkbox");
086: for (int index = 0; index < l.size(); index++) {
087: Object[] params = { communityName,
088: (String) l.get(index) };
089: String[] signatures = { "java.lang.String",
090: "java.lang.String" };
091: getMBeanServerConnection().invoke(on, "approveUser",
092: params, signatures);
093: }
094: setSessionAttribute("communitypendingusershome.showerror",
095: "false");
096: } catch (Exception e) {
097: log(Level.SEVERE,
098: " CommunityPendingUsersHomeBean.approve()", e);
099: setSessionAttribute("communitypendingusershome.showerror",
100: "true");
101: }
102:
103: retrieveCommunityPendingUsers();
104: return null;
105: }
106:
107: public String deny() {
108: try {
109: LinkedList path = new LinkedList();
110: path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
111: path
112: .addFirst((String) getSessionAttribute(ATTR_SELECTED_PORTAL));
113: path.addFirst("CommunityManager");
114: ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
115: AdminClientUtil.COMMUNITYMANAGER_MBEAN_TYPE, path);
116:
117: List l = Checkbox.getSelected("checkbox");
118: for (int index = 0; index < l.size(); index++) {
119: Object[] params = { communityName,
120: (String) l.get(index) };
121: String[] signatures = { "java.lang.String",
122: "java.lang.String" };
123: getMBeanServerConnection().invoke(on, "denyUser",
124: params, signatures);
125: }
126: setSessionAttribute("communitypendingusershome.showerror",
127: "false");
128: } catch (Exception e) {
129: log(Level.SEVERE, " CommunityPendingUsersHomeBean.deny()",
130: e);
131: setSessionAttribute("communitypendingusershome.showerror",
132: "true");
133: }
134:
135: retrieveCommunityPendingUsers();
136: return null;
137: }
138:
139: public String back() {
140: return "gotoCommunitiesHome";
141: }
142:
143: private void retrieveCommunityPendingUsers() {
144: ArrayList al = new ArrayList();
145: try {
146: LinkedList path = new LinkedList();
147: path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
148: path
149: .addFirst((String) getSessionAttribute(ATTR_SELECTED_PORTAL));
150: path.addFirst("CommunityManager");
151: ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
152: AdminClientUtil.COMMUNITYMANAGER_MBEAN_TYPE, path);
153:
154: Object[] params = { communityName };
155: String[] signatures = { "java.lang.String" };
156: ArrayList data = (ArrayList) getMBeanServerConnection()
157: .invoke(on, "getPendingUsers", params, signatures);
158: for (int index = 0; index < data.size(); index++) {
159: CommunityUserBean cub = new CommunityUserBean();
160: cub.initialize((Properties) data.get(index));
161: al.add(cub);
162: }
163: setSessionAttribute("communitypendingusershome.showerror",
164: "false");
165: } catch (Exception e) {
166: log(
167: Level.SEVERE,
168: " CommunityPendingUsersHomeBean.retrieveCommunityPendingUsers() : Exception ",
169: e);
170: setSessionAttribute("communitypendingusershome.showerror",
171: "true");
172: }
173: communityPendingUsers = new ObjectListDataProvider(al);
174: communityPendingUsers.setObjectType(CommunityUserBean.class);
175: }
176:
177: }
|