Search in sources :

Example 6 with DbProperties

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);
}
Also used : Agent(org.jivesoftware.xmpp.workgroup.Agent) Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ) AgentNotFoundException(org.jivesoftware.xmpp.workgroup.AgentNotFoundException) PacketError(org.xmpp.packet.PacketError) DbProperties(org.jivesoftware.xmpp.workgroup.DbProperties)

Example 7 with DbProperties

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);
    }
}
Also used : UnauthorizedException(org.jivesoftware.xmpp.workgroup.UnauthorizedException) DbProperties(org.jivesoftware.xmpp.workgroup.DbProperties)

Example 8 with DbProperties

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;
}
Also used : StringTokenizer(java.util.StringTokenizer) DbProperties(org.jivesoftware.xmpp.workgroup.DbProperties)

Example 9 with DbProperties

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;
}
Also used : DbProperties(org.jivesoftware.xmpp.workgroup.DbProperties)

Aggregations

DbProperties (org.jivesoftware.xmpp.workgroup.DbProperties)9 UnauthorizedException (org.jivesoftware.xmpp.workgroup.UnauthorizedException)6 XStream (com.thoughtworks.xstream.XStream)5 Element (org.dom4j.Element)2 Agent (org.jivesoftware.xmpp.workgroup.Agent)2 AgentNotFoundException (org.jivesoftware.xmpp.workgroup.AgentNotFoundException)2 DataForm (org.xmpp.forms.DataForm)2 IQ (org.xmpp.packet.IQ)2 PacketError (org.xmpp.packet.PacketError)2 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1 Workgroup (org.jivesoftware.xmpp.workgroup.Workgroup)1 WorkgroupManager (org.jivesoftware.xmpp.workgroup.WorkgroupManager)1 FormField (org.xmpp.forms.FormField)1