Search in sources :

Example 16 with NotFoundException

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

the class ConfigManager method deleteRegistration.

/**
     * Deletes a registration via the web interface.
     *
     * @param registrationID ID number associated with registration to delete.
     * @return Error message or null on success.
     */
public String deleteRegistration(Integer registrationID) {
    PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
    KrakenPlugin plugin = (KrakenPlugin) pluginManager.getPlugin("kraken");
    try {
        Registration reg = new Registration(registrationID);
        if (!plugin.getTransportInstance(reg.getTransportType().toString()).isEnabled()) {
            return LocaleUtils.getLocalizedString("gateway.web.registrations.notenabled", "kraken");
        }
        final BaseTransport transport = plugin.getTransportInstance(reg.getTransportType().toString()).getTransport();
        new RegistrationHandler(transport).deleteRegistration(reg.getJID());
        return null;
    } catch (NotFoundException e) {
        // Ok, nevermind.
        Log.error("Not found while deleting id " + registrationID, e);
        return LocaleUtils.getLocalizedString("gateway.web.registrations.xmppnotfound", "kraken");
    } catch (UserNotFoundException e) {
        // Ok, nevermind.
        Log.error("Not found while deleting id " + registrationID, e);
        return LocaleUtils.getLocalizedString("gateway.web.registrations.regnotfound", "kraken");
    }
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) Registration(net.sf.kraken.registration.Registration) RegistrationHandler(net.sf.kraken.registration.RegistrationHandler) NotFoundException(org.jivesoftware.util.NotFoundException) GroupNotFoundException(org.jivesoftware.openfire.group.GroupNotFoundException) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) BaseTransport(net.sf.kraken.BaseTransport) KrakenPlugin(net.sf.kraken.KrakenPlugin)

Example 17 with NotFoundException

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

the class Chatbot method userDepartQueue.

private void userDepartQueue(Message message) {
    // Remove the user from the queue if he was waiting in the queue
    try {
        Request request = UserRequest.getRequest(workgroup, message.getFrom());
        InterceptorManager interceptorManager = QueueInterceptorManager.getInstance();
        try {
            interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), message, true, false);
            request.cancel(Request.CancelType.DEPART);
            // Remove the session (the goodbye message is sent when leaving the queue)
            removeSession(message.getFrom());
            interceptorManager.invokeInterceptors(workgroup.getJID().toBareJID(), message, true, true);
        } catch (PacketRejectedException e) {
            workgroup.rejectPacket(message, e);
        }
    } catch (NotFoundException e) {
        // Send the goodbye message and close the session
        closeSession(message);
    }
}
Also used : InterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.InterceptorManager) QueueInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.QueueInterceptorManager) ChatbotInterceptorManager(org.jivesoftware.xmpp.workgroup.interceptor.ChatbotInterceptorManager) Request(org.jivesoftware.xmpp.workgroup.request.Request) UserRequest(org.jivesoftware.xmpp.workgroup.request.UserRequest) PacketRejectedException(org.jivesoftware.xmpp.workgroup.interceptor.PacketRejectedException) NotFoundException(org.jivesoftware.util.NotFoundException)

Example 18 with NotFoundException

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

the class Chatbot method handleCommand.

/**
     * Returns true if the message sent by the user requested to run a command. Depending on the
     * stage of the conversation different commands may be executed.
     *
     * @param message the message.
     * @param session the session.
     * @return true if the message sent by the user requested to run a command.
     */
private boolean handleCommand(Message message, ChatbotSession session) {
    String command = message.getBody().trim();
    if (getHelpCommand().equalsIgnoreCase(command)) {
        sendHelpMessage(message);
        return true;
    } else if (getByeCommand().equalsIgnoreCase(command)) {
        userDepartQueue(message);
        return true;
    }
    if (session.getCurrentStep() == 1) {
        if (getRepeatCommand().equalsIgnoreCase(command)) {
            // Send the join question
            sendJoinQuestion(message, session);
            return true;
        } else if (getPositionCommand().equalsIgnoreCase(command)) {
            // Tell the user that he is not waiting in the queue
            sendReply(message, getNotInQueueMessage());
            return true;
        }
    } else if (session.getCurrentStep() == 2) {
        if (getBackCommand().equalsIgnoreCase(command)) {
            sendPreviousQuestion(message, session);
            return true;
        } else if (getRepeatCommand().equalsIgnoreCase(command)) {
            // Resend the last question
            repeatQuestion(message, session);
            return true;
        } else if (getPositionCommand().equalsIgnoreCase(command)) {
            // Tell the user that he is not waiting in the queue
            sendReply(message, getNotInQueueMessage());
            return true;
        }
    } else if (session.getCurrentStep() == 3) {
        if (getPositionCommand().equalsIgnoreCase(command)) {
            try {
                UserRequest request = UserRequest.getRequest(workgroup, message.getFrom());
                request.updateQueueStatus(true);
            } catch (NotFoundException e) {
                // Tell the user that he is not waiting in the queue
                sendReply(message, getNotInQueueMessage());
            }
            return true;
        }
    } else if (session.getCurrentStep() == 6) {
        if (getRepeatCommand().equalsIgnoreCase(command)) {
            // Resend the last question
            sendEmailQuestion(message.getFrom(), session);
            return true;
        }
    } else if (session.getCurrentStep() == 7) {
        if (getRepeatCommand().equalsIgnoreCase(command)) {
            // Resend the last question
            sendGetEmailQuestion(message, session);
            return true;
        }
    }
    return false;
}
Also used : NotFoundException(org.jivesoftware.util.NotFoundException) UserRequest(org.jivesoftware.xmpp.workgroup.request.UserRequest)

Example 19 with NotFoundException

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

the class BookmarkManager method getBookmarks.

/**
     * Returns all bookmarks.
     *
     * @return the collection of bookmarks.
     */
public static Collection<Bookmark> getBookmarks() {
    // TODO: add caching.
    List<Bookmark> bookmarks = new ArrayList<Bookmark>();
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        con = DbConnectionManager.getConnection();
        pstmt = con.prepareStatement(SELECT_BOOKMARKS);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            long bookmarkID = rs.getLong(1);
            try {
                Bookmark bookmark = new Bookmark(bookmarkID);
                bookmarks.add(bookmark);
            } catch (NotFoundException nfe) {
                Log.error(nfe.getMessage(), nfe);
            }
        }
    } catch (SQLException e) {
        Log.error(e.getMessage(), e);
    } finally {
        DbConnectionManager.closeConnection(rs, pstmt, con);
    }
    return bookmarks;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NotFoundException(org.jivesoftware.util.NotFoundException) PreparedStatement(java.sql.PreparedStatement)

Example 20 with NotFoundException

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

the class MultiUserChatManager method removeMultiUserChatService.

/**
     * Deletes a configured MultiUserChatService by ID, and shuts it down.
     *
     * @param serviceID The ID opf the service to be deleted.
     * @throws NotFoundException if the service was not found.
     */
public void removeMultiUserChatService(Long serviceID) throws NotFoundException {
    MultiUserChatServiceImpl muc = (MultiUserChatServiceImpl) getMultiUserChatService(serviceID);
    if (muc == null) {
        Log.error("MultiUserChatManager: Unable to find service to remove for service ID " + serviceID);
        throw new NotFoundException();
    }
    unregisterMultiUserChatService(muc.getServiceName());
    deleteService(serviceID);
}
Also used : MultiUserChatServiceImpl(org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl) NotFoundException(org.jivesoftware.util.NotFoundException)

Aggregations

NotFoundException (org.jivesoftware.util.NotFoundException)67 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)29 Element (org.dom4j.Element)17 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 MultiUserChatServiceImpl (org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl)4 UserRequest (org.jivesoftware.xmpp.workgroup.request.UserRequest)4 KrakenPlugin (net.sf.kraken.KrakenPlugin)3 Registration (net.sf.kraken.registration.Registration)3 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)3