本文整理汇总了Java中org.jivesoftware.openfire.group.Group类的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Group类属于org.jivesoftware.openfire.group包,在下文中一共展示了Group类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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.
}
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:27,代码来源:LdapGroupProvider.java
示例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");
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:26,代码来源:DeleteGroup.java
示例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;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:AgentManager.java
示例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);
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:19,代码来源:RosterManager.java
示例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;
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:22,代码来源:PacketFilter.java
示例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);
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:33,代码来源:Roster.java
示例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;
}
开发者ID:coodeer,项目名称:g3server,代码行数:34,代码来源:BookmarkInterceptor.java
示例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);
}
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:20,代码来源:RosterManager.java
示例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);
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:20,代码来源:RosterManager.java
示例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);
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:24,代码来源:RosterManager.java
示例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);
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:31,代码来源:PermissionManager.java
示例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;
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:25,代码来源:IQSharedGroupHandler.java
示例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();
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:17,代码来源:SearchGroupServlet.java
示例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);
}
开发者ID:coodeer,项目名称:g3server,代码行数:33,代码来源:Roster.java
示例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();
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:SearchGroupServlet.java
示例16: sourceDestMatch
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
private boolean sourceDestMatch(Rule.SourceDestType type, String ruleToFrom, JID packetToFrom) {
if (type == Rule.SourceDestType.Any)
return true;
if (type == Rule.SourceDestType.User) {
if (ruleToFrom.equals(packetToFrom.toBareJID())) {
return true;
}
} else if (type == Rule.SourceDestType.Group) {
return packetToFromGroup(ruleToFrom, packetToFrom);
} else if (type == Rule.SourceDestType.Component) {
if (ruleToFrom.toLowerCase().equals(packetToFrom.getDomain().toLowerCase())) {
return true;
}
} else if (type == Rule.SourceDestType.Other) {
if (matchUser(ruleToFrom, packetToFrom)) {
return true;
}
}
return false;
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:21,代码来源:PacketFilter.java
示例17: deleteRequestQueue
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
public void deleteRequestQueue(RequestQueue queue) {
queues.remove(queue.getID());
// Delete the RequestQueue from the database
if (deleteQueue(queue.getID())) {
// Stop processing requests in this queue
queue.shutdown();
// Remove the agents from this queue
for (Agent agent : queue.getMembers()) {
queue.removeMember(agent);
}
// Remove the agent groups from this queue
for (Group group : queue.getGroups()) {
queue.removeGroup(group);
}
try {
// Delete the dispatcher of this queue from the database
dispatcherInfoProvider.deleteDispatcherInfo(queue.getID());
}
catch (UnauthorizedException e) {
Log.error(e.getMessage(), e);
}
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:24,代码来源:Workgroup.java
示例18: memberAdded
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
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<JID>(visibleGroup.getMembers());
users.addAll(visibleGroup.getAdmins());
groupUserAdded(visibleGroup, users, addedUser);
}
}
else {
groupUserAdded(group, addedUser);
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:19,代码来源:RosterManager.java
示例19: isGroupVisible
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
/**
* Returns true if a given group is visible to a given user. That means, if the user can
* see the group in his roster.
*
* @param group the group to check if the user can see.
* @param user the JID of the user to check if he may see the group.
* @return true if a given group is visible to a given user.
*/
boolean isGroupVisible(Group group, JID user) {
String showInRoster = group.getProperties().get("sharedRoster.showInRoster");
if ("everybody".equals(showInRoster)) {
return true;
}
else if ("onlyGroup".equals(showInRoster)) {
if (group.isUser(user)) {
return true;
}
// Check if the user belongs to a group that may see this group
Collection<Group> groupList = parseGroups(group.getProperties().get(
"sharedRoster.groupList"));
for (Group groupInList : groupList) {
if (groupInList.isUser(user)) {
return true;
}
}
}
return false;
}
开发者ID:coodeer,项目名称:g3server,代码行数:29,代码来源:RosterManager.java
示例20: createGroup
import org.jivesoftware.openfire.group.Group; //导入依赖的package包/类
/**
* Creates the group.
*
* @param groupEntity
* the group entity
* @return the group
* @throws ServiceException
* the service exception
*/
public Group createGroup(GroupEntity groupEntity) throws ServiceException {
Group group;
if (groupEntity != null && !groupEntity.getName().isEmpty()) {
try {
group = GroupManager.getInstance().createGroup(groupEntity.getName());
group.setDescription(groupEntity.getDescription());
group.getProperties().put("sharedRoster.showInRoster", "onlyGroup");
group.getProperties().put("sharedRoster.displayName", groupEntity.getName());
group.getProperties().put("sharedRoster.groupList", "");
} catch (GroupAlreadyExistsException e) {
throw new ServiceException("Could not create a group", groupEntity.getName(),
ExceptionType.GROUP_ALREADY_EXISTS, Response.Status.CONFLICT, e);
}
} else {
throw new ServiceException("Could not create new group", "groups",
ExceptionType.ILLEGAL_ARGUMENT_EXCEPTION, Response.Status.BAD_REQUEST);
}
return group;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:30,代码来源:GroupController.java
注:本文中的org.jivesoftware.openfire.group.Group类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论