This is an automated email from the ASF dual-hosted git repository. solomax pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push: new 265f035 [OPENMEETINGS-2478] some sonar issues are addressed 265f035 is described below commit 265f035d7ce5347018c5207edbe84cd85517a13f Author: Maxim Solodovnik <solomax...@gmail.com> AuthorDate: Fri Oct 23 23:12:02 2020 +0700 [OPENMEETINGS-2478] some sonar issues are addressed --- .../openmeetings/core/remote/KurentoHandler.java | 13 ++++----- .../openmeetings/core/remote/StreamProcessor.java | 32 +++++++++------------ .../apache/openmeetings/core/sip/SipManager.java | 4 +-- .../core/util/ChatWebSocketHelper.java | 2 +- .../db/dao/basic/ConfigurationDao.java | 2 +- .../openmeetings/db/entity/basic/Client.java | 2 +- .../apache/openmeetings/db/entity/room/Room.java | 2 +- .../apache/openmeetings/db/entity/user/User.java | 6 ++-- .../java/org/apache/openmeetings/cli/Admin.java | 2 +- .../openmeetings/service/mail/EmailManager.java | 2 +- .../service/room/InvitationManager.java | 2 +- .../openmeetings/util/OMContextListener.java | 2 +- .../org/apache/openmeetings/util/OmFileHelper.java | 33 +++++++++++----------- .../java/org/apache/openmeetings/util/Version.java | 2 +- .../openmeetings/util/process/ProcessHelper.java | 12 ++++---- .../apache/openmeetings/web/app/Application.java | 9 +----- .../org/apache/openmeetings/web/common/main.js | 2 +- .../web/user/calendar/calendar-functions.js | 3 +- .../web/user/profile/WidgetsPanel.java | 1 - 19 files changed, 60 insertions(+), 73 deletions(-) diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java index a43f62c..21ff59e 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java @@ -92,7 +92,7 @@ public class KurentoHandler { private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1"; private final ScheduledExecutorService kmsRecheckScheduler = Executors.newScheduledThreadPool(1); public static final String KURENTO_TYPE = "kurento"; - private static int FLOWOUT_TIMEOUT_SEC = 5; + private static int flowoutTimeout = 5; @Value("${kurento.ws.url}") private String kurentoWsUrl; @Value("${kurento.turn.url}") @@ -309,12 +309,11 @@ public class KurentoHandler { } KRoom getRoom(Long roomId) { - KRoom room = rooms.computeIfAbsent(roomId, k -> { + return rooms.computeIfAbsent(roomId, k -> { log.debug("Room {} does not exist. Will create now!", roomId); Room r = roomDao.get(roomId); return new KRoom(this, r); }); - return room; } public Collection<KRoom> getRooms() { @@ -410,12 +409,12 @@ public class KurentoHandler { } static int getFlowoutTimeout() { - return FLOWOUT_TIMEOUT_SEC; + return flowoutTimeout; } @Value("${kurento.flowout.timeout}") private void setFlowoutTimeout(int timeout) { - FLOWOUT_TIMEOUT_SEC = timeout; + flowoutTimeout = timeout; } @Value("${kurento.ignored.kuids}") @@ -465,7 +464,7 @@ public class KurentoHandler { } } } - } catch (Throwable e) { + } catch (Exception e) { log.warn("Invalid MediaPipeline {} detected, will be dropped, tags: {}", pipe.getId(), tags); pipe.release(); } @@ -504,7 +503,7 @@ public class KurentoHandler { if (stream != null && stream.contains(tags.get("uid"))) { return; } - } catch (Throwable e) { + } catch (Exception e) { log.warn("Kurento::ObjectCreated -> Invalid Endpoint {} detected, will be dropped, tags: {}", point.getId(), tags); point.release(); } diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java index 5e4635a..05e0a9b 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java @@ -307,31 +307,27 @@ public class StreamProcessor implements IStreamProcessor { return; } KRoom room = kHandler.getRoom(roomId); - if (room.isSharing()) { - if (cm.streamByRoom(roomId) + if (room.isSharing() && cm.streamByRoom(roomId) .flatMap(c -> c.getStreams().stream()) .filter(sd -> StreamType.SCREEN == sd.getType()) .findAny() .isEmpty()) - { - log.info("No more screen streams in the room, stopping sharing"); - room.stopSharing(); - if (Room.Type.INTERVIEW != room.getType() && room.isRecording()) { - log.info("No more screen streams in the non-interview room, stopping recording"); - room.stopRecording(null); - } - } - } - if (room.isRecording()) { - if (cm.streamByRoom(roomId) - .flatMap(c -> c.getStreams().stream()) - .findAny() - .isEmpty()) - { - log.info("No more streams in the room, stopping recording"); + { + log.info("No more screen streams in the room, stopping sharing"); + room.stopSharing(); + if (Room.Type.INTERVIEW != room.getType() && room.isRecording()) { + log.info("No more screen streams in the non-interview room, stopping recording"); room.stopRecording(null); } } + if (room.isRecording() && cm.streamByRoom(roomId) + .flatMap(c -> c.getStreams().stream()) + .findAny() + .isEmpty()) + { + log.info("No more streams in the room, stopping recording"); + room.stopRecording(null); + } } // Sharing diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/sip/SipManager.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/sip/SipManager.java index 715718a..167b800 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/sip/SipManager.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/sip/SipManager.java @@ -197,7 +197,7 @@ public class SipManager implements ISipManager, SipListenerExt { con.login(); ManagerResponse r = con.sendAction(action); if (r != null) { - log.debug(r.toString()); + log.debug("{}", r); } return (r instanceof ManagerError) ? null : r; } catch (Exception e) { @@ -222,7 +222,7 @@ public class SipManager implements ISipManager, SipListenerExt { con.login("on"); ResponseEvents r = con.sendEventGeneratingAction(action); if (r != null) { - log.debug(r.getResponse().toString()); + log.debug("{}", r.getResponse()); } return (r == null || r.getResponse() instanceof ManagerError) ? null : r; } catch (Exception e) { diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/ChatWebSocketHelper.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/ChatWebSocketHelper.java index 9f733f2..33d3a8e 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/ChatWebSocketHelper.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/ChatWebSocketHelper.java @@ -69,7 +69,7 @@ public class ChatWebSocketHelper { JSONArray arr = new JSONArray(); for (ChatMessage m : list) { String smsg = m.getMessage(); - smsg = smsg == null ? smsg : " " + smsg.replaceAll(" ", " ") + " "; + smsg = smsg == null ? smsg : " " + smsg.replace(" ", " ") + " "; JSONObject from = new JSONObject() .put("id", m.getFromUser().getId()) .put("displayName", m.getFromName()) diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java index 3561fdb..709ba5d 100644 --- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java +++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java @@ -583,7 +583,7 @@ public class ConfigurationDao implements IDataProviderDao<Configuration> { getLine(sb, "CSP headers are DISABLED", ' '); getLine(sb, "Disabling CSP can lead to XSS attacks! Use this mode only if you must!", ' '); getLine(sb, "", '#'); - log.warn(sb.toString()); + log.warn("{}", sb); WebApplication.get().getCspSettings().blocking().disabled(); return; } diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java index 0304452..c069f14 100644 --- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java +++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java @@ -114,7 +114,7 @@ public class Client implements IDataProviderEntity, IWsClient { } public boolean sameUserId(Long userId) { - return getUserId() == null ? false : getUserId().equals(userId); + return getUserId() != null && getUserId().equals(userId); } public String getPictureUri() { diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/Room.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/Room.java index e9e021c..bd222a8 100644 --- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/Room.java +++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/Room.java @@ -218,11 +218,11 @@ public class Room extends HistoricalEntity { private String externalId; @XmlElement(name = "externalType", required = false) - @Deprecated(since = "5.0") @Transient /** * @deprecated External group should be used instead */ + @Deprecated(since = "5.0") private String externalType; @Column(name = "demo_room", nullable = false) diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java index e225a32..e1ff983 100644 --- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java +++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java @@ -291,11 +291,11 @@ public class User extends HistoricalEntity { private String externalId; @XmlElement(name = "externalUserType", required = false) - @Deprecated(since = "5.0") @Transient /** * @deprecated External group should be used instead */ + @Deprecated(since = "5.0") private String externalType; /** @@ -550,18 +550,18 @@ public class User extends HistoricalEntity { return extType.isPresent() ? extType.get() : null; } - @Deprecated(since = "5.0") /** * @deprecated External group should be used instead */ + @Deprecated(since = "5.0") public String getExternalType() { return externalType; } - @Deprecated(since = "5.0") /** * @deprecated External group should be used instead */ + @Deprecated(since = "5.0") public void setExternalType(String externalType) { this.externalType = externalType; } diff --git a/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java b/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java index 05d603c..e653c2a 100644 --- a/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java +++ b/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java @@ -121,7 +121,7 @@ public class Admin { } private static void doLog(CharSequence msg) { - log.info(msg.toString()); + log.info("{}", msg); System.out.println(msg); } diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/EmailManager.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/EmailManager.java index d1d5bde..593c7c7 100644 --- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/EmailManager.java +++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/mail/EmailManager.java @@ -61,7 +61,7 @@ public class EmailManager { * @param sendEmailWithVerficationCode - if email with verification code should be sent * @param langId - language Id */ - public void sendMail(String username, String email, String hash, Boolean sendEmailWithVerficationCode, Long langId) { + public void sendMail(String username, String email, String hash, boolean sendEmailWithVerficationCode, Long langId) { log.debug("sendMail:: username = {}, email = {}", username, email); ensureApplication(langId != null ? langId : getDefaultLang()); diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java index 159c6ea..44e00b6 100644 --- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java +++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/room/InvitationManager.java @@ -129,7 +129,7 @@ public class InvitationManager implements IInvitationManager { .setSequence(0) .build(); - log.debug(handler.toString()); + log.debug("IcalHandler {}", handler); mailHandler.send(new MailMessage(email, replyToEmail, subject, template, handler)); } else { mailHandler.send(email, replyToEmail, subject, template); diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OMContextListener.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OMContextListener.java index aff5364..ef6de1e 100644 --- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OMContextListener.java +++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OMContextListener.java @@ -66,7 +66,7 @@ public class OMContextListener implements ServletContextListener { } private static String pathToName(ServletContextEvent event) { - String contextName = event.getServletContext().getContextPath().replaceAll("/", ""); + String contextName = event.getServletContext().getContextPath().replace("/", ""); if ("".equals(contextName)) { contextName = "root"; } diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OmFileHelper.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OmFileHelper.java index 7f2f161..5d2d6df 100644 --- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OmFileHelper.java +++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OmFileHelper.java @@ -40,8 +40,6 @@ public class OmFileHelper { /** * This variable needs to point to the openmeetings webapp directory */ - private static File OM_HOME = null; - private static File DATA_HOME = null; private static final String DATA_DIR = "data"; private static final String UPLOAD_DIR = "upload"; private static final String PUBLIC_DIR = "public"; @@ -96,17 +94,20 @@ public class OmFileHelper { public static final Long SIP_USER_ID = -1L; public static final String SIP_PICTURE_URI = "phone.png"; + private static File omHome = null; + private static File dataHome = null; + private OmFileHelper() {} public static void setOmHome(File home) { - OM_HOME = home; + omHome = home; final String dataDir = System.getProperty("DATA_DIR"); if (Strings.isEmpty(dataDir)) { - DATA_HOME = new File(OM_HOME, DATA_DIR); + dataHome = new File(omHome, DATA_DIR); } else { - DATA_HOME = new File(dataDir); + dataHome = new File(dataDir); } - log.info("Using file locations - OM_HOME: {} DATA_DIR: {}", OM_HOME, DATA_HOME); + log.info("Using file locations - omHome: {} DATA_DIR: {}", omHome, dataHome); } public static void setOmHome(String home) { @@ -114,7 +115,7 @@ public class OmFileHelper { } public static File getOmHome() { - return OM_HOME; + return omHome; } private static File getDir(File parent, String name) { @@ -126,7 +127,7 @@ public class OmFileHelper { } public static File getUploadDir() { - return new File(DATA_HOME, UPLOAD_DIR); + return new File(dataHome, UPLOAD_DIR); } public static File getUploadFilesDir() { @@ -205,7 +206,7 @@ public class OmFileHelper { } public static File getStreamsDir() { - return getDir(DATA_HOME, STREAMS_DIR); + return getDir(dataHome, STREAMS_DIR); } public static File getStreamsHibernateDir() { @@ -245,11 +246,11 @@ public class OmFileHelper { } public static File getLanguagesDir() { - return new File(OM_HOME, LANGUAGES_DIR); + return new File(omHome, LANGUAGES_DIR); } public static File getPublicDir() { - return new File(OM_HOME, PUBLIC_DIR); + return new File(omHome, PUBLIC_DIR); } public static File getPublicClipartsDir() { @@ -261,7 +262,7 @@ public class OmFileHelper { } public static File getWebinfDir() { - return new File(OM_HOME, WEB_INF_DIR); + return new File(omHome, WEB_INF_DIR); } public static File getPersistence() { @@ -273,7 +274,7 @@ public class OmFileHelper { } public static File getLdapConf(String name) { - return new File(new File(DATA_HOME, CONF_DIR), name); + return new File(new File(dataHome, CONF_DIR), name); } public static void loadLdapConf(String name, Properties config) { @@ -291,15 +292,15 @@ public class OmFileHelper { } public static File getScreenSharingDir() { - return new File(OM_HOME, SCREENSHARING_DIR); + return new File(omHome, SCREENSHARING_DIR); } public static File getImagesDir() { - return new File(OM_HOME, IMAGES_DIR); + return new File(omHome, IMAGES_DIR); } public static File getCssDir() { - return new File(OM_HOME, CSS_DIR); + return new File(omHome, CSS_DIR); } public static File getCssImagesDir() { diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/Version.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/Version.java index 4cd3a39..f8768f1 100644 --- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/Version.java +++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/Version.java @@ -79,6 +79,6 @@ public class Version { getLine(sb, getVersion() + " " + getRevision() + " " + getBuildDate(), ' '); getLine(sb, "and ready to use", ' '); getLine(sb, "", '#'); - log.debug(sb.toString()); + log.debug("{}", sb); } } diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java index 8b6f7bd..b4db748 100644 --- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java +++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java @@ -18,8 +18,9 @@ */ package org.apache.openmeetings.util.process; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.apache.openmeetings.util.CalendarHelper.formatMillis; +import static org.apache.openmeetings.util.OpenmeetingsVariables.getExtProcessTtl; import java.io.BufferedReader; import java.io.IOException; @@ -29,9 +30,8 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.openmeetings.util.CalendarHelper.formatMillis; -import static org.apache.openmeetings.util.OpenmeetingsVariables.getExtProcessTtl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ProcessHelper { public static final Logger log = LoggerFactory.getLogger(ProcessHelper.class); @@ -56,7 +56,7 @@ public class ProcessHelper { line = br.readLine(); } } catch (IOException ioexception) { - return; + // no-op } } diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java index 13e0c97..8adf62f 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java @@ -106,9 +106,7 @@ import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication; import org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler; import org.apache.wicket.core.request.handler.ListenerRequestHandler; import org.apache.wicket.core.request.mapper.MountedMapper; -import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.filter.FilteringHeaderResponse; -import org.apache.wicket.markup.html.IHeaderResponseDecorator; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.pageStore.IPageStore; import org.apache.wicket.pageStore.SerializingPageStore; @@ -287,12 +285,7 @@ public class Application extends AuthenticatedWebApplication implements IApplica if (sc != null) { sc.setDefaultMaxSessionIdleTimeout(60 * 1000L); // should be enough, should it be configurable? } - getHeaderResponseDecorators().add(new IHeaderResponseDecorator() { - @Override - public IHeaderResponse decorate(IHeaderResponse response) { - return new FilteringHeaderResponse(response); - } - }); + getHeaderResponseDecorators().add(response -> new FilteringHeaderResponse(response)); super.init(); final IBootstrapSettings settings = new BootstrapSettings(); settings.setThemeProvider(new BootswatchThemeProvider(BootswatchTheme.Sandstone));//FIXME TODO new SingleThemeProvider(new MaterialDesignTheme()) diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/main.js b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/main.js index b8778d5..6faf49c 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/main.js +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/main.js @@ -23,7 +23,7 @@ var Settings = (function() { }; })(); var OmUtil = (function() { - let options, errs, alertId = 0; + let options, alertId = 0; const self = {}; function _init(_options) { diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/calendar-functions.js b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/calendar-functions.js index 0354425..24ff8ba 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/calendar-functions.js +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/calendar-functions.js @@ -1,8 +1,7 @@ /* Licensed under the Apache License, Version 2.0 (the "License") http://www.apache.org/licenses/LICENSE-2.0 */ function onOmGotoClick() { const gotoBtn = $('#calendar .fc-gotoBtn-button'); - let selected = null - , gotoSpan = gotoBtn.parent().find('.goto-span'); + let gotoSpan = gotoBtn.parent().find('.goto-span'); if (gotoSpan.length < 1) { gotoBtn.parent().append($('<span class="goto-span"><span/></span>')); } diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/profile/WidgetsPanel.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/profile/WidgetsPanel.java index 704907e..0e80f38 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/profile/WidgetsPanel.java +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/profile/WidgetsPanel.java @@ -73,7 +73,6 @@ public class WidgetsPanel extends UserBasePanel { } if (!hasAdminLevel(getRights()) && AdminWidget.class.getCanonicalName().equals(wd.getWidgetClassName())) { i.remove(); - continue; } } add(new ListView<>("widgets", widgets) {