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");
}
}
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);
}
}
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;
}
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;
}
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);
}
Aggregations