119 Commits

Author SHA1 Message Date
Paulo Gustavo Veiga
f3afdc04cd Merge branch 'develop' 2022-03-27 15:02:24 -03:00
Paulo Gustavo Veiga
b4fb536137 Prepare for release 5.0.10 2022-03-27 15:01:50 -03:00
Paulo Gustavo Veiga
ef43e2889e Merge branch 'develop' 2022-03-27 14:56:51 -03:00
Paulo Gustavo Veiga
86a5b39124 Partial i18n share message. 2022-03-27 14:50:35 -03:00
Paulo Gustavo Veiga
791b99e753 Fix typo 2022-03-27 14:38:50 -03:00
Paulo Gustavo Veiga
d063e4eb20 Translate missing resources. 2022-03-27 14:37:58 -03:00
Paulo Gustavo Veiga
ff2b37f4cf i18n password changed. 2022-03-27 14:29:29 -03:00
Paulo Gustavo Veiga
8989914eb3 Merge branch 'develop' of bitbucket.org:wisemapping/wisemapping-open-source into develop 2022-03-27 07:34:32 -03:00
Paulo Gustavo Veiga
f70f1d89ab Translate welcome email. 2022-03-27 07:32:53 -03:00
Paulo Veiga
50f0dba93a Improve documentation 2022-03-27 00:24:56 +00:00
Paulo Gustavo Veiga
20b2e8f1e8 Improve mindmap format validation. 2022-03-26 21:06:51 -03:00
Paulo Gustavo Veiga
c5c47892cb Improve collab error email report. 2022-03-24 00:14:38 -03:00
Paulo Gustavo Veiga
9d08ad57b9 Fix failing lock test 2022-03-23 23:41:18 -03:00
Paulo Gustavo Veiga
d380b97938 Clean up lock implementation 2022-03-23 23:32:19 -03:00
Paulo Gustavo Veiga
b8eadb7533 Fix unit tests 2022-03-23 10:56:57 -03:00
Paulo Gustavo Veiga
63f83e879d Merge branch 'develop' into feature/lock2 2022-03-22 22:09:00 -03:00
Paulo Gustavo Veiga
0ee642c246 Improve exception un invalid email 2022-03-22 20:44:07 -03:00
Paulo Gustavo Veiga
20a9978577 Improve toString on User class. 2022-03-22 08:53:52 -03:00
Paulo Gustavo Veiga
b18505050a Revert "Fix CSS collition"
This reverts commit f4cf7e623e.
2022-03-22 08:48:09 -03:00
Paulo Gustavo Veiga
f4cf7e623e Fix CSS collition 2022-03-22 08:38:52 -03:00
Paulo Gustavo Veiga
cbdd6ebb47 WIp 2022-03-22 08:35:47 -03:00
Paulo Gustavo Veiga
fdd6fb928b Improve lock logic. 2022-03-17 19:25:33 -03:00
Paulo Gustavo Veiga
340ddcd1ef Update copyright 2022-03-17 18:47:34 -03:00
Paulo Gustavo Veiga
92dd4a7014 Improve lock code. 2022-03-16 23:16:34 -03:00
Paulo Gustavo Veiga
a9d091a187 Improve error handle on security errors. 2022-03-15 10:30:18 -03:00
Paulo Gustavo Veiga
4cab5299c4 Change mapping of securiy exceptions. 2022-03-14 23:33:16 -03:00
Paulo Gustavo Veiga
9d35aa8279 Fix resource in Chinese 2022-03-14 22:56:02 -03:00
Paulo Gustavo Veiga
c769a5fbe7 Fix compilation 2022-03-14 15:08:31 -03:00
Paulo Gustavo Veiga
7ca5bf716f Improve message on lack of permissions to perform map operations 2022-03-14 15:04:15 -03:00
Paulo Gustavo Veiga
e38c1bcc7c Bump up to 5.0.10 2022-03-14 00:09:47 -03:00
Paulo Gustavo Veiga
fe3a5f884b Merge branch 'develop' 2022-03-14 00:08:58 -03:00
Paulo Gustavo Veiga
c978d02514 Release 5.0.9 version 2022-03-14 00:08:31 -03:00
Paulo Gustavo Veiga
c68c43f5d7 Add chinese support 2022-03-13 23:08:19 -03:00
Paulo Gustavo Veiga
5694697c5f Improve exception handling on non permissions 2022-03-09 17:18:14 -08:00
Paulo Gustavo Veiga
d217768b83 Remove unused context variables. 2022-03-09 13:24:41 -08:00
Paulo Gustavo Veiga
d0a03ad2a3 Revert "Git add CORS"
This reverts commit 5c201d40df.
2022-03-06 21:27:06 -08:00
Paulo Gustavo Veiga
ffd976ffe5 Revert "Add header changes on cors"
This reverts commit 297931508a.
2022-03-06 21:26:54 -08:00
Paulo Gustavo Veiga
297931508a Add header changes on cors 2022-03-06 21:10:45 -08:00
Paulo Gustavo Veiga
5c201d40df Git add CORS 2022-03-06 20:47:45 -08:00
Paulo Gustavo Veiga
1acf84de3f Add anonymous to js loading 2022-03-06 20:16:48 -08:00
Paulo Gustavo Veiga
f5fabae644 Clean up JAVA_OPTS variable 2022-02-28 21:17:21 -08:00
Paulo Gustavo Veiga
e0dac73873 Fix NPE on null user. 2022-02-28 21:12:28 -08:00
Paulo Gustavo Veiga
a8e2c74a21 Remove homepage 2022-02-28 14:51:25 -08:00
Paulo Gustavo Veiga
8d5245da5a Fix typo 2022-02-27 15:02:18 -08:00
Paulo Gustavo Veiga
67cc7e586c Rember me redirect on maps on login 2022-02-27 13:16:39 -08:00
Paulo Gustavo Veiga
732127a7a9 Fix to many redirects on remember me 2022-02-27 13:11:55 -08:00
Paulo Gustavo Veiga
b60f5b331f Disable remember me until solve too many redirect problem. 2022-02-27 09:59:03 -08:00
Paulo Gustavo Veiga
82a3e1c793 Extract new relic config 2022-02-27 09:14:30 -08:00
Paulo Gustavo Veiga
402393a9f7 Enable tomcat redirect filter 2022-02-27 09:02:41 -08:00
Paulo Gustavo Veiga
5cdf2d6de2 Bump up version 2022-02-25 20:23:01 -08:00
Paulo Gustavo Veiga
c5f1ca88be Merge branch 'develop' of bitbucket.org:wisemapping/wisemapping-open-source into develop 2022-02-25 06:24:08 -08:00
Paulo Gustavo Veiga
194e858191 Bump up size limit 2022-02-25 06:23:52 -08:00
polly good
6892732389 Merged in ru-locale (pull request #11)
messages_ru.properties

* messages_ru.properties 

Approved-by: Paulo Veiga
2022-02-25 00:45:12 +00:00
Paulo Gustavo Veiga
8b61809bbe Fix css location for bootstrap 2022-02-23 16:36:08 -08:00
Paulo Gustavo Veiga
c3be0b6552 Increase number of nodes supported. 2022-02-23 14:34:55 -08:00
Paulo Gustavo Veiga
ba80f9479c Merge branch 'develop' of bitbucket.org:wisemapping/wisemapping-open-source into develop 2022-02-23 09:51:17 -08:00
Paulo Gustavo Veiga
50fa9d80f5 Improve error message 2022-02-23 09:51:02 -08:00
Paulo Veiga
5bb6f199c3 README.md edited online with Bitbucket 2022-02-23 15:39:06 +00:00
Paulo Gustavo Veiga
31980ca444 Fix version 2022-02-23 07:16:07 -08:00
Paulo Gustavo Veiga
dd8e9e2f5d Bump up version 2022-02-23 07:11:13 -08:00
Paulo Gustavo Veiga
e8c86bd159 Merge branch 'develop' 2022-02-23 06:59:36 -08:00
Paulo Gustavo Veiga
77a1560625 Merge branch 'develop' of bitbucket.org:wisemapping/wisemapping-open-source into develop 2022-02-23 06:58:18 -08:00
Paulo Gustavo Veiga
2cda03e80d Bump up version 2022-02-23 06:53:42 -08:00
Matias Arriola
73b0454d14 Fix error image. 2022-02-23 14:10:56 +00:00
Paulo Gustavo Veiga
fbbd2c43ff Fix marging on view 2022-02-22 18:14:21 -08:00
Paulo Gustavo Veiga
c3f93fdf4a Improve validation of xml mindmaps during save. 2022-02-22 14:17:13 -08:00
Paulo Gustavo Veiga
342099194d Add missing resources 2022-02-21 10:53:34 -08:00
Paulo Gustavo Veiga
0cd62f612b Improve error handling in not public maps. 2022-02-21 09:43:04 -08:00
Paulo Gustavo Veiga
820e268e3e Fix bug on non-existing last modified 2022-02-21 09:08:28 -08:00
Paulo Gustavo Veiga
aa6531efe1 Remove unsed resources. 2022-02-20 22:12:40 -08:00
Paulo Gustavo Veiga
859c3dd927 Clean up styles now that are part of the editor 2022-02-20 21:55:40 -08:00
Matias Arriola
93f3e91cc1 Delete log file
set session-timeout back to 180
2022-02-20 18:38:16 -03:00
Paulo Gustavo Veiga
f7a9804065 Clean up unused url patterns 2022-02-19 19:47:14 -08:00
Paulo Gustavo Veiga
1c8f3bb203 Fix unit tests. 2022-02-19 19:43:50 -08:00
Paulo Gustavo Veiga
6aadb5a363 Complete security filter 2022-02-19 17:21:45 -08:00
Paulo Gustavo Veiga
f2c15d100d Add CSRD to get operations 2022-02-19 15:57:57 -08:00
Paulo Gustavo Veiga
9966412705 Clean up paths 2022-02-19 12:43:35 -08:00
Paulo Gustavo Veiga
e1bd2630aa First steps on csfr impl 2022-02-19 12:39:38 -08:00
Paulo Gustavo Veiga
bea7bea486 Add flush to commit changes. 2022-02-17 18:11:54 -08:00
Paulo Gustavo Veiga
fad7442ffc Clean up code 2022-02-17 17:36:46 -08:00
Paulo Gustavo Veiga
1eab15f8f3 Fix constrain issue. 2022-02-17 17:34:22 -08:00
Paulo Gustavo Veiga
8e080075a0 Add missing image 2022-02-16 19:18:37 -08:00
Paulo Gustavo Veiga
f0f32178c7 Change mail image to png 2022-02-16 19:05:32 -08:00
Paulo Gustavo Veiga
7cf2644fa8 Bump up snapshot version 2022-02-16 18:46:41 -08:00
Paulo Gustavo Veiga
51b5de2eed Release 5.0.5 2022-02-16 18:43:21 -08:00
Paulo Gustavo Veiga
c84a583c3f Merge branch 'develop' 2022-02-16 18:41:21 -08:00
Paulo Gustavo Veiga
5c18c44a2f Bump up version. 2022-02-16 18:38:56 -08:00
Paulo Gustavo Veiga
f16762636b Chores: remove duplicated code 2022-02-16 18:31:41 -08:00
Paulo Gustavo Veiga
1f99ce3889 Fix sharing of man on new collabs. 2022-02-16 18:29:28 -08:00
Paulo Gustavo Veiga
63cfe44d50 Remove orphan collabs on registration 2022-02-16 18:05:26 -08:00
Paulo Gustavo Veiga
07ad57e3b4 Fix ui download version 2022-02-15 21:05:16 -08:00
Paulo Gustavo Veiga
7fd227d56f Fix version to be downloaded 2022-02-15 21:00:35 -08:00
Paulo Gustavo Veiga
5d7e7f8d30 Parametrize GA key 2022-02-15 20:36:17 -08:00
Paulo Gustavo Veiga
d69373f563 Update GA JS 2022-02-15 19:38:12 -08:00
Paulo Gustavo Veiga
7d7373768f Update dependencies 2022-02-14 20:06:21 -08:00
Paulo Gustavo Veiga
5c0c18eba0 Add email validation on collaborators. 2022-02-14 19:59:36 -08:00
Paulo Gustavo Veiga
188b280bf2 Add ads.txt file. 2022-02-13 21:35:26 -08:00
Paulo Gustavo Veiga
6f205e04ce Add newrelic config 2022-02-13 10:29:28 -08:00
Paulo Gustavo Veiga
ff4c7d2949 Fix distribution 2022-02-13 10:21:56 -08:00
Paulo Gustavo Veiga
fb1755768c Adjust log level 2022-02-13 08:25:09 -08:00
Paulo Gustavo Veiga
c269cd9edb Remove support for admin to remove mindmaps 2022-02-12 12:47:54 -08:00
Paulo Gustavo Veiga
89dd7e0193 Remove hackcode forze of lazy loading. 2022-02-12 12:34:30 -08:00
Paulo Gustavo Veiga
ccc0b10ea0 Improve captch erorr handling on invalid input 2022-02-12 10:33:05 -08:00
Paulo Gustavo Veiga
83cff3f66d Split error message 2022-02-12 09:17:52 -08:00
Paulo Gustavo Veiga
f35d145fb8 Improve JS error loggin 2022-02-12 09:15:18 -08:00
Paulo Gustavo Veiga
609fdd7144 Split error message on browser error. 2022-02-12 08:35:29 -08:00
Paulo Gustavo Veiga
b67cd407a4 Improve captcha error processing. 2022-02-12 08:29:53 -08:00
Paulo Gustavo Veiga
6c808dfc2a Disable ; strict control 2022-02-12 08:04:16 -08:00
Paulo Gustavo Veiga
9af7247072 Fix captcha error list 2022-02-12 07:52:16 -08:00
Paulo Gustavo Veiga
ea1349c518 Clean up code. 2022-02-12 00:33:50 -08:00
Paulo Gustavo Veiga
607418dcf7 Add missing message resource. 2022-02-12 00:27:24 -08:00
Paulo Gustavo Veiga
0da8c73d74 Clean up google analytics initialization 2022-02-12 00:12:03 -08:00
Paulo Gustavo Veiga
cd0ff1dc89 Merge branch 'develop' of bitbucket.org:wisemapping/wisemapping-open-source into develop 2022-02-12 00:04:15 -08:00
Paulo Gustavo Veiga
19ae88e93f Improve JS error loggin 2022-02-12 00:03:55 -08:00
Paulo Gustavo Veiga
18c67233da Improve JS error loggin 2022-02-11 23:56:53 -08:00
Paulo Veiga
ebea27b3df Update messages_es.properties (POEditor.com) 2022-02-12 06:23:20 +00:00
Paulo Veiga
13f8eb0898 Update messages_de.properties (POEditor.com) 2022-02-12 06:23:18 +00:00
Paulo Veiga
aed943ce5a Update messages_fr.properties (POEditor.com) 2022-02-12 06:23:16 +00:00
Paulo Veiga
d9c7db9c1f Update messages_en.properties (POEditor.com) 2022-02-12 06:23:14 +00:00
221 changed files with 1696 additions and 13112 deletions

View File

@@ -11,6 +11,7 @@ The following products must be installed:
* OpenJDK 11 or higher
* Maven 3.x or higher ([http://maven.apache.org/])
* npm 6 or higher ([https://www.npmjs.com/package/npm?activeTab=versions])
### Compiling
@@ -45,7 +46,7 @@ In order to reduce the life-cycle to develop UI backend testing, you can do the
A quick and dirty solution to share changes in the UI is to manually compile the dist. This will make the loader file available without the need to publish:
`cp -r wisemapping-frontend/packages/mindplot/dist/* wisemapping-open-source/wise-ui/target/wisemapping-mindplot/package/dist`
`yarn --cwd wisemapping-frontend build;cp -r wisemapping-frontend/packages/mindplot/dist/* wisemapping-open-source/wise-ui/target/wisemapping-mindplot/package/dist;cp -r wisemapping-frontend/packages/mindplot/dist/* wisemapping-open-source/wise-ui/target/wisemapping-mindplot/package/dist`
### Compiling and running with docker-compose

View File

@@ -9,7 +9,7 @@ LABEL maintainer="Paulo Gustavo Veiga <pveiga@wisemapping.com>"
ARG WEBAPP_TARGET_DIR="/usr/local/tomcat/webapps/ROOT"
ARG DB_BASE_DIR="/var/lib/wisemapping"
# Defautl ENV configurations ...
# Default ENV configurations ...
ENV JAVA_OPTS="-XX:+PrintFlagsFinal -XX:InitialRAMPercentage=30 -XX:MaxRAMPercentage=80"
ENV database.base.url=${DB_BASE_DIR}
@@ -22,6 +22,15 @@ RUN rm /tmp/wisemapping.war
# Change logger to
RUN cp ${WEBAPP_TARGET_DIR}/WEB-INF/classes/log4j-stdout.properties ${WEBAPP_TARGET_DIR}/WEB-INF/classes/log4j.properties
# Add support for proxy
RUN sed -i 's|\
</Host>|\
<Valve className="org.apache.catalina.valves.RemoteIpValve" \
remoteIpHeader="X-Forwarded-For" \
protocolHeader="X-Forwarded-Proto"/>\
</Host>|' \
/usr/local/tomcat/conf/server.xml
# Copy default HSQL DB for testing ...
RUN mkdir -p ${DB_BASE_DIR}/db
COPY db/ ${DB_BASE_DIR}/db

View File

@@ -4,7 +4,7 @@
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
<com.wisemapping.version>5.0.4</com.wisemapping.version>
<com.wisemapping.version>5.0.10</com.wisemapping.version>
<superpom.dir>${project.basedir}/wise-webapps</superpom.dir>
</properties>
@@ -16,7 +16,7 @@
<groupId>org.wisemapping</groupId>
<artifactId>wisemapping</artifactId>
<name>WiseMapping Project</name>
<version>5.0.4</version>
<version>5.0.10</version>
<packaging>pom</packaging>
<licenses>

View File

@@ -12,7 +12,7 @@
<groupId>org.wisemapping</groupId>
<artifactId>wisemapping</artifactId>
<relativePath>../pom.xml</relativePath>
<version>5.0.4</version>
<version>5.0.10</version>
</parent>
<build>
@@ -27,26 +27,26 @@
<tasks>
<!-- Download and unzip mindplot npm package -->
<mkdir dir="target/wisemapping-mindplot"/>
<exec executable="npm" dir="target">
<exec executable="npm" dir="target" failonerror="true">
<arg value="pack"/>
<arg value="@wisemapping/mindplot@5.0.3"/>
<arg value="@wisemapping/mindplot@5.0.10"/>
</exec>
<exec executable="tar" dir="target">
<exec executable="tar" dir="target" failonerror="true">
<arg value="-xvzf"/>
<arg value="wisemapping-mindplot-5.0.4.tgz"/>
<arg value="wisemapping-mindplot-5.0.10.tgz"/>
<arg value="-C"/>
<arg value="wisemapping-mindplot"/>
</exec>
<!-- Download and unzip webapp npm package -->
<mkdir dir="target/wisemapping-webapp"/>
<exec executable="npm" dir="target">
<exec executable="npm" dir="target" failonerror="true">
<arg value="pack"/>
<arg value="@wisemapping/webapp@5.0.3"/>
<arg value="@wisemapping/webapp@5.0.11"/>
</exec>
<exec executable="tar" dir="target">
<exec executable="tar" dir="target" failonerror="true">
<arg value="-xvzf"/>
<arg value="wisemapping-webapp-5.0.4.tgz"/>
<arg value="wisemapping-webapp-5.0.11.tgz"/>
<arg value="-C"/>
<arg value="wisemapping-webapp"/>
</exec>

View File

@@ -9,29 +9,15 @@
<groupId>org.wisemapping</groupId>
<artifactId>wisemapping</artifactId>
<relativePath>../pom.xml</relativePath>
<version>5.0.4</version>
<version>5.0.10</version>
</parent>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
<repository>
<id>maven2-repository.jahia.org</id>
<name>Jahia Repository for Maven</name>
<url>http://maven.jahia.org/maven2/</url>
<layout>default</layout>
</repository>
</repositories>
<properties>
<org.springframework.version>5.3.14</org.springframework.version>
<org.springframework.addons>5.3.5.RELEASE</org.springframework.addons>
<hibernate.version>5.6.3.Final</hibernate.version>
<hibernate.version>5.6.5.Final</hibernate.version>
<hibernate-validator.version>6.0.21.Final</hibernate-validator.version>
<spring-security-taglibs.version>5.6.1</spring-security-taglibs.version>
</properties>
<dependencies>
@@ -83,6 +69,11 @@
<version>${org.springframework.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${spring-security-taglibs.version}</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
@@ -205,7 +196,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.27</version>
<version>8.0.28</version>
<scope>runtime</scope>
</dependency>
<dependency>
@@ -213,12 +204,6 @@
<artifactId>commons-dbcp2</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
@@ -240,6 +225,12 @@
<version>1.2.17</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-validator/commons-validator -->
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.7</version>
</dependency>
<!-- Only for test purposes -->
<dependency>
<groupId>org.hsqldb</groupId>
@@ -250,7 +241,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.3</version>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
@@ -277,7 +268,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<version>4.5.5</version>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>junit</groupId>

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -27,9 +27,11 @@ import com.wisemapping.security.LegacyPasswordEncoder;
import org.hibernate.ObjectNotFoundException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.security.crypto.password.PasswordEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -102,22 +104,31 @@ public class UserManagerImpl
}
@Override
public User createUser(@NotNull User user, @NotNull Collaborator col) {
user.setPassword(passwordEncoder.encode(user.getPassword()));
public User createUser(@NotNull User user, @NotNull Collaborator collaborator) {
assert user != null : "Trying to store a null user";
final Set<Collaboration> set = col.getCollaborations();
for (Collaboration collaboration : set) {
Collaboration newMapUser = new Collaboration();
newMapUser.setRoleId(collaboration.getRole().ordinal());
newMapUser.setMindMap(collaboration.getMindMap());
newMapUser.setCollaborator(user);
user.addCollaboration(newMapUser);
// Migrate from previous temporal collab to new user ...
List<Collaboration> newCollabs = new ArrayList<>();
final Set<Collaboration> collaborations = collaborator.getCollaborations();
for (Collaboration oldCollab : collaborations) {
Collaboration newCollab = new Collaboration();
newCollab.setRoleId(oldCollab.getRole().ordinal());
newCollab.setMindMap(oldCollab.getMindMap());
newCollab.setCollaborator(user);
user.addCollaboration(newCollab);
newCollabs.add(newCollab);
}
getHibernateTemplate().delete(col);
getHibernateTemplate().flush();
getHibernateTemplate().saveOrUpdate(user);
// Delete old collaboration
final HibernateTemplate template = getHibernateTemplate();
collaborations.forEach(c -> template.delete(c));
template.delete(collaborator);
template.flush();
// Save all new...
this.createUser(user);
newCollabs.forEach(c -> template.saveOrUpdate(c));
return user;
}
@@ -136,8 +147,7 @@ public class UserManagerImpl
// Does the password need to be encrypted ?
final String password = user.getPassword();
if(password!=null && (!password.startsWith(LegacyPasswordEncoder.ENC_PREFIX) && !password.startsWith( "{"+ DefaultPasswordEncoderFactories.ENCODING_ID)))
{
if (password != null && (!password.startsWith(LegacyPasswordEncoder.ENC_PREFIX) && !password.startsWith("{" + DefaultPasswordEncoderFactories.ENCODING_ID))) {
user.setPassword(passwordEncoder.encode(user.getPassword()));
}
@@ -152,7 +162,7 @@ public class UserManagerImpl
query.setParameter("activationCode", code);
final List users = query.list();
if(users != null && !users.isEmpty()) {
if (users != null && !users.isEmpty()) {
assert users.size() == 1 : "More than one user with the same username!";
user = (User) users.get(0);

View File

@@ -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 [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.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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -0,0 +1,56 @@
/*
* 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 InvalidMindmapException
extends ClientException {
private static final String EMPTY_MINDMAP = "MINDMAP_EMPTY_ERROR";
private static final String INVALID_MINDMAP_FORMAT = "INVALID_MINDMAP_FORMAT";
private static final String TOO_BIG_MINDMAP = "TOO_BIG_MINDMAP";
private final String bundleKey;
private InvalidMindmapException(@NotNull String bundleKey, @Nullable String xmlDoc) {
super("Invalid mindmap format:" + xmlDoc, Severity.SEVERE);
this.bundleKey = bundleKey;
}
static public InvalidMindmapException emptyMindmap() {
return new InvalidMindmapException(EMPTY_MINDMAP, "<empty string>");
}
static public InvalidMindmapException invalidFormat(@Nullable String xmlDoc) {
return new InvalidMindmapException(INVALID_MINDMAP_FORMAT, xmlDoc);
}
static public InvalidMindmapException tooBigMindnap(int numberOfTopics) {
return new InvalidMindmapException(TOO_BIG_MINDMAP, "<too-big " + numberOfTopics + ">");
}
@NotNull
@Override
protected String getMsgBundleKey() {
return bundleKey;
}
}

View File

@@ -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;

View File

@@ -1,32 +1,39 @@
/*
* 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.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

View File

@@ -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

View File

@@ -0,0 +1,37 @@
/*
* 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;
public class MapNonPublicException
extends ClientException {
public static final String MSG_KEY = "ACCESS_HAS_BEEN_REVOKED";
public MapNonPublicException(@NotNull String msg) {
super(msg, Severity.FATAL);
}
@NotNull
@Override
protected String getMsgBundleKey() {
return MSG_KEY;
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -48,7 +48,7 @@ public class RequestPropertiesInterceptor implements HandlerInterceptor {
@Value("${site.homepage}")
private String siteHomepage;
@Value("${site.baseurl}")
@Value("${site.baseurl:http://localhost:8080}")
private String siteUrl;
@Value("${security.type}")

View File

@@ -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

View File

@@ -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

View File

@@ -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;
@@ -7,6 +24,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 +34,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) {
@@ -28,16 +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 e) {
e.printStackTrace();
} catch (AccessDeniedSecurityException e) {
e.printStackTrace();
synchronized (mindmapService.getLockManager()) {
try {
lockManager.unlockAll(user);
} catch (LockException | AccessDeniedSecurityException e) {
logger.error(e);
}
}
}
}

View File

@@ -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
@@ -41,7 +41,7 @@ public final class Mailer {
//~ Methods ..............................................................................................
public Mailer(@NotNull String siteEmail, @NotNull String supportEmail,@NotNull String errorReporterEmail) {
public Mailer(@NotNull String siteEmail, @NotNull String supportEmail, @NotNull String errorReporterEmail) {
this.serverFromEmail = siteEmail;
this.supportEmail = supportEmail;
this.errorReporterEmail = errorReporterEmail;
@@ -51,7 +51,7 @@ public final class Mailer {
return serverFromEmail;
}
public void sendEmail(final String from, final String to, final String subject, final Map model,
public void sendEmail(final String from, final String to, final String subject, final Map<String, Object> model,
@NotNull final String templateMail) {
final MimeMessagePreparator preparator =
new MimeMessagePreparator() {

View File

@@ -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
@@ -22,37 +22,36 @@ import com.wisemapping.filter.SupportedUserAgent;
import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User;
import com.wisemapping.util.VelocityEngineUtils;
import com.wisemapping.util.VelocityEngineWrapper;
import org.apache.commons.io.IOUtils;
import com.wisemapping.rest.model.RestLogItem;
import org.apache.commons.lang.StringEscapeUtils;
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.context.i18n.LocaleContextHolder;
import org.springframework.context.support.ResourceBundleMessageSource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
final public class NotificationService {
final private static Logger logger = Logger.getLogger(Mailer.class);
final private static String DEFAULT_WISE_URL = "http://localhost:8080/wisemapping";
private VelocityEngineWrapper velocityEngineWrapper;
private ResourceBundleMessageSource messageSource;
@Autowired
private Mailer mailer;
private String baseUrl;
public NotificationService() {
NotifierFilter notificationFilter = new NotifierFilter();
}
public void newCollaboration(@NotNull Collaboration collaboration, @NotNull Mindmap mindmap, @NotNull User user, @Nullable String message) {
final Locale locale = LocaleContextHolder.getLocale();
try {
// Sent collaboration email ...
@@ -62,12 +61,11 @@ final public class NotificationService {
final String collabEmail = collaboration.getCollaborator().getEmail();
// Build the subject ...
final String subject = "[WiseMapping] " + user.getFullName() + " has shared a mindmap with you";
final String subject = messageSource.getMessage("SHARE_MAP.EMAIL_SUBJECT", new Object[]{user.getFullName()}, locale);
// Fill template properties ...
final Map<String, Object> model = new HashMap<String, Object>();
final Map<String, Object> model = new HashMap<>();
model.put("mindmap", mindmap);
model.put("message", "message");
model.put("ownerName", user.getFirstname());
model.put("mapEditUrl", getBaseUrl() + "/c/maps/" + mindmap.getId() + "/edit");
model.put("baseUrl", getBaseUrl());
@@ -83,50 +81,46 @@ final public class NotificationService {
}
public void resetPassword(@NotNull User user, @NotNull String temporalPassword) {
final String mailSubject = "[WiseMapping] Your new password";
final String messageTitle = "Your new password has been generated";
final String messageBody =
"<p>Someone, most likely you, requested a new password for your WiseMapping account. </p>\n" +
"<p><strong>Here is your new password: " + temporalPassword + "</strong></p>\n" +
"<p>You can login clicking <a href=\"" + getBaseUrl() + "/c/login\">here</a>. We strongly encourage you to change the password as soon as possible.</p>";
final Locale locale = LocaleContextHolder.getLocale();
final String mailSubject = messageSource.getMessage("CHANGE_PASSWORD.EMAIL_SUBJECT", null, locale);
final String messageTitle = messageSource.getMessage("CHANGE_PASSWORD.EMAIL_TITLE", null, locale);
final String messageBody = messageSource.getMessage("CHANGE_PASSWORD.EMAIL_BODY", new Object[]{temporalPassword, getBaseUrl()}, locale);
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
}
private void logErrorMessage(final Map model,
@NotNull final String templateMail) {
final String messageBody = VelocityEngineUtils.mergeTemplateIntoString(velocityEngineWrapper.getVelocityEngine(), "/mail/" + templateMail, model);
logger.error("Unexpected editor error => " + messageBody);
}
public void passwordChanged(@NotNull User user) {
final String mailSubject = "[WiseMapping] Your password has been changed";
final String messageTitle = "Your password has been changed successfully";
final String messageBody =
"<p>This is only an notification that your password has been changed. No further action is required.</p>";
final Locale locale = LocaleContextHolder.getLocale();
final String mailSubject = messageSource.getMessage("PASSWORD_CHANGED.EMAIL_SUBJECT", null, locale);
final String messageTitle = messageSource.getMessage("PASSWORD_CHANGED.EMAIL_TITLE", null, locale);
final String messageBody = messageSource.getMessage("PASSWORD_CHANGED.EMAIL_BODY", null, locale);
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
}
public void newAccountCreated(@NotNull User user) {
final String mailSubject = "Welcome to WiseMapping !";
final String messageTitle = "Your account has been created successfully";
final String messageBody =
"<p> Thank you for your interest in WiseMapping. Click <a href='https://app.wisemapping.com/c/login'>here</a> to start creating and sharing new mind maps. If have any feedback or idea, send us an email to <a href=\"mailto:feedback@wisemapping.com\">feedback@wisemapping.com</a> .We'd love to hear from you.</p>";
final Locale locale = LocaleContextHolder.getLocale();
final String mailSubject = messageSource.getMessage("REGISTRATION.EMAIL_SUBJECT", null, locale);
final String messageTitle = messageSource.getMessage("REGISTRATION.EMAIL_TITLE", null, locale);
final String messageBody = messageSource.getMessage("REGISTRATION.EMAIL_BODY", null, locale);
sendTemplateMail(user, mailSubject, messageTitle, messageBody);
}
private void sendTemplateMail(@NotNull User user, @NotNull String mailSubject, @NotNull String messageTitle, @NotNull String messageBody) {
try {
final Map<String, Object> model = new HashMap<String, Object>();
final Map<String, Object> model = new HashMap<>();
model.put("firstName", user.getFirstname());
model.put("messageTitle", messageTitle);
model.put("messageBody", messageBody);
model.put("baseUrl", getBaseUrl());
model.put("supportEmail", mailer.getSupportEmail());
logger.debug("Email properties->" + model);
mailer.sendEmail(mailer.getServerSenderEmail(), user.getEmail(), mailSubject, model, "baseLayout.vm");
} catch (Exception e) {
handleException(e);
@@ -145,7 +139,7 @@ final public class NotificationService {
public void activateAccount(@NotNull User user) {
final Map<String, User> model = new HashMap<String, User>();
final Map<String, Object> model = new HashMap<>();
model.put("user", user);
mailer.sendEmail(mailer.getServerSenderEmail(), user.getEmail(), "[WiseMapping] Active account", model, "activationAccountMail.vm");
}
@@ -164,23 +158,24 @@ final public class NotificationService {
// }
}
public void setVelocityEngineWrapper(VelocityEngineWrapper engine) {
this.velocityEngineWrapper = engine;
}
public void reportJavascriptException(@Nullable Mindmap mindmap, @Nullable User user, @NotNull RestLogItem errorItem, @NotNull HttpServletRequest request) {
public void reportJavascriptException(@Nullable Mindmap mindmap, @Nullable User user, @Nullable String jsErrorMsg, @NotNull HttpServletRequest request) {
final Map<String, String> summary = new HashMap<>();
summary.put("JS-MSG", errorItem.getJsErrorMsg());
summary.put("JS-STACK", errorItem.getJsStack());
final Map<String, String> model = new HashMap<>();
model.put("errorMsg", jsErrorMsg);
String mindmapXML = "";
try {
model.put("mapXML", StringEscapeUtils.escapeXml(mindmap == null ? "map not found" : mindmap.getXmlStr()));
mindmapXML = StringEscapeUtils.escapeXml(mindmap == null ? "map not found" : mindmap.getXmlStr());
} catch (UnsupportedEncodingException e) {
// Ignore ...
}
model.put("mapId", Integer.toString(mindmap.getId()));
model.put("mapTitle", mindmap.getTitle());
summary.put("mapId", Integer.toString(mindmap.getId()));
summary.put("mapTitle", mindmap.getTitle());
logError(model, user, request);
logError(summary, user, request);
logger.error("Unexpected editor mindmap => " + mindmapXML);
logger.error("Unexpected editor JS Stack => " + errorItem.getJsErrorMsg() + "-" + errorItem.getJsStack());
}
private void logError(@NotNull Map<String, String> model, @Nullable User user, @NotNull HttpServletRequest request) {
@@ -194,44 +189,45 @@ final public class NotificationService {
model.put("method", request.getMethod());
model.put("remoteAddress", request.getRemoteAddr());
logErrorMessage(model,
"errorNotification.vm");
String errorAsString = model.keySet().stream()
.map(key -> key + "=" + model.get(key))
.collect(Collectors.joining(", ", "{", "}"));
logger.error("Unexpected editor info => " + errorAsString);
}
public void reportJavaException(@NotNull Throwable exception, @Nullable User user, @NotNull HttpServletRequest request) {
final Map<String, String> model = new HashMap<String, String>();
final Map<String, String> model = new HashMap<>();
model.put("errorMsg", stackTraceToString(exception));
logError(model, user, request);
}
public String stackTraceToString(@NotNull Throwable e) {
String retValue;
StringWriter sw = null;
PrintWriter pw = null;
try {
sw = new StringWriter();
pw = new PrintWriter(sw);
String retValue = "";
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try (sw; pw) {
e.printStackTrace(pw);
retValue = sw.toString();
} finally {
IOUtils.closeQuietly(pw);
IOUtils.closeQuietly(sw);
} catch (IOException ioException) {
ioException.printStackTrace();
}
return retValue;
}
public String getBaseUrl() {
if ("${site.baseurl}".equals(baseUrl)) {
baseUrl = DEFAULT_WISE_URL;
System.err.println("Warning: site.baseurl has not being configured. Mail site references could be not properly sent. Using :" + baseUrl);
}
return baseUrl;
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
public void setMessageSource(ResourceBundleMessageSource messageSource) {
this.messageSource = messageSource;
}
}

View File

@@ -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;

View File

@@ -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<String> exclude = new HashSet<String>();
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<String> exclude) {
this.exclude = exclude;
}
public void setNotificationService(NotificationService notificationService) {
this.notificationService = notificationService;
}
}

View File

@@ -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

View File

@@ -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;

View File

@@ -1,24 +1,27 @@
/*
* 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;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@@ -29,22 +32,23 @@ public class Collaboration implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;;
private int id;
;
@Column(name = "role_id",unique = true,nullable = true)
@Column(name = "role_id", unique = true)
private CollaborationRole role;
@ManyToOne
@JoinColumn(name="mindmap_id",nullable = false)
@JoinColumn(name = "mindmap_id", nullable = false)
private Mindmap mindMap;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="colaborator_id",nullable = false)
@JoinColumn(name = "colaborator_id", nullable = false)
private Collaborator collaborator;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name="properties_id",nullable = false, unique = true)
private CollaborationProperties collaborationProperties = new CollaborationProperties();;
@JoinColumn(name = "properties_id", nullable = false, unique = true)
private CollaborationProperties collaborationProperties = new CollaborationProperties();
public Collaboration() {
}
@@ -129,10 +133,9 @@ public class Collaboration implements Serializable {
@Override
public int hashCode() {
int result = (int) (id ^ (id >>> 32));
int result = id ^ (id >>> 32);
result = 31 * result + (role != null ? role.hashCode() : 0);
result = 31 * result + (mindMap != null ? mindMap.hashCode() : 0);
result = 31 * result + (collaborator != null ? collaborator.hashCode() : 0);
return result;
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -19,9 +19,12 @@
package com.wisemapping.model;
import com.wisemapping.exceptions.AccessDeniedSecurityException;
import com.wisemapping.exceptions.InvalidMindmapException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.util.ZipUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -34,12 +37,12 @@ import java.util.*;
@Entity
@Table(name = "MINDMAP")
public class Mindmap implements Serializable {
public class Mindmap implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "creation_date")
private Calendar creationTime;
@@ -52,6 +55,7 @@ public class Mindmap implements Serializable {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "last_editor_id", nullable = false)
@NotFound(action = NotFoundAction.IGNORE)
private User lastEditor;
private String description;
@@ -59,7 +63,7 @@ public class Mindmap implements Serializable {
@Column(name = "public")
private boolean isPublic;
@OneToMany(mappedBy="mindMap",orphanRemoval = true, cascade = {CascadeType.ALL})
@OneToMany(mappedBy = "mindMap", orphanRemoval = true, cascade = {CascadeType.ALL})
private Set<Collaboration> collaborations = new HashSet<>();
@ManyToMany(cascade = CascadeType.ALL)
@@ -91,7 +95,9 @@ public class Mindmap implements Serializable {
}
}
public void setXmlStr(@NotNull String xml) {
public void setXmlStr(@NotNull String xml) throws InvalidMindmapException {
// Is a valid mindmap ... ?
MindmapUtils.verifyMindmap(xml);
this.setUnzipXml(xml.getBytes(StandardCharsets.UTF_8));
}
@@ -155,7 +161,7 @@ public class Mindmap implements Serializable {
public Optional<Collaboration> findCollaboration(@NotNull Collaborator collaborator) {
return this.collaborations
.stream()
.filter(c->c.getCollaborator().identityEquality(collaborator))
.filter(c -> c.getCollaborator().identityEquality(collaborator))
.findAny();
}

View File

@@ -0,0 +1,51 @@
/*
* 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;
import com.wisemapping.exceptions.InvalidMindmapException;
import org.jetbrains.annotations.Nullable;
abstract public class MindmapUtils {
private static final int MAX_SUPPORTED_NODES = 4000;
public static void verifyMindmap(@Nullable String xmlDoc) throws InvalidMindmapException {
if (xmlDoc == null || xmlDoc.trim().isEmpty()) {
// Perform basic structure validation. Must have a map node and
throw InvalidMindmapException.emptyMindmap();
}
// Perform basic structure validation without parsing the XML.
if (!xmlDoc.trim().endsWith("</map>") || !xmlDoc.trim().startsWith("<map")) {
throw InvalidMindmapException.invalidFormat(xmlDoc);
}
int numberOfTopics = xmlDoc.split("<topic").length;
// Any valid map must contain at least a central topic ...
if (numberOfTopics == 0) {
throw InvalidMindmapException.invalidFormat(xmlDoc);
}
// Validate that the number of nodes is not bigger 5000 nodes.
if (numberOfTopics > MAX_SUPPORTED_NODES) {
throw InvalidMindmapException.tooBigMindnap(numberOfTopics);
}
}
}

View File

@@ -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,11 @@ public class User
this.authenticatorUri = authenticatorUri;
}
@Override
public String toString() {
return "User{" +
"firstname='" + firstname + '\'' +
", lastname='" + lastname + '\'' +
"', email = '" + this.getEmail() + "}";
}
}

View File

@@ -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
@@ -55,8 +55,6 @@ public class AccountController extends BaseController {
@Autowired
private NotificationService notificationService;
final Logger logger = Logger.getLogger(AccountController.class);
@RequestMapping(method = RequestMethod.PUT, value = "account/password", consumes = {"text/plain"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@@ -126,15 +124,4 @@ public class AccountController extends BaseController {
}
userService.removeUser(user);
}
@RequestMapping(method = RequestMethod.POST, value = "/logger/editor", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void logError(@RequestBody RestLogItem item, @NotNull HttpServletRequest request) {
final Mindmap mindmap = mindmapService.findMindmapById(item.getMapId());
final User user = Utils.getUser();
logger.error("Unexpected editor error - " + item.getJsErrorMsg());
notificationService.reportJavascriptException(mindmap, user, item.getJsErrorMsg() + "\n" + item.getJsStack(), request);
}
}

View File

@@ -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
@@ -138,77 +138,4 @@ public class AdminController extends BaseController {
userService.removeUser(user);
}
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@RequestMapping(method = RequestMethod.GET, value = "admin/database/purge")
public void purgeDB(@RequestParam(required = true) Integer minUid, @RequestParam(required = true) Integer maxUid, @RequestParam(required = true) Boolean apply) throws WiseMappingException, UnsupportedEncodingException {
for (int i = minUid; i < maxUid; i++) {
try {
System.out.println("Looking for user:" + i);
final User user = userService.getUserBy(i);
if (user != null) {
// Do not process admin accounts ...
if (user.getEmail().contains("wisemapping")) {
continue;
}
// Iterate over the list of maps ...
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
for (Collaboration collaboration : collaborations) {
final Mindmap mindmap = collaboration.getMindMap();
if (MindmapFilter.MY_MAPS.accept(mindmap, user)) {
final Calendar yearAgo = Calendar.getInstance();
yearAgo.add(Calendar.MONTH, -4);
// The use has only two maps... When they have been modified ..
System.out.println("Checking map id:" + mindmap.getId());
if (mindmap.getLastModificationTime().before(yearAgo) && !mindmap.isPublic()) {
System.out.println("Old map months map:" + mindmap.getId());
if (isWelcomeMap(mindmap) || isSimpleMap(mindmap)) {
System.out.println("Purged map id:" + mindmap.getId() + ", userId:" + user.getId());
if (apply) {
mindmapService.removeMindmap(mindmap, user);
}
}
}
// Purge history ...
mindmapService.purgeHistory(mindmap.getId());
}
}
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (WiseMappingException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (RuntimeException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@RequestMapping(method = RequestMethod.GET, value = "admin/database/purge/history")
public void purgeHistory(@RequestParam(required = true) Integer mapId) throws WiseMappingException, IOException {
mindmapService.purgeHistory(mapId);
}
private boolean isWelcomeMap(@NotNull Mindmap mindmap) throws UnsupportedEncodingException {
// Is welcome map ?
final String xmlStr = mindmap.getXmlStr();
boolean oldWelcomeMap = xmlStr.contains("Welcome to WiseMapping") && xmlStr.contains("My Wisemaps");
return oldWelcomeMap;
}
public boolean isSimpleMap(@NotNull Mindmap mindmap) throws UnsupportedEncodingException {
String xmlStr = mindmap.getXmlStr();
String[] topics = xmlStr.split(Pattern.quote("<topic"));
return topics.length <= 3;
}
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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
@@ -18,20 +18,19 @@
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;
import com.wisemapping.service.*;
import com.wisemapping.validator.MapInfoValidator;
import org.apache.commons.validator.routines.EmailValidator;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
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;
@@ -42,6 +41,7 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Controller
@@ -110,8 +110,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 = false) Long timestamp, @RequestParam(required = false) 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();
@@ -122,33 +122,20 @@ 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 ?
final LockManager lockManager = mindmapService.getLockManager();
lockManager.lock(mindmap, user);
// Update collaboration properties ...
final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(user);
collaborationProperties.setMindmapProperties(properties);
// Validate content ...
String xml = restMindmap.getXml();
if (xml == null) {
throw new IllegalArgumentException("Map xml can not be null");
}
final String xml = restMindmap.getXml();
mindmap.setXmlStr(xml);
// 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;
}
@RequestMapping(method = RequestMethod.GET, value = {"/maps/{id}/document/xml", "/maps/{id}/document/xml-pub"}, consumes = {"text/plain"}, produces = {"application/xml; charset=UTF-8"})
@@ -163,14 +150,10 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.PUT, value = {"/maps/{id}/document/xml"}, consumes = {"text/plain"})
@ResponseBody
public void updateDocument(@PathVariable int id, @RequestBody String xmlDoc) throws WiseMappingException, IOException {
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser();
if (xmlDoc != null && !xmlDoc.isEmpty()) {
mindmap.setXmlStr(xmlDoc);
}
mindmap.setXmlStr(xmlDoc);
saveMindmapDocument(false, mindmap, user);
}
@@ -182,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 ...
@@ -255,8 +208,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(id, user);
}
// Does the map exists ?
final Mindmap result = mindmapService.findMindmapById(id);
if (result == null) {
throw new MapCouldNotFoundException("Map could not be found. Id:" + id);
}
@@ -272,7 +232,6 @@ public class MindmapController extends BaseController {
// Is there a map with the same name ?
if (mindmapService.getMindmapByTitle(title, user) != null) {
throw buildValidationException("title", "You already have a mindmap with this title");
}
@@ -284,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 {
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...
@@ -296,14 +255,21 @@ public class MindmapController extends BaseController {
// Compare one by one if some of the elements has been changed ....
final Set<Collaboration> collabsToRemove = new HashSet<>(mindMap.getCollaborations());
for (RestCollaboration restCollab : restCollabs.getCollaborations()) {
final Collaboration collaboration = mindMap.findCollaboration(restCollab.getEmail());
final String email = restCollab.getEmail();
// Is a valid email address ?
if (!EmailValidator.getInstance().isValid(email)) {
throw new InvalidEmailException(email);
}
final Collaboration collaboration = mindMap.findCollaboration(email);
// Validate role format ...
String roleStr = restCollab.getRole();
if (roleStr == null) {
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);
}
@@ -324,13 +290,25 @@ 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, InvalidEmailException {
final Mindmap mindMap = findMindmapById(id);
// Only owner can change collaborators...
final User user = Utils.getUser();
if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) {
throw new IllegalArgumentException("No enough permissions");
throw new AccessDeniedSecurityException("User must be owner to share mindmap");
}
// Is valid email address ?
final EmailValidator emailValidator = EmailValidator.getInstance();
final Set<String> invalidEmails = restCollabs
.getCollaborations()
.stream()
.map(RestCollaboration::getEmail)
.filter(e -> !emailValidator.isValid(e)).collect(Collectors.toSet());
if (!invalidEmails.isEmpty()) {
throw new InvalidEmailException(String.join(", ", invalidEmails));
}
// Has any role changed ?. Just removed it.
@@ -374,7 +352,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<Collaboration> collaborations = mindMap.getCollaborations();
@@ -392,14 +370,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"})
@@ -432,6 +405,12 @@ public class MindmapController extends BaseController {
public void deleteCollabByEmail(@PathVariable int id, @RequestParam(required = false) String email) throws IOException, WiseMappingException {
logger.debug("Deleting permission for email:" + email);
// Is a valid email address ?
final EmailValidator emailValidator = EmailValidator.getInstance();
if (!emailValidator.isValid(email)) {
throw new InvalidEmailException(email);
}
final Mindmap mindmap = findMindmapById(id);
final User user = Utils.getUser();
@@ -470,21 +449,6 @@ 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 IOException, 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);
} else {
throw new UnsupportedOperationException("REST lock must be implemented.");
}
}
@RequestMapping(method = RequestMethod.DELETE, value = "/maps/batch")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void batchDelete(@RequestParam() String ids) throws IOException, WiseMappingException {
@@ -495,6 +459,7 @@ public class MindmapController extends BaseController {
mindmapService.removeMindmap(mindmap, user);
}
}
@RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json"})
@ResponseStatus(value = HttpStatus.CREATED)
public void createMap(@RequestBody(required = false) String mapXml, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws IOException, WiseMappingException {
@@ -506,7 +471,7 @@ public class MindmapController extends BaseController {
if (description != null && !description.isEmpty()) {
mindmap.setDescription(description);
}else {
} else {
mindmap.setDescription("description");
}
@@ -524,7 +489,7 @@ public class MindmapController extends BaseController {
mindmap.setXmlStr(mapXml);
// Add new mindmap ...
final User user = Utils.getUser();
final User user = Utils.getUser(true);
mindmapService.addMindmap(mindmap, user);
// Return the new created map ...
@@ -600,4 +565,21 @@ public class MindmapController extends BaseController {
mindmap.addLabel(label);
mindmapService.updateMindmap(mindmap, false);
}
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/lock", consumes = {"text/plain"}, produces = {"application/json", "application/xml"})
public ResponseEntity<RestLockInfo> 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<RestLockInfo> 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;
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -58,7 +58,7 @@ public class UserController extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = "/users", produces = {"application/json", "application/xml"})
@ResponseStatus(value = HttpStatus.CREATED)
public void registerUser(@RequestBody RestUserRegistration registration, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws WiseMappingException, BindException {
logger.info("Register new user:" + registration.getEmail());
logger.debug("Register new user:" + registration.getEmail());
// If tomcat is behind a reverse proxy, ip needs to be found in other header.
String remoteIp = request.getHeader(REAL_IP_ADDRESS_HEADER);

View File

@@ -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.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;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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.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,24 @@ import javax.xml.bind.annotation.XmlRootElement;
@JsonIgnoreProperties(ignoreUnknown = true)
public class RestLockInfo {
@NotNull
final private Collaborator user;
@Nullable
final private LockInfo lockInfo;
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 RestLockInfo(@Nullable LockInfo lockInfo, @NotNull User user) {
this.email = user.getEmail();
}
public boolean isLocked() {
return lockInfo != null;
public String getEmail() {
return email;
}
public void setLocked(boolean locked) {
// Ignore ...
public void setEmail(String email) {
this.email = email;
}
public boolean isLockedByMe() {
return isLocked() && lockInfo != null && lockInfo.getUser().identityEquality(user);
}
public void setLockedByMe(boolean lockedForMe) {
// Ignore ...
}
public long getTimestamp() {
return lockInfo != null ? lockInfo.getTimestamp() : -1;
}
public void setTimestamp(long value) {
//
}
}

View File

@@ -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

View File

@@ -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.rest.model;
@@ -22,9 +22,9 @@ package com.wisemapping.rest.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wisemapping.exceptions.InvalidMindmapException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.*;
import com.wisemapping.security.Utils;
import com.wisemapping.util.TimeUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -34,10 +34,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.IOException;
import java.util.Calendar;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@XmlRootElement(name = "map")
@XmlAccessorType(XmlAccessType.PROPERTY)
@@ -71,7 +67,7 @@ public class RestMindmap {
}
}
public void setCreationTime(final String creationTime){
public void setCreationTime(final String creationTime) {
// Ignore
}
@@ -154,10 +150,10 @@ public class RestMindmap {
return mindmap.getXmlStr();
}
public void setXml(@Nullable String xml) throws IOException {
if (xml != null)
public void setXml(@Nullable String xml) throws IOException, InvalidMindmapException {
if (xml != null) {
mindmap.setXmlStr(xml);
}
}
public String getOwner() {

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -0,0 +1,44 @@
/*
* 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;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
public class CSFRRequestMatcher implements RequestMatcher {
private String prefix;
static String[] supportedMethods = {"POST", "PUT", "GET", "DELETE", "PATCH"};
@Override
public boolean matches(HttpServletRequest request) {
final String requestURI = request.getRequestURI();
return Arrays.stream(supportedMethods).anyMatch(p -> request.getMethod().toUpperCase().equals(p))
&& requestURI.startsWith(prefix);
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 {

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
@@ -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,24 +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 +
", timeout=" + timeout +
", mapId=" + mapId +
'}';
}
}

View File

@@ -1,26 +1,26 @@
/*
* 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.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.Mindmap;
import com.wisemapping.model.User;
import org.jetbrains.annotations.NotNull;
@@ -30,16 +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);
@NotNull
LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws WiseMappingException;
boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User user);
long generateSession();
@NotNull
LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException;
}

View File

@@ -1,55 +1,39 @@
/*
* 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.service;
import com.wisemapping.exceptions.AccessDeniedSecurityException;
import com.wisemapping.exceptions.LockException;
import com.wisemapping.exceptions.WiseMappingException;
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<Integer, LockInfo> lockInfoByMapId;
final static Timer expirationTimer = new Timer();
private static final int ONE_MINUTE_MILLISECONDS = 1000 * 60;
private final Map<Integer, LockInfo> lockInfoByMapId;
private final static Timer expirationTimer = new Timer();
final private static Logger logger = Logger.getLogger(LockManagerImpl.class);
@Override
@@ -62,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<Integer> mapIds = lockInfoByMapId.keySet();
@@ -92,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("Invalid lock, this should not happen");
}
verifyHasLock(mindmap, user);
this.unlock(mindmap.getId());
}
@@ -124,53 +84,57 @@ class LockManagerImpl implements LockManager {
return System.nanoTime();
}
@Override
@NotNull
public LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws WiseMappingException {
@Override
public LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user) 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("Invalid lock, this should not happen");
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<Integer, LockInfo>();
lockInfoByMapId = new ConcurrentHashMap<>();
expirationTimer.schedule(new TimerTask() {
@Override
public void run() {
logger.debug("Lock expiration scheduler started. Current locks:" + lockInfoByMapId.keySet());
final List<Integer> toRemove = new ArrayList<Integer>();
final Set<Integer> mapIds = lockInfoByMapId.keySet();
for (Integer mapId : mapIds) {
final LockInfo lockInfo = lockInfoByMapId.get(mapId);
if (lockInfo.isExpired()) {
toRemove.add(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));
}
for (Integer mapId : toRemove) {
unlock(mapId);
}
}
}, ONE_MINUTE_MILLISECONDS, ONE_MINUTE_MILLISECONDS);
}
}

View File

@@ -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
@@ -57,6 +57,8 @@ public interface MindmapService {
boolean hasPermissions(@Nullable User user, int mapId, CollaborationRole allowedRole);
boolean isMindmapPublic(int mapId);
void revertChange(@NotNull Mindmap map, int historyId) throws WiseMappingException, IOException;
MindMapHistory findMindmapHistory(int id, int hid) throws WiseMappingException;

View File

@@ -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.service;
@@ -62,6 +62,12 @@ public class MindmapServiceImpl
return hasPermissions(user, map, grantedRole);
}
@Override
public boolean isMindmapPublic(int mapId) {
final Mindmap map = mindmapManager.getMindmapById(mapId);
return map != null && map.isPublic();
}
@Override
public boolean hasPermissions(@Nullable User user, @Nullable Mindmap map, @NotNull CollaborationRole role) {
boolean result = false;
@@ -70,7 +76,7 @@ public class MindmapServiceImpl
result = true;
} else if (user != null) {
final Optional<Collaboration> collaboration = map.findCollaboration(user);
if (collaboration .isPresent()) {
if (collaboration.isPresent()) {
result = collaboration
.get()
.hasPermissions(role);
@@ -156,7 +162,7 @@ public class MindmapServiceImpl
@Override
public void removeMindmap(@NotNull Mindmap mindmap, @NotNull User user) throws WiseMappingException {
if (mindmap.getCreator().identityEquality(user) || isAdmin(user)) {
if (mindmap.getCreator().identityEquality(user)) {
mindmapManager.removeMindmap(mindmap);
} else {
final Optional<Collaboration> collaboration = mindmap.findCollaboration(user);

View File

@@ -1,6 +1,24 @@
/*
* 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;
import com.wisemapping.validator.Messages;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.fluent.Form;
@@ -22,6 +40,8 @@ public class RecaptchaService {
"https://www.google.com/recaptcha/api/siteverify";
private final static ObjectMapper objectMapper = new ObjectMapper();
public static final String CATCH_ERROR_CODE_TIMEOUT_OR_DUPLICATE = "timeout-or-duplicate";
public static final String CATCHA_ERROR_CODE_INPUT_RESPONSE = "invalid-input-response";
private String recaptchaSecret;
@Nullable
@@ -48,12 +68,21 @@ public class RecaptchaService {
.asBytes();
final Map responseBody = objectMapper.readValue(body, HashMap.class);
logger.warn("Response from recaptcha after parse: " + responseBody);
logger.debug("Response from recaptcha after parse: " + responseBody);
final Boolean success = (Boolean) responseBody.get("success");
if (success!=null && !success) {
if (success != null && !success) {
final List<String> errorCodes = (List<String>) responseBody.get("error-codes");
result = RecaptchaUtil.codeToDescription(errorCodes.get(0));
String errorCode = errorCodes.get(0);
if (errorCode.equals(CATCH_ERROR_CODE_TIMEOUT_OR_DUPLICATE)) {
result = Messages.CAPTCHA_TIMEOUT_OUT_DUPLICATE;
} else if (errorCode.equals("invalid-input-response")) {
result = Messages.CAPTCHA_INVALID_INPUT_RESPONSE;
} else {
result = Messages.CAPTCHA_LOADING_ERROR;
logger.error("Unexpected error during catch resolution:" + errorCodes);
}
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
@@ -68,30 +97,4 @@ public class RecaptchaService {
public void setRecaptchaSecret(String recaptchaSecret) {
this.recaptchaSecret = recaptchaSecret;
}
}
class RecaptchaUtil {
private static final Map<String, String>
RECAPTCHA_ERROR_CODE = new HashMap<>();
static String codeToDescription(final String code)
{
return RECAPTCHA_ERROR_CODE.getOrDefault(code,"Unexpected error validating code. Please, refresh the page and try again.");
}
static {
RECAPTCHA_ERROR_CODE.put("missing-input-secret",
"The secret parameter is missing");
RECAPTCHA_ERROR_CODE.put("invalid-input-secret",
"The secret parameter is invalid or malformed");
RECAPTCHA_ERROR_CODE.put("missing-input-response",
"The response parameter is missing");
RECAPTCHA_ERROR_CODE.put("invalid-input-response",
"The response parameter is invalid or malformed");
RECAPTCHA_ERROR_CODE.put("bad-request",
"The request is invalid or malformed");
RECAPTCHA_ERROR_CODE.put("timeout-or-duplicate",
"Please, refresh the page and try again.");
}
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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
@@ -19,6 +19,7 @@
package com.wisemapping.service;
import com.wisemapping.dao.UserManager;
import com.wisemapping.exceptions.InvalidMindmapException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.*;
@@ -119,13 +120,11 @@ public class UserServiceImpl
if (emailConfirmEnabled) {
user.setActivationDate(null);
} else {
user.setActivationDate(Calendar.getInstance());
}
Collaborator col = userManager.getCollaboratorBy(user.getEmail());
final Collaborator col = userManager.getCollaboratorBy(user.getEmail());
if (col != null) {
userManager.createUser(user, col);
} else {
@@ -148,7 +147,7 @@ public class UserServiceImpl
return user;
}
public Mindmap buildTutorialMindmap(@NotNull String firstName) {
public Mindmap buildTutorialMindmap(@NotNull String firstName) throws InvalidMindmapException {
//To change body of created methods use File | Settings | File Templates.
final Locale locale = LocaleContextHolder.getLocale();
Mindmap result = new Mindmap();

View File

@@ -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);
}
}

View File

@@ -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;
}
}

Some files were not shown because too many files have changed in this diff Show More