本文整理汇总了Java中org.jivesoftware.openfire.group.GroupNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java GroupNotFoundException类的具体用法?Java GroupNotFoundException怎么用?Java GroupNotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GroupNotFoundException类属于org.jivesoftware.openfire.group包,在下文中一共展示了GroupNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGroup
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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.GroupNotFoundException; //导入依赖的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: getGroup
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的package包/类
@Override
public Group getGroup(String name) throws GroupNotFoundException {
try {
Cache<String, org.jivesoftware.openfire.crowd.jaxb.Group> groupCache = CacheFactory.createLocalCache(GROUP_CACHE_NAME);
org.jivesoftware.openfire.crowd.jaxb.Group group = groupCache.get(name);
if (group == null) {
group = manager.getGroup(name);
groupCache.put(name, group);
}
Collection<JID> members = getGroupMembers(name);
Collection<JID> admins = Collections.emptyList();
return new Group(name, group.description, members, admins);
} catch (RemoteException re) {
LOG.error("Failure to load group:" + String.valueOf(name), re);
throw new GroupNotFoundException(re);
}
}
示例4: isBookmarkForJID
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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;
}
示例5: packetToFromGroup
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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: getGroup
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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;
}
示例7: updateGroup
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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;
}
示例8: execute
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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");
}
示例9: getGroupID
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的package包/类
/**
* Returns the Clearspace group id of the group.
*
* @param groupname Name of the group to retrieve ID of.
* @return The ID number of the group in Clearspace.
* @throws org.jivesoftware.openfire.group.GroupNotFoundException
* If the group was not found.
*/
protected long getGroupID(String groupname) throws GroupNotFoundException {
if (groupIDCache.containsKey(groupname)) {
return groupIDCache.get(groupname);
}
try {
// Encode potentially non-ASCII characters
groupname = URLUTF8Encoder.encode(groupname);
String path = ClearspaceGroupProvider.URL_PREFIX + "groups/" + groupname;
Element element = executeRequest(org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET, path);
Long id = Long.valueOf(WSUtils.getElementText(element.selectSingleNode("return"), "ID"));
// Saves it into the cache
groupIDCache.put(groupname, id);
return id;
} catch (GroupNotFoundException gnfe) {
// It is a supported exception, throw it again
throw gnfe;
} catch (Exception e) {
// It is not a supported exception, wrap it into a GroupNotFoundException
throw new GroupNotFoundException("Unexpected error", e);
}
}
示例10: packetToFromGroup
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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;
}
示例11: createUser
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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));
}
}
}
示例12: getGroup
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的package包/类
public Group getGroup(String name) throws GroupNotFoundException {
try {
Cache<String, org.jivesoftware.openfire.crowd.jaxb.Group> groupCache = CacheFactory.createLocalCache(GROUP_CACHE_NAME);
org.jivesoftware.openfire.crowd.jaxb.Group group = groupCache.get(name);
if (group == null) {
group = manager.getGroup(name);
groupCache.put(name, group);
}
Collection<JID> members = getGroupMembers(name);
Collection<JID> admins = Collections.emptyList();
return new Group(name, group.description, members, admins);
} catch (RemoteException re) {
LOG.error("Failure to load group:" + String.valueOf(name), re);
throw new GroupNotFoundException(re);
}
}
示例13: packetToFromGroup
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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;
}
示例14: execute
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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");
}
示例15: execute
import org.jivesoftware.openfire.group.GroupNotFoundException; //导入依赖的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");
}