Search in sources :

Example 1 with ConversationManager

use of org.jivesoftware.openfire.archive.ConversationManager in project Openfire by igniterealtime.

the class GetConversationCountTask method run.

public void run() {
    MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin(MonitoringConstants.NAME);
    ConversationManager conversationManager = (ConversationManager) plugin.getModule(ConversationManager.class);
    conversationCount = conversationManager.getConversationCount();
}
Also used : MonitoringPlugin(org.jivesoftware.openfire.plugin.MonitoringPlugin) ConversationManager(org.jivesoftware.openfire.archive.ConversationManager)

Example 2 with ConversationManager

use of org.jivesoftware.openfire.archive.ConversationManager in project Openfire by igniterealtime.

the class GetConversationTask method run.

public void run() {
    MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin(MonitoringConstants.NAME);
    ConversationManager conversationManager = (ConversationManager) plugin.getModule(ConversationManager.class);
    try {
        conversation = conversationManager.getConversation(conversationID);
    } catch (NotFoundException e) {
    // Ignore. The requester of this task will throw this exception in his JVM
    }
}
Also used : MonitoringPlugin(org.jivesoftware.openfire.plugin.MonitoringPlugin) ConversationManager(org.jivesoftware.openfire.archive.ConversationManager) NotFoundException(org.jivesoftware.util.NotFoundException)

Example 3 with ConversationManager

use of org.jivesoftware.openfire.archive.ConversationManager in project Openfire by igniterealtime.

the class GetConversationsTask method run.

public void run() {
    MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin(MonitoringConstants.NAME);
    ConversationManager conversationManager = (ConversationManager) plugin.getModule(ConversationManager.class);
    conversations = conversationManager.getConversations();
}
Also used : MonitoringPlugin(org.jivesoftware.openfire.plugin.MonitoringPlugin) ConversationManager(org.jivesoftware.openfire.archive.ConversationManager)

Example 4 with ConversationManager

use of org.jivesoftware.openfire.archive.ConversationManager in project Openfire by igniterealtime.

the class SendConversationEventsTask method run.

public void run() {
    MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin(MonitoringConstants.NAME);
    ConversationManager conversationManager = (ConversationManager) plugin.getModule(ConversationManager.class);
    for (ConversationEvent event : events) {
        try {
            event.run(conversationManager);
        } catch (Exception e) {
            Log.error("Error while processing chat archiving event", e);
        }
    }
}
Also used : MonitoringPlugin(org.jivesoftware.openfire.plugin.MonitoringPlugin) ConversationManager(org.jivesoftware.openfire.archive.ConversationManager) ConversationEvent(org.jivesoftware.openfire.archive.ConversationEvent) IOException(java.io.IOException)

Example 5 with ConversationManager

use of org.jivesoftware.openfire.archive.ConversationManager in project Openfire by igniterealtime.

the class GetGroupConversationTranscript method execute.

@Override
public void execute(SessionData data, Element command) {
    Element note = command.addElement("note");
    // Get handle on the Monitoring plugin
    MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin(MonitoringConstants.NAME);
    ConversationManager conversationManager = (ConversationManager) plugin.getModule(ConversationManager.class);
    if (!conversationManager.isArchivingEnabled()) {
        note.addAttribute("type", "error");
        note.setText("Message archiving is not enabled.");
        DataForm form = new DataForm(DataForm.Type.result);
        FormField field = form.addField();
        field.setType(FormField.Type.hidden);
        field.setVariable("FORM_TYPE");
        field.addValue("http://jabber.org/protocol/admin");
        field = form.addField();
        field.setLabel("Conversation Found?");
        field.setVariable("found");
        field.addValue(false);
        // Add form to reply
        command.add(form.getElement());
        return;
    }
    try {
        JID participant = new JID(data.getData().get("participant").get(0));
        JID room = new JID(data.getData().get("room").get(0));
        Date time = DataForm.parseDate(data.getData().get("time").get(0));
        boolean includePDF = DataForm.parseBoolean(data.getData().get("includePDF").get(0));
        // Get archive searcher module
        ArchiveSearcher archiveSearcher = (ArchiveSearcher) plugin.getModule(ArchiveSearcher.class);
        ArchiveSearch search = new ArchiveSearch();
        search.setParticipants(participant);
        search.setIncludeTimestamp(time);
        search.setRoom(room);
        Collection<Conversation> conversations = archiveSearcher.search(search);
        DataForm form = new DataForm(DataForm.Type.result);
        FormField field = form.addField();
        field.setType(FormField.Type.hidden);
        field.setVariable("FORM_TYPE");
        field.addValue("http://jabber.org/protocol/admin");
        field = form.addField();
        field.setLabel("Conversation Found?");
        field.setVariable("found");
        field.addValue(!conversations.isEmpty());
        if (includePDF) {
            ByteArrayOutputStream stream = null;
            if (!conversations.isEmpty()) {
                stream = new ConversationUtils().getConversationPDF(conversations.iterator().next());
            }
            if (stream != null) {
                field = form.addField();
                field.setLabel("PDF");
                field.setVariable("pdf");
                field.addValue(StringUtils.encodeBase64(stream.toByteArray()));
            }
        }
        // Add form to reply
        command.add(form.getElement());
    } catch (Exception e) {
        Log.error("Error occurred while running the command", e);
        note.addAttribute("type", "error");
        note.setText("Error while processing the command.");
    }
}
Also used : JID(org.xmpp.packet.JID) Element(org.dom4j.Element) ConversationManager(org.jivesoftware.openfire.archive.ConversationManager) Conversation(org.jivesoftware.openfire.archive.Conversation) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Date(java.util.Date) ConversationUtils(org.jivesoftware.openfire.archive.ConversationUtils) MonitoringPlugin(org.jivesoftware.openfire.plugin.MonitoringPlugin) ArchiveSearch(org.jivesoftware.openfire.archive.ArchiveSearch) DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField) ArchiveSearcher(org.jivesoftware.openfire.archive.ArchiveSearcher)

Aggregations

ConversationManager (org.jivesoftware.openfire.archive.ConversationManager)6 MonitoringPlugin (org.jivesoftware.openfire.plugin.MonitoringPlugin)6 Conversation (org.jivesoftware.openfire.archive.Conversation)2 JID (org.xmpp.packet.JID)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Element (org.dom4j.Element)1 ArchiveSearch (org.jivesoftware.openfire.archive.ArchiveSearch)1 ArchiveSearcher (org.jivesoftware.openfire.archive.ArchiveSearcher)1 ConversationEvent (org.jivesoftware.openfire.archive.ConversationEvent)1 ConversationUtils (org.jivesoftware.openfire.archive.ConversationUtils)1 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)1 NotFoundException (org.jivesoftware.util.NotFoundException)1 DataForm (org.xmpp.forms.DataForm)1 FormField (org.xmpp.forms.FormField)1