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