From e38c1bcc7c02ed59c24e45d3971b39ba94955687 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 14 Mar 2022 00:09:47 -0300 Subject: [PATCH 01/25] Bump up to 5.0.10 --- pom.xml | 4 ++-- wise-ui/pom.xml | 2 +- wise-webapp/pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 3d273c7f..3deb0a34 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> - 5.0.9 + 5.0.10-SNAPSHOT ${project.basedir}/wise-webapps @@ -16,7 +16,7 @@ org.wisemapping wisemapping WiseMapping Project - 5.0.9 + 5.0.10-SNAPSHOT pom diff --git a/wise-ui/pom.xml b/wise-ui/pom.xml index 971c1096..63876504 100644 --- a/wise-ui/pom.xml +++ b/wise-ui/pom.xml @@ -12,7 +12,7 @@ org.wisemapping wisemapping ../pom.xml - 5.0.9 + 5.0.10-SNAPSHOT diff --git a/wise-webapp/pom.xml b/wise-webapp/pom.xml index 781a26e7..5e0c0f0a 100644 --- a/wise-webapp/pom.xml +++ b/wise-webapp/pom.xml @@ -9,7 +9,7 @@ org.wisemapping wisemapping ../pom.xml - 5.0.9 + 5.0.10-SNAPSHOT From 7ca5bf716fcebef387f0e4272f989f3135f65f5a Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 14 Mar 2022 15:04:15 -0300 Subject: [PATCH 02/25] Improve message on lack of permissions to perform map operations --- .../wisemapping/rest/MindmapController.java | 18 +++++++++++------- .../wisemapping/webmvc/MindmapController.java | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index d8d8222d..56857910 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -18,10 +18,7 @@ package com.wisemapping.rest; -import com.wisemapping.exceptions.LabelCouldNotFoundException; -import com.wisemapping.exceptions.MapCouldNotFoundException; -import com.wisemapping.exceptions.SessionExpiredException; -import com.wisemapping.exceptions.WiseMappingException; +import com.wisemapping.exceptions.*; import com.wisemapping.model.*; import com.wisemapping.rest.model.*; import com.wisemapping.security.Utils; @@ -249,8 +246,15 @@ public class MindmapController extends BaseController { } @NotNull - private Mindmap findMindmapById(int id) throws MapCouldNotFoundException { - Mindmap result = mindmapService.findMindmapById(id); + private Mindmap findMindmapById(int id) throws MapCouldNotFoundException, AccessDeniedSecurityException { + // Has enough permissions ? + final User user = Utils.getUser(); + if (!mindmapService.hasPermissions(user, id, CollaborationRole.VIEWER)) { + throw new AccessDeniedSecurityException("No enough permissions to open map. Id:" + id); + } + + // Does the map exists ? + final Mindmap result = mindmapService.findMindmapById(id); if (result == null) { throw new MapCouldNotFoundException("Map could not be found. Id:" + id); } @@ -489,7 +493,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/lock", consumes = {"text/plain"}, produces = {"application/json", "application/xml"}) @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void updateMapLock(@RequestBody String value, @PathVariable int id) throws IOException, WiseMappingException { + public void updateMapLock(@RequestBody String value, @PathVariable int id) throws WiseMappingException { final User user = Utils.getUser(); final LockManager lockManager = mindmapService.getLockManager(); final Mindmap mindmap = findMindmapById(id); 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 e38dc9c5..77e2b75e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java @@ -176,7 +176,7 @@ public class MindmapController { private MindMapBean findMindmapBean(int mapId) throws MapCouldNotFoundException, AccessDeniedSecurityException { final User user = Utils.getUser(); if (!mindmapService.hasPermissions(user, mapId, CollaborationRole.VIEWER)) { - throw new AccessDeniedSecurityException("No enough permissions to open map with id" + mapId); + throw new AccessDeniedSecurityException("No enough permissions to open map with id " + mapId); } final Mindmap mindmap = findMindmap(mapId); From c769a5fbe7f1f5c1fc1c212604faa6a60c52214d Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 14 Mar 2022 15:08:31 -0300 Subject: [PATCH 03/25] Fix compilation --- .../com/wisemapping/rest/MindmapController.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 56857910..0ea8a1be 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -281,7 +281,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.POST, value = "/maps/{id}/collabs/", consumes = {"application/json", "application/xml"}, produces = {"application/json", "application/xml"}) @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException { + public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException { final Mindmap mindMap = findMindmapById(id); // Only owner can change collaborators... @@ -328,7 +328,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs/", consumes = {"application/json", "application/xml"}, produces = {"application/json", "application/xml"}) @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void addCollab(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException { + public void addCollab(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException { final Mindmap mindMap = findMindmapById(id); // Only owner can change collaborators... @@ -389,7 +389,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/collabs", produces = {"application/json", "application/xml"}) - public RestCollaborationList retrieveList(@PathVariable int id) throws MapCouldNotFoundException { + public RestCollaborationList retrieveList(@PathVariable int id) throws MapCouldNotFoundException, AccessDeniedSecurityException { final Mindmap mindMap = findMindmapById(id); final Set collaborations = mindMap.getCollaborations(); @@ -407,14 +407,9 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/description", consumes = {"text/plain"}, produces = {"application/json", "application/xml"}) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void updateDescription(@RequestBody String description, @PathVariable int id) throws WiseMappingException { - - final Mindmap mindMap = findMindmapById(id); - final User user = Utils.getUser(); - - // Update map ... final Mindmap mindmap = findMindmapById(id); mindmap.setDescription(description); - mindmapService.updateMindmap(mindMap, false); + mindmapService.updateMindmap(mindmap, false); } @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/publish", consumes = {"text/plain"}, produces = {"application/json", "application/xml"}) From 9d35aa82791fe928144d791e74127503701043cc Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 14 Mar 2022 22:56:02 -0300 Subject: [PATCH 04/25] Fix resource in Chinese --- wise-webapp/src/main/resources/messages_zh.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wise-webapp/src/main/resources/messages_zh.properties b/wise-webapp/src/main/resources/messages_zh.properties index d4b5bf90..4c3d54d7 100644 --- a/wise-webapp/src/main/resources/messages_zh.properties +++ b/wise-webapp/src/main/resources/messages_zh.properties @@ -36,7 +36,7 @@ TUTORIAL.HOW_TO_START = 如何开始? TUTORIAL.FONT_COLOR = 颜色 TUTORIAL.FONT_STYLE = 样式 TUTORIAL.FONT_TYPE = 类型 -TUTORIAL.SAMPLE_NOTE = 这是一个简单的注释\!。 +TUTORIAL.SAMPLE_NOTE = 这是一个简单的注释! CAPTCHA_LOADING_ERROR = 无法加载ReCaptcha。您必须能够访问Google ReCaptcha服务。 ACCESS_HAS_BEEN_REVOKED = 您对该脑图的访问权限已被撤销。联系脑图所有人。 MAP_CAN_NOT_BE_FOUND = 找不到该脑图,应该是被删除了。 @@ -47,12 +47,12 @@ MINDMAP_LOCKED = 脑图正在被{0}<{1}>编辑。脑图以只读模式打开。 MINDMAP_IS_LOCKED = 脑图被锁定编辑。 # Confirmed RESET_PASSWORD_INVALID_EMAIL = 提供的电子邮件不是有效的用户账号。请使用有效的电子邮件重试。 -TRY_WELCOME = This edition space showcases some of the mindmap editor capabilities \!.此编辑区域展示了一些思维导图编辑器的功能\!。 +TRY_WELCOME = 此编辑区域展示了一些思维导图编辑器的功能! UNEXPECTED_ERROR_DETAILS = 处理请求时遇到意外错误。 NO_ENOUGH_PERMISSIONS=无法打开思维导图。 NO_ENOUGH_PERMISSIONS_DETAILS=您没有足够的权限查看此脑图。此脑图已更改为私有或被删除。 CAPTCHA_TIMEOUT_OUT_DUPLICATE=请刷新页面,然后重试。 -CAPTCHA_INVALID_INPUT_RESPONSE="输入无效,刷新页面后重试。 +CAPTCHA_INVALID_INPUT_RESPONSE=输入无效,刷新页面后重试。 MINDMAP_EMPTY_ERROR=思维导图不能为空。 INVALID_MINDMAP_FORMAT=思维导图格式无效。 TOO_BIG_MINDMAP=你已经达到了一张思维导图中500个主题的限制。 \ No newline at end of file From 4cab5299c430a525e4ba5430276f7ac3b842772e Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 14 Mar 2022 23:33:16 -0300 Subject: [PATCH 05/25] Change mapping of securiy exceptions. --- wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml | 5 ++--- wise-webapp/src/main/webapp/css/error.css | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml index 62da4794..13d7ef64 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml @@ -29,14 +29,13 @@ - securityError + securityError - - 200 + 404 diff --git a/wise-webapp/src/main/webapp/css/error.css b/wise-webapp/src/main/webapp/css/error.css index 34fe7a9f..4148f9b0 100644 --- a/wise-webapp/src/main/webapp/css/error.css +++ b/wise-webapp/src/main/webapp/css/error.css @@ -1,5 +1,3 @@ -@import "compatibility.css"; - div#errorContainer { font-family:Helvetica; display: flex; From a9d091a1871b1b654459d92b676bf1257ed90045 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 15 Mar 2022 10:30:18 -0300 Subject: [PATCH 06/25] Improve error handle on security errors. --- .../AccessDeniedSecurityException.java | 46 +++++++------- .../mail/NotifyingExceptionResolver.java | 43 ------------- .../wisemapping/rest/MindmapController.java | 2 +- .../wisemapping/service/LockManagerImpl.java | 60 +++++++++---------- .../wisemapping/webmvc/MindmapController.java | 2 +- .../webapp/WEB-INF/wisemapping-servlet.xml | 18 +++--- 6 files changed, 64 insertions(+), 107 deletions(-) delete mode 100644 wise-webapp/src/main/java/com/wisemapping/mail/NotifyingExceptionResolver.java diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/AccessDeniedSecurityException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/AccessDeniedSecurityException.java index 33e02186..d1e932e3 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/AccessDeniedSecurityException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/AccessDeniedSecurityException.java @@ -1,33 +1,37 @@ /* -* 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. -*/ + * 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 com.wisemapping.model.Collaborator; +import com.wisemapping.model.User; import org.jetbrains.annotations.NotNull; public class AccessDeniedSecurityException - extends ClientException -{ + extends ClientException { public static final String MSG_KEY = "ACCESS_HAS_BEEN_REVOKED"; - public AccessDeniedSecurityException(@NotNull String msg) - { - super(msg,Severity.FATAL); + public AccessDeniedSecurityException(@NotNull String msg) { + super(msg, Severity.FATAL); + } + + public AccessDeniedSecurityException(@NotNull long mapId, Collaborator user) { + super("No enough permissions to access map. Id: " + mapId + ", User: " + user, Severity.FATAL); } @NotNull diff --git a/wise-webapp/src/main/java/com/wisemapping/mail/NotifyingExceptionResolver.java b/wise-webapp/src/main/java/com/wisemapping/mail/NotifyingExceptionResolver.java deleted file mode 100644 index cecf9c86..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/mail/NotifyingExceptionResolver.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.wisemapping.mail; - -import com.wisemapping.model.User; -import com.wisemapping.security.Utils; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.HashSet; -import java.util.Set; - -public class NotifyingExceptionResolver extends SimpleMappingExceptionResolver { - - final private Logger logger = Logger.getLogger(NotifyingExceptionResolver.class); - private Set exclude = new HashSet(); - private NotificationService notificationService; - - @Override - protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { - if (!exclude.contains(ex.getClass().getName())) { - logger.error("An Exception has occurred in the application", ex); - sendNotification(ex, request); - } - - return super.doResolveException(request, response, handler, ex); - } - - private void sendNotification(@NotNull Exception ex, @NotNull HttpServletRequest request) { - final User user = Utils.getUser(false); - notificationService.reportJavaException(ex, user, request); - } - - public void setExclude(final Set exclude) { - this.exclude = exclude; - } - - public void setNotificationService(NotificationService notificationService) { - this.notificationService = notificationService; - } -} diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 0ea8a1be..7f90bdac 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -250,7 +250,7 @@ public class MindmapController extends BaseController { // Has enough permissions ? final User user = Utils.getUser(); if (!mindmapService.hasPermissions(user, id, CollaborationRole.VIEWER)) { - throw new AccessDeniedSecurityException("No enough permissions to open map. Id:" + id); + throw new AccessDeniedSecurityException(id, user); } // Does the map exists ? diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java index 6f703484..f59012ec 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java @@ -1,20 +1,20 @@ /* -* 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. -*/ + * 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.service; @@ -31,20 +31,20 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; /* -* Refresh page should not lost the lock. -* En caso que no sea posible grabar por que se perdio el lock, usar mensaje de error para explicar el por que... -* Mensaje modal explicando que el mapa esta siendo editado, por eso no es posible edilarlo.... -* Internacionalizacion de los mensaje ... -* Logout limpiar las sessiones ... -* -* Casos: -* - Usuario pierde el lock: -* - Y grabo con la misma sessions y el timestap ok. -* - Y grabo con la misma session y el timestap esta mal + * Refresh page should not lost the lock. + * En caso que no sea posible grabar por que se perdio el lock, usar mensaje de error para explicar el por que... + * Mensaje modal explicando que el mapa esta siendo editado, por eso no es posible edilarlo.... + * Internacionalizacion de los mensaje ... + * Logout limpiar las sessiones ... + * + * Casos: + * - Usuario pierde el lock: + * - Y grabo con la misma sessions y el timestap ok. + * - Y grabo con la misma session y el timestap esta mal * - Y grabo con distinta sessions * - -* - Usuario pierde el lock, pero intenta grabar camio -*/ + * - Usuario pierde el lock, pero intenta grabar camio + */ class LockManagerImpl implements LockManager { public static final int ONE_MINUTE_MILLISECONDS = 1000 * 60; @@ -97,7 +97,7 @@ class LockManagerImpl implements LockManager { } if (!mindmap.hasPermissions(user, CollaborationRole.EDITOR)) { - throw new AccessDeniedSecurityException("Invalid lock, this should not happen"); + throw new AccessDeniedSecurityException(mindmap.getId(), user); } this.unlock(mindmap.getId()); @@ -132,7 +132,7 @@ class LockManagerImpl implements LockManager { } if (!mindmap.hasPermissions(user, CollaborationRole.EDITOR)) { - throw new AccessDeniedSecurityException("Invalid lock, this should not happen"); + throw new AccessDeniedSecurityException(mindmap.getId(), user); } LockInfo result = lockInfoByMapId.get(mindmap.getId()); 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 77e2b75e..073ee245 100644 --- a/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java @@ -176,7 +176,7 @@ public class MindmapController { private MindMapBean findMindmapBean(int mapId) throws MapCouldNotFoundException, AccessDeniedSecurityException { final User user = Utils.getUser(); if (!mindmapService.hasPermissions(user, mapId, CollaborationRole.VIEWER)) { - throw new AccessDeniedSecurityException("No enough permissions to open map with id " + mapId); + throw new AccessDeniedSecurityException(mapId, user); } final Mindmap mindmap = findMindmap(mapId); diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml index 13d7ef64..29e70142 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml @@ -22,29 +22,25 @@ - + + + - + + securityError securityError - 404 + 403 - - - - java.lang.reflect.UndeclaredThrowableException - - - From 92dd4a7014501fd379e275e79622223986ff24fc Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 16 Mar 2022 23:16:34 -0300 Subject: [PATCH 07/25] Improve lock code. --- .../listener/UnlockOnExpireListener.java | 8 +++---- .../wisemapping/service/LockManagerImpl.java | 22 +++++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java b/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java index 6fd5edcf..a9dec968 100644 --- a/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java +++ b/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java @@ -7,6 +7,7 @@ import com.wisemapping.model.User; import com.wisemapping.security.Utils; import com.wisemapping.service.LockManager; import com.wisemapping.service.MindmapService; +import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -16,6 +17,7 @@ import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; public class UnlockOnExpireListener implements HttpSessionListener { + private static final Logger logger = Logger.getLogger(UnlockOnExpireListener.class); @Override public void sessionCreated(@NotNull HttpSessionEvent event) { @@ -34,10 +36,8 @@ public class UnlockOnExpireListener implements HttpSessionListener { if (user != null) { try { lockManager.unlockAll(user); - } catch (LockException e) { - e.printStackTrace(); - } catch (AccessDeniedSecurityException e) { - e.printStackTrace(); + } catch (LockException | AccessDeniedSecurityException e) { + logger.error(e); } } } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java index f59012ec..e621cd92 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java @@ -41,8 +41,7 @@ import java.util.concurrent.ConcurrentHashMap; * - Usuario pierde el lock: * - Y grabo con la misma sessions y el timestap ok. * - Y grabo con la misma session y el timestap esta mal - * - Y grabo con distinta sessions - * - + * - Y grabo con distinta sessions * - Usuario pierde el lock, pero intenta grabar camio */ @@ -150,25 +149,20 @@ class LockManagerImpl implements LockManager { } public LockManagerImpl() { - lockInfoByMapId = new ConcurrentHashMap(); + lockInfoByMapId = new ConcurrentHashMap<>(); expirationTimer.schedule(new TimerTask() { @Override public void run() { logger.debug("Lock expiration scheduler started. Current locks:" + lockInfoByMapId.keySet()); - final List toRemove = new ArrayList(); - final Set mapIds = lockInfoByMapId.keySet(); - for (Integer mapId : mapIds) { - final LockInfo lockInfo = lockInfoByMapId.get(mapId); - if (lockInfo.isExpired()) { - toRemove.add(mapId); - } - } + // Search for expired sessions and remove them .... + lockInfoByMapId. + keySet(). + stream(). + filter(mapId -> lockInfoByMapId.get(mapId).isExpired()). + forEach(mapId -> unlock(mapId)); - for (Integer mapId : toRemove) { - unlock(mapId); - } } }, ONE_MINUTE_MILLISECONDS, ONE_MINUTE_MILLISECONDS); } From 340ddcd1ef4ea5ca5c5877fa2ce6a689095253f7 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Thu, 17 Mar 2022 18:47:34 -0300 Subject: [PATCH 08/25] Update copyright --- .../com/wisemapping/dao/LabelManagerImpl.java | 2 +- .../com/wisemapping/dao/MindmapManager.java | 2 +- .../wisemapping/dao/MindmapManagerImpl.java | 2 +- .../java/com/wisemapping/dao/UserManager.java | 2 +- .../com/wisemapping/dao/UserManagerImpl.java | 2 +- .../AccessDeniedSecurityException.java | 2 +- .../exceptions/ClientException.java | 17 + .../EditionSessionExpiredException.java | 2 +- .../exceptions/EmailNotExistsException.java | 2 +- .../exceptions/InvalidMindmapException.java | 2 +- .../LabelCouldNotFoundException.java | 17 + .../wisemapping/exceptions/LockException.java | 2 +- .../exceptions/MapCouldNotFoundException.java | 2 +- .../exceptions/MapNonPublicException.java | 2 +- .../MultipleSessionsOpenException.java | 2 +- .../exceptions/SessionExpiredException.java | 2 +- .../com/wisemapping/exceptions/Severity.java | 2 +- .../exceptions/WiseMappingException.java | 2 +- .../filter/RequestPropertiesInterceptor.java | 2 +- .../filter/SupportedUserAgent.java | 2 +- .../filter/UserLocaleInterceptor.java | 2 +- .../listener/UnlockOnExpireListener.java | 17 + .../java/com/wisemapping/mail/Mailer.java | 2 +- .../wisemapping/mail/NotificationService.java | 2 +- .../com/wisemapping/mail/NotifierFilter.java | 17 + .../com/wisemapping/model/AccessAuditory.java | 2 +- .../wisemapping/model/AuthenticationType.java | 17 + .../com/wisemapping/model/Collaboration.java | 2 +- .../wisemapping/model/CollaborationEmail.java | 2 +- .../model/CollaborationProperties.java | 2 +- .../wisemapping/model/CollaborationRole.java | 2 +- .../com/wisemapping/model/Collaborator.java | 2 +- .../java/com/wisemapping/model/Constants.java | 2 +- .../java/com/wisemapping/model/Label.java | 17 + .../wisemapping/model/MindMapCriteria.java | 2 +- .../com/wisemapping/model/MindMapHistory.java | 2 +- .../java/com/wisemapping/model/Mindmap.java | 2 +- .../com/wisemapping/model/MindmapUtils.java | 17 + .../main/java/com/wisemapping/model/User.java | 52 +-- .../wisemapping/rest/AccountController.java | 2 +- .../com/wisemapping/rest/AdminController.java | 2 +- .../com/wisemapping/rest/BaseController.java | 3 +- ...bugMappingJacksonHttpMessageConverter.java | 2 +- .../JsonHttpMessageNotReadableException.java | 2 +- .../com/wisemapping/rest/LabelController.java | 17 + .../wisemapping/rest/MindmapController.java | 2 +- .../com/wisemapping/rest/MindmapFilter.java | 2 +- .../rest/TransformerController.java | 2 +- .../com/wisemapping/rest/UserController.java | 2 +- .../wisemapping/rest/ValidationException.java | 2 +- .../rest/model/RestCollaboration.java | 2 +- .../rest/model/RestCollaborationList.java | 2 +- .../rest/model/RestCollaborator.java | 2 +- .../wisemapping/rest/model/RestErrors.java | 2 +- .../wisemapping/rest/model/RestLockInfo.java | 2 +- .../wisemapping/rest/model/RestLogItem.java | 2 +- .../wisemapping/rest/model/RestMindmap.java | 2 +- .../rest/model/RestMindmapHistory.java | 2 +- .../rest/model/RestMindmapHistoryList.java | 2 +- .../rest/model/RestMindmapInfo.java | 2 +- .../rest/model/RestMindmapList.java | 2 +- .../com/wisemapping/rest/model/RestUser.java | 2 +- .../rest/model/RestUserRegistration.java | 2 +- .../security/AuthenticationProvider.java | 2 +- .../AuthenticationSuccessHandler.java | 17 + .../security/CSFRRequestMatcher.java | 17 + .../DefaultPasswordEncoderFactories.java | 17 + .../security/LegacyPasswordEncoder.java | 2 +- .../com/wisemapping/security/UserDetails.java | 2 +- .../security/UserDetailsService.java | 2 +- .../java/com/wisemapping/security/Utils.java | 2 +- .../security/aop/BaseSecurityAdvice.java | 2 +- .../security/aop/UpdateSecurityAdvise.java | 2 +- .../security/aop/ViewBaseSecurityAdvise.java | 2 +- .../service/CollaborationException.java | 2 +- .../service/HibernateAppListener.java | 3 +- .../wisemapping/service/HibernateUtil.java | 2 +- .../InvalidActivationCodeException.java | 2 +- .../service/InvalidAuthSchemaException.java | 2 +- .../service/InvalidUserEmailException.java | 2 +- .../com/wisemapping/service/LabelService.java | 17 + .../wisemapping/service/LabelServiceImpl.java | 17 + .../com/wisemapping/service/LockInfo.java | 2 +- .../com/wisemapping/service/LockManager.java | 2 +- .../wisemapping/service/LockManagerImpl.java | 2 +- .../wisemapping/service/MindmapService.java | 2 +- .../service/MindmapServiceImpl.java | 2 +- .../wisemapping/service/RecaptchaService.java | 17 + .../service/RegistrationException.java | 17 + .../com/wisemapping/service/UserService.java | 2 +- .../wisemapping/service/UserServiceImpl.java | 2 +- .../com/wisemapping/util/Application.java | 162 -------- .../com/wisemapping/util/ApplicationType.java | 63 ---- .../java/com/wisemapping/util/Browser.java | 351 ------------------ .../com/wisemapping/util/BrowserType.java | 83 ----- .../java/com/wisemapping/util/DeviceType.java | 71 ---- .../com/wisemapping/util/Manufacturer.java | 145 -------- .../com/wisemapping/util/OperatingSystem.java | 305 --------------- .../com/wisemapping/util/RenderingEngine.java | 85 ----- .../java/com/wisemapping/util/TimeUtils.java | 17 + .../java/com/wisemapping/util/UserAgent.java | 222 ----------- .../wisemapping/util/VelocityEngineUtils.java | 17 + .../util/VelocityEngineWrapper.java | 17 + .../java/com/wisemapping/util/Version.java | 112 ------ .../java/com/wisemapping/util/ZipUtils.java | 2 +- .../wisemapping/validator/LabelValidator.java | 17 + .../validator/MapInfoValidator.java | 2 +- .../com/wisemapping/validator/Messages.java | 2 +- .../wisemapping/validator/UserValidator.java | 2 +- .../java/com/wisemapping/validator/Utils.java | 2 +- .../wisemapping/validator/ValidatorUtils.java | 2 +- .../wisemapping/view/ChangePasswordBean.java | 2 +- .../wisemapping/view/CollaboratorBean.java | 2 +- .../com/wisemapping/view/MindMapBean.java | 2 +- .../com/wisemapping/view/MindMapInfoBean.java | 2 +- .../java/com/wisemapping/view/UserBean.java | 2 +- .../webmvc/ApplicationContextInitializer.java | 2 +- .../wisemapping/webmvc/LoginController.java | 2 +- .../wisemapping/webmvc/MindmapController.java | 2 +- .../wisemapping/webmvc/UsersController.java | 2 +- .../test/rest/RestAccountITCase.java | 2 +- .../test/rest/RestAdminITCase.java | 2 +- 122 files changed, 445 insertions(+), 1715 deletions(-) delete mode 100644 wise-webapp/src/main/java/com/wisemapping/util/Application.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/util/ApplicationType.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/util/Browser.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/util/BrowserType.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/util/DeviceType.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/util/Manufacturer.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/util/OperatingSystem.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/util/RenderingEngine.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/util/UserAgent.java delete mode 100644 wise-webapp/src/main/java/com/wisemapping/util/Version.java diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java index e241b043..b9bd4f64 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/LabelManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java index f82c0de5..abb9fa20 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java index ec083353..42683d26 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/UserManager.java b/wise-webapp/src/main/java/com/wisemapping/dao/UserManager.java index cd351ff5..8ca7056a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/UserManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/UserManager.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java index 4dba546c..3e5f9893 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/AccessDeniedSecurityException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/AccessDeniedSecurityException.java index d1e932e3..b6bdef87 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/AccessDeniedSecurityException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/AccessDeniedSecurityException.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java index 96fbe962..694db093 100644 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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; diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/EditionSessionExpiredException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/EditionSessionExpiredException.java index e22ed8dc..eda00256 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/EditionSessionExpiredException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/EditionSessionExpiredException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/EmailNotExistsException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/EmailNotExistsException.java index bca586c3..3baefb95 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/EmailNotExistsException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/EmailNotExistsException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidMindmapException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidMindmapException.java index 43fb75d1..59dcc5e9 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidMindmapException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidMindmapException.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/LabelCouldNotFoundException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/LabelCouldNotFoundException.java index 5be448b9..fc4cc38b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/LabelCouldNotFoundException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/LabelCouldNotFoundException.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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; diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/LockException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/LockException.java index f95d93dc..88bd18a8 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/LockException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/LockException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/MapCouldNotFoundException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/MapCouldNotFoundException.java index 4c6e33b9..ee8a641e 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/MapCouldNotFoundException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/MapCouldNotFoundException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/MapNonPublicException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/MapNonPublicException.java index 9bbb9e72..93a6b6ec 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/MapNonPublicException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/MapNonPublicException.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java index 58d7fe6d..e3915da8 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/SessionExpiredException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/SessionExpiredException.java index 995e4b50..6d34d39f 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/SessionExpiredException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/SessionExpiredException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/Severity.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/Severity.java index 4ddd6276..5bf99bcc 100644 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/Severity.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/Severity.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/WiseMappingException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/WiseMappingException.java index ac36df50..9c1cc00e 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/WiseMappingException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/WiseMappingException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the 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 0c28736c..4317910a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/RequestPropertiesInterceptor.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/RequestPropertiesInterceptor.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the 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 9a7bc216..13919387 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/SupportedUserAgent.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/SupportedUserAgent.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the 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 88cef60c..dfcaa888 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java b/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java index a9dec968..f9dd9722 100644 --- a/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java +++ b/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.listener; diff --git a/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java b/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java index 348da0ca..2c7e9133 100644 --- a/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java +++ b/wise-webapp/src/main/java/com/wisemapping/mail/Mailer.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java b/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java index ea86ee65..06b981bb 100644 --- a/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java +++ b/wise-webapp/src/main/java/com/wisemapping/mail/NotificationService.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/mail/NotifierFilter.java b/wise-webapp/src/main/java/com/wisemapping/mail/NotifierFilter.java index 626d5774..52803f93 100644 --- a/wise-webapp/src/main/java/com/wisemapping/mail/NotifierFilter.java +++ b/wise-webapp/src/main/java/com/wisemapping/mail/NotifierFilter.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.mail; import org.jetbrains.annotations.NotNull; diff --git a/wise-webapp/src/main/java/com/wisemapping/model/AccessAuditory.java b/wise-webapp/src/main/java/com/wisemapping/model/AccessAuditory.java index 7df24301..9b021285 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/AccessAuditory.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/AccessAuditory.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/model/AuthenticationType.java b/wise-webapp/src/main/java/com/wisemapping/model/AuthenticationType.java index f0bf0ace..92b7725e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/AuthenticationType.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/AuthenticationType.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.model; diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java index 81c690b9..8f766e25 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationEmail.java b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationEmail.java index 7d84009e..bfabe950 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationEmail.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationEmail.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java index a71c58eb..4c0fea46 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java index 8b2c35e3..35e304c2 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationRole.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java index de3a28f6..d9af2e99 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Constants.java b/wise-webapp/src/main/java/com/wisemapping/model/Constants.java index ec2b3321..7e95c46a 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/Constants.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Constants.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Label.java b/wise-webapp/src/main/java/com/wisemapping/model/Label.java index 4dd4fbd6..95e80415 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Label.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Label.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.model; diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindMapCriteria.java b/wise-webapp/src/main/java/com/wisemapping/model/MindMapCriteria.java index a77a57f1..05f88d7f 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMapCriteria.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMapCriteria.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindMapHistory.java b/wise-webapp/src/main/java/com/wisemapping/model/MindMapHistory.java index 3b218764..5ef3c1c5 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMapHistory.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMapHistory.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java b/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java index 5179cd61..bf413899 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindmapUtils.java b/wise-webapp/src/main/java/com/wisemapping/model/MindmapUtils.java index 9a519d4e..c3d96579 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindmapUtils.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindmapUtils.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.model; diff --git a/wise-webapp/src/main/java/com/wisemapping/model/User.java b/wise-webapp/src/main/java/com/wisemapping/model/User.java index 9ef2d86c..78e4e8ab 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/User.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/User.java @@ -1,20 +1,20 @@ /* -* 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. -*/ + * Copyright [2022] [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.model; @@ -29,7 +29,7 @@ import java.util.Set; @Entity @Table(name = "USER") -@PrimaryKeyJoinColumn(name="colaborator_id") +@PrimaryKeyJoinColumn(name = "colaborator_id") public class User extends Collaborator implements Serializable { @@ -48,10 +48,10 @@ public class User @Column(name = "allow_send_email") private boolean allowSendEmail = false; - @Column(name="authentication_type") + @Column(name = "authentication_type") private Character authenticationTypeCode = AuthenticationType.DATABASE.getCode(); - @Column(name="authenticator_uri") + @Column(name = "authenticator_uri") private String authenticatorUri; @ElementCollection @@ -93,6 +93,7 @@ public class User public String getPassword() { return password; } + public void setPassword(String password) { this.password = password; } @@ -143,14 +144,14 @@ public class User } public AuthenticationType getAuthenticationType() { - return authenticationTypeCode!=null ? AuthenticationType.valueOf(authenticationTypeCode):AuthenticationType.DATABASE; + return authenticationTypeCode != null ? AuthenticationType.valueOf(authenticationTypeCode) : AuthenticationType.DATABASE; } public void setAuthenticationType(@NotNull AuthenticationType authenticationType) { this.authenticationTypeCode = authenticationType.getCode(); } - public boolean isDatabaseSchema(){ + public boolean isDatabaseSchema() { return this.getAuthenticationType() == AuthenticationType.DATABASE; } @@ -162,5 +163,12 @@ public class User this.authenticatorUri = authenticatorUri; } - + @Override + public String toString() { + return "User{" + + "firstname='" + firstname + '\'' + + ", lastname='" + lastname + '\'' + + ", password='" + password + '\'' + + "', email = '" + this.getEmail() + "}"; + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java b/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java index 1cb040be..8a23a646 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/AccountController.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java b/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java index e1b3c1d5..3043fc28 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/AdminController.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the 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 e2505527..5c9f0fde 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java @@ -1,5 +1,5 @@ /* - * Copyright [2011] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.wisemapping.rest; import com.wisemapping.exceptions.ClientException; diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/DebugMappingJacksonHttpMessageConverter.java b/wise-webapp/src/main/java/com/wisemapping/rest/DebugMappingJacksonHttpMessageConverter.java index 1457aa0a..ddcff5fe 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/DebugMappingJacksonHttpMessageConverter.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/DebugMappingJacksonHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/JsonHttpMessageNotReadableException.java b/wise-webapp/src/main/java/com/wisemapping/rest/JsonHttpMessageNotReadableException.java index a8042111..a49c5563 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/JsonHttpMessageNotReadableException.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/JsonHttpMessageNotReadableException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java b/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java index 455b99f5..c4ec9117 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/LabelController.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.rest; import com.wisemapping.exceptions.LabelCouldNotFoundException; diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 7f90bdac..53377125 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java index 6842a80a..964b6969 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapFilter.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/TransformerController.java b/wise-webapp/src/main/java/com/wisemapping/rest/TransformerController.java index cc21b4f2..62d4b2c5 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/TransformerController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/TransformerController.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/UserController.java b/wise-webapp/src/main/java/com/wisemapping/rest/UserController.java index 3f69e152..76dbe9f5 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/UserController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/UserController.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/ValidationException.java b/wise-webapp/src/main/java/com/wisemapping/rest/ValidationException.java index d638e83c..84bcf896 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/ValidationException.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/ValidationException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaboration.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaboration.java index 56e3d8f9..8abbc2d7 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaboration.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaboration.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java index d8923980..37b26d47 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborationList.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborator.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborator.java index 53bad2cc..ec876ce1 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborator.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestCollaborator.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestErrors.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestErrors.java index caac5cb1..e156b63c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestErrors.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestErrors.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java index 2e6d570e..8fe3a57b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLogItem.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLogItem.java index 6a352d9a..5894962c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLogItem.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLogItem.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java index fcc176c2..98a74342 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmap.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java index 3f799bb4..cd464824 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistory.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistoryList.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistoryList.java index df557bfd..cfb9e3b6 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistoryList.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapHistoryList.java @@ -1,5 +1,5 @@ /** -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java index 53315291..fc13611b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java index ef5f9460..f3b5179f 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUser.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUser.java index 4b1a3d5b..8cf64298 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUser.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUser.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUserRegistration.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUserRegistration.java index 2099053d..9a9bc750 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUserRegistration.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestUserRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationProvider.java b/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationProvider.java index 078fffea..a4240d07 100644 --- a/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationProvider.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationSuccessHandler.java b/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationSuccessHandler.java index e0a29963..923eefca 100644 --- a/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationSuccessHandler.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationSuccessHandler.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.security; import org.springframework.security.core.Authentication; diff --git a/wise-webapp/src/main/java/com/wisemapping/security/CSFRRequestMatcher.java b/wise-webapp/src/main/java/com/wisemapping/security/CSFRRequestMatcher.java index dff0596a..4f3421eb 100644 --- a/wise-webapp/src/main/java/com/wisemapping/security/CSFRRequestMatcher.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/CSFRRequestMatcher.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.security; import org.springframework.security.web.util.matcher.RequestMatcher; diff --git a/wise-webapp/src/main/java/com/wisemapping/security/DefaultPasswordEncoderFactories.java b/wise-webapp/src/main/java/com/wisemapping/security/DefaultPasswordEncoderFactories.java index 9395a177..5d9d2b2e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/security/DefaultPasswordEncoderFactories.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/DefaultPasswordEncoderFactories.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.security; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; diff --git a/wise-webapp/src/main/java/com/wisemapping/security/LegacyPasswordEncoder.java b/wise-webapp/src/main/java/com/wisemapping/security/LegacyPasswordEncoder.java index 4008037c..eb89d119 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/LegacyPasswordEncoder.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/LegacyPasswordEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/security/UserDetails.java b/wise-webapp/src/main/java/com/wisemapping/security/UserDetails.java index 76939026..8f4b2d38 100644 --- a/wise-webapp/src/main/java/com/wisemapping/security/UserDetails.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/UserDetails.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/security/UserDetailsService.java b/wise-webapp/src/main/java/com/wisemapping/security/UserDetailsService.java index c66aaa10..a400294a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/security/UserDetailsService.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/UserDetailsService.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/security/Utils.java b/wise-webapp/src/main/java/com/wisemapping/security/Utils.java index e2c208d8..f5c68587 100644 --- a/wise-webapp/src/main/java/com/wisemapping/security/Utils.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/Utils.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java index f34fdf89..fce46766 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/BaseSecurityAdvice.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java index d98428b4..f2103225 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/UpdateSecurityAdvise.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java b/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java index 4a62da23..52c59944 100755 --- a/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/aop/ViewBaseSecurityAdvise.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/CollaborationException.java b/wise-webapp/src/main/java/com/wisemapping/service/CollaborationException.java index 56b29327..357eb3dc 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/CollaborationException.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/CollaborationException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/HibernateAppListener.java b/wise-webapp/src/main/java/com/wisemapping/service/HibernateAppListener.java index f0d61506..06aa1455 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/HibernateAppListener.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/HibernateAppListener.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the @@ -23,7 +23,6 @@ import javax.servlet.ServletContextListener; public class HibernateAppListener implements ServletContextListener { - /* Application Startup Event */ public void contextInitialized(ServletContextEvent ce) { try { diff --git a/wise-webapp/src/main/java/com/wisemapping/service/HibernateUtil.java b/wise-webapp/src/main/java/com/wisemapping/service/HibernateUtil.java index fb7e395e..600b3305 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/HibernateUtil.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/HibernateUtil.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/InvalidActivationCodeException.java b/wise-webapp/src/main/java/com/wisemapping/service/InvalidActivationCodeException.java index 723aef92..122691aa 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/InvalidActivationCodeException.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/InvalidActivationCodeException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/InvalidAuthSchemaException.java b/wise-webapp/src/main/java/com/wisemapping/service/InvalidAuthSchemaException.java index 5acd30a7..8b80868f 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/InvalidAuthSchemaException.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/InvalidAuthSchemaException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/InvalidUserEmailException.java b/wise-webapp/src/main/java/com/wisemapping/service/InvalidUserEmailException.java index 539d8cf1..4723c41f 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/InvalidUserEmailException.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/InvalidUserEmailException.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LabelService.java b/wise-webapp/src/main/java/com/wisemapping/service/LabelService.java index d5dbcfc8..e2ea8ec2 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LabelService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LabelService.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.service; import com.wisemapping.exceptions.WiseMappingException; diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LabelServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/LabelServiceImpl.java index 9aaf29bd..8217dc1b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LabelServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LabelServiceImpl.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.service; import com.wisemapping.dao.LabelManager; diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java b/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java index cf211ceb..30a24108 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java index 33ae24b1..d3c4d0bf 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java index e621cd92..c709f3d4 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java index eebf329a..16b44a57 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapService.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java index e9d7e865..115cca8c 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/MindmapServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/RecaptchaService.java b/wise-webapp/src/main/java/com/wisemapping/service/RecaptchaService.java index 91ba8406..2064734d 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/RecaptchaService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/RecaptchaService.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.service; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/wise-webapp/src/main/java/com/wisemapping/service/RegistrationException.java b/wise-webapp/src/main/java/com/wisemapping/service/RegistrationException.java index 56592944..ef3b2e63 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/RegistrationException.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/RegistrationException.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.service; import org.springframework.validation.BindException; diff --git a/wise-webapp/src/main/java/com/wisemapping/service/UserService.java b/wise-webapp/src/main/java/com/wisemapping/service/UserService.java index 3e9d61ae..ef0cf222 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/UserService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/UserService.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java index 188e0f1b..07866c1e 100755 --- a/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/UserServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/util/Application.java b/wise-webapp/src/main/java/com/wisemapping/util/Application.java deleted file mode 100644 index 9d100f64..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/util/Application.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2008, Harald Walker (bitwalker.nl) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * * Neither the name of bitwalker nor the names of its - * contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.wisemapping.util; - -/** - * Enum constants for internet applications like web-application and rich - * internet application. - * - * @author harald - * - */ - -public enum Application { - - HOTMAIL(Manufacturer.MICROSOFT, 1, "Windows Live Hotmail", - new String[] { "mail.live.com", "hotmail.msn" }, ApplicationType.WEBMAIL), - GMAIL( Manufacturer.GOOGLE, 5, "Gmail", - new String[] { "mail.google.com" }, ApplicationType.WEBMAIL), - YAHOO_MAIL( Manufacturer.YAHOO, 10, "Yahoo Mail", - new String[] { "mail.yahoo.com" }, ApplicationType.WEBMAIL), - COMPUSERVE( Manufacturer.COMPUSERVE, 20, "Compuserve", - new String[] { "csmail.compuserve.com" }, ApplicationType.WEBMAIL), - AOL_WEBMAIL( Manufacturer.AOL, 30, "AOL webmail", - new String[] { "webmail.aol.com" }, ApplicationType.WEBMAIL), - /** - * MobileMe webmail client by Apple. Previously known as .mac. - */ - MOBILEME( Manufacturer.APPLE, 40, "MobileMe", - new String[] { "www.me.com" }, ApplicationType.WEBMAIL), - /** - * Mail.com - * Mail.com provides consumers with web-based e-mail services - */ - MAIL_COM( Manufacturer.MMC, 50, "Mail.com", - new String[] { ".mail.com" }, ApplicationType.WEBMAIL), - /** - * Popular open source webmail client. Often installed by providers or privately. - */ - HORDE( Manufacturer.OTHER, 50, "horde", - new String[] { "horde" }, ApplicationType.WEBMAIL), - OTHER_WEBMAIL(Manufacturer.OTHER, 60, "Other webmail client", - new String[] { "webmail", "webemail" }, ApplicationType.WEBMAIL), - UNKNOWN(Manufacturer.OTHER, 0, "Unknown", - new String[0], ApplicationType.UNKNOWN); - - private final short id; - private final String name; - private final String[] aliases; - private final ApplicationType applicationType; - private final Manufacturer manufacturer; - - Application(Manufacturer manufacturer, int versionId, String name, - String[] aliases, ApplicationType applicationType) { - this.id = (short) ((manufacturer.getId() << 8) + (byte) versionId); - this.name = name; - this.aliases = aliases; - this.applicationType = applicationType; - this.manufacturer = manufacturer; - } - - public short getId() { - return id; - } - - public String getName() { - return name; - } - - /** - * @return the applicationType - */ - public ApplicationType getApplicationType() { - return applicationType; - } - - /** - * @return the manufacturer - */ - public Manufacturer getManufacturer() { - return manufacturer; - } - - /* - * Checks if the given referrer string matches to the application. Only - * checks for one specific application. - */ - public boolean isInReferrerString(String referrerString) { - for (String alias : aliases) { - if (referrerString.toLowerCase().indexOf(alias.toLowerCase()) != -1) - return true; - } - return false; - } - - /* - * Iterates over all Application to compare the signature with the referrer - * string. If no match can be found Application.UNKNOWN will be returned. - */ - public static Application parseReferrerString(String referrerString) { - // skip the empty and "-" referrer - if (referrerString != null && referrerString.length() > 1) { - for (Application applicationInList : Application.values()) { - if (applicationInList.isInReferrerString(referrerString)) - return applicationInList; - } - } - return Application.UNKNOWN; - } - - /** - * Returns the enum constant of this type with the specified id. Throws - * IllegalArgumentException if the value does not exist. - * - * @param id - * @return - */ - public static Application valueOf(short id) { - for (Application application : Application.values()) { - if (application.getId() == id) - return application; - } - - // same behavior as standard valueOf(string) method - throw new IllegalArgumentException("No enum const for id " + id); - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/util/ApplicationType.java b/wise-webapp/src/main/java/com/wisemapping/util/ApplicationType.java deleted file mode 100644 index e02a1734..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/util/ApplicationType.java +++ /dev/null @@ -1,63 +0,0 @@ -/* -* Copyright (c) 2008, Harald Walker (bitwalker.nl) -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the -* following conditions are met: -* -* * Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* * Neither the name of bitwalker nor the names of its -* contributors may be used to endorse or promote products -* derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package com.wisemapping.util; - -/** - * Enum constants classifying the different types of applications which are common in referrer strings - * @author harald - * - */ -public enum ApplicationType { - - /** - * Webmail service like Windows Live Hotmail and Gmail. - */ - WEBMAIL("Webmail client"), - UNKNOWN("unknown"); - - private final String name; - - ApplicationType(String name) { - this.name = name; - } - - public String getName() { - return name; - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/util/Browser.java b/wise-webapp/src/main/java/com/wisemapping/util/Browser.java deleted file mode 100644 index 82a5d775..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/util/Browser.java +++ /dev/null @@ -1,351 +0,0 @@ -/* -* Copyright (c) 2011, Harald Walker (bitwalker.nl) -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the -* following conditions are met: -* -* * Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* * Neither the name of bitwalker nor the names of its -* contributors may be used to endorse or promote products -* derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package com.wisemapping.util; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Enum constants for most common browsers, including e-mail clients and bots. - * - * @author harald - */ - -public enum Browser { - - OPERA(Manufacturer.OPERA, null, 1, "Opera", new String[]{"Opera"}, null, BrowserType.WEB_BROWSER, RenderingEngine.PRESTO, "Opera\\/(([\\d]+)\\.([\\w]+))"), // before MSIE - OPERA_MINI(Manufacturer.OPERA, Browser.OPERA, 20, "Opera Mini", new String[]{"Opera Mini"}, null, BrowserType.MOBILE_BROWSER, RenderingEngine.PRESTO, null), // Opera for mobile devices - /** - * For some strange reason Opera uses 9.80 in the user-agent string. - */ - OPERA10(Manufacturer.OPERA, Browser.OPERA, 10, "Opera 10", new String[]{"Opera/9.8"}, null, BrowserType.WEB_BROWSER, RenderingEngine.PRESTO, "Version\\/(([\\d]+)\\.([\\w]+))"), - OPERA9(Manufacturer.OPERA, Browser.OPERA, 5, "Opera 9", new String[]{"Opera/9"}, null, BrowserType.WEB_BROWSER, RenderingEngine.PRESTO, null), - KONQUEROR(Manufacturer.OTHER, null, 1, "Konqueror", new String[]{"Konqueror"}, null, BrowserType.WEB_BROWSER, RenderingEngine.KHTML, "Konqueror\\/(([0-9]+)\\.?([\\w]+)?(-[\\w]+)?)"), - - /** - * Outlook email client - */ - OUTLOOK(Manufacturer.MICROSOFT, null, 100, "Outlook", new String[]{"MSOffice"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.WORD, "MSOffice (([0-9]+))"), // before IE7 - /** - * Microsoft Outlook 2007 identifies itself as MSIE7 but uses the html rendering engine of Word 2007. - * Example user agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 1.1.4322; MSOffice 12) - */ - OUTLOOK2007(Manufacturer.MICROSOFT, Browser.OUTLOOK, 107, "Outlook 2007", new String[]{"MSOffice 12"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.WORD, null), // before IE7 - /** - * Outlook 2010 is still using the rendering engine of Word. http://www.fixoutlook.org - */ - OUTLOOK2010(Manufacturer.MICROSOFT, Browser.OUTLOOK, 108, "Outlook 2010", new String[]{"MSOffice 14"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.WORD, null), // before IE7 - - /** - * Family of Internet Explorer browsers - */ - IE11(Manufacturer.MICROSOFT, null, 1, "Internet Explorer", new String[]{") like Gecko"}, null, BrowserType.WEB_BROWSER, RenderingEngine.TRIDENT, "Mozilla/5.0 (([\\d]+)\\.([\\w]+))"), // before Mozilla - - /** - * Family of Internet Explorer browsers - */ - IE(Manufacturer.MICROSOFT, null, 1, "Internet Explorer", new String[]{"MSIE"}, null, BrowserType.WEB_BROWSER, RenderingEngine.TRIDENT, "MSIE (([\\d]+)\\.([\\w]+))"), // before Mozilla - /** - * Since version 7 Outlook Express is identifying itself. By detecting Outlook Express we can not - * identify the Internet Explorer version which is probably used for the rendering. - * Obviously this product is now called Windows Live Mail Desktop or just Windows Live Mail. - */ - OUTLOOK_EXPRESS7(Manufacturer.MICROSOFT, Browser.IE, 110, "Windows Live Mail", new String[]{"Outlook-Express/7.0"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.TRIDENT, null), // before IE7, previously known as Outlook Express. First released in 2006, offered with different name later - /** - * Since 2007 the mobile edition of Internet Explorer identifies itself as IEMobile in the user-agent. - * If previous versions have to be detected, use the operating system information as well. - */ - IEMOBILE7(Manufacturer.MICROSOFT, Browser.IE, 121, "IE Mobile 7", new String[]{"IEMobile 7"}, null, BrowserType.MOBILE_BROWSER, RenderingEngine.TRIDENT, null), // before MSIE strings - IEMOBILE6(Manufacturer.MICROSOFT, Browser.IE, 120, "IE Mobile 6", new String[]{"IEMobile 6"}, null, BrowserType.MOBILE_BROWSER, RenderingEngine.TRIDENT, null), // before MSIE - IE9(Manufacturer.MICROSOFT, Browser.IE, 90, "Internet Explorer 9", new String[]{"MSIE 9"}, null, BrowserType.WEB_BROWSER, RenderingEngine.TRIDENT, null), // before MSIE - IE8(Manufacturer.MICROSOFT, Browser.IE, 80, "Internet Explorer 8", new String[]{"MSIE 8"}, null, BrowserType.WEB_BROWSER, RenderingEngine.TRIDENT, null), // before MSIE - IE7(Manufacturer.MICROSOFT, Browser.IE, 70, "Internet Explorer 7", new String[]{"MSIE 7"}, null, BrowserType.WEB_BROWSER, RenderingEngine.TRIDENT, null), // before MSIE - IE6(Manufacturer.MICROSOFT, Browser.IE, 60, "Internet Explorer 6", new String[]{"MSIE 6"}, null, BrowserType.WEB_BROWSER, RenderingEngine.TRIDENT, null), // before MSIE - IE5_5(Manufacturer.MICROSOFT, Browser.IE, 55, "Internet Explorer 5.5", new String[]{"MSIE 5.5"}, null, BrowserType.WEB_BROWSER, RenderingEngine.TRIDENT, null), // before MSIE - IE5(Manufacturer.MICROSOFT, Browser.IE, 50, "Internet Explorer 5", new String[]{"MSIE 5"}, null, BrowserType.WEB_BROWSER, RenderingEngine.TRIDENT, null), // before MSIE - - /** - * Google Chrome browser - */ - CHROME(Manufacturer.GOOGLE, null, 1, "Chrome", new String[]{"Chrome"}, null, BrowserType.WEB_BROWSER, RenderingEngine.WEBKIT, "Chrome\\/(([0-9]+)\\.?([\\w]+)?(\\.[\\w]+)?(\\.[\\w]+)?)"), // before Mozilla - CHROME10(Manufacturer.GOOGLE, Browser.CHROME, 15, "Chrome 10", new String[]{"Chrome/10"}, null, BrowserType.WEB_BROWSER, RenderingEngine.WEBKIT, null), // before Mozilla - CHROME9(Manufacturer.GOOGLE, Browser.CHROME, 10, "Chrome 9", new String[]{"Chrome/9"}, null, BrowserType.WEB_BROWSER, RenderingEngine.WEBKIT, null), // before Mozilla - CHROME8(Manufacturer.GOOGLE, Browser.CHROME, 5, "Chrome 8", new String[]{"Chrome/8"}, null, BrowserType.WEB_BROWSER, RenderingEngine.WEBKIT, null), // before Mozilla - - OMNIWEB(Manufacturer.OTHER, null, 2, "Omniweb", new String[]{"OmniWeb"}, null, BrowserType.WEB_BROWSER, RenderingEngine.WEBKIT, null), // - - SAFARI(Manufacturer.APPLE, null, 1, "Safari", new String[]{"Safari"}, null, BrowserType.WEB_BROWSER, RenderingEngine.WEBKIT, "Version\\/(([0-9]+)\\.?([\\w]+)?(\\.[\\w]+)?)"), // before AppleWebKit - SAFARI5(Manufacturer.APPLE, Browser.SAFARI, 3, "Safari 5", new String[]{"Version/5"}, null, BrowserType.WEB_BROWSER, RenderingEngine.WEBKIT, null), // before AppleWebKit - MOBILE_SAFARI(Manufacturer.APPLE, Browser.SAFARI, 2, "Mobile Safari", new String[]{"Mobile Safari", "Mobile/"}, null, BrowserType.MOBILE_BROWSER, RenderingEngine.WEBKIT, null), // before Safari - SAFARI4(Manufacturer.APPLE, Browser.SAFARI, 4, "Safari 4", new String[]{"Version/4"}, null, BrowserType.WEB_BROWSER, RenderingEngine.WEBKIT, null), // before AppleWebKit - - APPLE_MAIL(Manufacturer.APPLE, null, 50, "Apple Mail", new String[]{"AppleWebKit"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.WEBKIT, null), // Microsoft Entrourage/Outlook 2010 also only identifies itself as AppleWebKit - LOTUS_NOTES(Manufacturer.OTHER, null, 3, "Lotus Notes", new String[]{"Lotus-Notes"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.OTHER, "Lotus-Notes\\/(([\\d]+)\\.([\\w]+))"), // before Mozilla - - /* - * Thunderbird email client, based on the same Gecko engine Firefox is using. - */ - THUNDERBIRD(Manufacturer.MOZILLA, null, 110, "Thunderbird", new String[]{"Thunderbird"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.GECKO, "Thunderbird\\/(([0-9]+)\\.?([\\w]+)?(\\.[\\w]+)?(\\.[\\w]+)?)"), // using Gecko Engine - THUNDERBIRD3(Manufacturer.MOZILLA, Browser.THUNDERBIRD, 130, "Thunderbird 3", new String[]{"Thunderbird/3"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.GECKO, null), // using Gecko Engine - THUNDERBIRD2(Manufacturer.MOZILLA, Browser.THUNDERBIRD, 120, "Thunderbird 2", new String[]{"Thunderbird/2"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.GECKO, null), // using Gecko Engine - - CAMINO(Manufacturer.OTHER, null, 5, "Camino", new String[]{"Camino"}, null, BrowserType.WEB_BROWSER, RenderingEngine.GECKO, "Camino\\/(([0-9]+)\\.?([\\w]+)?(\\.[\\w]+)?)"), // using Gecko Engine - CAMINO2(Manufacturer.OTHER, Browser.CAMINO, 17, "Camino 2", new String[]{"Camino/2"}, null, BrowserType.WEB_BROWSER, RenderingEngine.GECKO, null), // using Gecko Engine - FLOCK(Manufacturer.OTHER, null, 4, "Flock", new String[]{"Flock"}, null, BrowserType.WEB_BROWSER, RenderingEngine.GECKO, "Flock\\/(([0-9]+)\\.?([\\w]+)?(\\.[\\w]+)?)"), - - FIREFOX(Manufacturer.MOZILLA, null, 10, "Firefox", new String[]{"Firefox"}, null, BrowserType.WEB_BROWSER, RenderingEngine.GECKO, "Firefox\\/(([0-9]+)\\.?([\\w]+)?(\\.[\\w]+)?(\\.[\\w]+)?)"), // using Gecko Engine - FIREFOX3MOBILE(Manufacturer.MOZILLA, Browser.FIREFOX, 31, "Firefox 3 Mobile", new String[]{"Firefox/3.5 Maemo"}, null, BrowserType.MOBILE_BROWSER, RenderingEngine.GECKO, null), // using Gecko Engine - FIREFOX4(Manufacturer.MOZILLA, Browser.FIREFOX, 40, "Firefox 4", new String[]{"Firefox/4"}, null, BrowserType.WEB_BROWSER, RenderingEngine.GECKO, null), // using Gecko Engine - FIREFOX3(Manufacturer.MOZILLA, Browser.FIREFOX, 30, "Firefox 3", new String[]{"Firefox/3"}, null, BrowserType.WEB_BROWSER, RenderingEngine.GECKO, null), // using Gecko Engine - FIREFOX2(Manufacturer.MOZILLA, Browser.FIREFOX, 20, "Firefox 2", new String[]{"Firefox/2"}, null, BrowserType.WEB_BROWSER, RenderingEngine.GECKO, null), // using Gecko Engine - FIREFOX1_5(Manufacturer.MOZILLA, Browser.FIREFOX, 15, "Firefox 1.5", new String[]{"Firefox/1.5"}, null, BrowserType.WEB_BROWSER, RenderingEngine.GECKO, null), // using Gecko Engine - - SEAMONKEY(Manufacturer.OTHER, null, 15, "SeaMonkey", new String[]{"SeaMonkey"}, null, BrowserType.WEB_BROWSER, RenderingEngine.GECKO, "SeaMonkey\\/(([0-9]+)\\.?([\\w]+)?(\\.[\\w]+)?)"), // using Gecko Engine - - BOT(Manufacturer.OTHER, null, 12, "Robot/Spider", new String[]{"Mediapartners-Google", "Googlebot", "bot", "spider", "crawler", "Feedfetcher", "Slurp", "Twiceler", "Nutch", "BecomeBot"}, null, BrowserType.ROBOT, RenderingEngine.OTHER, null), - - MOZILLA(Manufacturer.MOZILLA, null, 1, "Mozilla", new String[]{"Mozilla", "Moozilla"}, null, BrowserType.WEB_BROWSER, RenderingEngine.OTHER, null), // rest of the mozilla browsers - - CFNETWORK(Manufacturer.OTHER, null, 6, "CFNetwork", new String[]{"CFNetwork"}, null, BrowserType.UNKNOWN, RenderingEngine.OTHER, null), // Mac OS X cocoa library - - EUDORA(Manufacturer.OTHER, null, 7, "Eudora", new String[]{"Eudora", "EUDORA"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.OTHER, null), // email client by Qualcomm - - POCOMAIL(Manufacturer.OTHER, null, 8, "PocoMail", new String[]{"PocoMail"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.OTHER, null), - - THEBAT(Manufacturer.OTHER, null, 9, "The Bat!", new String[]{"The Bat"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.OTHER, null), // Email Client - - NETFRONT(Manufacturer.OTHER, null, 10, "NetFront", new String[]{"NetFront"}, null, BrowserType.MOBILE_BROWSER, RenderingEngine.OTHER, null), // mobile device browser - - EVOLUTION(Manufacturer.OTHER, null, 11, "Evolution", new String[]{"CamelHttpStream"}, null, BrowserType.EMAIL_CLIENT, RenderingEngine.OTHER, null), // http://www.go-evolution.org/Camel.Stream - - LYNX(Manufacturer.OTHER, null, 13, "Lynx", new String[]{"Lynx"}, null, BrowserType.TEXT_BROWSER, RenderingEngine.OTHER, "Lynx\\/(([0-9]+)\\.([\\d]+)\\.?([\\w-+]+)?\\.?([\\w-+]+)?)"), - - DOWNLOAD(Manufacturer.OTHER, null, 16, "Downloading Tool", new String[]{"cURL", "wget"}, null, BrowserType.TEXT_BROWSER, RenderingEngine.OTHER, null), - - UNKNOWN(Manufacturer.OTHER, null, 14, "Unknown", new String[0], null, BrowserType.UNKNOWN, RenderingEngine.OTHER, null); - private final short id; - private final String name; - private final String[] aliases; - private final String[] excludeList; // don't match when these values are in the agent-string - private final BrowserType browserType; - private final Manufacturer manufacturer; - private final RenderingEngine renderingEngine; - private final Browser parent; - private final List children; - private Pattern versionRegEx; - - Browser(Manufacturer manufacturer, Browser parent, int versionId, String name, String[] aliases, String[] exclude, BrowserType browserType, RenderingEngine renderingEngine, String versionRegexString) { - this.id = (short) ((manufacturer.getId() << 8) + (byte) versionId); - this.name = name; - this.parent = parent; - this.children = new ArrayList<>(); - if (this.parent != null) { - this.parent.children.add(this); - } - this.aliases = aliases; - this.excludeList = exclude; - this.browserType = browserType; - this.manufacturer = manufacturer; - this.renderingEngine = renderingEngine; - if (versionRegexString != null) { - this.versionRegEx = Pattern.compile(versionRegexString); - } - } - - /** - * Iterates over all Browsers to compare the browser signature with - * the user agent string. If no match can be found Browser.UNKNOWN will - * be returned. - * - * @param agentString - * @return Browser - */ - public static Browser parseUserAgentString(String agentString) { - for (Browser browser : Browser.values()) { - // only check top level objects - if (browser.parent == null) { - Browser match = browser.checkUserAgent(agentString); - if (match != null) { - return match; // either current operatingSystem or a child object - } - } - } - return Browser.UNKNOWN; - } - - /** - * Returns the enum constant of this type with the specified id. - * Throws IllegalArgumentException if the value does not exist. - * - * @param id - * @return - */ - public static Browser valueOf(short id) { - for (Browser browser : Browser.values()) { - if (browser.getId() == id) - return browser; - } - - // same behavior as standard valueOf(string) method - throw new IllegalArgumentException( - "No enum const for id " + id); - } - - public short getId() { - return id; - } - - public String getName() { - return name; - } - - private Pattern getVersionRegEx() { - if (this.versionRegEx == null) { - if (this.getGroup() != this) - return this.getGroup().getVersionRegEx(); - else - return null; - } - return this.versionRegEx; - } - - /** - * Detects the detailed version information of the browser. Depends on the userAgent to be available. - * Returns null if it can not detect the version information. - * - * @return Version - */ - public Version getVersion(String userAgentString) { - Pattern pattern = this.getVersionRegEx(); - if (userAgentString != null && pattern != null) { - Matcher matcher = pattern.matcher(userAgentString); - if (matcher.find()) { - String fullVersionString = matcher.group(1); - String majorVersion = matcher.group(2); - String minorVersion = "0"; - if (matcher.groupCount() > 2) // usually but not always there is a minor version - minorVersion = matcher.group(3); - return new Version(fullVersionString, majorVersion, minorVersion); - } - } - return null; - } - - /** - * @return the browserType - */ - public BrowserType getBrowserType() { - return browserType; - } - - /** - * @return the manufacturer - */ - public Manufacturer getManufacturer() { - return manufacturer; - } - - /** - * @return the rendering engine - */ - public RenderingEngine getRenderingEngine() { - return renderingEngine; - } - - /** - * @return top level browser family - */ - public Browser getGroup() { - if (this.parent != null) { - return parent.getGroup(); - } - return this; - } - - /* - * Checks if the given user-agent string matches to the browser. - * Only checks for one specific browser. - */ - public boolean isInUserAgentString(String agentString) { - for (String alias : aliases) { - if (agentString.toLowerCase().indexOf(alias.toLowerCase()) != -1) - return true; - } - return false; - } - - /** - * Checks if the given user-agent does not contain one of the tokens which should not match. - * In most cases there are no excluding tokens, so the impact should be small. - * - * @param agentString - * @return - */ - private boolean containsExcludeToken(String agentString) { - if (excludeList != null) { - for (String exclude : excludeList) { - if (agentString.toLowerCase().indexOf(exclude.toLowerCase()) != -1) - return true; - } - } - return false; - } - - private Browser checkUserAgent(String agentString) { - if (this.isInUserAgentString(agentString)) { - if (this.children.size() > 0) { - for (Browser childBrowser : this.children) { - Browser match = childBrowser.checkUserAgent(agentString); - if (match != null) { - return match; - } - } - } - // if children didn't match we continue checking the current to prevent false positives - if (!this.containsExcludeToken(agentString)) { - return this; - } - - } - return null; - } - - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/util/BrowserType.java b/wise-webapp/src/main/java/com/wisemapping/util/BrowserType.java deleted file mode 100644 index bee131e1..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/util/BrowserType.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright (c) 2008, Harald Walker (bitwalker.nl) -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the -* following conditions are met: -* -* * Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* * Neither the name of bitwalker nor the names of its -* contributors may be used to endorse or promote products -* derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package com.wisemapping.util; - -/** - * Enum constants classifying the different types of browsers which are common in user-agent strings - * @author harald - * - */ -public enum BrowserType { - - /** - * Standard web-browser - */ - WEB_BROWSER("Browser"), - /** - * Special web-browser for mobile devices - */ - MOBILE_BROWSER("Browser (mobile)"), - /** - * Text only browser like the good old Lynx - */ - TEXT_BROWSER("Browser (text only)"), - /** - * Email client like Thunderbird - */ - EMAIL_CLIENT("Email Client"), - /** - * Search robot, spider, crawler,... - */ - ROBOT("Robot"), - /** - * Downloading tools - */ - TOOL("Downloading tool"), - UNKNOWN("unknown"); - - private final String name; - - BrowserType(String name) { - this.name = name; - } - - public String getName() { - return name; - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/util/DeviceType.java b/wise-webapp/src/main/java/com/wisemapping/util/DeviceType.java deleted file mode 100644 index 4de82645..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/util/DeviceType.java +++ /dev/null @@ -1,71 +0,0 @@ -/* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* * Neither the name of bitwalker nor the names of its -* contributors may be used to endorse or promote products -* derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package com.wisemapping.util; - -/** - * Enum contact for the type of used device - * @author harald - * - */ -public enum DeviceType { - - /** - * Standard desktop or laptop computer - */ - COMPUTER("Computer"), - /** - * Mobile phone or similar small mobile device - */ - MOBILE("Mobile"), - /** - * Small tablet type computer. - */ - TABLET("Tablet"), - /** - * Game console like the Wii or Playstation. - */ - GAME_CONSOLE("Game console"), - /** - * Digital media receiver like the Apple TV. - * No device detection implemented yet for this category. Please send provide user-agent strings if you have some. - */ - DMR("Digital media receiver"), - /** - * Other or unknow type of device. - */ - UNKNOWN("Unknown"); - - String name; - - DeviceType(String name) { - this.name = name; - } - - public String getName() { - return name; - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/util/Manufacturer.java b/wise-webapp/src/main/java/com/wisemapping/util/Manufacturer.java deleted file mode 100644 index be15d19d..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/util/Manufacturer.java +++ /dev/null @@ -1,145 +0,0 @@ -/* -* Copyright (c) 2008, Harald Walker (bitwalker.nl) -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the -* following conditions are met: -* -* * Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* * Neither the name of bitwalker nor the names of its -* contributors may be used to endorse or promote products -* derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package com.wisemapping.util; - -/** - * Enum constants representing manufacturers of operating systems and client software. - * Manufacturer could be used for specific handling of browser requests. - * @author harald - */ - -public enum Manufacturer { - - /** - * Unknow or rare manufacturer - */ - OTHER(1, "Other"), - /** - * Microsoft Corporation - */ - MICROSOFT(2, "Microsoft Corporation"), - /** - * Apple Inc. - */ - APPLE(3, "Apple Inc."), - /** - * Sun Microsystems, Inc. - */ - SUN(4, "Sun Microsystems, Inc."), - /** - * Symbian Ltd. - */ - SYMBIAN(5, "Symbian Ltd."), - /** - * Nokia Corporation - */ - NOKIA(6, "Nokia Corporation"), - /** - * Research In Motion Limited - */ - BLACKBERRY(7, "Research In Motion Limited"), - /** - * Palm, Inc. - */ - PALM(8, "Palm, Inc. "), - /** - * Sony Ericsson Mobile Communications AB - */ - SONY_ERICSSON(9, "Sony Ericsson Mobile Communications AB"), - /** - * Sony Computer Entertainment, Inc. - */ - SONY(10, "Sony Computer Entertainment, Inc."), - /** - * Nintendo - */ - NINTENDO(11, "Nintendo"), - /** - * Opera Software ASA - */ - OPERA(12, "Opera Software ASA"), - /** - * Mozilla Foundation - */ - MOZILLA(13, "Mozilla Foundation"), - /** - * Google Inc. - */ - GOOGLE(15, "Google Inc."), - /** - * CompuServe Interactive Services, Inc. - */ - COMPUSERVE(16, "CompuServe Interactive Services, Inc."), - /** - * Yahoo Inc. - */ - YAHOO(17, "Yahoo Inc."), - /** - * AOL LLC. - */ - AOL(18, "AOL LLC."), - /** - * Mail.com Media Corporation - */ - MMC(19, "Mail.com Media Corporation") - ; - - - private final byte id; - private final String name; - - Manufacturer(int id, String name) { - this.id = (byte) id; - this.name = name; - } - - /** - * @return the id - */ - public byte getId() { - return id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/util/OperatingSystem.java b/wise-webapp/src/main/java/com/wisemapping/util/OperatingSystem.java deleted file mode 100644 index bb5d5398..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/util/OperatingSystem.java +++ /dev/null @@ -1,305 +0,0 @@ -/* -* Copyright (c) 2011, Harald Walker (bitwalker.nl) -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the -* following conditions are met: -* -* * Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* * Neither the name of bitwalker nor the names of its -* contributors may be used to endorse or promote products -* derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package com.wisemapping.util; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; - -/** - * Enum constants for most common operating systems. - * @author harald - */ -public enum OperatingSystem { - - // the order is important since the agent string is being compared with the aliases - /** - * Windows Mobile / Windows CE. Exact version unknown. - */ - WINDOWS( Manufacturer.MICROSOFT,null,1, "Windows", new String[] { "Windows" }, new String[] { "Palm" }, DeviceType.COMPUTER, null ), // catch the rest of older Windows systems (95, NT,...) - WINDOWS_7( Manufacturer.MICROSOFT,OperatingSystem.WINDOWS,21, "Windows 7", new String[] { "Windows NT 6.1" }, null, DeviceType.COMPUTER, null ), // before Win, yes, Windows 7 is called 6.1 LOL - WINDOWS_VISTA( Manufacturer.MICROSOFT,OperatingSystem.WINDOWS,20, "Windows Vista", new String[] { "Windows NT 6" }, null, DeviceType.COMPUTER, null ), // before Win - WINDOWS_2000( Manufacturer.MICROSOFT,OperatingSystem.WINDOWS,15, "Windows 2000", new String[] { "Windows NT 5.0" }, null, DeviceType.COMPUTER, null ), // before Win - WINDOWS_XP( Manufacturer.MICROSOFT,OperatingSystem.WINDOWS,10, "Windows XP", new String[] { "Windows NT 5" }, null, DeviceType.COMPUTER, null ), // before Win, 5.1 and 5.2 are basically XP systems - WINDOWS_MOBILE7(Manufacturer.MICROSOFT,OperatingSystem.WINDOWS, 51, "Windows Mobile 7", new String[] { "Windows Phone OS 7" }, null, DeviceType.MOBILE, null ), // before Win - WINDOWS_MOBILE( Manufacturer.MICROSOFT,OperatingSystem.WINDOWS, 50, "Windows Mobile", new String[] { "Windows CE" }, null, DeviceType.MOBILE, null ), // before Win - WINDOWS_98( Manufacturer.MICROSOFT,OperatingSystem.WINDOWS,5, "Windows 98", new String[] { "Windows 98","Win98" }, new String[] { "Palm" }, DeviceType.COMPUTER, null ), // before Win - - ANDROID( Manufacturer.GOOGLE,null, 0, "Android", new String[] { "Android" }, null, DeviceType.MOBILE, null ), - ANDROID2( Manufacturer.GOOGLE,OperatingSystem.ANDROID, 2, "Android 2.x", new String[] { "Android 2" }, null, DeviceType.MOBILE, null ), - ANDROID2_TABLET(Manufacturer.GOOGLE,OperatingSystem.ANDROID2, 20, "Android 2.x Tablet", new String[] { "GT-P1000","SCH-I800" }, null, DeviceType.TABLET, null ), - ANDROID1( Manufacturer.GOOGLE,OperatingSystem.ANDROID, 1, "Android 1.x", new String[] { "Android 1" }, null, DeviceType.MOBILE, null ), - - /** - * PalmOS, exact version unkown - */ - WEBOS( Manufacturer.PALM,null,11, "WebOS", new String[] { "webOS" }, null, DeviceType.MOBILE, null ), - PALM( Manufacturer.PALM,null,10, "PalmOS", new String[] { "Palm" }, null, DeviceType.MOBILE, null ), - - - /** - * iOS4, with the release of the iPhone 4, Apple renamed the OS to iOS. - */ - IOS(Manufacturer.APPLE,null, 2, "iOS", new String[] { "like Mac OS X" }, null, DeviceType.MOBILE, null ), // before MAC_OS_X_IPHONE for all older versions - iOS4_IPHONE(Manufacturer.APPLE,OperatingSystem.IOS, 41, "iOS 4 (iPhone)", new String[] { "iPhone OS 4" }, null, DeviceType.MOBILE, null ), // before MAC_OS_X_IPHONE for all older versions - MAC_OS_X_IPAD( Manufacturer.APPLE, OperatingSystem.IOS, 50, "Mac OS X (iPad)", new String[] { "iPad" }, null, DeviceType.TABLET, null ), // before Mac OS X - MAC_OS_X_IPHONE(Manufacturer.APPLE, OperatingSystem.IOS, 40, "Mac OS X (iPhone)", new String[] { "iPhone" }, null, DeviceType.MOBILE, null ), // before Mac OS X - MAC_OS_X_IPOD( Manufacturer.APPLE, OperatingSystem.IOS, 30, "Mac OS X (iPod)", new String[] { "iPod" }, null, DeviceType.MOBILE, null ), // before Mac OS X - - MAC_OS_X( Manufacturer.APPLE,null, 10, "Mac OS X", new String[] { "Mac OS X" , "CFNetwork"}, null, DeviceType.COMPUTER, null ), // before Mac - - /** - * Older Mac OS systems before Mac OS X - */ - MAC_OS( Manufacturer.APPLE,null, 1, "Mac OS", new String[] { "Mac" }, null, DeviceType.COMPUTER, null ), // older Mac OS systems - - /** - * Linux based Maemo software platform by Nokia. Used in the N900 phone. http://maemo.nokia.com/ - */ - MAEMO( Manufacturer.NOKIA,null, 2, "Maemo", new String[] { "Maemo" }, null, DeviceType.MOBILE, null ), - - /** - * Various Linux based operating systems. - */ - LINUX( Manufacturer.OTHER,null, 2, "Linux", new String[] { "Linux" , "CamelHttpStream" }, null, DeviceType.COMPUTER, null ), // CamelHttpStream is being used by Evolution, an email client for Linux - - /** - * Other Symbian OS versions - */ - SYMBIAN( Manufacturer.SYMBIAN,null, 1, "Symbian OS", new String[] { "Symbian", "Series60"}, null, DeviceType.MOBILE, null ), - /** - * Symbian OS 9.x versions. Being used by Nokia (N71, N73, N81, N82, N91, N92, N95, ...) - */ - SYMBIAN9( Manufacturer.SYMBIAN,OperatingSystem.SYMBIAN, 20, "Symbian OS 9.x", new String[] {"SymbianOS/9", "Series60/3"}, null, DeviceType.MOBILE, null ), - /** - * Symbian OS 8.x versions. Being used by Nokia (6630, 6680, 6681, 6682, N70, N72, N90). - */ - SYMBIAN8( Manufacturer.SYMBIAN,OperatingSystem.SYMBIAN, 15, "Symbian OS 8.x", new String[] { "SymbianOS/8", "Series60/2.6", "Series60/2.8"}, null, DeviceType.MOBILE, null ), - /** - * Symbian OS 7.x versions. Being used by Nokia (3230, 6260, 6600, 6620, 6670, 7610), - * Panasonic (X700, X800), Samsung (SGH-D720, SGH-D730) and Lenovo (P930). - */ - SYMBIAN7( Manufacturer.SYMBIAN,OperatingSystem.SYMBIAN, 10, "Symbian OS 7.x", new String[] { "SymbianOS/7"}, null, DeviceType.MOBILE, null ), - /** - * Symbian OS 6.x versions. - */ - SYMBIAN6( Manufacturer.SYMBIAN,OperatingSystem.SYMBIAN, 5, "Symbian OS 6.x", new String[] { "SymbianOS/6"}, null, DeviceType.MOBILE, null ), - /** - * Nokia's Series 40 operating system. Series 60 (S60) uses the Symbian OS. - */ - SERIES40 ( Manufacturer.NOKIA,null, 1, "Series 40", new String[] { "Nokia6300"}, null, DeviceType.MOBILE, null ), - /** - * Proprietary operating system used for many Sony Ericsson phones. - */ - SONY_ERICSSON ( Manufacturer.SONY_ERICSSON, null, 1, "Sony Ericsson", new String[] { "SonyEricsson"}, null, DeviceType.MOBILE, null ), // after symbian, some SE phones use symbian - SUN_OS( Manufacturer.SUN, null, 1, "SunOS", new String[] { "SunOS" } , null, DeviceType.COMPUTER, null ), - PSP( Manufacturer.SONY, null, 1, "Sony Playstation", new String[] { "Playstation" }, null, DeviceType.GAME_CONSOLE, null ), - /** - * Nintendo Wii game console. - */ - WII( Manufacturer.NINTENDO,null, 1, "Nintendo Wii", new String[] { "Wii" }, null, DeviceType.GAME_CONSOLE, null ), - /** - * BlackBerryOS. The BlackBerryOS exists in different version. How relevant those versions are, is not clear. - */ - BLACKBERRY( Manufacturer.BLACKBERRY,null, 1, "BlackBerryOS", new String[] { "BlackBerry" }, null, DeviceType.MOBILE, null ), - BLACKBERRY6( Manufacturer.BLACKBERRY,OperatingSystem.BLACKBERRY, 6, "BlackBerry 6", new String[] { "Version/6" }, null, DeviceType.MOBILE, null ), - - UNKNOWN( Manufacturer.OTHER,null, 1, "Unknown", new String[0], null, DeviceType.UNKNOWN, null ); - - private final short id; - private final String name; - private final String[] aliases; - private final String[] excludeList; // don't match when these values are in the agent-string - private final Manufacturer manufacturer; - private final DeviceType deviceType; - private final OperatingSystem parent; - private final List children; - private Pattern versionRegEx; - - OperatingSystem(Manufacturer manufacturer, OperatingSystem parent, int versionId, String name, String[] aliases, - String[] exclude, DeviceType deviceType, String versionRegexString) { - this.manufacturer = manufacturer; - this.parent = parent; - this.children = new ArrayList(); - if (this.parent != null) { - this.parent.children.add(this); - } - // combine manufacturer and version id to one unique id. - this.id = (short) ( ( manufacturer.getId() << 8) + (byte) versionId); - this.name = name; - this.aliases = aliases; - this.excludeList = exclude; - this.deviceType = deviceType; - if (versionRegexString != null) { - this.versionRegEx = Pattern.compile(versionRegexString); - } - } - - - public short getId() { - return id; - } - - public String getName() { - return name; - } - - - /* - * Shortcut to check of an operating system is a mobile device. - * Left in here for backwards compatibility. - */ - public boolean isMobileDevice() { - return deviceType.equals(DeviceType.MOBILE); - } - - public DeviceType getDeviceType() { - return deviceType; - } - - /* - * Gets the top level grouping operating system - */ - public OperatingSystem getGroup() { - if (this.parent != null) { - return parent.getGroup(); - } - return this; - } - - /** - * Returns the manufacturer of the operating system - * @return the manufacturer - */ - public Manufacturer getManufacturer() { - return manufacturer; - } - - /** - * Checks if the given user-agent string matches to the operating system. - * Only checks for one specific operating system. - * @param agentString - * @return boolean - */ - public boolean isInUserAgentString(String agentString) - { - for (String alias : aliases) - { - if (agentString.toLowerCase().indexOf(alias.toLowerCase()) != -1) - return true; - } - return false; - } - - /** - * Checks if the given user-agent does not contain one of the tokens which should not match. - * In most cases there are no excluding tokens, so the impact should be small. - * @param agentString - * @return - */ - private boolean containsExcludeToken(String agentString) - { - if (excludeList != null) { - for (String exclude : excludeList) { - if (agentString.toLowerCase().indexOf(exclude.toLowerCase()) != -1) - return true; - } - } - return false; - } - - private OperatingSystem checkUserAgent(String agentString) { - if (this.isInUserAgentString(agentString)) { - if (this.children.size() > 0) { - for (OperatingSystem childOperatingSystem : this.children) { - OperatingSystem match = childOperatingSystem.checkUserAgent(agentString); - if (match != null) { - return match; - } - } - } - // if children didn't match we continue checking the current to prevent false positives - if (!this.containsExcludeToken(agentString)) { - return this; - } - - } - return null; - } - - /** - * Parses user agent string and returns the best match. - * Returns OperatingSystem.UNKNOWN if there is no match. - * @param agentString - * @return OperatingSystem - */ - public static OperatingSystem parseUserAgentString(String agentString) - { - for (OperatingSystem operatingSystem : OperatingSystem.values()) - { - // only check top level objects - if (operatingSystem.parent == null) { - OperatingSystem match = operatingSystem.checkUserAgent(agentString); - if (match != null) { - return match; // either current operatingSystem or a child object - } - } - } - return OperatingSystem.UNKNOWN; - } - - /** - * Returns the enum constant of this type with the specified id. - * Throws IllegalArgumentException if the value does not exist. - * @param id - * @return - */ - public static OperatingSystem valueOf(short id) - { - for (OperatingSystem operatingSystem : OperatingSystem.values()) - { - if (operatingSystem.getId() == id) - return operatingSystem; - } - - // same behavior as standard valueOf(string) method - throw new IllegalArgumentException( - "No enum const for id " + id); - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/util/RenderingEngine.java b/wise-webapp/src/main/java/com/wisemapping/util/RenderingEngine.java deleted file mode 100644 index bb1bb548..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/util/RenderingEngine.java +++ /dev/null @@ -1,85 +0,0 @@ -/* -* Copyright (c) 2011, Harald Walker (bitwalker.nl) -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the -* following conditions are met: -* -* * Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* * Neither the name of bitwalker nor the names of its -* contributors may be used to endorse or promote products -* derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package com.wisemapping.util; - -/** - * Enum constants classifying the different types of rendering engines which are being used by browsers. - * @author harald - * - */ -public enum RenderingEngine { - - /** - * Trident is the the Microsoft layout engine, mainly used by Internet Explorer. - */ - TRIDENT("Trident"), - /** - * HTML parsing and rendering engine of Microsoft Office Word, used by some other products of the Office suite instead of Trident. - */ - WORD("Microsoft Office Word"), - /** - * Open source and cross platform layout engine, used by Firefox and many other browsers. - */ - GECKO("Gecko"), - /** - * Layout engine based on KHTML, used by Safari, Chrome and some other browsers. - */ - WEBKIT("WebKit"), - /** - * Proprietary layout engine by Opera Software ASA - */ - PRESTO("Presto"), - /** - * Original layout engine of the Mozilla browser and related products. Predecessor of Gecko. - */ - MOZILLA("Mozilla"), - /** - * Layout engine of the KDE project - */ - KHTML("KHTML"), - /** - * Other or unknown layout engine. - */ - OTHER("Other"); - - String name; - - RenderingEngine(String name) { - this.name = name; - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/util/TimeUtils.java b/wise-webapp/src/main/java/com/wisemapping/util/TimeUtils.java index 5ac37d29..2fac153e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/util/TimeUtils.java +++ b/wise-webapp/src/main/java/com/wisemapping/util/TimeUtils.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.util; import org.jetbrains.annotations.Nullable; diff --git a/wise-webapp/src/main/java/com/wisemapping/util/UserAgent.java b/wise-webapp/src/main/java/com/wisemapping/util/UserAgent.java deleted file mode 100644 index 8be0b2fb..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/util/UserAgent.java +++ /dev/null @@ -1,222 +0,0 @@ -/* -* Copyright (c) 2008, Harald Walker (bitwalker.nl) -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the -* following conditions are met: -* -* * Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* * Neither the name of bitwalker nor the names of its -* contributors may be used to endorse or promote products -* derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package com.wisemapping.util; - -/** - * Container class for user-agent information with operating system and browser details. - * Can decode user-agent strings. - *

- * Resources:
- * User Agent String.Com
- * List of User-Agents
- * Browser ID (User-Agent) Strings
- * Mobile Browser ID (User-Agent) Strings
- * Browser-Kennungen
- * Device Atlas - Mobile Device Intelligence
- * Mobile Opera user-agent strings
- * S60 platform
- * Understanding User-Agent Strings
- * Sony Ericsson Web Docs & Tools
- * What is the Safari user-agent string
- * List of User Agent Strings
- * Detecting Internet Explorer Mobile's User-Agent on the server - */ - -import org.jetbrains.annotations.Nullable; - -/** - * @author harald - */ -public class UserAgent { - - private OperatingSystem operatingSystem = OperatingSystem.UNKNOWN; - private Browser browser = Browser.UNKNOWN; - private int id; - private String userAgentString; - - public UserAgent(OperatingSystem operatingSystem, Browser browser) { - this.operatingSystem = operatingSystem; - this.browser = browser; - this.id = ((operatingSystem.getId() << 16) + browser.getId()); - } - - public UserAgent(@Nullable String userAgentString) { - if (userAgentString != null) { - Browser browser = Browser.parseUserAgentString(userAgentString); - - OperatingSystem operatingSystem = OperatingSystem.UNKNOWN; - - // BOTs don't have an interesting OS for us - if (browser != Browser.BOT) - operatingSystem = OperatingSystem.parseUserAgentString(userAgentString); - - this.operatingSystem = operatingSystem; - this.browser = browser; - this.id = ((operatingSystem.getId() << 16) + browser.getId()); - this.userAgentString = userAgentString; - - } else { - this.operatingSystem = OperatingSystem.UNKNOWN; - this.browser = Browser.UNKNOWN; - } - } - - - /** - * @param userAgentString - * @return UserAgent - */ - public static UserAgent parseUserAgentString(String userAgentString) { - return new UserAgent(userAgentString); - } - - - /** - * Detects the detailed version information of the browser. Depends on the userAgent to be available. - * Use it only after using UserAgent(String) or UserAgent.parseUserAgent(String). - * Returns null if it can not detect the version information. - * - * @return Version - */ - public Version getBrowserVersion() { - return this.browser.getVersion(this.userAgentString); - } - - /** - * @return the system - */ - public OperatingSystem getOperatingSystem() { - return operatingSystem; - } - - /** - * @return the browser - */ - public Browser getBrowser() { - return browser; - } - - /** - * Returns an unique integer value of the operating system & browser combination - * - * @return the id - */ - public int getId() { - return id; - } - - /** - * Combined string representation of both enums - */ - public String toString() { - return this.operatingSystem.toString() + "-" + this.browser.toString(); - } - - /** - * Returns UserAgent based on specified unique id - * - * @param id - * @return - */ - public static UserAgent valueOf(int id) { - OperatingSystem operatingSystem = OperatingSystem.valueOf((short) (id >> 16)); - Browser browser = Browser.valueOf((short) (id & 0x0FFFF)); - return new UserAgent(operatingSystem, browser); - } - - /** - * Returns UserAgent based on combined string representation - * - * @param name - * @return - */ - public static UserAgent valueOf(String name) { - if (name == null) - throw new NullPointerException("Name is null"); - - String[] elements = name.split("-"); - - if (elements.length == 2) { - OperatingSystem operatingSystem = OperatingSystem.valueOf(elements[0]); - Browser browser = Browser.valueOf(elements[1]); - return new UserAgent(operatingSystem, browser); - } - - throw new IllegalArgumentException( - "Invalid string for userAgent " + name); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((browser == null) ? 0 : browser.hashCode()); - result = prime * result + id; - result = prime * result - + ((operatingSystem == null) ? 0 : operatingSystem.hashCode()); - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final UserAgent other = (UserAgent) obj; - if (browser == null) { - if (other.browser != null) - return false; - } else if (!browser.equals(other.browser)) - return false; - if (id != other.id) - return false; - if (operatingSystem == null) { - return other.operatingSystem == null; - } else return operatingSystem.equals(other.operatingSystem); - } - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/util/VelocityEngineUtils.java b/wise-webapp/src/main/java/com/wisemapping/util/VelocityEngineUtils.java index ca5e82a1..acded03b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/util/VelocityEngineUtils.java +++ b/wise-webapp/src/main/java/com/wisemapping/util/VelocityEngineUtils.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.util; import org.apache.commons.logging.Log; diff --git a/wise-webapp/src/main/java/com/wisemapping/util/VelocityEngineWrapper.java b/wise-webapp/src/main/java/com/wisemapping/util/VelocityEngineWrapper.java index f6cf0fcd..44ebb6a3 100644 --- a/wise-webapp/src/main/java/com/wisemapping/util/VelocityEngineWrapper.java +++ b/wise-webapp/src/main/java/com/wisemapping/util/VelocityEngineWrapper.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.util; import org.apache.commons.collections.ExtendedProperties; diff --git a/wise-webapp/src/main/java/com/wisemapping/util/Version.java b/wise-webapp/src/main/java/com/wisemapping/util/Version.java deleted file mode 100644 index 5a528815..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/util/Version.java +++ /dev/null @@ -1,112 +0,0 @@ -/* -* Copyright (c) 2011, Harald Walker (bitwalker.nl) -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the -* following conditions are met: -* -* * Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* * Neither the name of bitwalker nor the names of its -* contributors may be used to endorse or promote products -* derived from this software without specific prior written -* permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package com.wisemapping.util; - -/** - * Container for general version information. - * All version information is stored as String as sometimes version information includes alphabetical characters. - * @author harald - */ -public class Version { - - String version; - String majorVersion; - String minorVersion; - - public Version(String version, String majorVersion, String minorVersion) { - super(); - this.version = version; - this.majorVersion = majorVersion; - this.minorVersion = minorVersion; - } - - public String getVersion() { - return version; - } - - public String getMajorVersion() { - return majorVersion; - } - - public String getMinorVersion() { - return minorVersion; - } - - @Override - public String toString() { - return version; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((majorVersion == null) ? 0 : majorVersion.hashCode()); - result = prime * result - + ((minorVersion == null) ? 0 : minorVersion.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Version other = (Version) obj; - if (majorVersion == null) { - if (other.majorVersion != null) - return false; - } else if (!majorVersion.equals(other.majorVersion)) - return false; - if (minorVersion == null) { - if (other.minorVersion != null) - return false; - } else if (!minorVersion.equals(other.minorVersion)) - return false; - if (version == null) { - return other.version == null; - } else return version.equals(other.version); - } - - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/util/ZipUtils.java b/wise-webapp/src/main/java/com/wisemapping/util/ZipUtils.java index 4fab1a60..bff6a6e2 100755 --- a/wise-webapp/src/main/java/com/wisemapping/util/ZipUtils.java +++ b/wise-webapp/src/main/java/com/wisemapping/util/ZipUtils.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/LabelValidator.java b/wise-webapp/src/main/java/com/wisemapping/validator/LabelValidator.java index bd5e2035..4f64de9b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/validator/LabelValidator.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/LabelValidator.java @@ -1,3 +1,20 @@ +/* + * Copyright [2022] [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.validator; import com.wisemapping.model.Constants; diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/MapInfoValidator.java b/wise-webapp/src/main/java/com/wisemapping/validator/MapInfoValidator.java index b0dbfad8..79ba7024 100755 --- a/wise-webapp/src/main/java/com/wisemapping/validator/MapInfoValidator.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/MapInfoValidator.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/Messages.java b/wise-webapp/src/main/java/com/wisemapping/validator/Messages.java index ac28ad7e..f094f854 100644 --- a/wise-webapp/src/main/java/com/wisemapping/validator/Messages.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/Messages.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/UserValidator.java b/wise-webapp/src/main/java/com/wisemapping/validator/UserValidator.java index 88c48589..77e87a9c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/validator/UserValidator.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/UserValidator.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/Utils.java b/wise-webapp/src/main/java/com/wisemapping/validator/Utils.java index 9ed6e51e..1ccc04e6 100644 --- a/wise-webapp/src/main/java/com/wisemapping/validator/Utils.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/Utils.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/ValidatorUtils.java b/wise-webapp/src/main/java/com/wisemapping/validator/ValidatorUtils.java index 076db874..f4184b48 100755 --- a/wise-webapp/src/main/java/com/wisemapping/validator/ValidatorUtils.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/ValidatorUtils.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/view/ChangePasswordBean.java b/wise-webapp/src/main/java/com/wisemapping/view/ChangePasswordBean.java index d5df6b53..eeec894c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/ChangePasswordBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/ChangePasswordBean.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/view/CollaboratorBean.java b/wise-webapp/src/main/java/com/wisemapping/view/CollaboratorBean.java index ed1e9693..f6c2b2f8 100755 --- a/wise-webapp/src/main/java/com/wisemapping/view/CollaboratorBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/CollaboratorBean.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java index 4c061062..4b806f3a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapBean.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/view/MindMapInfoBean.java b/wise-webapp/src/main/java/com/wisemapping/view/MindMapInfoBean.java index dcb348bf..3ef6ca20 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/MindMapInfoBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/MindMapInfoBean.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/view/UserBean.java b/wise-webapp/src/main/java/com/wisemapping/view/UserBean.java index 125f323e..e32cd3d6 100644 --- a/wise-webapp/src/main/java/com/wisemapping/view/UserBean.java +++ b/wise-webapp/src/main/java/com/wisemapping/view/UserBean.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/webmvc/ApplicationContextInitializer.java b/wise-webapp/src/main/java/com/wisemapping/webmvc/ApplicationContextInitializer.java index 5f31863b..d011e92c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/webmvc/ApplicationContextInitializer.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/ApplicationContextInitializer.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/webmvc/LoginController.java b/wise-webapp/src/main/java/com/wisemapping/webmvc/LoginController.java index 36295d53..4c01c51d 100644 --- a/wise-webapp/src/main/java/com/wisemapping/webmvc/LoginController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/LoginController.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the 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 073ee245..b8d4776e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/main/java/com/wisemapping/webmvc/UsersController.java b/wise-webapp/src/main/java/com/wisemapping/webmvc/UsersController.java index d21768a2..2db75cd5 100644 --- a/wise-webapp/src/main/java/com/wisemapping/webmvc/UsersController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/UsersController.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestAccountITCase.java b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestAccountITCase.java index d7732910..103caa9f 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestAccountITCase.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestAccountITCase.java @@ -1,5 +1,5 @@ /* -* Copyright [2015] [wisemapping] +* Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the diff --git a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestAdminITCase.java b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestAdminITCase.java index 4b7eae9a..cafeb61c 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestAdminITCase.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestAdminITCase.java @@ -1,5 +1,5 @@ /* - * Copyright [2015] [wisemapping] + * Copyright [2022] [wisemapping] * * Licensed under WiseMapping Public License, Version 1.0 (the "License"). * It is basically the Apache License, Version 2.0 (the "License") plus the From fdd6fb928bdd93a2bc2324f75f253c6c45abfbf9 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Thu, 17 Mar 2022 19:25:33 -0300 Subject: [PATCH 09/25] Improve lock logic. --- .../wisemapping/rest/MindmapController.java | 88 ++++++++++--------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 53377125..53f0dd4a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -27,6 +27,7 @@ import com.wisemapping.validator.MapInfoValidator; import org.apache.commons.validator.routines.EmailValidator; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; @@ -109,7 +110,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "application/xml"}) @ResponseBody - public Long updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor, @RequestParam(required = false) Long timestamp, @RequestParam(required = false) Long session) throws WiseMappingException, IOException { + public Long updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor, @RequestParam(required = true) long timestamp, @RequestParam(required = true) long session) throws WiseMappingException, IOException { final Mindmap mindmap = findMindmapById(id); final User user = Utils.getUser(); @@ -120,10 +121,8 @@ public class MindmapController extends BaseController { throw new IllegalArgumentException("Map properties can not be null"); } - // Could the map be updated ? - if (session != null) { - verifyLock(mindmap, user, session, timestamp); - } + // Have permissions ? + long result = verifyAndUpdateLock(mindmap, user, session, timestamp); // Update collaboration properties ... final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(user); @@ -136,13 +135,6 @@ public class MindmapController extends BaseController { // Update map ... saveMindmapDocument(minor, mindmap, user); - // Update edition timeout ... - final LockManager lockManager = mindmapService.getLockManager(); - long result = -1; - if (session != null) { - final LockInfo lockInfo = lockManager.updateExpirationTimeout(mindmap, user); - result = lockInfo.getTimestamp(); - } return result; } @@ -173,36 +165,6 @@ public class MindmapController extends BaseController { return mindmapHistory.getUnzipXml(); } - private void verifyLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws WiseMappingException { - - // The lock was lost, reclaim as the ownership of it. - final LockManager lockManager = mindmapService.getLockManager(); - final boolean lockLost = lockManager.isLocked(mindmap); - if (!lockLost) { - lockManager.lock(mindmap, user, session); - } - - final LockInfo lockInfo = lockManager.getLockInfo(mindmap); - if (lockInfo.getUser().identityEquality(user)) { - long savedTimestamp = mindmap.getLastModificationTime().getTimeInMillis(); - final boolean outdated = savedTimestamp > timestamp; - - if (lockInfo.getSession() == session) { - // Timestamp might not be returned to the client. This try to cover this case, ignoring the client timestamp check. - final User lastEditor = mindmap.getLastEditor(); - boolean editedBySameUser = lastEditor == null || user.identityEquality(lastEditor); - if (outdated && !editedBySameUser) { - throw new SessionExpiredException("Map has been updated by " + (lastEditor.getEmail()) + ",Timestamp:" + timestamp + "," + savedTimestamp + ", User:" + lastEditor.getId() + ":" + user.getId() + ",Mail:'" + lastEditor.getEmail() + "':'" + user.getEmail(), lastEditor); - } - } else if (outdated) { - logger.warn("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + savedTimestamp); - // @Todo: Temporally disabled to unblock save action. More research needed. -// throw new MultipleSessionsOpenException("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + savedTimestamp); - } - } else { - throw new SessionExpiredException("Different Users.", lockInfo.getUser()); - } - } /** * The intention of this method is the update of several properties at once ... @@ -617,4 +579,46 @@ public class MindmapController extends BaseController { mindmap.addLabel(label); mindmapService.updateMindmap(mindmap, false); } + + private long verifyAndUpdateLock(@NotNull Mindmap mindmap, @NotNull User user, @Nullable long session, @NotNull long timestamp) throws WiseMappingException { + // Could the map be updated ? + verifyLock(mindmap, user, session, timestamp); + + // Update timestamp for lock ... + final LockManager lockManager = mindmapService.getLockManager(); + final LockInfo lockInfo = lockManager.updateExpirationTimeout(mindmap, user); + return lockInfo.getTimestamp(); + } + + private void verifyLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws WiseMappingException { + + // The lock was lost, reclaim as the ownership of it. + final LockManager lockManager = mindmapService.getLockManager(); + final boolean lockLost = lockManager.isLocked(mindmap); + if (!lockLost) { + lockManager.lock(mindmap, user, session); + } + + final LockInfo lockInfo = lockManager.getLockInfo(mindmap); + if (lockInfo.getUser().identityEquality(user)) { + long savedTimestamp = mindmap.getLastModificationTime().getTimeInMillis(); + final boolean outdated = savedTimestamp > timestamp; + + if (lockInfo.getSession() == session) { + // Timestamp might not be returned to the client. This try to cover this case, ignoring the client timestamp check. + final User lastEditor = mindmap.getLastEditor(); + boolean editedBySameUser = lastEditor == null || user.identityEquality(lastEditor); + if (outdated && !editedBySameUser) { + throw new SessionExpiredException("Map has been updated by " + (lastEditor.getEmail()) + ",Timestamp:" + timestamp + "," + savedTimestamp + ", User:" + lastEditor.getId() + ":" + user.getId() + ",Mail:'" + lastEditor.getEmail() + "':'" + user.getEmail(), lastEditor); + } + } else if (outdated) { + logger.warn("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + savedTimestamp); + // @Todo: Temporally disabled to unblock save action. More research needed. +// throw new MultipleSessionsOpenException("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + savedTimestamp); + } + } else { + throw new SessionExpiredException("Different Users.", lockInfo.getUser()); + } + } + } From cbdd6ebb476c244e256ab07a6ffc29e9b795da7b Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 22 Mar 2022 08:35:47 -0300 Subject: [PATCH 10/25] WIp --- .../listener/UnlockOnExpireListener.java | 12 +-- .../wisemapping/rest/MindmapController.java | 43 +-------- .../com/wisemapping/service/LockManager.java | 6 +- .../wisemapping/service/LockManagerImpl.java | 89 ++++++++++++------- .../src/main/webapp/jsp/mindmapEditor.jsp | 2 +- 5 files changed, 69 insertions(+), 83 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java b/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java index f9dd9722..f49eeab1 100644 --- a/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java +++ b/wise-webapp/src/main/java/com/wisemapping/listener/UnlockOnExpireListener.java @@ -47,14 +47,16 @@ public class UnlockOnExpireListener implements HttpSessionListener { final ServletContext servletContext = event.getSession().getServletContext(); final WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); final MindmapService mindmapService = (MindmapService) wc.getBean("mindmapService"); - final LockManager lockManager = mindmapService.getLockManager(); + final LockManager lockManager = mindmapService.getLockManager(); final User user = Utils.getUser(false); if (user != null) { - try { - lockManager.unlockAll(user); - } catch (LockException | AccessDeniedSecurityException e) { - logger.error(e); + synchronized (mindmapService.getLockManager()) { + try { + lockManager.unlockAll(user); + } catch (LockException | AccessDeniedSecurityException e) { + logger.error(e); + } } } } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 53f0dd4a..9697fa5d 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -122,7 +122,8 @@ public class MindmapController extends BaseController { } // Have permissions ? - long result = verifyAndUpdateLock(mindmap, user, session, timestamp); + final LockManager lockManager = mindmapService.getLockManager(); + long result = lockManager.verifyAndUpdateLock(mindmap, user, session, timestamp); // Update collaboration properties ... final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(user); @@ -580,45 +581,5 @@ public class MindmapController extends BaseController { mindmapService.updateMindmap(mindmap, false); } - private long verifyAndUpdateLock(@NotNull Mindmap mindmap, @NotNull User user, @Nullable long session, @NotNull long timestamp) throws WiseMappingException { - // Could the map be updated ? - verifyLock(mindmap, user, session, timestamp); - - // Update timestamp for lock ... - final LockManager lockManager = mindmapService.getLockManager(); - final LockInfo lockInfo = lockManager.updateExpirationTimeout(mindmap, user); - return lockInfo.getTimestamp(); - } - - private void verifyLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws WiseMappingException { - - // The lock was lost, reclaim as the ownership of it. - final LockManager lockManager = mindmapService.getLockManager(); - final boolean lockLost = lockManager.isLocked(mindmap); - if (!lockLost) { - lockManager.lock(mindmap, user, session); - } - - final LockInfo lockInfo = lockManager.getLockInfo(mindmap); - if (lockInfo.getUser().identityEquality(user)) { - long savedTimestamp = mindmap.getLastModificationTime().getTimeInMillis(); - final boolean outdated = savedTimestamp > timestamp; - - if (lockInfo.getSession() == session) { - // Timestamp might not be returned to the client. This try to cover this case, ignoring the client timestamp check. - final User lastEditor = mindmap.getLastEditor(); - boolean editedBySameUser = lastEditor == null || user.identityEquality(lastEditor); - if (outdated && !editedBySameUser) { - throw new SessionExpiredException("Map has been updated by " + (lastEditor.getEmail()) + ",Timestamp:" + timestamp + "," + savedTimestamp + ", User:" + lastEditor.getId() + ":" + user.getId() + ",Mail:'" + lastEditor.getEmail() + "':'" + user.getEmail(), lastEditor); - } - } else if (outdated) { - logger.warn("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + savedTimestamp); - // @Todo: Temporally disabled to unblock save action. More research needed. -// throw new MultipleSessionsOpenException("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + savedTimestamp); - } - } else { - throw new SessionExpiredException("Different Users.", lockInfo.getUser()); - } - } } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java index d3c4d0bf..3aee7a19 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java @@ -20,6 +20,7 @@ package com.wisemapping.service; import com.wisemapping.exceptions.AccessDeniedSecurityException; import com.wisemapping.exceptions.LockException; +import com.wisemapping.exceptions.SessionExpiredException; import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.model.Mindmap; import com.wisemapping.model.User; @@ -38,8 +39,7 @@ public interface LockManager { boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User collaborator); - @NotNull - LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws WiseMappingException; - long generateSession(); + + long verifyAndUpdateLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws LockException, SessionExpiredException; } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java index c709f3d4..24cb5e83 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java @@ -20,35 +20,21 @@ package com.wisemapping.service; import com.wisemapping.exceptions.AccessDeniedSecurityException; import com.wisemapping.exceptions.LockException; -import com.wisemapping.exceptions.WiseMappingException; +import com.wisemapping.exceptions.SessionExpiredException; import com.wisemapping.model.CollaborationRole; import com.wisemapping.model.Mindmap; import com.wisemapping.model.User; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -/* - * Refresh page should not lost the lock. - * En caso que no sea posible grabar por que se perdio el lock, usar mensaje de error para explicar el por que... - * Mensaje modal explicando que el mapa esta siendo editado, por eso no es posible edilarlo.... - * Internacionalizacion de los mensaje ... - * Logout limpiar las sessiones ... - * - * Casos: - * - Usuario pierde el lock: - * - Y grabo con la misma sessions y el timestap ok. - * - Y grabo con la misma session y el timestap esta mal - * - Y grabo con distinta sessions - * - Usuario pierde el lock, pero intenta grabar camio - */ - class LockManagerImpl implements LockManager { - public static final int ONE_MINUTE_MILLISECONDS = 1000 * 60; - final Map lockInfoByMapId; - final static Timer expirationTimer = new Timer(); + private static final int ONE_MINUTE_MILLISECONDS = 1000 * 60; + private final Map lockInfoByMapId; + private final static Timer expirationTimer = new Timer(); final private static Logger logger = Logger.getLogger(LockManagerImpl.class); @Override @@ -123,17 +109,12 @@ class LockManagerImpl implements LockManager { return System.nanoTime(); } - @Override @NotNull - public LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws WiseMappingException { + private LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws LockException { if (isLocked(mindmap) && !isLockedBy(mindmap, user)) { throw new LockException("Invalid lock, this should not happen"); } - if (!mindmap.hasPermissions(user, CollaborationRole.EDITOR)) { - throw new AccessDeniedSecurityException(mindmap.getId(), user); - } - LockInfo result = lockInfoByMapId.get(mindmap.getId()); if (result != null) { // Update timeout only... @@ -154,17 +135,59 @@ class LockManagerImpl implements LockManager { @Override public void run() { - logger.debug("Lock expiration scheduler started. Current locks:" + lockInfoByMapId.keySet()); - - // Search for expired sessions and remove them .... - lockInfoByMapId. - keySet(). - stream(). - filter(mapId -> lockInfoByMapId.get(mapId).isExpired()). - forEach(mapId -> unlock(mapId)); + synchronized (this) { + logger.debug("Lock expiration scheduler started. Current locks:" + lockInfoByMapId.keySet()); + // Search for expired sessions and remove them .... + lockInfoByMapId. + keySet(). + stream(). + filter(mapId -> lockInfoByMapId.get(mapId).isExpired()). + forEach(mapId -> unlock(mapId)); + } } }, ONE_MINUTE_MILLISECONDS, ONE_MINUTE_MILLISECONDS); } + public long verifyAndUpdateLock(@NotNull Mindmap mindmap, @NotNull User user, @Nullable long session, @NotNull long timestamp) throws LockException, SessionExpiredException { + synchronized (this) { + // Could the map be updated ? + verifyLock(mindmap, user, session, timestamp); + + // Update timestamp for lock ... + final LockInfo lockInfo = this.updateExpirationTimeout(mindmap, user); + return lockInfo.getTimestamp(); + } + } + + private void verifyLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws LockException, SessionExpiredException { + + // The lock was lost, reclaim as the ownership of it. + final boolean lockLost = this.isLocked(mindmap); + if (!lockLost) { + this.lock(mindmap, user, session); + } + + final LockInfo lockInfo = this.getLockInfo(mindmap); + if (lockInfo.getUser().identityEquality(user)) { + long savedTimestamp = mindmap.getLastModificationTime().getTimeInMillis(); + final boolean outdated = savedTimestamp > timestamp; + + if (lockInfo.getSession() == session) { + // Timestamp might not be returned to the client. This try to cover this case, ignoring the client timestamp check. + final User lastEditor = mindmap.getLastEditor(); + boolean editedBySameUser = lastEditor == null || user.identityEquality(lastEditor); + if (outdated && !editedBySameUser) { + throw new SessionExpiredException("Map has been updated by " + (lastEditor.getEmail()) + ",Timestamp:" + timestamp + "," + savedTimestamp + ", User:" + lastEditor.getId() + ":" + user.getId() + ",Mail:'" + lastEditor.getEmail() + "':'" + user.getEmail(), lastEditor); + } + } else if (outdated) { + logger.warn("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + savedTimestamp); + // @Todo: Temporally disabled to unblock save action. More research needed. +// throw new MultipleSessionsOpenException("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + savedTimestamp); + } + } else { + throw new SessionExpiredException("Different Users.", lockInfo.getUser()); + } + } + } diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp index fe9613de..6712efe4 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp @@ -34,7 +34,7 @@ - +
diff --git a/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp b/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp index 52e71778..8cc7b36c 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp @@ -23,7 +23,7 @@ <%@ include file="/jsp/googleAnalytics.jsf" %> - +
From b18505050a8be6524c83269a100819e167bced9e Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 22 Mar 2022 08:48:09 -0300 Subject: [PATCH 12/25] Revert "Fix CSS collition" This reverts commit f4cf7e623ee9d3ce1b493f6ff4cb81da17553404. --- wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp | 2 +- wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp index 049e9103..fe9613de 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp @@ -44,7 +44,7 @@ - +
diff --git a/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp b/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp index 8cc7b36c..52e71778 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapViewonly.jsp @@ -23,7 +23,7 @@ <%@ include file="/jsp/googleAnalytics.jsf" %> - +
From 20a9978577b4c856af3549d8e939700b7e9723cc Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 22 Mar 2022 08:53:52 -0300 Subject: [PATCH 13/25] Improve toString on User class. --- wise-webapp/src/main/java/com/wisemapping/model/User.java | 1 - 1 file changed, 1 deletion(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/model/User.java b/wise-webapp/src/main/java/com/wisemapping/model/User.java index 78e4e8ab..663c6a00 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/User.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/User.java @@ -168,7 +168,6 @@ public class User return "User{" + "firstname='" + firstname + '\'' + ", lastname='" + lastname + '\'' + - ", password='" + password + '\'' + "', email = '" + this.getEmail() + "}"; } } From 0ee642c24689ed85cea28a3eab9b0412a3dd1b98 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 22 Mar 2022 20:44:07 -0300 Subject: [PATCH 14/25] Improve exception un invalid email --- .../exceptions/InvalidEmailException.java | 39 +++++++++++++++++++ .../wisemapping/rest/MindmapController.java | 8 ++-- .../src/main/resources/messages_en.properties | 1 + 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100755 wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidEmailException.java diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidEmailException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidEmailException.java new file mode 100755 index 00000000..92739682 --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidEmailException.java @@ -0,0 +1,39 @@ +/* + * Copyright [2022] [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.springframework.lang.Nullable; + +import javax.validation.constraints.NotNull; + +public class InvalidEmailException + extends ClientException { + private static final String EMAIL_IS_INVALID = "INVALID_EMAIL_ADDRESS"; + + public InvalidEmailException(@NotNull String emails) { + super("Invalid email exception:" + emails, Severity.WARNING); + } + + @NotNull + @Override + protected String getMsgBundleKey() { + return EMAIL_IS_INVALID; + } +} diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 53f0dd4a..ec8a9ac0 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -243,7 +243,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.POST, value = "/maps/{id}/collabs/", consumes = {"application/json", "application/xml"}, produces = {"application/json", "application/xml"}) @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException { + public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException, InvalidEmailException { final Mindmap mindMap = findMindmapById(id); // Only owner can change collaborators... @@ -259,7 +259,7 @@ public class MindmapController extends BaseController { // Is a valid email address ? if (!EmailValidator.getInstance().isValid(email)) { - throw new IllegalArgumentException(email + " is not valid email address"); + throw new InvalidEmailException(email); } final Collaboration collaboration = mindMap.findCollaboration(email); @@ -269,7 +269,7 @@ public class MindmapController extends BaseController { throw new IllegalArgumentException(roleStr + " is not a valid role"); } - // Remove from the list of pendings to remove ... + // Remove from the list of pending to remove ... if (collaboration != null) { collabsToRemove.remove(collaboration); } @@ -407,7 +407,7 @@ public class MindmapController extends BaseController { // Is a valid email address ? final EmailValidator emailValidator = EmailValidator.getInstance(); if (!emailValidator.isValid(email)) { - throw new IllegalArgumentException(email + " is not valid email address"); + throw new InvalidEmailException(email); } final Mindmap mindmap = findMindmapById(id); diff --git a/wise-webapp/src/main/resources/messages_en.properties b/wise-webapp/src/main/resources/messages_en.properties index a6a9fafc..163f0a66 100644 --- a/wise-webapp/src/main/resources/messages_en.properties +++ b/wise-webapp/src/main/resources/messages_en.properties @@ -4,6 +4,7 @@ SITE.TITLE = WiseMapping FIELD_REQUIRED = Required field cannot be left blank EMAIL_ALREADY_EXIST = There is an account already with this email. NO_VALID_EMAIL_ADDRESS = Invalid email address +INVALID_EMAIL_ADDRESS = Invalid email address. Please, verify that your entered valid email address. PASSWORD_MISMATCH = Your password entries did not match CREATOR = Creator WELCOME = Welcome From b8eadb7533bf2a0869ca78b2814b5b7f74b71c31 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 23 Mar 2022 10:56:57 -0300 Subject: [PATCH 15/25] Fix unit tests --- .../wisemapping/exceptions/LockException.java | 45 +++++---- .../wisemapping/rest/MindmapController.java | 20 ++-- .../wisemapping/rest/ValidationException.java | 36 ++++---- .../wisemapping/rest/model/RestLockInfo.java | 91 +++++++++---------- .../com/wisemapping/service/LockInfo.java | 9 ++ .../com/wisemapping/service/LockManager.java | 38 ++++---- .../wisemapping/service/LockManagerImpl.java | 5 +- .../com/wisemapping/test/rest/RestHelper.java | 2 +- .../test/rest/RestMindmapITCase.java | 11 ++- 9 files changed, 144 insertions(+), 113 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/LockException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/LockException.java index 88bd18a8..31f2c07f 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/LockException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/LockException.java @@ -1,32 +1,39 @@ /* -* Copyright [2022] [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. -*/ + * Copyright [2022] [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 com.wisemapping.model.Mindmap; +import com.wisemapping.model.User; +import com.wisemapping.service.LockManager; import org.jetbrains.annotations.NotNull; public class LockException - extends ClientException -{ + extends ClientException { private static final String MSG_KEY = "MINDMAP_IS_LOCKED"; + public LockException(@NotNull String message) { - super(message,Severity.INFO); + super(message, Severity.INFO); + } + + public static LockException createLockLost(@NotNull Mindmap mindmap, @NotNull User user, @NotNull LockManager manager) { + return new LockException("Lock can not be granted to " + user.getEmail() + ". The lock is assigned to " + manager.getLockInfo(mindmap)); } @NotNull diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 93e7ab20..bb8bfb4c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -31,10 +31,12 @@ import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; +import org.springframework.web.server.ResponseStatusException; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -449,19 +451,23 @@ public class MindmapController extends BaseController { mindmapService.updateCollaboration(user, collaboration.get()); } - @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/lock", consumes = {"text/plain"}, produces = {"application/json", "application/xml"}) - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void updateMapLock(@RequestBody String value, @PathVariable int id) throws WiseMappingException { + @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/locks/{lockid}", consumes = {"text/plain"}, produces = {"application/json", "application/xml"}) + public ResponseEntity lockMindmap(@RequestBody String value, @PathVariable int id, @PathVariable long lockid) throws WiseMappingException { final User user = Utils.getUser(); final LockManager lockManager = mindmapService.getLockManager(); final Mindmap mindmap = findMindmapById(id); - final boolean lock = Boolean.parseBoolean(value); - if (!lock) { - lockManager.unlock(mindmap, user); + ResponseEntity result = new ResponseEntity<>(null, HttpStatus.NO_CONTENT); + if (Boolean.parseBoolean(value)) { + if (!lockManager.isLocked(mindmap)) { + final LockInfo lockInfo = lockManager.lock(mindmap, user, lockid); + final RestLockInfo restLockInfo = new RestLockInfo(lockInfo, user); + result = new ResponseEntity<>(restLockInfo, HttpStatus.OK); + } } else { - throw new UnsupportedOperationException("REST lock must be implemented."); + lockManager.unlock(mindmap, user); } + return result; } @RequestMapping(method = RequestMethod.DELETE, value = "/maps/batch") diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/ValidationException.java b/wise-webapp/src/main/java/com/wisemapping/rest/ValidationException.java index 84bcf896..a3962513 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/ValidationException.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/ValidationException.java @@ -1,20 +1,20 @@ /* -* Copyright [2022] [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. -*/ + * Copyright [2022] [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.rest; @@ -23,11 +23,11 @@ import com.wisemapping.exceptions.WiseMappingException; import org.jetbrains.annotations.NotNull; import org.springframework.validation.Errors; -public class ValidationException extends WiseMappingException{ +public class ValidationException extends WiseMappingException { private final Errors errors; public ValidationException(@NotNull Errors errors) { - super("Validation Exceptions:"+errors); + super("Validation Exceptions:" + errors); this.errors = errors; } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java index 8fe3a57b..7cb226df 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java @@ -1,20 +1,20 @@ /* -* Copyright [2022] [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. -*/ + * Copyright [2022] [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.rest.model; @@ -22,6 +22,7 @@ package com.wisemapping.rest.model; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.wisemapping.model.Collaborator; +import com.wisemapping.model.User; import com.wisemapping.service.LockInfo; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,48 +40,42 @@ import javax.xml.bind.annotation.XmlRootElement; @JsonIgnoreProperties(ignoreUnknown = true) public class RestLockInfo { - @NotNull - final private Collaborator user; - - @Nullable - final private LockInfo lockInfo; + private long session; + private long timestamp; + private String email; // This is required only for compliance with the JAXB serializer. - public RestLockInfo(){ + public RestLockInfo() { - this.lockInfo = null; - //noinspection ConstantConditions - this.user = null; } - public RestLockInfo(@Nullable LockInfo lockInfo, @NotNull Collaborator collaborator) { - - this.lockInfo = lockInfo; - this.user = collaborator; - } - - public boolean isLocked() { - return lockInfo != null; - } - - public void setLocked(boolean locked) { - // Ignore ... - } - - public boolean isLockedByMe() { - return isLocked() && lockInfo != null && lockInfo.getUser().identityEquality(user); - } - - public void setLockedByMe(boolean lockedForMe) { - // Ignore ... + public RestLockInfo(@Nullable LockInfo lockInfo, @NotNull User user) { + this.session = lockInfo.getSession(); + this.timestamp = lockInfo.getTimestamp(); + this.email = user.getEmail(); } public long getTimestamp() { - return lockInfo != null ? lockInfo.getTimestamp() : -1; + return this.timestamp; + } + + public long getSession() { + return this.session; + } + + public void setSession(long session) { + this.session = session; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; } public void setTimestamp(long value) { - // + this.timestamp = value; } - } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java b/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java index 30a24108..962230bc 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java @@ -74,4 +74,13 @@ public class LockInfo { this.previousTimestamp = this.timestamp; this.timestamp = mindmap.getLastModificationTime().getTimeInMillis(); } + + @Override + public String toString() { + return "LockInfo{" + + "user=" + user + + ", session=" + session + + ", timestamp=" + timestamp + + '}'; + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java index 3aee7a19..711bef73 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java @@ -1,20 +1,20 @@ /* -* Copyright [2022] [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. -*/ + * Copyright [2022] [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.service; @@ -41,5 +41,9 @@ public interface LockManager { long generateSession(); - long verifyAndUpdateLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws LockException, SessionExpiredException; + @NotNull + LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws LockException; + + long verifyAndUpdateLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws + LockException, SessionExpiredException; } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java index 24cb5e83..c8225873 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java @@ -110,9 +110,10 @@ class LockManagerImpl implements LockManager { } @NotNull - private LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws LockException { + @Override + public LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws LockException { if (isLocked(mindmap) && !isLockedBy(mindmap, user)) { - throw new LockException("Invalid lock, this should not happen"); + throw LockException.createLockLost(mindmap, user, this); } LockInfo result = lockInfoByMapId.get(mindmap.getId()); diff --git a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestHelper.java b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestHelper.java index 6272540f..7430e5a4 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestHelper.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestHelper.java @@ -21,7 +21,7 @@ public class RestHelper { public static final String COLOR = "#000000"; static HttpHeaders createHeaders(@NotNull MediaType mediaType) { - List acceptableMediaTypes = new ArrayList(); + List acceptableMediaTypes = new ArrayList<>(); acceptableMediaTypes.add(mediaType); final HttpHeaders result = new HttpHeaders(); diff --git a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java index fd8b418e..b5de2537 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java @@ -23,6 +23,7 @@ import static org.testng.Assert.*; @Test public class RestMindmapITCase { + private static final int SESSION_ID = 100; private String userEmail = "admin@wisemapping.com"; private static final String ICON = "glyphicon glyphicon-tag"; @@ -217,8 +218,16 @@ public class RestMindmapITCase { mapToUpdate.setXml("this is not valid"); mapToUpdate.setProperties("{zoom:x}"); + // Create lock ... + final HttpHeaders lockHeaders = createHeaders(mediaType); + lockHeaders.setContentType(MediaType.TEXT_PLAIN); + + HttpEntity lockEntity = new HttpEntity<>("true", lockHeaders); + final ResponseEntity lockResponse = template.exchange(HOST_PORT + resourceUri + "/locks/{lockid}", HttpMethod.PUT, lockEntity, RestLockInfo.class, SESSION_ID); + final RestLockInfo lockInfo = lockResponse.getBody(); + // Update map ... - final String resourceUrl = HOST_PORT + resourceUri.toString() + "/document"; + final String resourceUrl = HOST_PORT + resourceUri.toString() + "/document?session=" + lockInfo.getSession() + "×tamp=" + lockInfo.getTimestamp(); requestHeaders.setContentType(MediaType.APPLICATION_XML); final HttpEntity updateEntity = new HttpEntity<>(mapToUpdate, requestHeaders); template.put(resourceUrl, updateEntity); From d380b97938e53770b7c05fe04430d7c4c27922d0 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 23 Mar 2022 23:32:19 -0300 Subject: [PATCH 16/25] Clean up lock implementation --- .../wisemapping/rest/MindmapController.java | 44 ++++---- .../wisemapping/rest/model/RestLockInfo.java | 20 +--- .../com/wisemapping/service/LockInfo.java | 43 +++----- .../com/wisemapping/service/LockManager.java | 10 +- .../wisemapping/service/LockManagerImpl.java | 100 ++++-------------- .../wisemapping/webmvc/MindmapController.java | 21 +--- .../src/main/webapp/jsp/mindmapEditor.jsp | 2 - .../src/main/webapp/jsp/mindmapViewonly.jsp | 1 - .../test/rest/RestMindmapITCase.java | 10 +- 9 files changed, 68 insertions(+), 183 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index bb8bfb4c..21cd984b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -27,7 +27,6 @@ import com.wisemapping.validator.MapInfoValidator; import org.apache.commons.validator.routines.EmailValidator; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; @@ -36,7 +35,6 @@ import org.springframework.stereotype.Controller; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; -import org.springframework.web.server.ResponseStatusException; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -111,8 +109,8 @@ public class MindmapController extends BaseController { } @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "application/xml"}) - @ResponseBody - public Long updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor, @RequestParam(required = true) long timestamp, @RequestParam(required = true) long session) throws WiseMappingException, IOException { + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws WiseMappingException, IOException { final Mindmap mindmap = findMindmapById(id); final User user = Utils.getUser(); @@ -125,7 +123,7 @@ public class MindmapController extends BaseController { // Have permissions ? final LockManager lockManager = mindmapService.getLockManager(); - long result = lockManager.verifyAndUpdateLock(mindmap, user, session, timestamp); + lockManager.lock(mindmap, user); // Update collaboration properties ... final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(user); @@ -137,8 +135,6 @@ public class MindmapController extends BaseController { // Update map ... saveMindmapDocument(minor, mindmap, user); - - return result; } @RequestMapping(method = RequestMethod.GET, value = {"/maps/{id}/document/xml", "/maps/{id}/document/xml-pub"}, consumes = {"text/plain"}, produces = {"application/xml; charset=UTF-8"}) @@ -451,25 +447,6 @@ public class MindmapController extends BaseController { mindmapService.updateCollaboration(user, collaboration.get()); } - @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/locks/{lockid}", consumes = {"text/plain"}, produces = {"application/json", "application/xml"}) - public ResponseEntity lockMindmap(@RequestBody String value, @PathVariable int id, @PathVariable long lockid) throws WiseMappingException { - final User user = Utils.getUser(); - final LockManager lockManager = mindmapService.getLockManager(); - final Mindmap mindmap = findMindmapById(id); - - ResponseEntity result = new ResponseEntity<>(null, HttpStatus.NO_CONTENT); - if (Boolean.parseBoolean(value)) { - if (!lockManager.isLocked(mindmap)) { - final LockInfo lockInfo = lockManager.lock(mindmap, user, lockid); - final RestLockInfo restLockInfo = new RestLockInfo(lockInfo, user); - result = new ResponseEntity<>(restLockInfo, HttpStatus.OK); - } - } else { - lockManager.unlock(mindmap, user); - } - return result; - } - @RequestMapping(method = RequestMethod.DELETE, value = "/maps/batch") @ResponseStatus(value = HttpStatus.NO_CONTENT) public void batchDelete(@RequestParam() String ids) throws IOException, WiseMappingException { @@ -587,5 +564,20 @@ public class MindmapController extends BaseController { mindmapService.updateMindmap(mindmap, false); } + @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/lock", consumes = {"text/plain"}, produces = {"application/json", "application/xml"}) + public ResponseEntity lockMindmap(@RequestBody String value, @PathVariable int id) throws WiseMappingException { + final User user = Utils.getUser(); + final LockManager lockManager = mindmapService.getLockManager(); + final Mindmap mindmap = findMindmapById(id); + ResponseEntity result = new ResponseEntity<>(null, HttpStatus.NO_CONTENT); + if (Boolean.parseBoolean(value)) { + final LockInfo lockInfo = lockManager.lock(mindmap, user); + final RestLockInfo restLockInfo = new RestLockInfo(lockInfo, user); + result = new ResponseEntity<>(restLockInfo, HttpStatus.OK); + } else { + lockManager.unlock(mindmap, user); + } + return result; + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java index 7cb226df..7da4b783 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java @@ -40,8 +40,6 @@ import javax.xml.bind.annotation.XmlRootElement; @JsonIgnoreProperties(ignoreUnknown = true) public class RestLockInfo { - private long session; - private long timestamp; private String email; // This is required only for compliance with the JAXB serializer. @@ -50,22 +48,9 @@ public class RestLockInfo { } public RestLockInfo(@Nullable LockInfo lockInfo, @NotNull User user) { - this.session = lockInfo.getSession(); - this.timestamp = lockInfo.getTimestamp(); this.email = user.getEmail(); } - public long getTimestamp() { - return this.timestamp; - } - - public long getSession() { - return this.session; - } - - public void setSession(long session) { - this.session = session; - } public String getEmail() { return email; @@ -74,8 +59,5 @@ public class RestLockInfo { public void setEmail(String email) { this.email = email; } - - public void setTimestamp(long value) { - this.timestamp = value; - } } + diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java b/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java index 962230bc..f8771053 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java @@ -27,16 +27,22 @@ import java.util.Calendar; public class LockInfo { final private User user; private Calendar timeout; - private long session; private static final int EXPIRATION_MIN = 30; - private long timestamp = -1; - private long previousTimestamp; - public LockInfo(@NotNull User user, @NotNull Mindmap mindmap, long session) { + public int getMapId() { + return mapId; + } + + public void setMapId(int mapId) { + this.mapId = mapId; + } + + private int mapId; + + public LockInfo(@NotNull User user, @NotNull Mindmap mindmap) { this.user = user; + this.mapId = mindmap.getId(); this.updateTimeout(); - this.updateTimestamp(mindmap); - this.session = session; } public User getUser() { @@ -54,33 +60,12 @@ public class LockInfo { } - public long getSession() { - return session; - } - - public void setSession(long session) { - this.session = session; - } - - public long getTimestamp() { - return timestamp; - } - - public long getPreviousTimestamp() { - return previousTimestamp; - } - - public void updateTimestamp(@NotNull Mindmap mindmap) { - this.previousTimestamp = this.timestamp; - this.timestamp = mindmap.getLastModificationTime().getTimeInMillis(); - } - @Override public String toString() { return "LockInfo{" + "user=" + user + - ", session=" + session + - ", timestamp=" + timestamp + + ", timeout=" + timeout + + ", mapId=" + mapId + '}'; } } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java index 711bef73..05ae6fbb 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java @@ -21,7 +21,6 @@ package com.wisemapping.service; import com.wisemapping.exceptions.AccessDeniedSecurityException; import com.wisemapping.exceptions.LockException; import com.wisemapping.exceptions.SessionExpiredException; -import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.model.Mindmap; import com.wisemapping.model.User; import org.jetbrains.annotations.NotNull; @@ -31,19 +30,14 @@ public interface LockManager { LockInfo getLockInfo(@NotNull Mindmap mindmap); - LockInfo updateExpirationTimeout(@NotNull Mindmap mindmap, @NotNull User user); - void unlock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException, AccessDeniedSecurityException; void unlockAll(@NotNull User user) throws LockException, AccessDeniedSecurityException; - boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User collaborator); + boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User user); long generateSession(); @NotNull - LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws LockException; - - long verifyAndUpdateLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws - LockException, SessionExpiredException; + LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException; } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java index c8225873..b7247559 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java @@ -20,7 +20,6 @@ package com.wisemapping.service; import com.wisemapping.exceptions.AccessDeniedSecurityException; import com.wisemapping.exceptions.LockException; -import com.wisemapping.exceptions.SessionExpiredException; import com.wisemapping.model.CollaborationRole; import com.wisemapping.model.Mindmap; import com.wisemapping.model.User; @@ -47,23 +46,6 @@ class LockManagerImpl implements LockManager { return lockInfoByMapId.get(mindmap.getId()); } - @Override - public LockInfo updateExpirationTimeout(@NotNull Mindmap mindmap, @NotNull User user) { - if (!this.isLocked(mindmap)) { - throw new IllegalStateException("Lock lost for map. No update possible."); - } - - final LockInfo result = this.getLockInfo(mindmap); - if (!result.getUser().identityEquality(user)) { - throw new IllegalStateException("Could not update map lock timeout if you are not the locking user. User:" + result.getUser() + ", " + user); - } - - result.updateTimeout(); - result.updateTimestamp(mindmap); - logger.debug("Timeout updated for:" + mindmap.getId()); - return result; - } - @Override public void unlockAll(@NotNull final User user) throws LockException, AccessDeniedSecurityException { final Set mapIds = lockInfoByMapId.keySet(); @@ -77,14 +59,7 @@ class LockManagerImpl implements LockManager { @Override public void unlock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException, AccessDeniedSecurityException { - if (isLocked(mindmap) && !isLockedBy(mindmap, user)) { - throw new LockException("Lock can be only revoked by the locker."); - } - - if (!mindmap.hasPermissions(user, CollaborationRole.EDITOR)) { - throw new AccessDeniedSecurityException(mindmap.getId(), user); - } - + verifyHasLock(mindmap, user); this.unlock(mindmap.getId()); } @@ -111,25 +86,38 @@ class LockManagerImpl implements LockManager { @NotNull @Override - public LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws LockException { + public LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException { if (isLocked(mindmap) && !isLockedBy(mindmap, user)) { throw LockException.createLockLost(mindmap, user, this); } + // Do I need to create a new lock ? LockInfo result = lockInfoByMapId.get(mindmap.getId()); - if (result != null) { - // Update timeout only... - logger.debug("Update timestamp:" + mindmap.getId()); - updateExpirationTimeout(mindmap, user); - // result.setSession(session); - } else { - logger.debug("Lock map id:" + mindmap.getId()); - result = new LockInfo(user, mindmap, session); + if (result == null) { + logger.debug("Creating new lock for map id:" + mindmap.getId()); + result = new LockInfo(user, mindmap); lockInfoByMapId.put(mindmap.getId(), result); } + + // Update timestamp ... + logger.debug("Updating timeout:" + result); + result.updateTimeout(); + return result; } + private void verifyHasLock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException, AccessDeniedSecurityException { + // Only editor can have lock ... + if (!mindmap.hasPermissions(user, CollaborationRole.EDITOR)) { + throw new AccessDeniedSecurityException(mindmap.getId(), user); + } + + // Is the lock assigned to the user ... + if (isLocked(mindmap) && !isLockedBy(mindmap, user)) { + throw LockException.createLockLost(mindmap, user, this); + } + } + public LockManagerImpl() { lockInfoByMapId = new ConcurrentHashMap<>(); expirationTimer.schedule(new TimerTask() { @@ -149,46 +137,4 @@ class LockManagerImpl implements LockManager { } }, ONE_MINUTE_MILLISECONDS, ONE_MINUTE_MILLISECONDS); } - - public long verifyAndUpdateLock(@NotNull Mindmap mindmap, @NotNull User user, @Nullable long session, @NotNull long timestamp) throws LockException, SessionExpiredException { - synchronized (this) { - // Could the map be updated ? - verifyLock(mindmap, user, session, timestamp); - - // Update timestamp for lock ... - final LockInfo lockInfo = this.updateExpirationTimeout(mindmap, user); - return lockInfo.getTimestamp(); - } - } - - private void verifyLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws LockException, SessionExpiredException { - - // The lock was lost, reclaim as the ownership of it. - final boolean lockLost = this.isLocked(mindmap); - if (!lockLost) { - this.lock(mindmap, user, session); - } - - final LockInfo lockInfo = this.getLockInfo(mindmap); - if (lockInfo.getUser().identityEquality(user)) { - long savedTimestamp = mindmap.getLastModificationTime().getTimeInMillis(); - final boolean outdated = savedTimestamp > timestamp; - - if (lockInfo.getSession() == session) { - // Timestamp might not be returned to the client. This try to cover this case, ignoring the client timestamp check. - final User lastEditor = mindmap.getLastEditor(); - boolean editedBySameUser = lastEditor == null || user.identityEquality(lastEditor); - if (outdated && !editedBySameUser) { - throw new SessionExpiredException("Map has been updated by " + (lastEditor.getEmail()) + ",Timestamp:" + timestamp + "," + savedTimestamp + ", User:" + lastEditor.getId() + ":" + user.getId() + ",Mail:'" + lastEditor.getEmail() + "':'" + user.getEmail(), lastEditor); - } - } else if (outdated) { - logger.warn("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + savedTimestamp); - // @Todo: Temporally disabled to unblock save action. More research needed. -// throw new MultipleSessionsOpenException("Sessions:" + session + ":" + lockInfo.getSession() + ",Timestamp: " + timestamp + ": " + savedTimestamp); - } - } else { - throw new SessionExpiredException("Different Users.", lockInfo.getUser()); - } - } - } 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 b8d4776e..03317139 100644 --- a/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java @@ -47,7 +47,6 @@ import java.util.Locale; @Controller public class MindmapController { - public static final String LOCK_SESSION_ATTRIBUTE = "lockSession"; @Qualifier("mindmapService") @Autowired private MindmapService mindmapService; @@ -76,19 +75,16 @@ public class MindmapController { private String showEditorPage(int id, @NotNull final Model model, boolean requiresLock) throws WiseMappingException { final MindMapBean mindmapBean = findMindmapBean(id); final Mindmap mindmap = mindmapBean.getDelegated(); - final User collaborator = Utils.getUser(); + final User user = Utils.getUser(); final Locale locale = LocaleContextHolder.getLocale(); // Is the mindmap locked ?. boolean isLocked = false; - boolean readOnlyMode = !requiresLock || !mindmap.hasPermissions(collaborator, CollaborationRole.EDITOR); + boolean readOnlyMode = !requiresLock || !mindmap.hasPermissions(user, CollaborationRole.EDITOR); if (!readOnlyMode) { final LockManager lockManager = this.mindmapService.getLockManager(); - if (lockManager.isLocked(mindmap) && !lockManager.isLockedBy(mindmap, collaborator)) { + if (lockManager.isLocked(mindmap) && !lockManager.isLockedBy(mindmap, user)) { isLocked = true; - } else { - model.addAttribute("lockTimestamp", mindmap.getLastModificationTime().getTimeInMillis()); - model.addAttribute(LOCK_SESSION_ATTRIBUTE, lockManager.generateSession()); } model.addAttribute("lockInfo", lockManager.getLockInfo(mindmap)); } @@ -97,8 +93,7 @@ public class MindmapController { // Configure default locale for the editor ... model.addAttribute("locale", locale.toString().toLowerCase()); - model.addAttribute("principal", collaborator); - model.addAttribute("memoryPersistence", false); + model.addAttribute("principal", user); model.addAttribute("mindmapLocked", isLocked); return "mindmapEditor"; @@ -107,23 +102,17 @@ public class MindmapController { @RequestMapping(value = "maps/{id}/view", method = RequestMethod.GET) public String showMindmapViewerPage(@PathVariable int id, @NotNull Model model) throws WiseMappingException { final String result = showPrintPage(id, model); - model.addAttribute("readOnlyMode", true); return result; } @RequestMapping(value = "maps/{id}/try", method = RequestMethod.GET) public String showMindmapTryPage(@PathVariable int id, @NotNull Model model) throws WiseMappingException { - final String result = showEditorPage(id, model, false); - model.addAttribute("memoryPersistence", true); - model.addAttribute("readOnlyMode", false); - return result; + return showEditorPage(id, model, false); } @RequestMapping(value = "maps/{id}/{hid}/view", method = RequestMethod.GET) public String showMindmapViewerRevPage(@PathVariable int id, @PathVariable int hid, @NotNull Model model) throws WiseMappingException { - final String result = showPrintPage(id, model); - model.addAttribute("readOnlyMode", true); model.addAttribute("hid", String.valueOf(hid)); return result; } diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp index 6712efe4..637bf2cb 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp @@ -33,8 +33,6 @@