use of org.jivesoftware.xmpp.workgroup.WorkgroupManager in project Openfire by igniterealtime.
the class ImageServlet method getImage.
/**
* Returns the image bytes of the encoded image.
*
* @param imageName the name of the image.
* @param workgroupName the name of the workgroup.
* @return the image bytes found, otherwise null.
*/
public byte[] getImage(String imageName, String workgroupName) {
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
JID workgroupJID = new JID(workgroupName);
Workgroup workgroup;
try {
workgroup = workgroupManager.getWorkgroup(workgroupJID);
} catch (UserNotFoundException e) {
Log.error(e.getMessage(), e);
return null;
}
ChatSettings chatSettings = chatSettingsManager.getChatSettings(workgroup);
ChatSetting setting = chatSettings.getChatSetting(imageName);
String encodedValue = setting.getValue();
if (encodedValue == null) {
return null;
}
return StringUtils.decodeBase64(encodedValue);
}
use of org.jivesoftware.xmpp.workgroup.WorkgroupManager in project Openfire by igniterealtime.
the class DeleteWorkgroup method execute.
@Override
public void execute(SessionData data, Element command) {
Element note = command.addElement("note");
// Get requested group
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
// Load the workgroup
try {
Workgroup workgroup = workgroupManager.getWorkgroup(new JID(data.getData().get("workgroup").get(0)));
workgroupManager.deleteWorkgroup(workgroup);
} catch (UserNotFoundException e) {
// Group not found
note.addAttribute("type", "error");
note.setText("Workgroup not found");
return;
} catch (Exception e) {
// Group not found
note.addAttribute("type", "error");
note.setText("Error executing the command");
return;
}
note.addAttribute("type", "info");
note.setText("Operation finished successfully");
}
use of org.jivesoftware.xmpp.workgroup.WorkgroupManager in project Openfire by igniterealtime.
the class WorkgroupUtils method addAgents.
/**
* Adds agents to a request queue.
*
* @param queue the <code>RequestQueue</code> to add agents to.
* @param agents a comma-delimited list of agents.
*/
public static void addAgents(RequestQueue queue, String agents) {
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
AgentManager agentManager = workgroupManager.getAgentManager();
// loop thru all params
StringTokenizer tokenizer = new StringTokenizer(agents, ", \t\n\r\f");
while (tokenizer.hasMoreTokens()) {
String usernameToken = tokenizer.nextToken();
if (usernameToken.indexOf('@') != -1) {
usernameToken = JID.escapeNode(usernameToken);
}
try {
// See if they are a user in the system.
UserManager.getInstance().getUser(usernameToken);
usernameToken += ("@" + ComponentManagerFactory.getComponentManager().getServerName());
JID address = new JID(usernameToken.trim());
Agent agent;
if (agentManager.hasAgent(address)) {
agent = agentManager.getAgent(address);
} else {
agent = agentManager.createAgent(address);
}
queue.addMember(agent);
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
}
}
use of org.jivesoftware.xmpp.workgroup.WorkgroupManager in project Openfire by igniterealtime.
the class WorkgroupUtils method updateWorkgroup.
public static String updateWorkgroup(String workgroupName, String displayName, String description, int maxSize, int minSize, long requestTimeout, long offerTimeout) {
final WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
Workgroup workgroup;
try {
workgroup = workgroupManager.getWorkgroup(new JID(workgroupName));
} catch (UserNotFoundException e) {
return getUpdateMessage(false, "The JID specified is invalid.");
}
workgroup.setDisplayName(displayName);
workgroup.setDescription(description);
if (maxSize < minSize) {
return getUpdateMessage(false, "Max size must be greater or equal to min size.");
}
workgroup.setMaxChats(maxSize);
workgroup.setMinChats(minSize);
workgroup.setRequestTimeout(requestTimeout);
workgroup.setOfferTimeout(offerTimeout);
return getUpdateMessage(true, "Workgroup has been updated");
}
use of org.jivesoftware.xmpp.workgroup.WorkgroupManager in project Openfire by igniterealtime.
the class MonitorProvider method executeSet.
public void executeSet(IQ packet, Workgroup workgroup) {
IQ reply = null;
Element iq = packet.getChildElement();
try {
JID from = packet.getFrom();
String bareJID = from.toBareJID();
if (!isOwner(bareJID, workgroup)) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.forbidden));
workgroup.send(reply);
return;
}
// Verify that an agent is requesting this information.
WorkgroupManager workgroupManager = WorkgroupManager.getInstance();
if (iq.element("makeOwner") != null) {
String sessionID = iq.element("makeOwner").attributeValue("sessionID");
final String serviceName = workgroupManager.getMUCServiceName();
final String roomName = sessionID + "@" + serviceName;
// final String roomJID = roomName + "/" + workgroup.getJID().getNode();
IQ iqPacket = new IQ(IQ.Type.set);
iqPacket.setTo(roomName);
iqPacket.setFrom(workgroup.getFullJID());
Element query = iqPacket.setChildElement("query", "http://jabber.org/protocol/muc#admin");
Element item = query.addElement("item");
item.addAttribute("affiliation", "owner");
item.addAttribute("jid", packet.getFrom().toBareJID());
workgroup.send(iqPacket);
}
reply = IQ.createResultIQ(packet);
} catch (Exception e) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
}
workgroup.send(reply);
}
Aggregations