use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class BookmarkInterceptor method isBookmarkForJID.
/**
* True if the specified bookmark should be appended to the users list of
* bookmarks.
*
* @param jid the jid of the user.
* @param bookmark the bookmark.
* @return true if bookmark should be appended.
*/
private static boolean isBookmarkForJID(JID jid, Bookmark bookmark) {
String username = jid.getNode();
if (bookmark.getUsers().contains(username)) {
return true;
}
Collection<String> groups = bookmark.getGroups();
if (groups != null && !groups.isEmpty()) {
GroupManager groupManager = GroupManager.getInstance();
for (String groupName : groups) {
try {
Group group = groupManager.getGroup(groupName);
if (group.isUser(jid.getNode())) {
return true;
}
} catch (GroupNotFoundException e) {
Log.debug(e.getMessage(), e);
}
}
}
return false;
}
use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class WorkgroupManager method addGroupManagerListener.
/**
* Listens for changes in the Group model to update respective agents.
*/
private void addGroupManagerListener() {
groupEventListener = new GroupEventListener() {
public void groupCreated(Group group, Map params) {
}
public void groupDeleting(Group group, Map params) {
}
public void groupModified(Group group, Map params) {
}
public void memberAdded(Group group, Map params) {
String userJID = (String) params.get("member");
JID jid = new JID(userJID);
if (!agentManager.hasAgent(jid)) {
for (Workgroup workgroup : workgroups.values()) {
for (RequestQueue queue : workgroup.getRequestQueues()) {
if (queue.hasGroup(group)) {
agentManager.getAgents(group);
}
}
}
}
}
public void memberRemoved(Group group, Map params) {
}
public void adminAdded(Group group, Map params) {
}
public void adminRemoved(Group group, Map params) {
}
};
GroupEventDispatcher.addListener(groupEventListener);
}
use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class JustMarriedPlugin method copyRoster.
private static void copyRoster(User currentUser, User newUser, String currentUserName) {
Roster newRoster = newUser.getRoster();
Roster currentRoster = currentUser.getRoster();
for (RosterItem item : currentRoster.getRosterItems()) {
try {
List<String> groups = item.getGroups();
RosterItem justCreated = newRoster.createRosterItem(item.getJid(), item.getNickname(), groups, true, true);
justCreated.setAskStatus(item.getAskStatus());
justCreated.setRecvStatus(item.getRecvStatus());
justCreated.setSubStatus(item.getSubStatus());
for (Group gr : item.getSharedGroups()) {
justCreated.addSharedGroup(gr);
}
for (Group gr : item.getInvisibleSharedGroups()) {
justCreated.addInvisibleSharedGroup(gr);
}
newRoster.updateRosterItem(justCreated);
addNewUserToOthersRoster(newUser, item, currentUserName);
} catch (UserAlreadyExistsException e) {
Log.error("Could not create roster item for user " + item.getJid(), e);
} catch (SharedGroupException e) {
Log.error("Could not create roster item for user " + item.getJid() + " because it is a contact from a shared group", e);
} catch (UserNotFoundException e) {
Log.error("Could not update Roster item for user " + newUser.getName() + " because it was not properly created.", e);
}
}
}
use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class SearchGroupServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String param = req.getParameter("search");
Element root = new DefaultElement("result");
if (param != null && param.length() > 0) {
GroupManager manager = GroupManager.getInstance();
Collection<Group> groups = manager.getGroups();
for (Group gr : groups) {
if (gr.getName().startsWith(param)) {
root.addElement("item").addText(gr.getName());
}
}
}
resp.getOutputStream().write(root.asXML().getBytes());
resp.getOutputStream().close();
}
use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class PermissionManager method isUserInAllowedGroup.
/**
* Checks if a user is in a group that has access to the transport.
*
* @param jid JID of the user who may or may not have access.
* @return True or false of the user is in a group that has access.
*/
public boolean isUserInAllowedGroup(JID jid) {
ArrayList<String> allowedGroups = new ArrayList<String>();
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(GROUPS_LISTED);
pstmt.setString(1, transportType.toString());
rs = pstmt.executeQuery();
while (rs.next()) {
allowedGroups.add(rs.getString(1));
}
} catch (SQLException sqle) {
Log.error(sqle);
} finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
Collection<Group> userGroups = GroupManager.getInstance().getGroups(jid);
for (Group g : userGroups) {
if (allowedGroups.contains(g.getName())) {
return true;
}
}
return false;
}
Aggregations