Skip to content

Commit

Permalink
Merge pull request #26 from HassHz/sofia-protect
Browse files Browse the repository at this point in the history
protect recordings & fix thumbnails
  • Loading branch information
jfederico authored Dec 16, 2016
2 parents 171b6be + ad63114 commit c1a238c
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 27 deletions.
6 changes: 6 additions & 0 deletions api/src/java/org/sakaiproject/bbb/api/BBBMeetingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ public boolean deleteRecordings(String meetingID, String recordID)
public boolean publishRecordings(String meetingID, String recordID,
String publish) throws SecurityException, BBBException;

/**
* Protect and unprotect recordings using the *_______________* api command
*/
public boolean protectRecordings(String meetingID, String recordID,
String protect) throws SecurityException, BBBException;

/**
* Check if meeting is ready to be joined.
*/
Expand Down
6 changes: 6 additions & 0 deletions bundle/src/resources/ToolMessages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ bbb_action_show_tooltip = Click to make this recording visible for Students
bbb_action_delete_recording = Delete
bbb_action_delete_recording_tooltip = Click to delete this recordings from the server
bbb_action_delete_recording_question = Are you sure you want to delete permanently this recording {0}?\n\nClick OK to continue.
bbb_action_protect = Protect
bbb_action_unprotect = Unprotect
bbb_action_protect_tooltip = Click to make this recording protected
bbb_action_unprotect_tooltip = Click to unprotect this recording
bbb_recording_status_hidden = Unpublished
bbb_recording_status_shown = Published
bbb_recording_thumbnails_hidden = Only for published recordings
Expand Down Expand Up @@ -216,6 +220,8 @@ bbb_err_get_recording = Failed to get recordings from server
bbb_err_delete_recording = Failed to delete recording {0}
bbb_err_publish_recording = Failed to publish recording {0}
bbb_err_unpublish_recording = Failed to unpublish recording {0}
bbb_err_protect_recording = Failed to protect recording {0}
bbb_err_unprotect_recording = Failed to unprotect recording {0}
bbb_err_unreachable_server = Unreachable server
bbb_err_meeting_description_too_long = The meeting description must be {0} characters or shorter, this one has {1}

Expand Down
6 changes: 6 additions & 0 deletions bundle/src/resources/ToolMessages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ bbb_action_show_tooltip = Click to make this recording visible for Students
bbb_action_delete_recording = Delete
bbb_action_delete_recording_tooltip = Click to delete this recordings from the server
bbb_action_delete_recording_question = Are you sure you want to delete permanently this recording {0}?\n\nClick OK to continue.
bbb_action_protect = Protect
bbb_action_unprotect = Unprotect
bbb_action_protect_tooltip = Click to make this recording protected
bbb_action_unprotect_tooltip = Click to unprotect this recording
bbb_recording_status_hidden = Unpublished
bbb_recording_status_shown = Published
bbb_recording_thumbnails_hidden = Only for published recordings
Expand Down Expand Up @@ -214,6 +218,8 @@ bbb_err_get_recording = Failed to get recordings from server
bbb_err_delete_recording = Failed to delete recording {0}
bbb_err_publish_recording = Failed to publish recording {0}
bbb_err_unpublish_recording = Failed to unpublish recording {0}
bbb_err_protect_recording = Failed to protect recording {0}
bbb_err_unprotect_recording = Failed to unprotect recording {0}
bbb_err_unreachable_server = Unreachable server
bbb_err_meeting_description_too_long = The meeting description must be {0} characters or shorter, this one has {1}

Expand Down
6 changes: 6 additions & 0 deletions bundle/src/resources/ToolMessages_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ bbb_action_show_tooltip = Click to make this recording visible for Students
bbb_action_delete_recording = Delete
bbb_action_delete_recording_tooltip = Click to delete this recordings from the server
bbb_action_delete_recording_question = Are you sure you want to delete permanently this recording {0}?\n\nClick OK to continue.
bbb_action_protect = Protect
bbb_action_unprotect = Unprotect
bbb_action_protect_tooltip = Click to make this recording protected
bbb_action_unprotect_tooltip = Click to unprotect this recording
bbb_recording_status_hidden = Unpublished
bbb_recording_status_shown = Published
bbb_recording_thumbnails_hidden = Only for published recordings
Expand Down Expand Up @@ -214,6 +218,8 @@ bbb_err_get_recording = Failed to get recordings from server
bbb_err_delete_recording = Failed to delete recording {0}
bbb_err_publish_recording = Failed to publish recording {0}
bbb_err_unpublish_recording = Failed to unpublish recording {0}
bbb_err_protect_recording = Failed to protect recording {0}
bbb_err_unprotect_recording = Failed to unprotect recording {0}
bbb_err_unreachable_server = Unreachable server
bbb_err_meeting_description_too_long = The meeting description must be {0} characters or shorter, this one has {1}

Expand Down
15 changes: 15 additions & 0 deletions impl/src/java/org/sakaiproject/bbb/impl/BBBAPIWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,21 @@ public boolean publishRecordings(String meetingID, String recordingID, String pu
return publishRecordingsResponse;
}

public boolean protectRecordings(String meetingID, String recordingID, String protect)
throws BBBException {
if (logger.isDebugEnabled()) logger.debug("protectRecordings()");

boolean protectRecordingsResponse = false;

if ( api != null ) {
protectRecordingsResponse = api.protectRecordings(meetingID, recordingID, protect);
} else {
throw new BBBException(BBBException.MESSAGEKEY_INTERNALERROR, "Internal tool configuration error");
}

return protectRecordingsResponse;
}

public boolean deleteRecordings(String meetingID, String recordingID)
throws BBBException {
if (logger.isDebugEnabled()) logger.debug("publishRecordings()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,12 @@ public boolean publishRecordings(String meetingID, String recordID, String publi
return bbbAPI.publishRecordings(meetingID, recordID, publish);
}

public boolean protectRecordings(String meetingID, String recordID, String protect)
throws SecurityException, BBBException {
// protect or unprotect the recording
return bbbAPI.protectRecordings(meetingID, recordID, protect);
}

public void checkJoinMeetingPreConditions(BBBMeeting meeting)
throws BBBException {
// check if meeting is within dates
Expand Down
2 changes: 2 additions & 0 deletions impl/src/java/org/sakaiproject/bbb/impl/bbbapi/BBBAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public interface BBBAPI {

public boolean publishRecordings(String meetingID, String recordID, String publish) throws BBBException;

public boolean protectRecordings(String meetingID, String recordID, String protect) throws BBBException;

public String getJoinMeetingURL(String meetingID, User user, String password);

public void makeSureMeetingExists(BBBMeeting meeting) throws BBBException;
Expand Down
24 changes: 22 additions & 2 deletions impl/src/java/org/sakaiproject/bbb/impl/bbbapi/BaseBBBAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class BaseBBBAPI implements BBBAPI {
protected final static String APICALL_VERSION = "";
protected final static String APICALL_GETRECORDINGS = "getRecordings";
protected final static String APICALL_PUBLISHRECORDINGS = "publishRecordings";
protected final static String APICALL_PROTECTRECORDINGS = "updateRecordings";
protected final static String APICALL_DELETERECORDINGS = "deleteRecordings";

// API Response Codes
Expand Down Expand Up @@ -236,7 +237,6 @@ public BBBMeeting createMeeting(final BBBMeeting meeting)
StringBuilder presentationUrl = new StringBuilder(config.getServerUrl());
presentationUrl.append(meeting.getPresentation());
xml_presentation = "<modules> <module name=\"presentation\"> <document url=\""+presentationUrl+"\" /> </module> </modules>";
logger.debug(xml_presentation);
}
}

Expand Down Expand Up @@ -415,6 +415,26 @@ public boolean publishRecordings(String meetingID, String recordID, String publi
return true;
}

/** Protect/Unprotect a recording on BBB server */
public boolean protectRecordings(String meetingID, String recordID, String protect)
throws BBBException {
StringBuilder query = new StringBuilder();
query.append("recordID=");
query.append(recordID);
query.append("&protect=");
query.append(protect);
query.append(getCheckSumParameterForQuery(APICALL_PROTECTRECORDINGS, query.toString()));

try {
doAPICall(APICALL_PROTECTRECORDINGS, query.toString());

} catch (BBBException e) {
throw e;
}

return true;
}

/** Build the join meeting url based on user role */
public String getJoinMeetingURL(String meetingID, User user, String password) {
String userDisplayName, userId;
Expand Down Expand Up @@ -687,7 +707,7 @@ protected Map<String, Object> processNode(Node _node) {
}
if (nodeName == "preview"){
Node n = node.getChildNodes().item(0);
map.put(nodeName, processNode(n));
map.put(nodeName, new ArrayList<Object>(processNode(n).values()));
}else{
map.put(nodeName, list);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,34 @@ public String publishRecordings(Map<String, Object> params) {

}

@EntityCustomAction(viewKey = EntityView.VIEW_LIST)
public String protectRecordings(Map<String, Object> params) {
if (logger.isDebugEnabled())
logger.debug("protectRecordings");
String meetingID = (String) params.get("meetingID");
String recordID = (String) params.get("recordID");
String protect = (String) params.get("protect");
if (meetingID == null) {
throw new IllegalArgumentException("Missing required parameter [meetingID]");
}
if (recordID == null) {
throw new IllegalArgumentException("Missing required parameter [recordID]");
}
if (protect == null) {
throw new IllegalArgumentException("Missing required parameter [protect]");
}

try {
return Boolean.toString(meetingManager.protectRecordings(meetingID,
recordID, protect));
} catch (BBBException e) {
String ref = Entity.SEPARATOR + BBBMeetingManager.ENTITY_PREFIX
+ Entity.SEPARATOR + meetingID;
throw new EntityException(e.getPrettyMessage(), ref, 400);
}

}

@EntityCustomAction(viewKey = EntityView.VIEW_LIST)
public String deleteRecordings(Map<String, Object> params) {
if (logger.isDebugEnabled())
Expand Down Expand Up @@ -1038,7 +1066,7 @@ private String getHtmlForJoining(String joinUrl, String meetingId, boolean waitf
@EntityCustomAction(viewKey = EntityView.VIEW_LIST)
public ActionReturn getGroups(Map<String, Object> params) {
if(logger.isDebugEnabled())
logger.debug("Getting Groups");
logger.debug("getGroups");

String meetingID = (String) params.get("meetingID");
if (meetingID == null) {
Expand Down
40 changes: 19 additions & 21 deletions tool/src/webapp/WEB-INF/bootstrap.vm
Original file line number Diff line number Diff line change
Expand Up @@ -188,32 +188,30 @@
&nbsp;|&nbsp;
<a href="javascript:;" onclick="return meetings.utils.deleteRecordings('${D}{r.meetingID}','${D}{r.recordID}','${D}{stateFunction}','${D}{escape(r.name)} [${D}{new Date(parseInt(r.startTime)).toISO8601String()}]');" title="${D}{bbb_action_delete_recording_tooltip}">${D}{bbb_action_delete_recording}</a>
{/if}
{if r.canDelete}
{if r.protected}
&nbsp;|&nbsp;
{if r.protected == 'true'}
<a href="javascript:;" onclick="return meetings.utils.unprotectRecordings('${D}{r.meetingID}','${D}{r.recordID}','${D}{stateFunction}');" title="${D}{bbb_action_unprotect_tooltip}">${D}{bbb_action_unprotect}</a>
{else}
<a href="javascript:;" onclick="return meetings.utils.protectRecordings('${D}{r.meetingID}','${D}{r.recordID}','${D}{stateFunction}');" title="${D}{bbb_action_protect_tooltip}">${D}{bbb_action_protect}</a>
{/if}
{/if}
{/if}
</small>
</div>
</td>
<td class="bbb_thumbnails">
<div class="bbb_preview_images">
{for p in r.playback}
{if p.preview && r.published == 'true'}
{if p.preview.image1}
<a href="${D}{p.preview.image1.url}" class="preview" target="_blank">
<img src="${D}{p.preview.image1.url}" class="thumbnails" width="44px" height="34px" alt="${D}{p.preview.image1.title}">
</a>
{/if}
{if p.preview.image2}
<a href="${D}{p.preview.image2.url}" class="preview" target="_blank">
<img src="${D}{p.preview.image2.url}" class="thumbnails" width="44px" height="34px" alt="${D}{p.preview.image2.title}">
</a>
{/if}
{if p.preview.image3}
<a href="${D}{p.preview.image3.url}" class="preview" target="_blank">
<img src="${D}{p.preview.image3.url}" class="thumbnails" width="44px" height="34px" alt="${D}{p.preview.image3.title}">
</a>
{/if}
{else if p.preview}
${D}{bbb_recording_thumbnails_hidden}
{/if}
{/for}
{if r.images && r.published == 'true'}
{for image in r.images}
<a href="${D}{image.url}" class="preview" target="_blank">
<img src="${D}{image.url}" class="thumbnails" width="44px" height="34px" alt="${D}{image.title}">
</a>
{/for}
{elseif r.images}
${D}{bbb_recording_thumbnails_hidden}
{/if}
</div>
</td>
<td>
Expand Down
13 changes: 11 additions & 2 deletions tool/src/webapp/js/bbb.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,19 @@ meetings.switchState = function (state, arg) {
meetings.refreshRecordingList();

// watch for permissions changes, check meeting dates
for(var i=0,j=meetings.currentRecordings.length;i<j;i++) {
for(var i=0;i<meetings.currentRecordings.length;i++) {
meetings.utils.setRecordingPermissionParams(meetings.currentRecordings[i]);
}

var images = [];
for(var j=0;j<meetings.currentRecordings[i].playback.length; j++){
if (meetings.currentRecordings[i].playback[j].preview && meetings.currentRecordings[i].playback[j].preview.length > images.length){
images = meetings.currentRecordings[i].playback[j].preview;
}
}
if(images.length){
meetings.currentRecordings[i].images = images;
}
}
meetings.utils.render('bbb_recordings_template',{'recordings':meetings.currentRecordings,'stateFunction':'recordings'},'bbb_content');

var $rows = $('#bbb_recording_table tbody tr');
Expand Down
33 changes: 32 additions & 1 deletion tool/src/webapp/js/bbb_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@
meetings.switchState('recordings_meeting',{'meetingId':meetingID});
},
error : function (xmlHttpRequest,status,error) {
if( action == 'PUBLISH' )
if( action == 'true' )
var msg = bbb_err_publish_recording(recordID);
else
var msg = bbb_err_unpublish_recording(recordID);
Expand All @@ -610,6 +610,37 @@
});
};

meetings.utils.protectRecordings = function (meetingID, recordID, stateFunction) {
meetings.utils.updateRecordings(meetingID, recordID, "true", stateFunction);
};

meetings.utils.unprotectRecordings = function (meetingID, recordID, stateFunction) {
meetings.utils.updateRecordings(meetingID, recordID, "false", stateFunction);
}

// Protect the specified recording from the BigBlueButton server.
meetings.utils.updateRecordings = function (meetingID, recordID, action, stateFunction) {

jQuery.ajax({
url : "/direct/bbb-tool/protectRecordings?meetingID=" + meetingID + "&recordID=" + recordID + "&protect=" + action,
dataType:'text',
type: "GET",
success : function (result) {
if(stateFunction == 'recordings')
meetings.switchState('recordings');
else
meetings.switchState('recordings_meeting',{'meetingID':meetingID});
},
error : function (xmlHttpRequest,status,error) {
if( action == 'true' )
var msg = bbb_err_protect_recording(recordID);
else
var msg = bbb_err_unprotect_recording(recordID);
meetings.utils.handleError(msg, xmlHttpRequest.status, xmlHttpRequest.statusText);
}
});
};

//Get meetings from BBB server
meetings.utils.getMeetings = function () {
var meetingsInfo;
Expand Down

0 comments on commit c1a238c

Please sign in to comment.