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.lang.*;
017: import java.io.*;
018: import java.net.*;
019: import java.text.*;
020:
021: import javax.faces.context.FacesContext;
022: import javax.faces.component.*;
023: import javax.faces.el.*;
024: import javax.faces.event.*;
025: import javax.faces.application.Application;
026: import javax.servlet.http.HttpServletRequest;
027: import javax.management.*;
028:
029: import com.sun.web.ui.model.*;
030: import com.sun.web.ui.event.*;
031: import com.sun.web.ui.component.*;
032:
033: import com.sun.data.provider.*;
034: import com.sun.data.provider.impl.ObjectListDataProvider;
035:
036: import com.sun.cacao.agent.JmxClient;
037:
038: import com.sun.portal.admin.common.util.AdminClientUtil;
039: import com.sun.portal.admin.console.common.PSBaseBean;
040:
041: public class AddCommunityUserUsersPopupBean extends PSBaseBean {
042:
043: private ObjectListDataProvider users = null;
044:
045: public AddCommunityUserUsersPopupBean() {
046: String searchText = (String) getSessionAttribute("addcommunityuseruserspopup.searchtext");
047: if (searchText == null) {
048: setSessionAttribute(
049: "addcommunityuseruserspopup.searchtext", "");
050: } else {
051: search();
052: }
053: }
054:
055: public String getSearchText() {
056: return (String) getSessionAttribute("addcommunityuseruserspopup.searchtext");
057: }
058:
059: public void setSearchText(String searchText) {
060: setSessionAttribute("addcommunityuseruserspopup.searchtext",
061: searchText);
062: }
063:
064: public ObjectListDataProvider getUsers() {
065: return users;
066: }
067:
068: public void setUsers(ObjectListDataProvider users) {
069: this .users = users;
070: }
071:
072: public boolean getHasUsers() {
073: if (users == null) {
074: return false;
075: }
076: List l = users.getList();
077: if (l.size() == 0) {
078: return false;
079: }
080: return true;
081: }
082:
083: public String search() {
084: ArrayList al = new ArrayList();
085:
086: String searchText = (String) getSessionAttribute("addcommunityuseruserspopup.searchtext");
087: if (!searchText.equals("")) {
088: try {
089: LinkedList path = new LinkedList();
090: path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
091: path.addFirst("amobjsearch");
092: ObjectName on = AdminClientUtil
093: .getResourceMBeanObjectName(
094: AdminClientUtil.AMOBJECTSEARCH_MBEAN_TYPE,
095: path);
096:
097: Object[] params1 = {};
098: String[] signatures1 = {};
099: HashMap objectTypes = (HashMap) getMBeanServerConnection()
100: .invoke(on, "queryObjectTypes", params1,
101: signatures1);
102:
103: Object[] params2 = {};
104: String[] signatures2 = {};
105: String baseDN = (String) getMBeanServerConnection()
106: .invoke(on, "queryRootSuffix", params2,
107: signatures2);
108:
109: Object[] params3 = { baseDN, searchText,
110: (Integer) objectTypes.get("user"),
111: new Integer(2) };
112: String[] signatures3 = new String[] {
113: "java.lang.String", "java.lang.String",
114: "java.lang.Integer", "java.lang.Integer" };
115: HashMap hm = (HashMap) getMBeanServerConnection()
116: .invoke(on, "searchObjects", params3,
117: signatures3);
118:
119: Iterator i = hm.keySet().iterator();
120: while (i.hasNext()) {
121: String dn = (String) i.next();
122: String name = (String) hm.get(dn);
123:
124: UserBean ub = new UserBean();
125: ub.initialize(name, dn);
126: al.add(ub);
127: }
128: } catch (Exception e) {
129: log(
130: Level.SEVERE,
131: "AddCommunityUserUsersPopupBean.retrieveSearchResults()",
132: e);
133: }
134: }
135: users = new ObjectListDataProvider(al);
136: users.setObjectType(UserBean.class);
137: return null;
138: }
139:
140: }
|