diff --git a/wise-api/src/main/java/com/wisemapping/rest/BaseController.java b/wise-api/src/main/java/com/wisemapping/rest/BaseController.java index 5ebc93fc..eccea8a0 100644 --- a/wise-api/src/main/java/com/wisemapping/rest/BaseController.java +++ b/wise-api/src/main/java/com/wisemapping/rest/BaseController.java @@ -50,7 +50,7 @@ public class BaseController { private ResourceBundleMessageSource messageSource; @Autowired - ServletContext context; + private ServletContext context; @Autowired private NotificationService notificationService; @@ -125,7 +125,6 @@ public class BaseController { public RestErrors handleServerErrors(@NotNull Exception ex, @NotNull HttpServletRequest request) { logger.error(ex.getMessage(), ex); final Account user = Utils.getUser(false); - notificationService.reportJavaException(ex, user, request); return new RestErrors(ex.getMessage(), Severity.SEVERE); } diff --git a/wise-api/src/main/java/com/wisemapping/service/NotificationService.java b/wise-api/src/main/java/com/wisemapping/service/NotificationService.java index 262e96c1..bbc17817 100644 --- a/wise-api/src/main/java/com/wisemapping/service/NotificationService.java +++ b/wise-api/src/main/java/com/wisemapping/service/NotificationService.java @@ -18,11 +18,9 @@ package com.wisemapping.service; +import com.wisemapping.model.Account; import com.wisemapping.model.Collaboration; import com.wisemapping.model.Mindmap; -import com.wisemapping.model.Account; -import com.wisemapping.rest.model.RestLogItem; -import org.apache.commons.lang.StringEscapeUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -31,18 +29,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.support.ResourceBundleMessageSource; - -import jakarta.servlet.http.HttpServletRequest; import org.springframework.stereotype.Service; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Locale; import java.util.Map; -import java.util.stream.Collectors; @Service final public class NotificationService { @@ -53,7 +44,7 @@ final public class NotificationService { @Autowired private MailerService mailerService; - @Value("${site.baseurl:http://localhost:8080/}") + @Value("${app.site.baseurl:http://localhost:8080/}") private String baseUrl; public void newCollaboration(@NotNull Collaboration collaboration, @NotNull Mindmap mindmap, @NotNull Account user, @Nullable String message) { @@ -145,10 +136,6 @@ final public class NotificationService { } } - public void setMailer(MailerService mailerService) { - this.mailerService = mailerService; - } - public void activateAccount(@NotNull Account user) { final Map model = new HashMap<>(); @@ -170,64 +157,6 @@ final public class NotificationService { // } } - public void reportJavascriptException(@Nullable Mindmap mindmap, @Nullable Account user, @NotNull RestLogItem errorItem, @NotNull HttpServletRequest request) { - - final Map summary = new HashMap<>(); - summary.put("JS-MSG", errorItem.getJsErrorMsg()); - summary.put("JS-STACK", errorItem.getJsStack()); - - String mindmapXML = ""; - try { - mindmapXML = StringEscapeUtils.escapeXml(mindmap == null ? "map not found" : mindmap.getXmlStr()); - } catch (UnsupportedEncodingException e) { - // Ignore ... - } - summary.put("mapId", Integer.toString(mindmap.getId())); - summary.put("mapTitle", mindmap.getTitle()); - - logError(summary, user, request); - logger.error("Unexpected editor mindmap => " + mindmapXML); - logger.error("Unexpected editor JS Stack => " + errorItem.getJsErrorMsg() + "-" + errorItem.getJsStack()); - } - - private void logError(@NotNull Map model, @Nullable Account user, @NotNull HttpServletRequest request) { - model.put("fullName", (user != null ? user.getFullName() : "'anonymous'")); - final String userEmail = user != null ? user.getEmail() : "'anonymous'"; - - model.put("email", userEmail); - model.put("userAgent", request.getHeader("User-Agent")); - model.put("server", request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()); - model.put("requestURI", request.getRequestURI()); - model.put("method", request.getMethod()); - model.put("remoteAddress", request.getRemoteAddr()); - - String errorAsString = model.keySet().stream() - .map(key -> key + "=" + model.get(key)) - .collect(Collectors.joining(", ", "{", "}")); - - logger.error("Unexpected editor info => " + errorAsString); - } - - public void reportJavaException(@NotNull Throwable exception, @Nullable Account user, @NotNull HttpServletRequest request) { - final Map model = new HashMap<>(); - model.put("errorMsg", stackTraceToString(exception)); - - logError(model, user, request); - } - - public String stackTraceToString(@NotNull Throwable e) { - String retValue = ""; - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - try (sw; pw) { - e.printStackTrace(pw); - retValue = sw.toString(); - } catch (IOException ioException) { - ioException.printStackTrace(); - } - return retValue; - } - public String getBaseUrl() { return baseUrl; } diff --git a/wise-api/src/main/resources/application.yml b/wise-api/src/main/resources/application.yml index 6b613378..d98339d3 100644 --- a/wise-api/src/main/resources/application.yml +++ b/wise-api/src/main/resources/application.yml @@ -54,6 +54,8 @@ logging: # Application Configuration. app: + site: + baseurl: https://localhost:8080 api: http-basic-enabled: false jwt: @@ -81,26 +83,13 @@ app: confirmUrl: https://oauth2.googleapis.com/token userinfoUrl: https://www:googleapis.com/oauth2/v3/userinfo url: https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=${app.security.oauth2.google.callbackUrl}&prompt=consent&response_type=code&client_id=${app.security.oauth2.google.clientId}&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&access_type=offline&state=wisemapping&include_granted_scopes=true - # accounts: # exclusion: # domain: - google: - ads: - enabled: false - analytics: - account: UA-XXXX - enabled: false recaptcha2: enabled: true secretKey: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe siteKey: 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI -site: - homepage: c/login - static: - js: - url: /static -