use of org.jivesoftware.xmpp.workgroup.dispatcher.BasicDispatcherInfo in project Openfire by igniterealtime.
the class Workgroup method createRequestQueue.
// ###############################################################################
// Request queue management
// ###############################################################################
public RequestQueue createRequestQueue(String name) throws UnauthorizedException {
RequestQueue queue = null;
long queueID = SequenceManager.nextID(FastpathConstants.WORKGROUP_QUEUE);
// This should probably be moved into a queue manager class
// First create the queue, then the dispatcher,
// then the queue implementation object
boolean queueCreated = createQueue(queueID, name);
if (queueCreated) {
BasicDispatcherInfo info = new BasicDispatcherInfo(this, queueID, "Round Robin Dispatcher", "None", -1, -1);
try {
dispatcherInfoProvider.insertDispatcherInfo(queueID, info);
queue = new RequestQueue(this, queueID);
} catch (UserAlreadyExistsException e) {
Log.error(e.getMessage(), e);
}
} else {
throw new UnauthorizedException();
}
queues.put(queueID, queue);
return queue;
}
use of org.jivesoftware.xmpp.workgroup.dispatcher.BasicDispatcherInfo in project Openfire by igniterealtime.
the class DbDispatcherInfoProvider method getDispatcherInfo.
/**
* Returns the Dispatcher to be used for the given queue.
*
* @param workgroup the owning workgroup.
* @param queueID the id of the queue this dispatcher belongs to.
* @return the Dispatcher.
* @throws NotFoundException thrown if no dispatcher was found.
*/
public DispatcherInfo getDispatcherInfo(Workgroup workgroup, long queueID) throws NotFoundException {
BasicDispatcherInfo userInfo = null;
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(LOAD_DISPATCHER_BY_ID);
pstmt.setLong(1, queueID);
rs = pstmt.executeQuery();
if (!rs.next()) {
throw new NotFoundException();
}
userInfo = new BasicDispatcherInfo(workgroup, queueID, // name
rs.getString(1), // description
rs.getString(2), // offer timeout
rs.getInt(3), // request timeout
rs.getInt(4));
} catch (SQLException e) {
throw new NotFoundException("Failed to read dispatcher " + queueID + " from database. " + e.getMessage());
} catch (NumberFormatException nfe) {
Log.error("WARNING: There was an error parsing the dates " + "returned from the database. Ensure that they're being stored " + "correctly.");
throw new NotFoundException("Dispatcher with id " + queueID + " could not be loaded from the database.");
} finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
return userInfo;
}
Aggregations