Search in sources :

Example 61 with NotFoundException

use of org.jivesoftware.util.NotFoundException in project Openfire by igniterealtime.

the class ConversationPDFServlet method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    long conversationID = ParamUtils.getLongParameter(request, "conversationID", -1);
    if (conversationID == -1) {
        return;
    }
    MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin(MonitoringConstants.NAME);
    ConversationManager conversationManager = (ConversationManager) plugin.getModule(ConversationManager.class);
    Conversation conversation;
    if (conversationID > -1) {
        try {
            conversation = new Conversation(conversationManager, conversationID);
            ByteArrayOutputStream stream = new ConversationUtils().getConversationPDF(conversation);
            // setting some response headers
            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            // setting the content type
            response.setContentType("application/pdf");
            // the content length is needed for MSIE!!!
            response.setContentLength(stream.size());
            // write ByteArrayOutputStream to the ServletOutputStream
            ServletOutputStream out = response.getOutputStream();
            stream.writeTo(out);
            out.flush();
        } catch (NotFoundException nfe) {
            Log.error(nfe.getMessage(), nfe);
        }
    }
}
Also used : MonitoringPlugin(org.jivesoftware.openfire.plugin.MonitoringPlugin) ServletOutputStream(javax.servlet.ServletOutputStream) NotFoundException(org.jivesoftware.util.NotFoundException) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 62 with NotFoundException

use of org.jivesoftware.util.NotFoundException in project Openfire by igniterealtime.

the class ConversationUtils method getConversationInfo.

public ConversationInfo getConversationInfo(long conversationID, boolean formatParticipants) {
    // Create ConversationInfo bean
    ConversationInfo info = new ConversationInfo();
    // Get handle on the Monitoring plugin
    MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin(MonitoringConstants.NAME);
    ConversationManager conversationmanager = (ConversationManager) plugin.getModule(ConversationManager.class);
    try {
        Conversation conversation = conversationmanager.getConversation(conversationID);
        info = toConversationInfo(conversation, formatParticipants);
    } catch (NotFoundException e) {
        Log.error(e.getMessage(), e);
    }
    return info;
}
Also used : MonitoringPlugin(org.jivesoftware.openfire.plugin.MonitoringPlugin) NotFoundException(org.jivesoftware.util.NotFoundException)

Example 63 with NotFoundException

use of org.jivesoftware.util.NotFoundException in project Openfire by igniterealtime.

the class Registration method loadFromDb.

/**
     * Load registration from database.
     *
     * @throws NotFoundException if registration was not found in database.
     */
private void loadFromDb() throws NotFoundException {
    if (disconnectedMode) {
        return;
    }
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        con = DbConnectionManager.getConnection();
        pstmt = con.prepareStatement(LOAD_REGISTRATION);
        pstmt.setLong(1, registrationID);
        rs = pstmt.executeQuery();
        if (!rs.next()) {
            throw new NotFoundException("Registration not found: " + registrationID);
        }
        this.jid = new JID(rs.getString(1));
        this.transportType = TransportType.valueOf(rs.getString(2));
        this.username = rs.getString(3);
        // The password is stored in encrypted form, so decrypt it.
        this.password = AuthFactory.decryptPassword(rs.getString(4));
        this.nickname = rs.getString(5);
        this.registrationDate = new Date(rs.getLong(6));
        long loginDate = rs.getLong(7);
        if (rs.wasNull()) {
            this.lastLogin = null;
        } else {
            this.lastLogin = new Date(loginDate);
        }
    } catch (SQLException sqle) {
        Log.error(sqle);
    } finally {
        DbConnectionManager.closeConnection(rs, pstmt, con);
    }
}
Also used : JID(org.xmpp.packet.JID) NotFoundException(org.jivesoftware.util.NotFoundException) Date(java.util.Date)

Example 64 with NotFoundException

use of org.jivesoftware.util.NotFoundException in project Openfire by igniterealtime.

the class RegistrationHandler method deleteRegistration.

/**
     * Removes a registration from this transport.
     *
     * @param jid JID of user to add registration to.
     * @throws UserNotFoundException if registration or roster not found.
     */
public void deleteRegistration(JID jid) throws UserNotFoundException {
    Collection<Registration> registrations = RegistrationManager.getInstance().getRegistrations(jid, parent.transportType);
    if (registrations.isEmpty()) {
        throw new UserNotFoundException("User was not registered.");
    }
    // Log out any active sessions.
    try {
        TransportSession session = parent.sessionManager.getSession(jid);
        if (session.isLoggedIn()) {
            parent.registrationLoggedOut(session);
        }
        parent.sessionManager.removeSession(jid);
    } catch (NotFoundException e) {
    // Ok then.
    }
    // For now, we're going to have to just nuke all of these. Sorry.
    for (final Registration reg : registrations) {
        RegistrationManager.getInstance().deleteRegistration(reg);
    }
    // Clean up the user's contact list.
    try {
        parent.cleanUpRoster(jid, false, true);
    } catch (UserNotFoundException e) {
        throw new UserNotFoundException("Unable to find roster.");
    }
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) NotFoundException(org.jivesoftware.util.NotFoundException) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) TransportSession(net.sf.kraken.session.TransportSession)

Aggregations

NotFoundException (org.jivesoftware.util.NotFoundException)64 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)28 Element (org.dom4j.Element)16 JID (org.xmpp.packet.JID)15 ArrayList (java.util.ArrayList)10 Connection (java.sql.Connection)8 PreparedStatement (java.sql.PreparedStatement)8 SQLException (java.sql.SQLException)8 ResultSet (java.sql.ResultSet)7 TransportSession (net.sf.kraken.session.TransportSession)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 Avatar (net.sf.kraken.avatars.Avatar)5 TransportBuddy (net.sf.kraken.roster.TransportBuddy)5 Packet (org.xmpp.packet.Packet)5 Date (java.util.Date)4 UserRequest (org.jivesoftware.xmpp.workgroup.request.UserRequest)4 KrakenPlugin (net.sf.kraken.KrakenPlugin)3 Registration (net.sf.kraken.registration.Registration)3 PluginManager (org.jivesoftware.openfire.container.PluginManager)3 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)3