本文整理汇总了Java中org.jivesoftware.openfire.group.Group类的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Group类属于org.jivesoftware.openfire.group包,在下文中一共展示了Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGroup
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
public Group getGroup(String groupName) throws GroupNotFoundException {
LdapContext ctx = null;
try {
String groupDN = manager.findGroupDN(groupName);
// Load record.
ctx = manager.getContext(manager.getGroupsBaseDN(groupName));
Attributes attrs = ctx.getAttributes(groupDN, standardAttributes);
return processGroup(ctx, attrs);
}
catch (Exception e) {
Log.error(e.getMessage(), e);
throw new GroupNotFoundException("Group with name " + groupName + " not found.", e);
}
finally {
try {
if (ctx != null) {
ctx.setRequestControls(null);
ctx.close();
}
}
catch (Exception ignored) {
// Ignore.
}
}
}
示例2: execute
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
@Override
public void execute(SessionData data, Element command) {
Element note = command.addElement("note");
// Check if groups cannot be modified (backend is read-only)
if (GroupManager.getInstance().isReadOnly()) {
note.addAttribute("type", "error");
note.setText("Groups are read only");
return;
}
// Get requested group
Group group;
try {
group = GroupManager.getInstance().getGroup(data.getData().get("group").get(0));
} catch (GroupNotFoundException e) {
// Group not found
note.addAttribute("type", "error");
note.setText("Group name does not exist");
return;
}
GroupManager.getInstance().deleteGroup(group);
note.addAttribute("type", "info");
note.setText("Operation finished successfully");
}
示例3: getAgents
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
/**
* Returns all agents belonging to a Shared Group.
*
* @param group the shared group.
* @return the collection of agents.
*/
public Collection<Agent> getAgents(Group group) {
final Set<Agent> set = new HashSet<Agent>();
for (JID jid : group.getMembers()) {
Agent agent;
try {
agent = getAgent(jid);
}
catch (AgentNotFoundException e) {
agent = createAgent(jid);
}
set.add(agent);
}
return set;
}
示例4: adminAdded
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
public void adminAdded(Group group, Map params) {
JID addedUser = new JID((String) params.get("admin"));
// Do nothing if the user was a member that became an admin
if (group.getMembers().contains(addedUser)) {
return;
}
if (!isSharedGroup(group)) {
for (Group visibleGroup : getVisibleGroups(group)) {
// Get the list of affected users
Collection<JID> users = new HashSet<JID>(visibleGroup.getMembers());
users.addAll(visibleGroup.getAdmins());
groupUserAdded(visibleGroup, users, addedUser);
}
}
else {
groupUserAdded(group, addedUser);
}
}
示例5: packetToFromGroup
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
private boolean packetToFromGroup(String rulegroup, JID packetToFrom) {
Group group = null;
boolean result = false;
try {
group = GroupManager.getInstance().getGroup(rulegroup);
} catch (GroupNotFoundException e) {
if (PacketFilterConstants.ANY_GROUP.equals(rulegroup)) {
if (!GroupManager.getInstance().getGroups(packetToFrom).isEmpty()) {
result = true;
}
} else {
e.printStackTrace();
}
}
if (group != null) {
if (group.isUser(packetToFrom)) {
result = true;
}
}
return result;
}
示例6: broadcast
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
/**
* Broadcasts the RosterItem to all the connected resources of this user. Due to performance
* optimizations and due to some clients errors that are showing items with subscription status
* FROM we added a flag that indicates if a roster items that exists only because of a shared
* group with subscription status FROM will not be sent.
*
* @param item the item to broadcast.
* @param optimize true indicates that items that exists only because of a shared
* group with subscription status FROM will not be sent
*/
public void broadcast(RosterItem item, boolean optimize) {
// Do not broadcast items with status FROM that exist only because of shared groups
if (optimize && item.isOnlyShared() && item.getSubStatus() == RosterItem.SUB_FROM) {
return;
}
// Set the groups to broadcast (include personal and shared groups)
List<String> groups = new ArrayList<>(item.getGroups());
for (Group sharedGroup : item.getSharedGroups()) {
String displayName = sharedGroup.getProperties().get("sharedRoster.displayName");
if (displayName != null) {
groups.add(displayName);
}
}
org.xmpp.packet.Roster roster = new org.xmpp.packet.Roster();
roster.setType(IQ.Type.set);
roster.addItem(item.getJid(), item.getNickname(),
getAskStatus(item.getAskStatus()),
org.xmpp.packet.Roster.Subscription.valueOf(item.getSubStatus().getName()),
groups);
broadcast(roster);
}
示例7: isBookmarkForJID
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
/**
* 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;
}
示例8: adminRemoved
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
public void adminRemoved(Group group, Map params) {
JID deletedUser = new JID((String) params.get("admin"));
// Do nothing if the user is still a member
if (group.getMembers().contains(deletedUser)) {
return;
}
// Do nothing if the group is not being shown in group members' rosters
if (!isSharedGroup(group)) {
for (Group visibleGroup : getVisibleGroups(group)) {
// Get the list of affected users
Collection<JID> users = new HashSet<JID>(visibleGroup.getMembers());
users.addAll(visibleGroup.getAdmins());
groupUserDeleted(visibleGroup, users, deletedUser);
}
}
else {
groupUserDeleted(group, deletedUser);
}
}
示例9: memberAdded
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
@Override
public void memberAdded(Group group, Map params) {
JID addedUser = new JID((String) params.get("member"));
// Do nothing if the user was an admin that became a member
if (group.getAdmins().contains(addedUser)) {
return;
}
if (!isSharedGroup(group)) {
for (Group visibleGroup : getVisibleGroups(group)) {
// Get the list of affected users
Collection<JID> users = new HashSet<>(visibleGroup.getMembers());
users.addAll(visibleGroup.getAdmins());
groupUserAdded(visibleGroup, users, addedUser);
}
}
else {
groupUserAdded(group, addedUser);
}
}
示例10: memberRemoved
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
@Override
public void memberRemoved(Group group, Map params) {
String member = (String) params.get("member");
if (member == null) {
return;
}
JID deletedUser = new JID(member);
// Do nothing if the user is still an admin
if (group.getAdmins().contains(deletedUser)) {
return;
}
if (!isSharedGroup(group)) {
for (Group visibleGroup : getVisibleGroups(group)) {
// Get the list of affected users
Collection<JID> users = new HashSet<>(visibleGroup.getMembers());
users.addAll(visibleGroup.getAdmins());
groupUserDeleted(visibleGroup, users, deletedUser);
}
}
else {
groupUserDeleted(group, deletedUser);
}
}
示例11: storeGroupList
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
/**
* Stores a list of groups as having access to the transport in question.
*
* @param groups list of groups who should have access.
*/
public void storeGroupList(ArrayList<Group> groups) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(DELETE_ALL_GROUPS);
pstmt.setString(1, transportType.toString());
pstmt.executeUpdate();
pstmt.close();
pstmt = con.prepareStatement(ADD_NEW_GROUP);
pstmt.setString(1, transportType.toString());
for (Group group : groups) {
pstmt.setString(2, group.getName());
pstmt.executeUpdate();
}
pstmt.close();
}
catch (SQLException sqle) {
Log.error(sqle);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
}
}
示例12: handleIQ
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
@Override
public IQ handleIQ(IQ packet) throws UnauthorizedException {
IQ result = IQ.createResultIQ(packet);
String username = packet.getFrom().getNode();
if (!serverName.equals(packet.getFrom().getDomain()) || username == null) {
// Users of remote servers are not allowed to get their "shared groups". Users of
// remote servers cannot have shared groups in this server.
// Besides, anonymous users do not belong to shared groups so answer an error
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.not_allowed);
return result;
}
Collection<Group> groups = rosterManager.getSharedGroups(username);
Element sharedGroups = result.setChildElement("sharedgroup",
"http://www.jivesoftware.org/protocol/sharedgroup");
for (Group sharedGroup : groups) {
String displayName = sharedGroup.getProperties().get("sharedRoster.displayName");
if (displayName != null) {
sharedGroups.addElement("group").setText(displayName);
}
}
return result;
}
示例13: doGet
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
@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();
}
示例14: broadcast
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
/**
* Broadcasts the RosterItem to all the connected resources of this user. Due to performance
* optimizations and due to some clients errors that are showing items with subscription status
* FROM we added a flag that indicates if a roster items that exists only because of a shared
* group with subscription status FROM will not be sent.
*
* @param item the item to broadcast.
* @param optimize true indicates that items that exists only because of a shared
* group with subscription status FROM will not be sent
*/
public void broadcast(RosterItem item, boolean optimize) {
// Do not broadcast items with status FROM that exist only because of shared groups
if (optimize && item.isOnlyShared() && item.getSubStatus() == RosterItem.SUB_FROM) {
return;
}
// Set the groups to broadcast (include personal and shared groups)
List<String> groups = new ArrayList<String>(item.getGroups());
for (Group sharedGroup : item.getSharedGroups()) {
String displayName = sharedGroup.getProperties().get("sharedRoster.displayName");
if (displayName != null) {
groups.add(displayName);
}
}
org.xmpp.packet.Roster roster = new org.xmpp.packet.Roster();
roster.setType(IQ.Type.set);
roster.addItem(item.getJid(), item.getNickname(),
getAskStatus(item.getAskStatus()),
org.xmpp.packet.Roster.Subscription.valueOf(item.getSubStatus().getName()),
groups);
broadcast(roster);
}
示例15: doGet
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
@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();
}