From 4668cba3bf6f874bef5b2475ba3aca1462a3a65a Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Fri, 14 Jan 2022 16:39:20 -0800 Subject: [PATCH] Fix url for static --- distribution/docker-conf/app.properties | 3 +- .../exceptions/ImportUnexpectedException.java | 41 ---------- .../filter/RequestPropertiesInterceptor.java | 5 +- .../filter/SupportedUserAgent.java | 70 +---------------- .../filter/UserLocaleInterceptor.java | 4 +- .../com/wisemapping/rest/BaseController.java | 10 --- .../wisemapping/webmvc/MindmapController.java | 13 ---- .../src/main/webapp/WEB-INF/app.properties | 2 +- .../src/main/webapp/jsp/mindmapEditor.jsp | 2 +- .../src/main/webapp/jsp/mindmapViewonly.jsp | 2 +- .../src/main/webapp/jsp/reactInclude.jsp | 4 +- .../wisemapping/test/model/UserAgentTest.java | 77 ------------------- 12 files changed, 14 insertions(+), 219 deletions(-) delete mode 100755 wise-webapp/src/main/java/com/wisemapping/exceptions/ImportUnexpectedException.java delete mode 100644 wise-webapp/src/test/java/com/wisemapping/test/model/UserAgentTest.java diff --git a/distribution/docker-conf/app.properties b/distribution/docker-conf/app.properties index 9620b810..b08f02b8 100644 --- a/distribution/docker-conf/app.properties +++ b/distribution/docker-conf/app.properties @@ -101,8 +101,7 @@ admin.user = admin@wisemapping.org # Base URL where WiseMapping is deployed. By default, It will be automatically inferred. # If you are planning to put wisemapping behind an Apache using an Apache Proxy setup, you must enable this property. -#site.baseurl = http://example.com:8080/wisemapping - +site.static.js.url = /static # Site Homepage URL. This will be used as URL for homepage location. site.homepage = c/home diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/ImportUnexpectedException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/ImportUnexpectedException.java deleted file mode 100755 index b5e70d29..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/ImportUnexpectedException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Copyright [2015] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package com.wisemapping.exceptions; - -import org.jetbrains.annotations.NotNull; - -public class ImportUnexpectedException - extends WiseMappingException { - private byte[] freemindXml; - - - public ImportUnexpectedException(@NotNull Throwable e, @NotNull byte[] map) { - super("Unexpected expected error importing freemind. Please, try latter.", e); - this.freemindXml = map; - } - - public ImportUnexpectedException(String str, Exception e) { - super(str); - initCause(e); - } - - public byte[] getFreemindXml() { - return freemindXml; - } -} diff --git a/wise-webapp/src/main/java/com/wisemapping/filter/RequestPropertiesInterceptor.java b/wise-webapp/src/main/java/com/wisemapping/filter/RequestPropertiesInterceptor.java index d0a262cb..0c28736c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/RequestPropertiesInterceptor.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/RequestPropertiesInterceptor.java @@ -20,13 +20,13 @@ package com.wisemapping.filter; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import org.springframework.web.servlet.HandlerInterceptor; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter { +public class RequestPropertiesInterceptor implements HandlerInterceptor { @Value("${google.analytics.enabled}") private Boolean analyticsEnabled; @@ -54,6 +54,7 @@ public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter { @Value("${security.type}") private String securityType; + @Override public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception { request.setAttribute("google.analytics.enabled", analyticsEnabled); diff --git a/wise-webapp/src/main/java/com/wisemapping/filter/SupportedUserAgent.java b/wise-webapp/src/main/java/com/wisemapping/filter/SupportedUserAgent.java index 629c92ed..9a7bc216 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/SupportedUserAgent.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/SupportedUserAgent.java @@ -18,72 +18,6 @@ package com.wisemapping.filter; -import com.wisemapping.util.Browser; -import com.wisemapping.util.UserAgent; -import com.wisemapping.util.Version; -import org.jetbrains.annotations.NotNull; - -import javax.servlet.http.HttpServletRequest; -import java.io.Serializable; - -public class SupportedUserAgent implements Serializable { - public static final String USER_AGENT_HEADER = "User-Agent"; - transient private UserAgent userAgent; - private final String header; - - private SupportedUserAgent(@NotNull final String header) { - this.header = header; - } - - public static SupportedUserAgent create(@NotNull final HttpServletRequest request) { - return new SupportedUserAgent(request.getHeader(USER_AGENT_HEADER)); - } - - public boolean isBrowserSupported() { - -// final UserAgent userAgent = this.getUserAgent(); -// final Browser browser = userAgent.getBrowser(); -// final OperatingSystem os = userAgent.getOperatingSystem(); -// final Version version = userAgent.getBrowserVersion(); -// final int majorVersion = version != null ? Integer.parseInt(version.getMajorVersion()) : -1; -// -// boolean result = browser == Browser.FIREFOX && majorVersion >= 10; -// result = result || browser == Browser.FIREFOX2 && majorVersion >= 17; -// result = result || browser == Browser.FIREFOX3 && majorVersion >= 29; -// result = result || browser == Browser.FIREFOX4 && majorVersion >= 40; -// result = result || browser == Browser.IE8 || browser == Browser.IE9 || browser == Browser.IE11 ; -// result = result || browser == Browser.IE && majorVersion >= 8; -// result = result || browser == Browser.OPERA10 && majorVersion >= 11; -// result = result || browser == Browser.CHROME && majorVersion >= 18; -// result = result || browser == Browser.SAFARI5; -// result = result || browser == Browser.SAFARI && majorVersion >= 5; -// result = result || browser == Browser.MOBILE_SAFARI; -// result = result || os.isMobileDevice() && (os == OperatingSystem.ANDROID || os == OperatingSystem.iOS4_IPHONE); -// result = result || browser.getBrowserType() == BrowserType.ROBOT; - - return true; - } - - @NotNull - synchronized - private UserAgent getUserAgent() { - if (userAgent == null) { - userAgent = new UserAgent(header); - } - return userAgent; - } - - public boolean needsGCF() { - final UserAgent userAgent = this.getUserAgent(); - final Browser browser = userAgent.getBrowser(); - final Version version = userAgent.getBrowserVersion(); - - return (browser == Browser.IE8 || browser == Browser.IE && Integer.parseInt(version.getMajorVersion()) == 8) && !header.contains("chromeframe"); - } - - public static SupportedUserAgent create(@NotNull final String userAgent) { - return new SupportedUserAgent(userAgent); - } - - +public interface SupportedUserAgent{ + String USER_AGENT_HEADER = "User-Agent"; } diff --git a/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java b/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java index 57c903b7..88cef60c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java @@ -21,6 +21,7 @@ package com.wisemapping.filter; import com.wisemapping.model.User; import com.wisemapping.security.Utils; import org.jetbrains.annotations.NotNull; +import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import org.springframework.web.servlet.i18n.SessionLocaleResolver; @@ -29,8 +30,9 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.Locale; -public class UserLocaleInterceptor extends HandlerInterceptorAdapter { +public class UserLocaleInterceptor implements HandlerInterceptor { + @Override public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception { final HttpSession session = request.getSession(false); diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java b/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java index bec0f7e3..e2505527 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java @@ -19,7 +19,6 @@ package com.wisemapping.rest; import com.wisemapping.exceptions.ClientException; -import com.wisemapping.exceptions.ImportUnexpectedException; import com.wisemapping.exceptions.Severity; import com.wisemapping.mail.NotificationService; import com.wisemapping.model.User; @@ -64,15 +63,6 @@ public class BaseController { return new RestErrors(ex.getMessage(), Severity.WARNING); } - @ExceptionHandler(ImportUnexpectedException.class) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - @ResponseBody - public RestErrors handleImportErrors(@NotNull ImportUnexpectedException ex, @NotNull HttpServletRequest request) { - final User user = Utils.getUser(); - notificationService.reportJavaException(ex, user, new String(ex.getFreemindXml()), request); - return new RestErrors(ex.getMessage(), Severity.SEVERE); - } - @ExceptionHandler(ValidationException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public RestErrors handleValidationErrors(@NotNull ValidationException ex) { diff --git a/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java index b1d33939..88b60517 100644 --- a/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java @@ -60,19 +60,6 @@ public class MindmapController { return "mindmapPrint"; } - @RequestMapping(value = "maps/{id}/share") - public String showSharePage(@PathVariable int id, @NotNull Model model) throws MapCouldNotFoundException { - final Mindmap mindmap = findMindmap(id); - model.addAttribute("mindmap", mindmap); - return "mindmapShare"; - } - - @RequestMapping(value = "maps/{id}/sharef") - public String showSharePageFull(@PathVariable int id, @NotNull Model model) throws MapCouldNotFoundException { - showSharePage(id, model); - return "mindmapShareFull"; - } - @RequestMapping(value = "maps/") public String showListPage(@NotNull Model model) { return "mindmapList"; diff --git a/wise-webapp/src/main/webapp/WEB-INF/app.properties b/wise-webapp/src/main/webapp/WEB-INF/app.properties index 7fcf243f..9ce5f186 100755 --- a/wise-webapp/src/main/webapp/WEB-INF/app.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/app.properties @@ -99,7 +99,7 @@ admin.user = admin@wisemapping.org site.homepage = c/home # Font end static content can be deployed externally to the web app. Uncomment here and specify the url base location. -# site.static.js.url = http://www.example.com/ +site.static.js.url = /static ################################################################################## # Google Analytics Settings diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp index c0600a3e..50e8328d 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp @@ -72,7 +72,7 @@ - + diff --git a/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp b/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp index f40e536c..4204d3a5 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp @@ -34,7 +34,7 @@ : - +
diff --git a/wise-webapp/src/main/webapp/jsp/reactInclude.jsp b/wise-webapp/src/main/webapp/jsp/reactInclude.jsp index a38b3594..94c7789f 100644 --- a/wise-webapp/src/main/webapp/jsp/reactInclude.jsp +++ b/wise-webapp/src/main/webapp/jsp/reactInclude.jsp @@ -35,8 +35,8 @@
- - + + diff --git a/wise-webapp/src/test/java/com/wisemapping/test/model/UserAgentTest.java b/wise-webapp/src/test/java/com/wisemapping/test/model/UserAgentTest.java deleted file mode 100644 index e3a1d7f3..00000000 --- a/wise-webapp/src/test/java/com/wisemapping/test/model/UserAgentTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.wisemapping.test.model; - -import com.wisemapping.filter.SupportedUserAgent; -import org.testng.Assert; -import org.testng.annotations.Test; - -@Test(enabled=false) -public class UserAgentTest { - - - public void isBrowserSupported() { - - final SupportedUserAgent firefox15 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15"); - Assert.assertEquals(firefox15.isBrowserSupported(), true); - - final SupportedUserAgent firefox9 = SupportedUserAgent.create("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0a2) Gecko/20111101 Firefox/9.0a2"); - Assert.assertEquals(firefox9.isBrowserSupported(), false); - - final SupportedUserAgent chrome18 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/18.6.872.0 Safari/535.2 UNTRUSTED/1.0 3gpp-gba UNTRUSTED/1.0"); - Assert.assertEquals(chrome18.isBrowserSupported(), true); - - final SupportedUserAgent chrome21 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1"); - Assert.assertEquals(chrome21.isBrowserSupported(), true); - - final SupportedUserAgent ie10 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)"); - Assert.assertEquals(ie10.isBrowserSupported(), true); - - final SupportedUserAgent ie10_6 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0"); - Assert.assertEquals(ie10_6.isBrowserSupported(), true); - - final SupportedUserAgent ie9 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET CLR 1.1.4322; .NET4.0C; Tablet PC 2.0)"); - Assert.assertEquals(ie9.isBrowserSupported(), true); - - final SupportedUserAgent ie8 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"); - Assert.assertEquals(ie8.isBrowserSupported(), true); - - final SupportedUserAgent safari = SupportedUserAgent.create("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; da-dk) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1"); - Assert.assertEquals(safari.isBrowserSupported(), true); - - final SupportedUserAgent safari6 = SupportedUserAgent.create("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25"); - Assert.assertEquals(safari6.isBrowserSupported(), true); - - final SupportedUserAgent safariIpad = SupportedUserAgent.create("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25"); - Assert.assertEquals(safariIpad.isBrowserSupported(), true); - - final SupportedUserAgent googlebot = SupportedUserAgent.create("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"); - Assert.assertEquals(googlebot.isBrowserSupported(), true); - - final SupportedUserAgent mediapartners = SupportedUserAgent.create("Mediapartners-Google/2.1"); - Assert.assertEquals(mediapartners.isBrowserSupported(), true); - - final SupportedUserAgent ie11 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"); - Assert.assertEquals(ie11.isBrowserSupported(), true); - - final SupportedUserAgent firefox20 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20121215 Firefox/20.0 AppEngine-Google; (+http://code.google.com/appengine; appid: slubuntuk)"); - Assert.assertEquals(firefox20.isBrowserSupported(), true); - - final SupportedUserAgent firefox30 = SupportedUserAgent.create("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"); - Assert.assertEquals(firefox30.isBrowserSupported(), true); - } - - - public void isGCFRequired() { - - final SupportedUserAgent ie10 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)"); - Assert.assertEquals(ie10.needsGCF(), false); - - final SupportedUserAgent ie8 = SupportedUserAgent.create("Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"); - Assert.assertEquals(ie8.needsGCF(), true); - - final SupportedUserAgent ie8WithGCF = SupportedUserAgent.create("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; SV1) chromeframe/11.0.660.0"); - Assert.assertEquals(ie8WithGCF.needsGCF(), false); - - } - -} -