use of org.jivesoftware.xmpp.workgroup.DbProperties in project Openfire by igniterealtime.
the class MacroProvider method executeGet.
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
Element iq = packet.getChildElement();
String name = iq.getName();
boolean isPersonal = iq.element("personal") != null;
Agent agent;
try {
agent = workgroup.getAgentManager().getAgent(packet.getFrom());
} catch (AgentNotFoundException e) {
sendItemNotFound(packet, workgroup);
return;
}
if ("macros".equals(name) && !isPersonal) {
Element globalMacros = reply.setChildElement("macros", "http://jivesoftware.com/protocol/workgroup");
DbProperties props = workgroup.getProperties();
String macroModel = props.getProperty("jive.macro" + workgroup.getID());
if (ModelUtil.hasLength(macroModel)) {
globalMacros.addElement("model").setText(macroModel);
} else {
sendItemNotFound(packet, workgroup);
return;
}
} else if (isPersonal) {
Element personalMacros = reply.setChildElement("macros", "http://jivesoftware.com/protocol/workgroup");
DbProperties props = agent.getProperties();
String macroModel = props.getProperty("personal.macro");
if (ModelUtil.hasLength(macroModel)) {
personalMacros.addElement("model").setText(macroModel);
} else {
sendItemNotFound(packet, workgroup);
return;
}
} else {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
workgroup.send(reply);
}
use of org.jivesoftware.xmpp.workgroup.DbProperties in project Openfire by igniterealtime.
the class WorkgroupMacros method saveMacros.
public void saveMacros(Workgroup workgroup) {
long id = workgroup.getID();
MacroGroup group = getMacroGroup(workgroup);
String saveString = xstream.toXML(group);
DbProperties props = workgroup.getProperties();
try {
props.deleteProperty("jive.macro" + id);
props.setProperty("jive.macro" + id, saveString);
} catch (UnauthorizedException e) {
Log.error(e.getMessage(), e);
}
}
use of org.jivesoftware.xmpp.workgroup.DbProperties in project Openfire by igniterealtime.
the class MonitorProvider method isOwner.
private boolean isOwner(String jid, Workgroup workgroup) {
DbProperties props = workgroup.getProperties();
// Add monitors if you wish :)
String monitors = props.getProperty("monitors");
if (monitors != null) {
StringTokenizer tkn = new StringTokenizer(monitors, ",");
while (tkn.hasMoreTokens()) {
String monitor = tkn.nextToken();
if (monitor.equalsIgnoreCase(jid)) {
return true;
}
}
}
return false;
}
use of org.jivesoftware.xmpp.workgroup.DbProperties in project Openfire by igniterealtime.
the class MetaDataRouter method calculateMatchScore.
/**
* <p>Calculates the match score between the queue's properties and the
* given info metadata</p>
* <p/>
* <p>Matching is done by simple comparison of the metadata name value
* pairs, and the property name value pairs of the queue. The total
* number of matches found is the match score.</p>
*
* @param queue The queue to inspect for properties
* @param metaData The metada to locate name value pairs
* @return The number of matches found
*/
private int calculateMatchScore(RequestQueue queue, Map<String, List<String>> metaData) {
int currentMatch = 0;
try {
DbProperties queueProps = queue.getProperties();
for (String name : metaData.keySet()) {
List<String> values = metaData.get(name);
String queueProp = queueProps.getProperty(name);
for (String value : values) {
if (queueProp != null && queueProp.equalsIgnoreCase(value)) {
currentMatch++;
break;
}
}
}
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
return currentMatch;
}
Aggregations