Merge pull request #736 from ritzalam/add-get-sessions-api
- add an api to let us query the user sessions in bbb-web. We use th…
This commit is contained in:
commit
ba85882aec
@ -52,7 +52,12 @@ class UrlMappings {
|
||||
"/api/getMeetings"(controller:"api") {
|
||||
action = [GET:'getMeetingsHandler', POST:'getMeetingsHandler']
|
||||
}
|
||||
|
||||
|
||||
|
||||
"/api/getSessions"(controller:"api") {
|
||||
action = [GET:'getSessionsHandler', POST:'getSessionsHandler']
|
||||
}
|
||||
|
||||
"/api/getRecordings"(controller:"api") {
|
||||
action = [GET:'getRecordingsHandler', POST:'getRecordingsHandler']
|
||||
}
|
||||
|
@ -822,6 +822,87 @@ class ApiController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************
|
||||
* GETSESSIONS API
|
||||
************************************/
|
||||
def getSessionsHandler = {
|
||||
String API_CALL = "getSessions"
|
||||
log.debug CONTROLLER_NAME + "#${API_CALL}"
|
||||
|
||||
println("##### GETSESSIONS API CALL ####")
|
||||
|
||||
// BEGIN - backward compatibility
|
||||
if (StringUtils.isEmpty(params.checksum)) {
|
||||
invalid("checksumError", "You did not pass the checksum security check")
|
||||
return
|
||||
}
|
||||
|
||||
if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
|
||||
invalid("checksumError", "You did not pass the checksum security check")
|
||||
return
|
||||
}
|
||||
// END - backward compatibility
|
||||
|
||||
ApiErrors errors = new ApiErrors()
|
||||
|
||||
// Do we have a checksum? If none, complain.
|
||||
if (StringUtils.isEmpty(params.checksum)) {
|
||||
errors.missingParamError("checksum");
|
||||
}
|
||||
|
||||
if (errors.hasErrors()) {
|
||||
respondWithErrors(errors)
|
||||
return
|
||||
}
|
||||
|
||||
// Do we agree on the checksum? If not, complain.
|
||||
if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
|
||||
errors.checksumError()
|
||||
respondWithErrors(errors)
|
||||
return
|
||||
}
|
||||
|
||||
Collection<Meeting> sssns = meetingService.getSessions();
|
||||
|
||||
if (sssns == null || sssns.isEmpty()) {
|
||||
response.addHeader("Cache-Control", "no-cache")
|
||||
withFormat {
|
||||
xml {
|
||||
render(contentType:"text/xml") {
|
||||
response() {
|
||||
returncode(RESP_CODE_SUCCESS)
|
||||
sessions()
|
||||
messageKey("noSessions")
|
||||
message("no sessions were found on this server")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println("#### Has sessions [" + sssns.size() + "] #####")
|
||||
response.addHeader("Cache-Control", "no-cache")
|
||||
withFormat {
|
||||
xml {
|
||||
render(contentType:"text/xml") {
|
||||
response() {
|
||||
returncode(RESP_CODE_SUCCESS)
|
||||
sessions {
|
||||
for (m in sssns) {
|
||||
meeting {
|
||||
meetingID(m.meetingID)
|
||||
meetingName(m.conferencename)
|
||||
userName(m.fullname)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def getDefaultConfigXML = {
|
||||
|
||||
|
@ -247,9 +247,13 @@ public class MeetingService implements MessageListener {
|
||||
return meetings.isEmpty() ? Collections.<Meeting>emptySet() : Collections.unmodifiableCollection(meetings.values());
|
||||
}
|
||||
|
||||
public Collection<UserSession> getSessions() {
|
||||
log.debug("Num sessions = [" + sessions.size() + "]");
|
||||
return sessions.isEmpty() ? Collections.<UserSession>emptySet() : Collections.unmodifiableCollection(sessions.values());
|
||||
}
|
||||
|
||||
public void createMeeting(Meeting m) {
|
||||
handle(new CreateMeeting(m));
|
||||
// handleCreateMeeting(m);
|
||||
}
|
||||
|
||||
private void handleCreateMeeting(Meeting m) {
|
||||
|
Loading…
Reference in New Issue
Block a user