本文整理汇总了Java中org.jivesoftware.openfire.group.GroupManager类的典型用法代码示例。如果您正苦于以下问题:Java GroupManager类的具体用法?Java GroupManager怎么用?Java GroupManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GroupManager类属于org.jivesoftware.openfire.group包,在下文中一共展示了GroupManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的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
示例2: initializePlugin
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
public void initializePlugin(PluginManager manager, File pluginDirectory) {
pluginManager = manager;
sessionManager = SessionManager.getInstance();
groupManager = GroupManager.getInstance();
userManager = UserManager.getInstance();
// Register as a component.
componentManager = ComponentManagerFactory.getComponentManager();
try {
componentManager.addComponent(serviceName, this);
}
catch (Exception e) {
Log.error(e.getMessage(), e);
}
PropertyEventDispatcher.addListener(this);
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:BroadcastPlugin.java
示例3: isBookmarkForJID
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的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:igniterealtime,项目名称:Openfire,代码行数:34,代码来源:BookmarkInterceptor.java
示例4: doGet
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的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
示例5: packetToFromGroup
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的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:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:PacketFilter.java
示例6: getGroup
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
/**
* Gets the group.
*
* @param groupName
* the group name
* @return the group
* @throws ServiceException
* the service exception
*/
public GroupEntity getGroup(String groupName) throws ServiceException {
Group group;
try {
group = GroupManager.getInstance().getGroup(groupName);
} catch (GroupNotFoundException e) {
throw new ServiceException("Could not find group", groupName, ExceptionType.GROUP_NOT_FOUND,
Response.Status.NOT_FOUND, e);
}
GroupEntity groupEntity = new GroupEntity(group.getName(), group.getDescription());
groupEntity.setAdmins(MUCRoomUtils.convertJIDsToStringList(group.getAdmins()));
groupEntity.setMembers(MUCRoomUtils.convertJIDsToStringList(group.getMembers()));
return groupEntity;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:25,代码来源:GroupController.java
示例7: createGroup
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的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
示例8: updateGroup
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
/**
* Update group.
*
* @param groupName the group name
* @param groupEntity the group entity
* @return the group
* @throws ServiceException the service exception
*/
public Group updateGroup(String groupName, GroupEntity groupEntity) throws ServiceException {
Group group;
if (groupEntity != null && !groupEntity.getName().isEmpty()) {
if (groupName.equals(groupEntity.getName())) {
try {
group = GroupManager.getInstance().getGroup(groupName);
group.setDescription(groupEntity.getDescription());
} catch (GroupNotFoundException e) {
throw new ServiceException("Could not find group", groupName, ExceptionType.GROUP_NOT_FOUND,
Response.Status.NOT_FOUND, e);
}
} else {
throw new ServiceException(
"Could not update the group. The group name is different to the payload group name.", groupName + " != " + groupEntity.getName(),
ExceptionType.ILLEGAL_ARGUMENT_EXCEPTION, Response.Status.BAD_REQUEST);
}
} else {
throw new ServiceException("Could not update new group", "groups",
ExceptionType.ILLEGAL_ARGUMENT_EXCEPTION, Response.Status.BAD_REQUEST);
}
return group;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:31,代码来源:GroupController.java
示例9: execute
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的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:coodeer,项目名称:g3server,代码行数:26,代码来源:DeleteGroup.java
示例10: getVisibleGroups
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
private Collection<Group> getVisibleGroups(Group groupToCheck) {
Collection<Group> answer = new HashSet<Group>();
Collection<Group> groups = GroupManager.getInstance().getSharedGroups();
for (Group group : groups) {
if (group.equals(groupToCheck)) {
continue;
}
String showInRoster = group.getProperties().get("sharedRoster.showInRoster");
if ("onlyGroup".equals(showInRoster)) {
// Check if the user belongs to a group that may see this group
Collection<String> groupList =
parseGroupNames(group.getProperties().get("sharedRoster.groupList"));
if (groupList.contains(groupToCheck.getName())) {
answer.add(group);
}
}
else if ("everybody".equals(showInRoster)) {
answer.add(group);
}
}
return answer;
}
开发者ID:coodeer,项目名称:g3server,代码行数:23,代码来源:RosterManager.java
示例11: packetToFromGroup
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
private boolean packetToFromGroup(String rulegroup, JID packetToFrom) {
Group group = null;
try {
group = GroupManager.getInstance().getGroup(rulegroup);
} catch (GroupNotFoundException e) {
e.printStackTrace();
}
if (group == null) {
return false;
} else {
if (group.isUser(packetToFrom)) {
return true;
}
}
return false;
}
开发者ID:coodeer,项目名称:g3server,代码行数:17,代码来源:PacketFilter.java
示例12: createUser
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
public void createUser(String username, String password, String name, String email, String groupNames)
throws UserAlreadyExistsException
{
userManager.createUser(username, password, name, email);
if (groupNames != null) {
Collection<Group> groups = new ArrayList<Group>();
StringTokenizer tkn = new StringTokenizer(groupNames, ",");
while (tkn.hasMoreTokens()) {
try {
groups.add(GroupManager.getInstance().getGroup(tkn.nextToken()));
} catch (GroupNotFoundException e) {
// Ignore this group
}
}
for (Group group : groups) {
group.getMembers().add(server.createJID(username, null));
}
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:21,代码来源:UserServicePlugin.java
示例13: doGet
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的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: packetToFromGroup
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的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
示例15: getUserGroups
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
private void getUserGroups(String defaultUsername, IQ reply, JSONObject requestJSON)
{
Element childElement = reply.setChildElement("response", "http://igniterealtime.org/protocol/ofmeet");
try {
String username = requestJSON.getString("username");
if (username == null) username = defaultUsername;
UserManager userManager = XMPPServer.getInstance().getUserManager();
User user = userManager.getUser(username);
Collection<Group> groups = GroupManager.getInstance().getGroups(user);
JSONArray groupsJSON = new JSONArray();
int index = 0;
for (Group group : groups)
{
groupsJSON.put(index++, getJsonFromGroupXml(group.getName()));
}
childElement.setText(groupsJSON.toString());
} catch (UserNotFoundException e) {
reply.setError(new PacketError(PacketError.Condition.not_allowed, PacketError.Type.modify, "User not found"));
return;
} catch (Exception e1) {
reply.setError(new PacketError(PacketError.Condition.not_allowed, PacketError.Type.modify, requestJSON.toString() + " " + e1));
return;
}
}
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:33,代码来源:OfMeetIQHandler.java
示例16: execute
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
@Override
public void execute(SessionData sessionData, Element command) {
Element note = command.addElement("note");
Map<String, List<String>> data = sessionData.getData();
// Get the group name
String groupname;
try {
groupname = get(data, "groupName", 0);
}
catch (NullPointerException npe) {
note.addAttribute("type", "error");
note.setText("Group name required parameter.");
return;
}
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
Map<String, Object> params = Collections.emptyMap();
GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.group_created, params);
} catch (GroupNotFoundException e) {
note.addAttribute("type", "error");
note.setText("Group not found.");
}
// Answer that the operation was successful
note.addAttribute("type", "info");
note.setText("Operation finished successfully");
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:36,代码来源:GroupCreated.java
示例17: execute
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
@Override
public void execute(SessionData sessionData, Element command) {
Element note = command.addElement("note");
Map<String, List<String>> data = sessionData.getData();
// Get the group name
String groupname;
try {
groupname = get(data, "groupName", 0);
}
catch (NullPointerException npe) {
note.addAttribute("type", "error");
note.setText("Group name required parameter.");
return;
}
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
Map<String, Object> params = Collections.emptyMap();
GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.group_deleting, params);
} catch (GroupNotFoundException e) {
note.addAttribute("type", "error");
note.setText("Group not found.");
}
// Answer that the operation was successful
note.addAttribute("type", "info");
note.setText("Operation finished successfully");
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:36,代码来源:GroupDeleting.java
示例18: PubSubServiceInfo
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
public PubSubServiceInfo(PubSubService pubSubService) {
if (pubSubService == null) {
throw new IllegalArgumentException("Argument 'pubSubService' cannot be null.");
}
this.pubSubService = pubSubService;
xmppServer = XMPPServer.getInstance();
pubSubModule = xmppServer.getPubSubModule();
groupManager = GroupManager.getInstance();
userManager = xmppServer.getUserManager();
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:12,代码来源:PubSubServiceInfo.java
示例19: canSubscribe
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
@Override
public boolean canSubscribe(Node node, JID owner, JID subscriber) {
// Let node owners and sysadmins always subscribe to the node
if (node.isAdmin(owner)) {
return true;
}
for (JID nodeOwner : node.getOwners()) {
if (nodeOwner.equals(owner)) {
return true;
}
}
// Check that the subscriber is a local user
XMPPServer server = XMPPServer.getInstance();
if (server.isLocal(owner)) {
GroupManager gMgr = GroupManager.getInstance();
Collection<String> nodeGroups = node.getRosterGroupsAllowed();
for (String groupName : nodeGroups) {
try {
Group group = gMgr.getGroup(groupName);
// access allowed if the node group is visible to the subscriber
if (server.getRosterManager().isGroupVisible(group, owner)) {
return true;
}
} catch (GroupNotFoundException gnfe){
// ignore
}
}
}
else {
// Subscriber is a remote user. This should never happen.
Log.warn("Node with access model Roster has a remote user as subscriber: " +
node.getNodeID());
}
return false;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:36,代码来源:RosterAccess.java
示例20: getAdmins
import org.jivesoftware.openfire.group.GroupManager; //导入依赖的package包/类
@Override
public List<JID> getAdmins() {
List<JID> results = new ArrayList<>();
GroupProvider provider = GroupManager.getInstance().getProvider();
String groups = JiveGlobals.getProperty(JIVE_AUTHORIZED_GROUPS);
groups = (groups == null || groups.trim().length() == 0) ? "" : groups;
JiveGlobals.setProperty(JIVE_AUTHORIZED_GROUPS, groups); // make sure the property is created
StringTokenizer tokenizer = new StringTokenizer(groups, ",");
while (tokenizer.hasMoreTokens()) {
String groupName = tokenizer.nextToken().trim().toLowerCase();
if (groupName != null && groupName.length() > 0) {
try {
LOG.info("Adding admin users from group: " + groupName);
Group group = provider.getGroup(groupName);
if (group != null) {
results.addAll(group.getMembers());
}
} catch (GroupNotFoundException gnfe) {
LOG.error("Error when trying to load the members of group:" + String.valueOf(groupName), gnfe);
}
}
}
if (results.isEmpty()) {
// Add default admin account when none was specified
results.add(new JID("admin", XMPPServer.getInstance().getServerInfo().getXMPPDomain(), null, true));
}
if (LOG.isDebugEnabled()) {
LOG.debug("admin users: " + results.toString());
}
return results;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:40,代码来源:CrowdAdminProvider.java
注:本文中的org.jivesoftware.openfire.group.GroupManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论