added setpublish, pending response xml

This commit is contained in:
Marco Calderon 2011-06-16 14:43:31 +00:00
parent 6d53c5025d
commit 42f4acd250
5 changed files with 80 additions and 8 deletions

View File

@ -617,12 +617,13 @@ class ApiController {
ArrayList<String> externalMeetingIds = new ArrayList<String>();
if (!StringUtils.isEmpty(params.meetingID)) {
externalMeetingIds=paramsProcessorUtil.processMeetingIds(params.meetingID);
externalMeetingIds=paramsProcessorUtil.decodeIds(params.meetingID);
}
// Everything is good so far. Translate the external meeting ids to an internal meeting ids.
ArrayList<String> internalMeetingIds = paramsProcessorUtil.convertToInternalMeetingIds(externalMeetingIds);
ArrayList<String> internalMeetingIds = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingIds);
ArrayList<Recording> recs = meetingService.getRecordings(internalMeetingIds);
if (recs.isEmpty()) {
response.addHeader("Cache-Control", "no-cache")
withFormat {
@ -672,7 +673,53 @@ class ApiController {
}
}
/******************************************************
* SET_PUBLISH_RECORDINGS API
******************************************************/
def setPublishRecordings = {
String API_CALL = "setPublishRecordings"
log.debug CONTROLLER_NAME + "#${API_CALL}"
ApiErrors errors = new ApiErrors()
// Do we have a checksum? If none, complain.
if (StringUtils.isEmpty(params.checksum)) {
errors.missingParamError("checksum");
}
// Do we have a meeting 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
}
ArrayList<String> recordIdList = new ArrayList<String>();
if (!StringUtils.isEmpty(recordId)) {
recordIdList=paramsProcessorUtil.decodeIds(recordId);
}
if(!meetingService.existsAnyRecording(recordIdList)){
errors.recordingNotFound();
respondWithErrors(errors);
return;
}
meetingService.setPublishRecording(recordIdList, true);
}
def uploadDocuments(conf) {
log.debug("ApiController#uploadDocuments(${conf.getInternalId()})");

View File

@ -33,6 +33,10 @@ public class ApiErrors {
errors.add(new String[] {"mismatchCreateTime", "The createTime parameter submitted mismatches with the current meeting."});
}
public void recordingNotFound() {
errors.add(new String[] {"recordingNotFound", "We could not find a recording with that recordID."});
}
public boolean hasErrors() {
return errors.size() > 0;
}

View File

@ -71,8 +71,16 @@ public class MeetingService {
return null;
}
public ArrayList<Recording> getRecordings(ArrayList<String> meetingId) {
return recordingService.getRecordings(meetingId);
public ArrayList<Recording> getRecordings(ArrayList<String> idList) {
return recordingService.getRecordings(idList);
}
public boolean existsAnyRecording(ArrayList<String> idList){
return recordingService.existAnyRecording(idList);
}
public void setPublishRecording(ArrayList<String> idList,boolean publish){
for(String id:idList){
recordingService.publish(id, publish);
}
}
public void processRecording(String meetingId) {

View File

@ -479,17 +479,18 @@ public class ParamsProcessorUtil {
this.defaultMeetingDuration = defaultMeetingDuration;
}
public ArrayList<String> processMeetingIds(String externalMeetingIds){
public ArrayList<String> decodeIds(String encodeid){
ArrayList<String> ids=new ArrayList<String>();
try {
ids.addAll(Arrays.asList(URLDecoder.decode(externalMeetingIds,"UTF-8").split(URLDECODER_SEPARATOR)));
ids.addAll(Arrays.asList(URLDecoder.decode(encodeid,"UTF-8").split(URLDECODER_SEPARATOR)));
} catch (UnsupportedEncodingException e) {
log.error("Couldn't decode the parameter");
log.error("Couldn't decode the IDs");
}
return ids;
}
public ArrayList<String> convertToInternalMeetingIds(ArrayList<String> extMeetingIds) {
public ArrayList<String> convertToInternalMeetingId(ArrayList<String> extMeetingIds) {
ArrayList<String> internalMeetingIds=new ArrayList<String>();
for(String extid : extMeetingIds){
internalMeetingIds.add(convertToInternalMeetingId(extid));

View File

@ -57,6 +57,18 @@ public class RecordingService {
return recs;
}
public boolean existAnyRecording(ArrayList<String> idList){
ArrayList<String> publishList=getAllRecordingIds(publishedDir);
ArrayList<String> unpublishList=getAllRecordingIds(unpublishedDir);
for(String id:idList){
if(publishList.contains(id)||unpublishList.contains(id)){
return true;
}
}
return false;
}
private ArrayList<String> getAllRecordingIds(String path){
ArrayList<String> ids=new ArrayList<String>();