use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class UserServicePluginNG method createGroup.
/**
* Creates the group.
*
* @param groupName
* the group name
* @return the group
* @throws ServiceException
* @throws GroupAlreadyExistsException
* the group already exists exception
*/
private Group createGroup(String groupName) throws ServiceException {
Group group = null;
try {
group = GroupManager.getInstance().createGroup(groupName);
group.getProperties().put("sharedRoster.showInRoster", "onlyGroup");
group.getProperties().put("sharedRoster.displayName", groupName);
group.getProperties().put("sharedRoster.groupList", "");
} catch (GroupAlreadyExistsException e) {
throw new ServiceException("Could not create group", groupName, ExceptionType.GROUP_ALREADY_EXISTS, Response.Status.BAD_REQUEST, e);
}
return group;
}
use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class RequestQueue method getGroupObjects.
private Collection<Group> getGroupObjects() {
final GroupManager groupManager = GroupManager.getInstance();
Set<Group> objects = new HashSet<Group>(groups.size());
for (String group : groups) {
try {
objects.add(groupManager.getGroup(group));
} catch (GroupNotFoundException e) {
Log.error("Error retrieving group: " + group, e);
}
}
return objects;
}
use of org.jivesoftware.openfire.group.Group 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.Group 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.Group 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");
}
Aggregations