More code quality improvements for bbb-common-web.

This commit is contained in:
Ghazi Triki 2017-12-29 09:02:42 +01:00
parent aa91cf6562
commit cdab773fe7
31 changed files with 332 additions and 276 deletions

View File

@ -0,0 +1,53 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2017 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.api;
public class ApiParams {
public static final String ALLOW_START_STOP_RECORDING = "allowStartStopRecording";
public static final String ATTENDEE_PW = "attendeePW";
public static final String AUTO_START_RECORDING = "autoStartRecording";
public static final String BANNER_COLOR = "bannerColor";
public static final String BANNER_TEXT = "bannerText";
public static final String CHECKSUM = "checksum";
public static final String DIAL_NUMBER = "dialNumber";
public static final String DURATION = "duration";
public static final String GUEST_POLICY = "guestPolicy";
public static final String IS_BREAKOUT = "isBreakout";
public static final String LOGOUT_TIMER = "logoutTimer";
public static final String LOGOUT_URL = "logoutURL";
public static final String MAX_PARTICIPANTS = "maxParticipants";
public static final String MEETING_ID = "meetingID";
public static final String META = "meta";
public static final String MODERATOR_ONLY_MESSAGE = "moderatorOnlyMessage";
public static final String MODERATOR_PW = "moderatorPW";
public static final String NAME = "name";
public static final String PARENT_MEETING_ID = "parentMeetingID";
public static final String RECORD = "record";
public static final String VOICE_BRIDGE = "voiceBridge";
public static final String WEB_VOICE = "webVoice";
public static final String WEBCAMS_ONLY_FOR_MODERATOR = "webcamsOnlyForModerator";
public static final String WELCOME = "welcome";
private ApiParams() {
throw new IllegalStateException("ApiParams is a utility class. Instanciation is forbidden.");
}
}

View File

@ -31,7 +31,7 @@ public class ClientConfigService {
private String configDir = "/var/bigbluebutton/configs";
private IClientConfigServiceHelper helper;
private Map<String, String> configs = new HashMap<String, String>();
private Map<String, String> configs = new HashMap<>();
public void init() {
configs = helper.getPreBuiltConfigs(configDir);

View File

@ -22,5 +22,5 @@ package org.bigbluebutton.api;
import java.util.Map;
public interface IClientConfigServiceHelper {
public Map<String, String> getPreBuiltConfigs(String dir);
public Map<String, String> getPreBuiltConfigs(String dir);
}

View File

@ -174,7 +174,7 @@ public class MeetingService implements MessageListener {
private void kickOffProcessingOfRecording(Meeting m) {
if (m.isRecord() && m.getNumUsers() == 0) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
logData.put("name", m.getName());
@ -191,8 +191,7 @@ public class MeetingService implements MessageListener {
}
public Boolean authzTokenIsValid(String authzToken) { // Note we DO NOT expire the token
Boolean valid = uploadAuthzTokens.containsKey(authzToken);
return valid;
return uploadAuthzTokens.containsKey(authzToken);
}
public Boolean authzTokenIsValidAndExpired(String authzToken) { // Note we DO expire the token
@ -256,7 +255,7 @@ public class MeetingService implements MessageListener {
}
if (m.isRecord()) {
Map<String, String> metadata = new TreeMap<String, String>();
Map<String, String> metadata = new TreeMap<>();
metadata.putAll(m.getMetadata());
// TODO: Need a better way to store these values for recordings
metadata.put("meetingId", m.getExternalId());
@ -266,7 +265,7 @@ public class MeetingService implements MessageListener {
storeService.recordMeetingInfo(m.getInternalId(), metadata);
if (m.isBreakout()) {
Map<String, String> breakoutMetadata = new TreeMap<String, String>();
Map<String, String> breakoutMetadata = new TreeMap<>();
breakoutMetadata.put("meetingId", m.getExternalId());
breakoutMetadata.put("sequence", m.getSequence().toString());
breakoutMetadata.put("parentMeetingId", m.getParentMeetingId());
@ -274,7 +273,7 @@ public class MeetingService implements MessageListener {
}
}
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
if (m.isBreakout()) {
@ -319,7 +318,7 @@ public class MeetingService implements MessageListener {
if (m != null) {
User prevUser = m.getUserWithExternalId(message.externUserID);
if (prevUser != null) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
logData.put("name", m.getName());
@ -350,7 +349,7 @@ public class MeetingService implements MessageListener {
return null;
for (String key : meetings.keySet()) {
if (key.startsWith(meetingId))
return (Meeting) meetings.get(key);
return meetings.get(key);
}
return null;
@ -360,7 +359,7 @@ public class MeetingService implements MessageListener {
if (meetingId == null)
return Collections.<Meeting>emptySet();
Collection<Meeting> m = new HashSet<Meeting>();
Collection<Meeting> m = new HashSet<>();
for (String key : meetings.keySet()) {
if (key.startsWith(meetingId))
@ -375,7 +374,7 @@ public class MeetingService implements MessageListener {
return null;
for (String key : meetings.keySet()) {
if (key.startsWith(meetingId)) {
Meeting m = (Meeting) meetings.get(key);
Meeting m = meetings.get(key);
if (!m.isForciblyEnded())
return m;
}
@ -454,7 +453,7 @@ public class MeetingService implements MessageListener {
Meeting parentMeeting = getMeeting(message.parentMeetingId);
if (parentMeeting != null) {
Map<String, String> params = new HashMap<String, String>();
Map<String, String> params = new HashMap<>();
params.put("name", message.name);
params.put("meetingID", message.meetingId);
params.put("parentMeetingID", message.parentMeetingId);
@ -548,7 +547,7 @@ public class MeetingService implements MessageListener {
long now = System.currentTimeMillis();
m.setStartTime(now);
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
if (m.isBreakout()) {
@ -566,7 +565,7 @@ public class MeetingService implements MessageListener {
log.info("Meeting started: data={}", logStr);
} else {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
if (m.isBreakout()) {
@ -594,7 +593,7 @@ public class MeetingService implements MessageListener {
long now = System.currentTimeMillis();
m.setEndTime(now);
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
logData.put("name", m.getName());
@ -618,7 +617,7 @@ public class MeetingService implements MessageListener {
long now = System.currentTimeMillis();
m.setEndTime(now);
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
logData.put("name", m.getName());
@ -657,7 +656,7 @@ public class MeetingService implements MessageListener {
userSession.guestStatus = message.guestStatus;
}
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
logData.put("name", m.getName());
@ -685,7 +684,7 @@ public class MeetingService implements MessageListener {
User user = m.userLeft(message.userId);
if (user != null) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
logData.put("name", m.getName());

View File

@ -23,10 +23,12 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
@ -100,11 +102,13 @@ public class ParamsProcessorUtil {
private String substituteKeywords(String message, String dialNumber, String telVoice, String meetingName) {
String welcomeMessage = message;
ArrayList<String> keywordList = new ArrayList<String>();
keywordList.add(DIAL_NUM);keywordList.add(CONF_NUM);keywordList.add(CONF_NAME);keywordList.add(SERVER_URL);
ArrayList<String> keywordList = new ArrayList<>();
keywordList.add(DIAL_NUM);
keywordList.add(CONF_NUM);
keywordList.add(CONF_NAME);
keywordList.add(SERVER_URL);
for (String aKeywordList : keywordList) {
String keyword = (String) aKeywordList;
for (String keyword : keywordList) {
if (keyword.equals(DIAL_NUM)) {
welcomeMessage = welcomeMessage.replaceAll(DIAL_NUM, dialNumber);
} else if (keyword.equals(CONF_NUM)) {
@ -120,22 +124,22 @@ public class ParamsProcessorUtil {
public void processRequiredCreateParams(Map<String, String> params, ApiErrors errors) {
// Do we have a checksum? If not, complain.
if (StringUtils.isEmpty(params.get("checksum"))) {
errors.missingParamError("checksum");
if (StringUtils.isEmpty(params.get(ApiParams.CHECKSUM))) {
errors.missingParamError(ApiParams.CHECKSUM);
}
// Do we have a meeting id? If not, complain.
if(!StringUtils.isEmpty(params.get("meetingID"))) {
String meetingId = StringUtils.strip(params.get("meetingID"));
if (!StringUtils.isEmpty(params.get(ApiParams.MEETING_ID))) {
String meetingId = StringUtils.strip(params.get(ApiParams.MEETING_ID));
if (StringUtils.isEmpty(meetingId)) {
errors.missingParamError("meetingID");
errors.missingParamError(ApiParams.MEETING_ID);
} else {
if (! ParamsUtil.isValidMeetingId(meetingId)) {
errors.addError(new String[] {"invalidFormat", "Meeting id contains invalid characters."});
}
}
if (!ParamsUtil.isValidMeetingId(meetingId)) {
errors.addError(new String[] { "invalidFormat", "Meeting id contains invalid characters." });
}
}
} else {
errors.missingParamError("meetingID");
errors.missingParamError(ApiParams.MEETING_ID);
}
}
@ -215,68 +219,68 @@ public class ParamsProcessorUtil {
}
public Map<String, Object> processUpdateCreateParams(Map<String, String> params) {
Map<String, Object> newParams = new HashMap<String, Object>();
Map<String, Object> newParams = new HashMap<>();
// Do we have a meeting name? If not, complain.
String meetingName = params.get("name");
String meetingName = params.get(ApiParams.NAME);
if (! StringUtils.isEmpty(meetingName) ) {
newParams.put("name", meetingName);
newParams.put(ApiParams.NAME, meetingName);
}
String viewerPass = params.get("attendeePW");
String viewerPass = params.get(ApiParams.ATTENDEE_PW);
if (! StringUtils.isEmpty(viewerPass) ) {
newParams.put("attendeePW", viewerPass);
newParams.put(ApiParams.ATTENDEE_PW, viewerPass);
}
String modPass = params.get("moderatorPW");
String modPass = params.get(ApiParams.MODERATOR_PW);
if (! StringUtils.isEmpty(modPass) ) {
newParams.put("moderatorPW", modPass);
newParams.put(ApiParams.MODERATOR_PW, modPass);
}
String telVoice = params.get("voiceBridge");
String telVoice = params.get(ApiParams.VOICE_BRIDGE);
if (! StringUtils.isEmpty(telVoice) ) {
newParams.put("voiceBridge", telVoice);
newParams.put(ApiParams.VOICE_BRIDGE, telVoice);
}
String webVoice = params.get("webVoice");
String webVoice = params.get(ApiParams.WEB_VOICE);
if (! StringUtils.isEmpty(webVoice)) {
newParams.put("webVoice", webVoice);
newParams.put(ApiParams.WEB_VOICE, webVoice);
}
String dialNumber = params.get("dialNumber");
String dialNumber = params.get(ApiParams.DIAL_NUMBER);
if (! StringUtils.isEmpty(dialNumber)) {
newParams.put("dialNumber", dialNumber);
newParams.put(ApiParams.DIAL_NUMBER, dialNumber);
}
String logoutUrl = params.get("logoutURL");
String logoutUrl = params.get(ApiParams.LOGOUT_URL);
if (! StringUtils.isEmpty(logoutUrl)) {
newParams.put("logoutURL", logoutUrl);
newParams.put(ApiParams.LOGOUT_URL, logoutUrl);
}
String record = params.get("record");
String record = params.get(ApiParams.RECORD);
if (! StringUtils.isEmpty(record)) {
newParams.put("record", record);
newParams.put(ApiParams.RECORD, record);
}
String maxUsers = params.get("maxParticipants");
String maxUsers = params.get(ApiParams.MAX_PARTICIPANTS);
if (! StringUtils.isEmpty(maxUsers)) {
newParams.put("maxParticipants", maxUsers);
newParams.put(ApiParams.MAX_PARTICIPANTS, maxUsers);
}
String meetingDuration = params.get("duration");
String meetingDuration = params.get(ApiParams.DURATION);
if (! StringUtils.isEmpty(meetingDuration)) {
newParams.put("duration", meetingDuration);
newParams.put(ApiParams.DURATION, meetingDuration);
}
String welcomeMessage = params.get("welcome");
String welcomeMessage = params.get(ApiParams.WELCOME);
if (! StringUtils.isEmpty(welcomeMessage)) {
newParams.put("welcome", welcomeMessage);
newParams.put(ApiParams.WELCOME, welcomeMessage);
}
// Collect metadata for this meeting that the third-party app wants to store if meeting is recorded.
Map<String, String> meetingInfo = new HashMap<String, String>();
Map<String, String> meetingInfo = new HashMap<>();
for (String key: params.keySet()) {
if (key.contains("meta")){
if (key.contains(ApiParams.META)){
String[] meta = key.split("_");
if(meta.length == 2){
meetingInfo.put(meta[1], params.get(key));
@ -284,9 +288,9 @@ public class ParamsProcessorUtil {
}
}
if (! meetingInfo.isEmpty()) {
newParams.put("metadata", meetingInfo);
}
if (!meetingInfo.isEmpty()) {
newParams.put("metadata", meetingInfo);
}
return newParams;
}
@ -304,69 +308,70 @@ public class ParamsProcessorUtil {
return StringUtils.removeStart(param, "meta_");
}
public static Map<String, String> processMetaParam(Map<String, String> params) {
Map<String, String> metas = new HashMap<String, String>();
for (String key: params.keySet()) {
if (isMetaValid(key)){
// Need to lowercase to maintain backward compatibility with 0.81
String metaName = removeMetaString(key).toLowerCase();
metas.put(metaName, params.get(key));
}
public static Map<String, String> processMetaParam(Map<String, String> params) {
Map<String, String> metas = new HashMap<>();
for (String key : params.keySet()) {
if (isMetaValid(key)) {
// Need to lowercase to maintain backward compatibility with
// 0.81
String metaName = removeMetaString(key).toLowerCase();
metas.put(metaName, params.get(key));
}
}
return metas;
}
return metas;
}
public Meeting processCreateParams(Map<String, String> params) {
String meetingName = params.get("name");
String meetingName = params.get(ApiParams.NAME);
if (meetingName == null) {
meetingName = "";
}
meetingName = ParamsUtil.stripControlChars(meetingName);
String externalMeetingId = params.get("meetingID");
String externalMeetingId = params.get(ApiParams.MEETING_ID);
String viewerPass = processPassword(params.get("attendeePW"));
String modPass = processPassword(params.get("moderatorPW"));
String viewerPass = processPassword(params.get(ApiParams.ATTENDEE_PW));
String modPass = processPassword(params.get(ApiParams.MODERATOR_PW));
// Get the digits for voice conference for users joining through the
// phone.
// If none is provided, generate one.
String telVoice = processTelVoice(params.get("voiceBridge"));
String telVoice = processTelVoice(params.get(ApiParams.VOICE_BRIDGE));
// Get the voice conference digits/chars for users joing through VOIP on
// the client.
// If none is provided, make it the same as the telVoice. If one has
// been provided,
// we expect that the users will be joined in the same voice conference.
String webVoice = params.get("webVoice");
String webVoice = params.get(ApiParams.WEB_VOICE);
if (StringUtils.isEmpty(webVoice)) {
webVoice = telVoice;
}
// Get all the other relevant parameters and generate defaults if none
// has been provided.
String dialNumber = processDialNumber(params.get("dialNumber"));
String logoutUrl = processLogoutUrl(params.get("logoutURL"));
boolean record = processRecordMeeting(params.get("record"));
int maxUsers = processMaxUser(params.get("maxParticipants"));
int meetingDuration = processMeetingDuration(params.get("duration"));
int logoutTimer = processLogoutTimer(params.get("logoutTimer"));
String dialNumber = processDialNumber(params.get(ApiParams.DIAL_NUMBER));
String logoutUrl = processLogoutUrl(params.get(ApiParams.LOGOUT_URL));
boolean record = processRecordMeeting(params.get(ApiParams.RECORD));
int maxUsers = processMaxUser(params.get(ApiParams.MAX_PARTICIPANTS));
int meetingDuration = processMeetingDuration(params.get(ApiParams.DURATION));
int logoutTimer = processLogoutTimer(params.get(ApiParams.LOGOUT_TIMER));
// Banner parameters
String bannerText = params.get("bannerText");
String bannerColor = params.get("bannerColor");
String bannerText = params.get(ApiParams.BANNER_TEXT);
String bannerColor = params.get(ApiParams.BANNER_COLOR);
// set is breakout room property
boolean isBreakout = false;
if (!StringUtils.isEmpty(params.get("isBreakout"))) {
isBreakout = Boolean.valueOf(params.get("isBreakout"));
if (!StringUtils.isEmpty(params.get(ApiParams.IS_BREAKOUT))) {
isBreakout = Boolean.valueOf(params.get(ApiParams.IS_BREAKOUT));
}
String welcomeMessageTemplate = processWelcomeMessage(
params.get("welcome"), isBreakout);
params.get(ApiParams.WELCOME), isBreakout);
String welcomeMessage = substituteKeywords(welcomeMessageTemplate,
dialNumber, telVoice, meetingName);
@ -379,10 +384,10 @@ public class ParamsProcessorUtil {
}
boolean autoStartRec = autoStartRecording;
if (!StringUtils.isEmpty(params.get("autoStartRecording"))) {
if (!StringUtils.isEmpty(params.get(ApiParams.AUTO_START_RECORDING))) {
try {
autoStartRec = Boolean.parseBoolean(params
.get("autoStartRecording"));
.get(ApiParams.AUTO_START_RECORDING));
} catch (Exception ex) {
log.warn("Invalid param [autoStartRecording] for meeting=[{}]",
internalMeetingId);
@ -390,10 +395,10 @@ public class ParamsProcessorUtil {
}
boolean allowStartStoptRec = allowStartStopRecording;
if (!StringUtils.isEmpty(params.get("allowStartStopRecording"))) {
if (!StringUtils.isEmpty(params.get(ApiParams.ALLOW_START_STOP_RECORDING))) {
try {
allowStartStoptRec = Boolean.parseBoolean(params
.get("allowStartStopRecording"));
.get(ApiParams.ALLOW_START_STOP_RECORDING));
} catch (Exception ex) {
log.warn(
"Invalid param [allowStartStopRecording] for meeting=[{}]",
@ -402,10 +407,10 @@ public class ParamsProcessorUtil {
}
boolean webcamsOnlyForMod = webcamsOnlyForModerator;
if (!StringUtils.isEmpty(params.get("webcamsOnlyForModerator"))) {
if (!StringUtils.isEmpty(params.get(ApiParams.WEBCAMS_ONLY_FOR_MODERATOR))) {
try {
webcamsOnlyForMod = Boolean.parseBoolean(params
.get("webcamsOnlyForModerator"));
.get(ApiParams.WEBCAMS_ONLY_FOR_MODERATOR));
} catch (Exception ex) {
log.warn(
"Invalid param [webcamsOnlyForModerator] for meeting=[{}]",
@ -414,14 +419,13 @@ public class ParamsProcessorUtil {
}
String guestPolicy = defaultGuestPolicy;
if (!StringUtils.isEmpty(params.get("guestPolicy"))) {
guestPolicy = params.get("guestPolicy");
if (!StringUtils.isEmpty(params.get(ApiParams.GUEST_POLICY))) {
guestPolicy = params.get(ApiParams.GUEST_POLICY);
}
// Collect metadata for this meeting that the third-party app wants to
// store if meeting is recorded.
Map<String, String> meetingInfo = new HashMap<String, String>();
meetingInfo = processMetaParam(params);
Map<String, String> meetingInfo = processMetaParam(params);
// Create a unique internal id by appending the current time. This way,
// the 3rd-party
@ -434,8 +438,8 @@ public class ParamsProcessorUtil {
// tracks of the parent meeting id
String parentMeetingId = "";
if (isBreakout) {
internalMeetingId = params.get("meetingID");
parentMeetingId = params.get("parentMeetingID");
internalMeetingId = params.get(ApiParams.MEETING_ID);
parentMeetingId = params.get(ApiParams.PARENT_MEETING_ID);
// We rebuild the the external meeting using the has of the parent
// meeting, the shared timestamp and the sequence number
String timeStamp = StringUtils.substringAfter(internalMeetingId, "-");
@ -467,8 +471,8 @@ public class ParamsProcessorUtil {
String configXML = getDefaultConfigXML();
meeting.storeConfig(true, configXML);
if (!StringUtils.isEmpty(params.get("moderatorOnlyMessage"))) {
String moderatorOnlyMessage = params.get("moderatorOnlyMessage");
if (!StringUtils.isEmpty(params.get(ApiParams.MODERATOR_ONLY_MESSAGE))) {
String moderatorOnlyMessage = params.get(ApiParams.MODERATOR_ONLY_MESSAGE);
meeting.setModeratorOnlyMessage(moderatorOnlyMessage);
}
@ -532,7 +536,7 @@ public class ParamsProcessorUtil {
@Override
public String handleResponse(
final HttpResponse response) throws ClientProtocolException, IOException {
final HttpResponse response) throws IOException {
int status = response.getStatusLine().getStatusCode();
if (status >= 200 && status < 300) {
HttpEntity entity = response.getEntity();
@ -746,12 +750,12 @@ public class ParamsProcessorUtil {
StringBuilder csbuf = new StringBuilder();
csbuf.append(apiCall);
SortedSet<String> keys = new TreeSet<String>(params.keySet());
SortedSet<String> keys = new TreeSet<>(params.keySet());
boolean first = true;
String checksum = null;
for (String key: keys) {
if ("checksum".equals(key)) {
if (ApiParams.CHECKSUM.equals(key)) {
// Don't include the "checksum" parameter in the checksum
checksum = params.get(key)[0];
continue;
@ -775,7 +779,7 @@ public class ParamsProcessorUtil {
*/ try {
// we need to re-encode the values because Grails unencoded it
// when it received the 'POST'ed data. Might not need to do in a GET request.
encResult = URLEncoder.encode(value, "UTF-8");
encResult = URLEncoder.encode(value, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
encResult = value;
}
@ -788,7 +792,7 @@ public class ParamsProcessorUtil {
String baseString = csbuf.toString();
String cs = DigestUtils.sha1Hex(baseString);
if (cs == null || cs.equals(checksum) == false) {
if (cs == null || !cs.equals(checksum)) {
log.info("POST basestring = {}", baseString);
log.info("checksumError: failed checksum. our checksum: [{}], client: [{}]", cs, checksum);
return false;
@ -942,10 +946,10 @@ public class ParamsProcessorUtil {
return maxPresentationFileUpload;
}
public ArrayList<String> decodeIds(String encodeid) {
ArrayList<String> ids=new ArrayList<String>();
public List<String> decodeIds(String encodeid) {
ArrayList<String> ids=new ArrayList<>();
try {
ids.addAll(Arrays.asList(URLDecoder.decode(encodeid,"UTF-8").split(URLDECODER_SEPARATOR)));
ids.addAll(Arrays.asList(URLDecoder.decode(encodeid, StandardCharsets.UTF_8.name()).split(URLDECODER_SEPARATOR)));
} catch (UnsupportedEncodingException e) {
log.error("Couldn't decode the IDs");
}
@ -953,38 +957,38 @@ public class ParamsProcessorUtil {
return ids;
}
public ArrayList<String> convertToInternalMeetingId(ArrayList<String> extMeetingIds) {
ArrayList<String> internalMeetingIds=new ArrayList<String>();
for(String extid : extMeetingIds){
internalMeetingIds.add(convertToInternalMeetingId(extid));
}
return internalMeetingIds;
}
public List<String> convertToInternalMeetingId(List<String> extMeetingIds) {
ArrayList<String> internalMeetingIds = new ArrayList<>();
for (String extid : extMeetingIds) {
internalMeetingIds.add(convertToInternalMeetingId(extid));
}
return internalMeetingIds;
}
public Map<String,String> getUserCustomData(Map<String,String> params) {
Map<String,String> resp = new HashMap<String, String>();
public Map<String, String> getUserCustomData(Map<String, String> params) {
Map<String, String> resp = new HashMap<>();
for (String key: params.keySet()) {
if (key.contains("userdata")&&key.indexOf("userdata")==0){
String[] userdata = key.split("-");
if(userdata.length == 2){
log.debug("Got user custom data {} = {}", key, params.get(key));
resp.put(userdata[1], params.get(key));
}
}
}
for (String key : params.keySet()) {
if (key.contains("userdata") && key.indexOf("userdata") == 0) {
String[] userdata = key.split("-");
if (userdata.length == 2) {
log.debug("Got user custom data {} = {}", key, params.get(key));
resp.put(userdata[1], params.get(key));
}
}
}
return resp;
}
return resp;
}
public Map<String, Map<String, Object>> decodeFilters(String encodedFilters) {
Map<String, Map<String, Object>> filters = new LinkedHashMap<String, Map<String, Object>>();
Map<String, Map<String, Object>> filters = new LinkedHashMap<>();
try {
String[] sFilters = encodedFilters.split(URLDECODER_SEPARATOR);
for( String sFilter: sFilters) {
String[] filterElements = sFilter.split(FILTERDECODER_SEPARATOR_ELEMENTS, 3);
Map<String, Object> filter = new LinkedHashMap<String, Object>();
Map<String, Object> filter = new LinkedHashMap<>();
filter.put("op", filterElements[1]);
String[] fValues = filterElements[2].split(FILTERDECODER_SEPARATOR_OPERATORS);
filter.put("values", fValues );

View File

@ -85,7 +85,7 @@ public class RecordingService {
}
public List<RecordingMetadata> getRecordingsMetadata(List<String> recordIDs, List<String> states) {
List<RecordingMetadata> recs = new ArrayList<RecordingMetadata>();
List<RecordingMetadata> recs = new ArrayList<>();
Map<String, List<File>> allDirectories = getAllDirectories(states);
if (recordIDs.isEmpty()) {
@ -153,7 +153,7 @@ public class RecordingService {
public ArrayList<RecordingMetadata> filterRecordingsByMetadata(List<RecordingMetadata> recordings, Map<String, String> metadataFilters) {
ArrayList<RecordingMetadata> resultRecordings = new ArrayList<RecordingMetadata>();
ArrayList<RecordingMetadata> resultRecordings = new ArrayList<>();
for (RecordingMetadata entry : recordings) {
if (recordingMatchesMetadata(entry, metadataFilters))
resultRecordings.add(entry);
@ -180,7 +180,7 @@ public class RecordingService {
}
private List<String> getAllRecordingIds(String path, String[] format) {
List<String> ids = new ArrayList<String>();
List<String> ids = new ArrayList<>();
for (String aFormat : format) {
List<File> recordings = getDirectories(path + File.separatorChar + aFormat);
@ -195,7 +195,7 @@ public class RecordingService {
}
private Set<String> getAllRecordingIds(List<File> recs) {
Set<String> ids = new HashSet<String>();
Set<String> ids = new HashSet<>();
Iterator<File> iterator = recs.iterator();
while (iterator.hasNext()) {
@ -206,7 +206,7 @@ public class RecordingService {
}
private List<File> getRecordingsForPath(String id, List<File> recordings) {
List<File> recs = new ArrayList<File>();
List<File> recs = new ArrayList<>();
Iterator<File> iterator = recordings.iterator();
while (iterator.hasNext()) {
@ -254,7 +254,7 @@ public class RecordingService {
}
private static List<File> getDirectories(String path) {
List<File> files = new ArrayList<File>();
List<File> files = new ArrayList<>();
try {
DirectoryStream<Path> stream = Files.newDirectoryStream(FileSystems.getDefault().getPath(path));
Iterator<Path> iter = stream.iterator();
@ -434,7 +434,7 @@ public class RecordingService {
private List<File> getAllDirectories(String state) {
List<File> allDirectories = new ArrayList<File>();
List<File> allDirectories = new ArrayList<>();
String dir = getDestinationBaseDirectoryName(state);
@ -449,31 +449,31 @@ public class RecordingService {
}
private Map<String, List<File>> getAllDirectories(List<String> states) {
Map<String, List<File>> allDirectories = new HashMap<String, List<File>>();
Map<String, List<File>> allDirectories = new HashMap<>();
if ( shouldIncludeState(states, Recording.STATE_PUBLISHED) ) {
List<File> _allDirectories = getAllDirectories(Recording.STATE_PUBLISHED);
allDirectories.put(Recording.STATE_PUBLISHED, _allDirectories);
List<File> listedDirectories = getAllDirectories(Recording.STATE_PUBLISHED);
allDirectories.put(Recording.STATE_PUBLISHED, listedDirectories);
}
if ( shouldIncludeState(states, Recording.STATE_UNPUBLISHED) ) {
List<File> _allDirectories = getAllDirectories(Recording.STATE_UNPUBLISHED);
allDirectories.put(Recording.STATE_UNPUBLISHED, _allDirectories);
List<File> listedDirectories = getAllDirectories(Recording.STATE_UNPUBLISHED);
allDirectories.put(Recording.STATE_UNPUBLISHED, listedDirectories);
}
if ( shouldIncludeState(states, Recording.STATE_DELETED) ) {
List<File> _allDirectories = getAllDirectories(Recording.STATE_DELETED);
allDirectories.put(Recording.STATE_DELETED, _allDirectories);
List<File> listedDirectories = getAllDirectories(Recording.STATE_DELETED);
allDirectories.put(Recording.STATE_DELETED, listedDirectories);
}
if ( shouldIncludeState(states, Recording.STATE_PROCESSING) ) {
List<File> _allDirectories = getAllDirectories(Recording.STATE_PROCESSING);
allDirectories.put(Recording.STATE_PROCESSING, _allDirectories);
List<File> listedDirectories = getAllDirectories(Recording.STATE_PROCESSING);
allDirectories.put(Recording.STATE_PROCESSING, listedDirectories);
}
if ( shouldIncludeState(states, Recording.STATE_PROCESSED) ) {
List<File> _allDirectories = getAllDirectories(Recording.STATE_PROCESSED);
allDirectories.put(Recording.STATE_PROCESSED, _allDirectories);
List<File> listedDirectories = getAllDirectories(Recording.STATE_PROCESSED);
allDirectories.put(Recording.STATE_PROCESSED, listedDirectories);
}
return allDirectories;
@ -481,7 +481,7 @@ public class RecordingService {
public void updateMetaParams(List<String> recordIDs, Map<String,String> metaParams) {
// Define the directories used to lookup the recording
List<String> states = new ArrayList<String>();
List<String> states = new ArrayList<>();
states.add(Recording.STATE_PUBLISHED);
states.add(Recording.STATE_UNPUBLISHED);
states.add(Recording.STATE_DELETED);
@ -533,7 +533,7 @@ public class RecordingService {
private Map<String,File> indexRecordings(List<File> recs) {
Map<String,File> indexedRecs = new HashMap<String,File>();
Map<String,File> indexedRecs = new HashMap<>();
Iterator<File> iterator = recs.iterator();
while (iterator.hasNext()) {

View File

@ -72,7 +72,7 @@ public class Meeting {
private final ConcurrentMap<String, RegisteredUser> registeredUsers;
private final ConcurrentMap<String, Config> configs;
private final Boolean isBreakout;
private final List<String> breakoutRooms = new ArrayList<String>();
private final List<String> breakoutRooms = new ArrayList<>();
private Integer maxInactivityTimeoutMinutes = 120;
private Integer warnMinutesBeforeMax = 5;
@ -106,12 +106,12 @@ public class Meeting {
isBreakout = builder.isBreakout;
guestPolicy = builder.guestPolicy;
userCustomData = new HashMap<String, Object>();
userCustomData = new HashMap<>();
users = new ConcurrentHashMap<String, User>();
registeredUsers = new ConcurrentHashMap<String, RegisteredUser>();
users = new ConcurrentHashMap<>();
registeredUsers = new ConcurrentHashMap<>();
configs = new ConcurrentHashMap<String, Config>();
configs = new ConcurrentHashMap<>();
}
public void addBreakoutRoom(String meetingId) {
@ -209,8 +209,8 @@ public class Meeting {
return createdTime;
}
public Integer setSequence(Integer s) {
return sequence = s;
public void setSequence(Integer s) {
sequence = s;
}
public Integer getSequence() {
@ -265,8 +265,8 @@ public class Meeting {
return intMeetingId;
}
public String setParentMeetingId(String p) {
return parentMeetingId = p;
public void setParentMeetingId(String p) {
parentMeetingId = p;
}
public String getParentMeetingId() {
@ -386,7 +386,7 @@ public class Meeting {
public User getUserWithExternalId(String externalUserId) {
for (String key : users.keySet()) {
User u = (User) users.get(key);
User u = users.get(key);
if (u.getExternalUserId().equals(externalUserId)) {
return u;
}
@ -401,7 +401,7 @@ public class Meeting {
public int getNumModerators(){
int sum = 0;
for (String key : users.keySet()) {
User u = (User) users.get(key);
User u = users.get(key);
if (u.isModerator()) sum++;
}
return sum;
@ -414,7 +414,7 @@ public class Meeting {
public int getNumListenOnly() {
int sum = 0;
for (String key : users.keySet()) {
User u = (User) users.get(key);
User u = users.get(key);
if (u.isListeningOnly()) sum++;
}
return sum;
@ -423,7 +423,7 @@ public class Meeting {
public int getNumVoiceJoined() {
int sum = 0;
for (String key : users.keySet()) {
User u = (User) users.get(key);
User u = users.get(key);
if (u.isVoiceJoined()) sum++;
}
return sum;
@ -432,7 +432,7 @@ public class Meeting {
public int getNumVideos() {
int sum = 0;
for (String key : users.keySet()) {
User u = (User) users.get(key);
User u = users.get(key);
sum += u.getStreams().size();
}
return sum;
@ -485,7 +485,7 @@ public class Meeting {
}
public RegisteredUser userUnregistered(String userid) {
return (RegisteredUser) this.registeredUsers.remove(userid);
return this.registeredUsers.remove(userid);
}
public ConcurrentMap<String, RegisteredUser> getRegisteredUsers() {

View File

@ -9,7 +9,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@JacksonXmlRootElement(localName = "meta")
public class Metadata {
private Map<String,String> map = new TreeMap<String,String>();
private Map<String,String> map = new TreeMap<>();
@JsonAnyGetter
public Map<String, String> get() {

View File

@ -36,7 +36,7 @@ public class Poll{
this.title = title;
this.question = question;
this.datetime = Long.toString(System.currentTimeMillis());
this.answers = new HashMap<String,String>();
this.answers = new HashMap<>();
}
public void addAnswer(String answer){
@ -69,7 +69,7 @@ public class Poll{
}
public HashMap<String,String> toMap(){
HashMap<String,String> map = new HashMap<String,String>();
HashMap<String,String> map = new HashMap<>();
map.put("pollID",pollID);
map.put("meetingID",meetingID);
map.put("title", title);

View File

@ -37,8 +37,8 @@ public class Recording {
private String endTime;
private String numParticipants;
private String rawSize;
private Map<String, String> metadata = new TreeMap<String, String>();
private List<Playback> playbacks=new ArrayList<Playback>();
private Map<String, String> metadata = new TreeMap<>();
private List<Playback> playbacks=new ArrayList<>();
//TODO:
private String state;
@ -73,11 +73,11 @@ public class Recording {
}
public String getState() {
String state = this.state;
if ( state == null || "".equals(state) || "available".equals(state) ) {
state = isPublished()? STATE_PUBLISHED: STATE_UNPUBLISHED;
String currentState = this.state;
if ( currentState == null || "".equals(currentState) || "available".equals(currentState) ) {
currentState = isPublished()? STATE_PUBLISHED: STATE_UNPUBLISHED;
}
return state;
return currentState;
}
public void setState(String state) {

View File

@ -23,22 +23,18 @@ import java.io.File;
import java.io.FileFilter;
public class Recordings {
public String[] getRecordings(String recordingDir) {
File dir = new File(recordingDir);
FileFilter fileFilter = new FileFilter() {
public boolean accept(File file) {
return file.isDirectory();
}
};
File[] dirs = dir.listFiles(fileFilter);
String[] meetings = new String[dirs.length];
for (int i = 0; i < dirs.length; i++) {
meetings[i] = dirs[i].getName();
}
return meetings;
}
public String[] getRecordings(String recordingDir) {
File dir = new File(recordingDir);
FileFilter fileFilter = File::isDirectory;
File[] dirs = dir.listFiles(fileFilter);
String[] meetings = new String[dirs.length];
for (int i = 0; i < dirs.length; i++) {
meetings[i] = dirs[i].getName();
}
return meetings;
}
}

View File

@ -49,7 +49,7 @@ public class User {
this.avatarURL = avatarURL;
this.guest = guest;
this.guestStatus = guestStatus;
this.status = new ConcurrentHashMap<String, String>();
this.status = new ConcurrentHashMap<>();
this.streams = Collections.synchronizedList(new ArrayList<String>());
}
@ -139,9 +139,9 @@ public class User {
return streams;
}
public Boolean hasVideo() {
return this.getStreams().size() > 0;
}
public Boolean hasVideo() {
return !this.getStreams().isEmpty();
}
public Boolean isListeningOnly() {
return listeningOnly;

View File

@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory;
public class ReceivedMessageHandler implements IReceivedOldMessageHandler {
private static Logger log = LoggerFactory.getLogger(ReceivedMessageHandler.class);
private BlockingQueue<ReceivedMessage> receivedMessages = new LinkedBlockingQueue<ReceivedMessage>();
private BlockingQueue<ReceivedMessage> receivedMessages = new LinkedBlockingQueue<>();
private volatile boolean processMessage = false;

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@ -33,7 +34,7 @@ public class ResponseBuilder {
} catch (IOException e) {
e.printStackTrace();
}
cfg.setDefaultEncoding("UTF-8");
cfg.setDefaultEncoding(StandardCharsets.UTF_8.name());
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
cfg.setLogTemplateExceptions(false);
}

View File

@ -21,7 +21,7 @@ public class BbbAppsIsAliveMessage {
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
HashMap<String, Object> payload = new HashMap<>();
payload.put(TIMESTAMP, timestamp);
payload.put(STARTED_ON, timestamp);

View File

@ -67,7 +67,7 @@ public class PdfToSwfSlide {
public void generateBlankSlide() {
if (BLANK_SLIDE != null) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -80,7 +80,7 @@ public class PdfToSwfSlide {
copyBlankSlide(slide);
} else {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());

View File

@ -54,10 +54,8 @@ public class SupportedDocumentFilter {
private void notifyProgressListener(boolean supported, UploadedPresentation pres) {
String msgKey = ConversionMessageConstants.SUPPORTED_DOCUMENT_KEY;
if (supported) {
msgKey = ConversionMessageConstants.SUPPORTED_DOCUMENT_KEY;
} else {
msgKey = ConversionMessageConstants.UNSUPPORTED_DOCUMENT_KEY;
if (!supported) {
msgKey = ConversionMessageConstants.UNSUPPORTED_DOCUMENT_KEY;
}
if (gw != null) {

View File

@ -40,9 +40,10 @@ public class Pdf2SwfPageConverterHandler extends AbstractCommandHandler {
private static final String PLACEMENT_OUTPUT = "DEBUG Using";
private static final String TEXT_TAG_OUTPUT = "VERBOSE Updating";
private static final String IMAGE_TAG_OUTPUT = "VERBOSE Drawing";
private static final String PLACEMENT_PATTERN = "\\d+\\s" + PLACEMENT_OUTPUT;
private static final String TEXT_TAG_PATTERN = "\\d+\\s" + TEXT_TAG_OUTPUT;
private static final String IMAGE_TAG_PATTERN = "\\d+\\s" + IMAGE_TAG_OUTPUT;
private static final String DIGITS_AND_WHITESPACES = "\\d+\\s";
private static final String PLACEMENT_PATTERN = DIGITS_AND_WHITESPACES + PLACEMENT_OUTPUT;
private static final String TEXT_TAG_PATTERN = DIGITS_AND_WHITESPACES + TEXT_TAG_OUTPUT;
private static final String IMAGE_TAG_PATTERN = DIGITS_AND_WHITESPACES + IMAGE_TAG_OUTPUT;
/**
*

View File

@ -22,28 +22,30 @@ package org.bigbluebutton.presentation.imp;
@SuppressWarnings("serial")
public class CountingPageException extends Exception {
private final int maxNumberOfPages;
private final ExceptionType exceptionType;
private final int pageCount;
public CountingPageException(CountingPageException.ExceptionType type, int pageCount, int maxNumberOfPages) {
super("Exception while trying to determine number of pages.");
this.pageCount = pageCount;
this.maxNumberOfPages = maxNumberOfPages;
exceptionType = type;
}
private final int maxNumberOfPages;
private final ExceptionType exceptionType;
private final int pageCount;
public CountingPageException(CountingPageException.ExceptionType type, int pageCount, int maxNumberOfPages) {
super("Exception while trying to determine number of pages.");
this.pageCount = pageCount;
this.maxNumberOfPages = maxNumberOfPages;
exceptionType = type;
}
public int getMaxNumberOfPages() {
return maxNumberOfPages;
}
return maxNumberOfPages;
}
public CountingPageException.ExceptionType getExceptionType() {
return exceptionType;
}
return exceptionType;
}
public int getPageCount() {
return pageCount;
}
return pageCount;
}
public enum ExceptionType {PAGE_COUNT_EXCEPTION, PAGE_EXCEEDED_EXCEPTION}
public enum ExceptionType {
PAGE_COUNT_EXCEPTION, PAGE_EXCEEDED_EXCEPTION
}
}

View File

@ -29,6 +29,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.bigbluebutton.presentation.FileTypeConstants;
import org.bigbluebutton.presentation.ImageToSwfSlide;
import org.bigbluebutton.presentation.PageConverter;
import org.bigbluebutton.presentation.SvgImageCreator;
@ -75,7 +76,7 @@ public class ImageToSwfSlidesGenerationService {
private PageConverter determinePageConverter(UploadedPresentation pres) {
String fileType = pres.getFileType().toUpperCase();
if (("JPEG".equals(fileType)) || ("JPG".equals(fileType))) {
if ((FileTypeConstants.JPEG.equalsIgnoreCase(fileType)) || (FileTypeConstants.JPG.equalsIgnoreCase(fileType))) {
return jpgToSwfConverter;
}

View File

@ -44,7 +44,7 @@ public class Jpeg2SwfPageConverter implements PageConverter {
if (done && output.exists()) {
return true;
} else {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());

View File

@ -36,7 +36,7 @@ public class Office2PdfPageConverter {
public boolean convert(File presentationFile, File output, int page, UploadedPresentation pres,
final OfficeDocumentConverter converter){
try {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -49,7 +49,7 @@ public class Office2PdfPageConverter {
if (output.exists()) {
return true;
} else {
logData = new HashMap<String, Object>();
logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -61,7 +61,7 @@ public class Office2PdfPageConverter {
return false;
}
} catch (Exception e) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());

View File

@ -35,7 +35,7 @@ public class OfficeDocumentValidator {
// Close the resource once we finished reading it
xmlSlideShow.close();
} catch (IOException e) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -62,7 +62,7 @@ public class OfficeDocumentValidator {
.select(xmlSlideShow.getPictureData(), emfPredicate);
if (!embeddedEmfFiles.isEmpty()) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -88,7 +88,7 @@ public class OfficeDocumentValidator {
.select(xmlSlideShow.getPictureData(), tinyTileCondition);
if (!tileImage.isEmpty()) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());

View File

@ -29,7 +29,7 @@ public class OfficeDocumentValidator2 {
if (done) {
return true;
} else {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());

View File

@ -59,7 +59,7 @@ public class OfficeToPdfConversionService {
if (SupportedFileTypes.isOfficeFile(pres.getFileType())) {
boolean valid = officeDocumentValidator.isValid(pres);
if (!valid) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -73,7 +73,7 @@ public class OfficeToPdfConversionService {
}
File pdfOutput = setupOutputPdfFile(pres);
if (convertOfficeDocToPdf(pres, pdfOutput)) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -84,7 +84,7 @@ public class OfficeToPdfConversionService {
makePdfTheUploadedFileAndSetStepAsSuccess(pres, pdfOutput);
} else {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -104,7 +104,7 @@ public class OfficeToPdfConversionService {
private File setupOutputPdfFile(UploadedPresentation pres) {
File presentationFile = pres.getUploadedFile();
String filenameWithoutExt = presentationFile.getAbsolutePath().substring(0,
presentationFile.getAbsolutePath().lastIndexOf("."));
presentationFile.getAbsolutePath().lastIndexOf('.'));
return new File(filenameWithoutExt + ".pdf");
}

View File

@ -64,7 +64,7 @@ public class Pdf2SwfPageConverter implements PageConverter {
NuProcessBuilder pb = new NuProcessBuilder(Arrays.asList("timeout",
convTimeout, "/bin/sh", "-c",
SWFTOOLS_DIR + File.separatorChar + "pdf2swf" + " -vv " + AVM2SWF + " -F "
+ fontsDir + " -p " + String.valueOf(page) + " " + source + " -o "
+ fontsDir + " -p " + Integer.toString(page) + " " + source + " -o "
+ dest
+ " | egrep 'shape id|Updating font|Drawing' | sed 's/ / /g' | cut -d' ' -f 1-3 | sort | uniq -cw 15"));
@ -105,7 +105,7 @@ public class Pdf2SwfPageConverter implements PageConverter {
destFile.delete();
}
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -127,7 +127,7 @@ public class Pdf2SwfPageConverter implements PageConverter {
tempPng = File.createTempFile(basePresentationame + "-" + page, ".png");
} catch (IOException ioException) {
// We should never fall into this if the server is correctly configured
logData = new HashMap<String, Object>();
logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -187,7 +187,7 @@ public class Pdf2SwfPageConverter implements PageConverter {
long convertEnd = System.currentTimeMillis();
logData = new HashMap<String, Object>();
logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());
@ -200,7 +200,7 @@ public class Pdf2SwfPageConverter implements PageConverter {
if (doneSwf && destFile.exists()) {
return true;
} else {
logData = new HashMap<String, Object>();
logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());

View File

@ -34,7 +34,7 @@ import com.zaxxer.nuprocess.NuProcessBuilder;
public class PdfPageCounter implements PageCounter {
private static Logger log = LoggerFactory.getLogger(PdfPageCounter.class);
private int WAIT_FOR_SEC = 5;
private static int waitForSec = 5;
public int countNumberOfPages(File presentationFile) {
int numPages = 0; // total numbers of this pdf
@ -47,7 +47,7 @@ public class PdfPageCounter implements PageCounter {
NuProcess process = pdfInfo.start();
try {
process.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS);
process.waitFor(waitForSec, TimeUnit.SECONDS);
} catch (InterruptedException e) {
log.error(e.getMessage());
}

View File

@ -101,7 +101,7 @@ public class PdfToSwfSlidesGenerationService {
if (e.getExceptionType() == CountingPageException.ExceptionType.PAGE_COUNT_EXCEPTION) {
builder.messageKey(ConversionMessageConstants.PAGE_COUNT_FAILED_KEY);
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
@ -174,7 +174,6 @@ public class PdfToSwfSlidesGenerationService {
private void generateSlides(UploadedPresentation pres,
List<PdfToSwfSlide> slides,
CompletionService<PdfToSwfSlide> completionService) {
long MAXWAIT = MAX_CONVERSION_TIME * 60 /* seconds */ * 1000 /* millis */;
int slidesCompleted = 0;
long presConvStart = System.currentTimeMillis();
@ -197,7 +196,7 @@ public class PdfToSwfSlidesGenerationService {
slidesCompleted++;
notifier.sendConversionUpdateMessage(slidesCompleted, pres);
} catch (ExecutionException e) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
@ -210,7 +209,7 @@ public class PdfToSwfSlidesGenerationService {
log.error(e.getMessage());
} catch (InterruptedException e) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
@ -223,7 +222,7 @@ public class PdfToSwfSlidesGenerationService {
Thread.currentThread().interrupt();
} catch (TimeoutException e) {
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
@ -238,7 +237,7 @@ public class PdfToSwfSlidesGenerationService {
}
long pageConvEnd = System.currentTimeMillis();
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
@ -257,7 +256,7 @@ public class PdfToSwfSlidesGenerationService {
slide.generateBlankSlide();
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
@ -273,7 +272,7 @@ public class PdfToSwfSlidesGenerationService {
}
long presConvEnd = System.currentTimeMillis();
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("podId", pres.getPodId());
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
@ -288,7 +287,7 @@ public class PdfToSwfSlidesGenerationService {
private List<PdfToSwfSlide> setupSlides(UploadedPresentation pres,
int numPages) {
List<PdfToSwfSlide> slides = new ArrayList<PdfToSwfSlide>(numPages);
List<PdfToSwfSlide> slides = new ArrayList<>(numPages);
for (int page = 1; page <= numPages; page++) {
PdfToSwfSlide slide = new PdfToSwfSlide(pres, page);

View File

@ -79,7 +79,7 @@ public class SvgImageCreatorImp implements SvgImageCreator {
return true;
}
Map<String, Object> logData = new HashMap<String, Object>();
Map<String, Object> logData = new HashMap<>();
logData.put("meetingId", pres.getMeetingId());
logData.put("presId", pres.getId());
logData.put("filename", pres.getName());

View File

@ -27,27 +27,28 @@ import org.bigbluebutton.api.MeetingService;
public class RegisteredUserCleanupTimerTask {
private MeetingService service;
private ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
private long runEvery = 60000;
private MeetingService service;
private ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
private long runEvery = 60000;
public void setMeetingService(MeetingService svc) {
this.service = svc;
}
public void setMeetingService(MeetingService svc) {
this.service = svc;
}
public void start() {
scheduledThreadPool.scheduleWithFixedDelay(new CleanupTask(), 60000, runEvery, TimeUnit.MILLISECONDS);
}
public void start() {
scheduledThreadPool.scheduleWithFixedDelay(new CleanupTask(), 60000, runEvery, TimeUnit.MILLISECONDS);
}
public void stop() {
scheduledThreadPool.shutdownNow();
}
public void stop() {
scheduledThreadPool.shutdownNow();
}
public void setRunEvery(long v) {
runEvery = v;
}
public void setRunEvery(long v) {
runEvery = v;
}
private class CleanupTask implements Runnable {
private class CleanupTask implements Runnable {
@Override
public void run() {
service.purgeRegisteredUsers();
}

View File

@ -2,13 +2,14 @@ package org.bigbluebutton.api2.util
import java.io.{File, FileOutputStream, IOException}
import java.nio.channels.Channels
import java.nio.charset.StandardCharsets
import java.util
import org.bigbluebutton.api.domain.RecordingMetadata
import org.bigbluebutton.api2.RecordingServiceGW
import org.bigbluebutton.api2.domain.RecMeta
import scala.xml.{Elem, PrettyPrinter, XML}
import scala.xml.{Elem, PrettyPrinter, XML}
import scala.collection.JavaConverters._
class RecMetaXmlHelper extends RecordingServiceGW with LogHelper {
@ -16,7 +17,7 @@ class RecMetaXmlHelper extends RecordingServiceGW with LogHelper {
def loadMetadataXml(path: String): Option[Elem] = {
try {
//val xml = XML.loadFile(path)
val xml = XML.load(new java.io.InputStreamReader(new java.io.FileInputStream(path), "UTF-8"))
val xml = XML.load(new java.io.InputStreamReader(new java.io.FileInputStream(path), StandardCharsets.UTF_8.name()))
Some(xml)
} catch {
case ioe: IOException =>
@ -31,7 +32,7 @@ class RecMetaXmlHelper extends RecordingServiceGW with LogHelper {
def saveRecordingMetadata(xml: File, metadata: RecordingMetadata): Unit = {
try {
val Encoding = "UTF-8"
val Encoding = StandardCharsets.UTF_8.name()
val pp = new PrettyPrinter(80, 2)
val fos = new FileOutputStream(xml.getAbsolutePath)
val writer = Channels.newWriter(fos.getChannel(), Encoding)