- handle upload of text tracks

This commit is contained in:
Richard Alam 2018-06-29 12:27:23 -07:00
parent b9c9120a4e
commit 6401bf905d
8 changed files with 77 additions and 93 deletions

View File

@ -384,11 +384,29 @@ public class MeetingService implements MessageListener {
return recordingService.getRecordingTextTracks(recordId);
}
public String putRecordingTextTrack(String recordId, String kind, String lang, File file, String label, String origFilename) {
UploadedTrack track = new UploadedTrack(recordId, kind, lang, label, origFilename, file);
public String putRecordingTextTrack(String recordId,
String kind,
String lang,
File file,
String label,
String origFilename,
String trackId) {
UploadedTrack track = new UploadedTrack(recordId,
kind,
lang,
label,
origFilename,
file,
trackId,
getCaptionTrackInboxDir());
return recordingService.putRecordingTextTrack(track);
}
public String getCaptionTrackInboxDir() {
return recordingService.getCaptionTrackInboxDir();
}
public String getRecordings2x(ArrayList<String> idList, ArrayList<String> states, Map<String, String> metadataFilters) {
return recordingService.getRecordings2x(idList, states, metadataFilters);
}

View File

@ -149,11 +149,7 @@ public class RecordingService {
}
public String getRecordingTextTracks(String recordId) {
ArrayList<File> recs = getAllRecordingsFor(recordId);
for (File id : recs) {
System.out.println("RECORDING FILE = " + id.getAbsolutePath());
}
return recordingServiceHelper.getRecordingTextTracks(recordId, recs);
return recordingServiceHelper.getRecordingTextTracks(recordId, captionsDir);
}
public String putRecordingTextTrack(UploadedTrack track) {
@ -638,4 +634,8 @@ public class RecordingService {
return baseDir;
}
public String getCaptionTrackInboxDir() {
return captionsDir + File.separatorChar + "inbox";
}
}

View File

@ -17,8 +17,8 @@ public class RecordingMetadataReaderHelper {
private RecordingServiceGW recordingServiceGW;
public String getRecordingTextTracks(String recordId, ArrayList<File> recs) {
return recordingServiceGW.getRecordingTextTracks(recordId, recs);
public String getRecordingTextTracks(String recordId, String captionsDir) {
return recordingServiceGW.getRecordingTextTracks(recordId, captionsDir);
}
public String putRecordingTextTrack(UploadedTrack track) {

View File

@ -11,6 +11,6 @@ public interface RecordingServiceGW {
String getRecordings2x(ArrayList<RecordingMetadata> recs);
Option<RecordingMetadata> getRecordingMetadata(File xml);
void saveRecordingMetadata(File xml, RecordingMetadata metadata);
String getRecordingTextTracks(String recordId, ArrayList<File> file);
String getRecordingTextTracks(String recordId, String captionsDir);
String putRecordingTextTrack(UploadedTrack track);
}

View File

@ -4,13 +4,24 @@ import java.io.File
import java.util
case class CaptionsDirPaths(captionsDir: String, inboxDir: String, statusDir: String)
case class UploadedTrack(recordId: String, kind: String, lang: String, label: String, origFilename: String, track: File)
case class UploadedTrackInfo(recordId: String, kind: String, lang: String, label: String, origFilename: String)
case class UploadedTrack(recordId: String,
kind: String,
lang: String,
label: String,
origFilename: String,
track: File,
trackId: String,
inboxDir: String)
case class UploadedTrackInfo(recordId: String,
kind: String,
lang: String,
label: String,
origFilename: String)
case class Track(kind: String, lang: String, label: String, source: String, href: String)
case class Tracks(tracks: util.ArrayList[Track])
case class GetRecTextTracksResult(returncode: String, tracks: Tracks)
case class GetRecTextTracksResp(response: GetRecTextTracksResult)
case class GetRecTextTracksResultFailed(returncode: String, key: String, msg: String)
case class GetRecTextTracksResultFailed(returncode: String, messageKey: String, message: String)
case class GetRecTextTracksRespFailed(response: GetRecTextTracksResultFailed)
case class PutRecTextTrackResult(returncode: String, recordId: String, key: String, msg: String)
case class PutRecTextTrackResult(returncode: String, recordId: String, messageKey: String, message: String)
case class PutRecTextTrackResp(response: PutRecTextTrackResult)

View File

@ -184,25 +184,25 @@ class RecMetaXmlHelper extends RecordingServiceGW with LogHelper {
}
}
def getRecordingTextTracks(recordId: String, recs: util.ArrayList[File]):String = {
def getRecordingTextTracks(recordId: String, captionsDir: String):String = {
val gson = new Gson()
var returnResponse:String = ""
val captionsFilePath = CAPTIONS_DIR + File.separatorChar + recordId + File.separatorChar + CAPTIONS_FILE
val captionsFilePath = captionsDir + File.separatorChar + recordId + File.separatorChar + CAPTIONS_FILE
readCaptionJsonFile(captionsFilePath, StandardCharsets.UTF_8) match {
case Some(captions) => println("Captions: \n" + captions)
case Some(captions) =>
val ctracks = gson.fromJson(captions, classOf[util.ArrayList[Track]])
val xtracks = Tracks(ctracks)
val result1 = GetRecTextTracksResult(SUCCESS, xtracks)
val response1 = GetRecTextTracksResp(result1)
val respText1 = gson.toJson(response1)
println(respText1)
returnResponse = respText1
case None => println("Captions file not found for " + recordId)
case None =>
val resFailed = GetRecTextTracksResultFailed(FAILED, "noCaptionsFound", "No captions found for " + recordId)
val respFailed = GetRecTextTracksRespFailed(resFailed)
val failedTxt = gson.toJson(respFailed)
println(failedTxt)
returnResponse = failedTxt
}
@ -229,9 +229,6 @@ class RecMetaXmlHelper extends RecordingServiceGW with LogHelper {
}
}
val CAPTIONS_DIR = "/var/bigbluebutton/captions"
val INBOX_DIR = CAPTIONS_DIR + File.pathSeparator + "inbox"
val STATUS_DIR = "/var/bigbluebutton/recording/status/captioned"
def saveTrackInfoFile(trackInfoJson:String, trackInfoFilePath: String):Boolean = {
var result = false
@ -256,12 +253,7 @@ class RecMetaXmlHelper extends RecordingServiceGW with LogHelper {
}
def putRecordingTextTrack(track: UploadedTrack):String = {
val trackId = track.recordId + "-" + System.currentTimeMillis()
val tempTrackFilePath = INBOX_DIR + File.pathSeparator + trackId + "-track.txt"
val trackInfoFilePath = INBOX_DIR + File.pathSeparator + trackId + "-track.json"
val procTriggerPath = STATUS_DIR + File.pathSeparator + trackId + ".track"
FileUtils.copyFile(track.track, new File(tempTrackFilePath))
val trackInfoFilePath = track.inboxDir + File.separatorChar + track.trackId + "-track.json"
val trackInfo = new UploadedTrackInfo(recordId = track.recordId,
kind = track.kind,
@ -275,15 +267,15 @@ class RecMetaXmlHelper extends RecordingServiceGW with LogHelper {
if (success) {
val result = PutRecTextTrackResult(SUCCESS,
track.recordId,
key = "upload_text_track_success",
msg = "Text track uploaded successfully")
messageKey = "upload_text_track_success",
message = "Text track uploaded successfully")
val resp = PutRecTextTrackResp(result)
gson.toJson(resp)
} else {
val result = PutRecTextTrackResult(FAILED,
track.recordId,
key = "upload_text_track_failed",
msg = "Text track upload failed.")
messageKey = "upload_text_track_failed",
message = "Text track upload failed.")
val resp = PutRecTextTrackResp(result)
gson.toJson(resp)
}

View File

@ -174,7 +174,7 @@ muteOnStart=false
#----------------------------------------------------
# This URL is where the BBB client is accessible. When a user sucessfully
# enters a name and password, she is redirected here to load the client.
bigbluebutton.web.serverURL=http://10.130.218.89
bigbluebutton.web.serverURL=http://10.130.218.38
#----------------------------------------------------
@ -211,7 +211,7 @@ defaultConfigURL=${bigbluebutton.web.serverURL}/client/conf/config.xml
apiVersion=2.0
# Salt which is used by 3rd-party apps to authenticate api calls
securitySalt=3895c0fc987abdd47edf0352fea2a458
securitySalt=330a8b08c3b4c61533e1d0c5ce1ac88f
# Directory where we drop the <meeting-id-recorded>.done file
recordStatusDir=/var/bigbluebutton/recording/status/recorded
@ -223,6 +223,7 @@ redisPort=6379
# the get recording* api calls
publishedDir=/var/bigbluebutton/published
unpublishedDir=/var/bigbluebutton/unpublished
captionsDir=/var/bigbluebutton/captions
# The directory where the pre-built configs are stored
configDir=/var/bigbluebutton/configs

View File

@ -13,7 +13,7 @@ class RecordingController {
def getRecordingTextTracks = {
String API_CALL = "publishRecordings"
String API_CALL = "getRecordingTextTracks"
log.debug CONTROLLER_NAME + "#${API_CALL}"
// BEGIN - backward compatibility
@ -22,12 +22,12 @@ class RecordingController {
return
}
if (StringUtils.isEmpty(params.recordId)) {
if (StringUtils.isEmpty(params.recordID)) {
respondWithError("paramError", "Missing param recordID.");
return
}
String recordId = StringUtils.strip(params.recordId)
String recordId = StringUtils.strip(params.recordID)
// Do we agree on the checksum? If not, complain.
//if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
@ -35,35 +35,8 @@ class RecordingController {
// return
//}
/*
ApiErrors errors = new ApiErrors()
// Do we have a checksum? If none, complain.
if (StringUtils.isEmpty(params.checksum)) {
errors.missingParamError("checksum");
}
// Do we have a recording id? If none, complain.
String recordId = params.recordID
if (StringUtils.isEmpty(recordId)) {
errors.missingParamError("recordID");
}
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
//}
*/
String result = meetingService.getRecordingTextTracks(recordId)
println("************* RESULT = " + result)
response.addHeader("Cache-Control", "no-cache")
withFormat {
json {
@ -79,26 +52,8 @@ class RecordingController {
render(contentType: "application/json") {
response () {
returncode = "FAILED"
key = errorKey
msg = errorMessage
}
}
}
}
}
private void respondWithErrors(reqErrors) {
response.addHeader("Cache-Control", "no-cache")
withFormat {
json {
render(contentType: "application/json") {
response () {
returncode = "FAILED"
errors = array {
for (b in reqErrors.getErrors()) {
error key: b[0], msg: b[1]
}
}
messageKey = errorKey
messsage = errorMessage
}
}
}
@ -114,12 +69,12 @@ class RecordingController {
return
}
if (StringUtils.isEmpty(params.recordId)) {
if (StringUtils.isEmpty(params.recordID)) {
respondWithError("paramError", "Missing param recordID.");
return
}
String recordId = StringUtils.strip(params.recordId)
String recordId = StringUtils.strip(params.recordID)
if (StringUtils.isEmpty(params.kind)) {
respondWithError("paramError", "Missing param kind.");
@ -140,12 +95,18 @@ class RecordingController {
captionsLabel = StringUtils.strip(params.label)
}
def captionsFile = request.getFile('file')
if (captionsFile && !captionsFile.empty) {
def origFilename = captionsFile.getOriginalFilename()
def uploadedCaptionsFile = request.getFile('file')
if (uploadedCaptionsFile && !uploadedCaptionsFile.empty) {
def origFilename = uploadedCaptionsFile.getOriginalFilename()
def trackId = recordId + "-" + System.currentTimeMillis()
def captionsFilePath = meetingService.getCaptionTrackInboxDir() + File.separatorChar + trackId + "-track.txt"
def captionsFile = new File(captionsFilePath)
uploadedCaptionsFile.transferTo(captionsFile)
String result = meetingService.putRecordingTextTrack(recordId, captionsKind,
captionsLang, captionsFile, captionsLabel, origFilename)
println("************* RESULT = " + result)
captionsLang, captionsFile, captionsLabel, origFilename, trackId)
response.addHeader("Cache-Control", "no-cache")
withFormat {
json {
@ -160,7 +121,8 @@ class RecordingController {
render(contentType: "application/json") {
response = {
returncode = "FAILED"
message = "Failed to put recording text tracks."
messageKey = "empty_uploaded_text_track"
message = "Empty uploaded text track."
}
}
}