use of org.jivesoftware.openfire.group.GroupNotFoundException in project Openfire by igniterealtime.
the class GroupModified method execute.
@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;
}
// Get the modification type
String type;
try {
type = get(data, "changeType", 0);
} catch (NullPointerException npe) {
note.addAttribute("type", "error");
note.setText("Change type required parameter.");
return;
}
// Identifies the value variable
String valueVariable = null;
String valueVariableName = null;
if ("nameModified".equals(type) || "descriptionModified".equals(type)) {
valueVariable = "originalValue";
valueVariableName = "Original value";
} else if ("propertyModified".equals(type) || "propertyAdded".equals(type) || "propertyDeleted".equals(type)) {
valueVariable = "propertyKey";
valueVariableName = "Property key";
}
// Creates event params.
Map<String, Object> params = new HashMap<>();
// Gets the value of the change if it exist
String value;
if (valueVariable != null) {
try {
// Gets the value
value = get(data, valueVariable, 0);
// Adds it to the event params
params.put(valueVariable, value);
} catch (NullPointerException npe) {
note.addAttribute("type", "error");
note.setText(valueVariableName + " required parameter.");
return;
}
}
// Adds the type of change
params.put("type", type);
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.group_modified, 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");
}
use of org.jivesoftware.openfire.group.GroupNotFoundException in project Openfire by igniterealtime.
the class GroupAdminAdded method execute.
@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;
}
// Creates event params.
Map<String, Object> params = null;
try {
// Get the admin
String admin = get(data, "admin", 0);
// Adds the admin
params = new HashMap<>();
params.put("admin", admin);
} catch (NullPointerException npe) {
note.addAttribute("type", "error");
note.setText("Admin required parameter.");
return;
}
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.admin_added, 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");
}
use of org.jivesoftware.openfire.group.GroupNotFoundException in project Openfire by igniterealtime.
the class GroupAdminRemoved method execute.
@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;
}
// Creates event params.
Map<String, Object> params = null;
try {
// Get the admin
String admin = get(data, "admin", 0);
// Adds the admin
params = new HashMap<>();
params.put("admin", admin);
} catch (NullPointerException npe) {
note.addAttribute("type", "error");
note.setText("Admin required parameter.");
return;
}
// Sends the event
Group group;
try {
group = GroupManager.getInstance().getGroup(groupname, true);
// Fire event.
GroupEventDispatcher.dispatchEvent(group, GroupEventDispatcher.EventType.admin_removed, 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");
}
use of org.jivesoftware.openfire.group.GroupNotFoundException in project Openfire by igniterealtime.
the class GroupCreated method execute.
@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");
}
use of org.jivesoftware.openfire.group.GroupNotFoundException in project Openfire by igniterealtime.
the class RosterAccess method canSubscribe.
@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;
}
Aggregations