mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-24 12:13:49 +01:00
Merge branch 'develop' of bitbucket.org:wisemapping/wisemapping-open-source into develop
This commit is contained in:
commit
433cb5549a
@ -53,6 +53,11 @@ A quick and dirty solution to share changes in the UI is to manually compile the
|
||||
|
||||
Check out the [docker section](./docker/README.)
|
||||
|
||||
### Test reports
|
||||
|
||||
Individual test result reports can be found in wisemapping-open-source/wise-webapp/target/failsafe-reports/index.html
|
||||
Test coverage report of unit and integration test can be found in wisemapping-open-source/wise-webapp/target/site/jacoco and wisemapping-open-source/wise-webapp/target/site/jacoco-it folders. Coverage report is generated in the verify phase of [lifecicle](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#introduction-to-the-build-lifecyclea) using [jacoco](https://www.jacoco.org/jacoco/trunk/doc/maven.html)
|
||||
|
||||
## Members
|
||||
|
||||
### Founders
|
||||
|
@ -1,6 +1,6 @@
|
||||
CREATE TABLE COLLABORATOR (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL UNIQUE,
|
||||
creation_date DATE
|
||||
);
|
||||
|
||||
@ -27,7 +27,6 @@ CREATE TABLE MINDMAP (
|
||||
creation_date DATETIME,
|
||||
edition_date DATETIME,
|
||||
creator_id INTEGER NOT NULL,
|
||||
tags VARCHAR(1014),
|
||||
last_editor_id INTEGER NOT NULL
|
||||
--FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id)
|
||||
);
|
||||
@ -76,14 +75,6 @@ CREATE TABLE COLLABORATION (
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE TAG (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
--FOREIGN KEY(user_id) REFERENCES USER(colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
user_id INTEGER NOT NULL,
|
||||
|
@ -1,5 +1,4 @@
|
||||
DROP TABLE IF EXISTS ACCESS_AUDITORY;
|
||||
DROP TABLE IF EXISTS TAG;
|
||||
DROP TABLE IF EXISTS COLLABORATION;
|
||||
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
|
||||
DROP TABLE IF EXISTS MINDMAP_HISTORY;
|
||||
|
@ -42,8 +42,6 @@ CREATE TABLE MINDMAP (
|
||||
creation_date DATETIME,
|
||||
edition_date DATETIME,
|
||||
creator_id INTEGER NOT NULL,
|
||||
tags VARCHAR(1014)
|
||||
CHARACTER SET utf8,
|
||||
last_editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
@ -110,17 +108,7 @@ CREATE TABLE COLLABORATION (
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE TAG (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
UNIQUE KEY UC_ROLE (mindmap_id,colaborator_id)
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
DROP TABLE IF EXISTS TAG;
|
||||
DROP TABLE IF EXISTS ACCESS_AUDITORY;
|
||||
DROP TABLE IF EXISTS COLLABORATION;
|
||||
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
|
||||
|
@ -1,57 +0,0 @@
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
starred BOOL NOT NULL DEFAULT 0,
|
||||
mindmap_properties VARCHAR(512)
|
||||
CHARACTER SET utf8
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
DROP TABLE `MINDMAP_NATIVE`;
|
||||
ALTER TABLE `MINDMAP_COLABORATOR` RENAME TO `COLLABORATION`;
|
||||
ALTER TABLE `COLABORATOR` RENAME TO `COLLABORATOR`;
|
||||
|
||||
ALTER TABLE `MINDMAP` DROP COLUMN `editor_properties`, DROP COLUMN `mindMapNative_id`;
|
||||
|
||||
ALTER TABLE `MINDMAP` CHANGE COLUMN `owner_id` `creator_id` INT(11) NOT NULL
|
||||
, DROP INDEX `owner_id`
|
||||
, ADD INDEX `owner_id` (`creator_id` ASC);
|
||||
|
||||
ALTER TABLE `COLLABORATION` ADD COLUMN `properties_id` INT(11) NULL DEFAULT NULL
|
||||
AFTER `role_id`;
|
||||
DROP TABLE USER_LOGIN;
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
login_date DATE
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
#ALTER TABLE ACCESS_AUDITORY
|
||||
# ADD CONSTRAINT `user_id`
|
||||
# FOREIGN KEY ()
|
||||
# REFERENCES `USER` ()
|
||||
# ON DELETE CASCADE
|
||||
# ON UPDATE NO ACTION
|
||||
#, ADD INDEX `user_id` () ;
|
||||
|
||||
ALTER TABLE `MINDMAP_HISTORY` DROP COLUMN `creator_user`, ADD COLUMN `editor_id` INT(11) NULL DEFAULT NULL AFTER `creation_date`;
|
||||
|
||||
ALTER TABLE `USER` ADD COLUMN `locale` VARCHAR(5) NULL
|
||||
AFTER `allowSendEmail`;
|
||||
|
||||
ALTER TABLE `MINDMAP` DROP COLUMN `last_editor`, ADD COLUMN `last_editor_id` INT(11) NULL DEFAULT 2
|
||||
AFTER `tags`;
|
||||
|
||||
ALTER TABLE `USER` DROP COLUMN `username`, CHANGE COLUMN `activationCode` `activation_code` BIGINT(20) NOT NULL, CHANGE COLUMN `allowSendEmail` `allow_send_email` CHAR(1) NOT NULL DEFAULT '0';
|
||||
|
||||
INSERT INTO `MINDMAP` (`last_editor_id`) VALUES (1);
|
||||
|
||||
INSERT INTO `COLLABORATOR` (`id`, `email`, `creation_date`) VALUES (8081, 'migfake@wis.com', '2007-10-09');
|
||||
DELETE FROM `USER`
|
||||
WHERE activation_date IS null;
|
||||
DROP TABLE FEEDBACK;
|
||||
|
||||
|
||||
ALTER TABLE `MINDMAP` CHANGE COLUMN `XML` `XML` MEDIUMBLOB NULL DEFAULT NULL;
|
||||
ALTER TABLE `MINDMAP_HISTORY` CHANGE COLUMN `XML` `XML` MEDIUMBLOB NULL DEFAULT NULL;
|
@ -1,5 +0,0 @@
|
||||
ALTER TABLE `USER` ADD COLUMN `authentication_type` CHAR(1) CHARACTER SET utf8 NOT NULL DEFAULT 'D'
|
||||
AFTER `colaborator_id`;
|
||||
|
||||
ALTER TABLE `USER` ADD COLUMN `authenticator_uri` VARCHAR(255) CHARACTER SET utf8
|
||||
AFTER `authentication_type`;
|
@ -1,37 +0,0 @@
|
||||
ALTER TABLE `USER` DROP COLUMN `id`;
|
||||
|
||||
ALTER TABLE `ACCESS_AUDITORY`
|
||||
ADD CONSTRAINT
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(30)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
ALTER TABLE `LABEL`
|
||||
ADD COLUMN iconName VARCHAR(50) NOT NULL;
|
||||
|
||||
UPDATE LABEL SET iconName = 'glyphicon glyphicon-tag';
|
@ -27,14 +27,6 @@ CREATE TABLE LABEL (
|
||||
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
@ -44,11 +36,17 @@ CREATE TABLE MINDMAP (
|
||||
creation_date TIMESTAMP,
|
||||
edition_date TIMESTAMP,
|
||||
creator_id INTEGER NOT NULL,
|
||||
tags VARCHAR(1014),
|
||||
last_editor_id INTEGER NOT NULL --,
|
||||
--FOREIGN KEY(creator_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY
|
||||
(id SERIAL NOT NULL PRIMARY KEY,
|
||||
@ -77,14 +75,6 @@ CREATE TABLE COLLABORATION (
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE TAG (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL --,
|
||||
--FOREIGN KEY(user_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
login_date DATE,
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Based on ubuntu:latest, installs WiseMapping (http://ww.wisemapping.org)
|
||||
|
||||
# Based info setup ...
|
||||
FROM tomcat:9.0-jdk17-openjdk
|
||||
FROM tomcat:jdk17
|
||||
LABEL maintainer="Paulo Gustavo Veiga <pveiga@wisemapping.com>"
|
||||
|
||||
# Build variables ...
|
||||
@ -31,6 +31,9 @@ RUN sed -i 's|\
|
||||
</Host>|' \
|
||||
/usr/local/tomcat/conf/server.xml
|
||||
|
||||
RUN sed -i 's|<Context>|<Context>\
|
||||
<Loader jakartaConverter="TOMCAT" />|' \
|
||||
/usr/local/tomcat/conf/context.xml
|
||||
# Copy default HSQL DB for testing ...
|
||||
RUN mkdir -p ${DB_BASE_DIR}/db
|
||||
COPY db/ ${DB_BASE_DIR}/db
|
||||
|
@ -11,7 +11,7 @@ There are multiple ways to run WiseMapping depending on your database configurat
|
||||
|
||||
> $ docker run -it --rm -p 8080:8080 wisemapping/wisemapping:latest
|
||||
|
||||
Then, open your browser at `http://localhost:8888`. A default user is available for testing `test@wisemapping.com` and password `test`.
|
||||
Then, open your browser at `http://localhost:8888`. A default user is available for testing `test@wisemapping.org` and password `test`.
|
||||
|
||||
***This option, all changes will be lost once the image is stopped. Use it for testing only***
|
||||
|
||||
@ -42,7 +42,7 @@ Depending on the database your want to configure, you can create initialization
|
||||
The next step is configure the WiseMapping for the database and credentials.
|
||||
Download `app.properties` configuration file and configure the required sections:
|
||||
|
||||
> $ curl https://bitbucket.org/wisemapping/wisemapping-open-source/raw/644b7078d790220c7844b732a83d45495f11d64e/wise-webapp/src/main/webapp/WEB-INF/app.properties
|
||||
> $ curl https://bitbucket.org/wisemapping/wisemapping-open-source/src/master/wise-webapp/src/main/webapp/WEB-INF/app.properties
|
||||
|
||||
### Starting the application
|
||||
|
||||
|
@ -4,4 +4,4 @@ set -o
|
||||
set -u
|
||||
|
||||
mvn -f ../pom.xml clean package
|
||||
docker build -t wisemapping/wisemapping:latest -f ./Dockerfile ../wise-webapp/target/
|
||||
docker build --platform linux/amd64 -t wisemapping/wisemapping:latest -f ./Dockerfile ../wise-webapp/target/
|
||||
|
@ -113,17 +113,6 @@ CREATE TABLE COLLABORATION (
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE TAG (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
login_date DATE,
|
||||
|
4
pom.xml
4
pom.xml
@ -4,7 +4,7 @@
|
||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<properties>
|
||||
<com.wisemapping.version>5.0.12-SNAPSHOT</com.wisemapping.version>
|
||||
<com.wisemapping.version>5.0.15-SNAPSHOT</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.12-SNAPSHOT</version>
|
||||
<version>5.0.15-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<licenses>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>5.0.12-SNAPSHOT</version>
|
||||
<version>5.0.15-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
@ -29,11 +29,11 @@
|
||||
<mkdir dir="target/wisemapping-mindplot"/>
|
||||
<exec executable="npm" dir="target" failonerror="true">
|
||||
<arg value="pack"/>
|
||||
<arg value="@wisemapping/mindplot@5.0.13"/>
|
||||
<arg value="@wisemapping/mindplot@5.0.17"/>
|
||||
</exec>
|
||||
<exec executable="tar" dir="target" failonerror="true">
|
||||
<arg value="-xvzf"/>
|
||||
<arg value="wisemapping-mindplot-5.0.13.tgz"/>
|
||||
<arg value="wisemapping-mindplot-5.0.17.tgz"/>
|
||||
<arg value="-C"/>
|
||||
<arg value="wisemapping-mindplot"/>
|
||||
</exec>
|
||||
@ -42,11 +42,11 @@
|
||||
<mkdir dir="target/wisemapping-webapp"/>
|
||||
<exec executable="npm" dir="target" failonerror="true">
|
||||
<arg value="pack"/>
|
||||
<arg value="@wisemapping/webapp@5.0.14"/>
|
||||
<arg value="@wisemapping/webapp@5.0.18"/>
|
||||
</exec>
|
||||
<exec executable="tar" dir="target" failonerror="true">
|
||||
<arg value="-xvzf"/>
|
||||
<arg value="wisemapping-webapp-5.0.14.tgz"/>
|
||||
<arg value="wisemapping-webapp-5.0.18.tgz"/>
|
||||
<arg value="-C"/>
|
||||
<arg value="wisemapping-webapp"/>
|
||||
</exec>
|
||||
|
@ -9,13 +9,13 @@
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>5.0.12-SNAPSHOT</version>
|
||||
<version>5.0.15-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<org.springframework.version>5.3.20</org.springframework.version>
|
||||
<org.springframework.version>5.3.23</org.springframework.version>
|
||||
<org.springframework.addons>5.6.2</org.springframework.addons>
|
||||
<hibernate.version>5.6.9.Final</hibernate.version>
|
||||
<hibernate.version>5.6.12.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>
|
||||
@ -196,7 +196,7 @@
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.28</version>
|
||||
<version>8.0.31</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -220,10 +220,9 @@
|
||||
<version>3.9.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
<scope>compile</scope>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.19.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-validator/commons-validator -->
|
||||
<dependency>
|
||||
@ -241,7 +240,7 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.13.1</version>
|
||||
<version>2.13.4.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- This is required in case of Tomcat, do not remove -->
|
||||
@ -295,12 +294,19 @@
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.5</version>
|
||||
<version>8.0.31</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>2.6.1</version>
|
||||
<version>2.7.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -344,7 +350,7 @@
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.5</version>
|
||||
<version>8.0.31</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
@ -452,6 +458,69 @@
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-prepare-agent</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>default-prepare-agent-integration</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>prepare-agent-integration</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*Test*</exclude>
|
||||
</excludes>
|
||||
<propertyName>integrationTestArgLine</propertyName>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>default-check</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<rule>
|
||||
<element>BUNDLE</element>
|
||||
<limits>
|
||||
<limit>
|
||||
<counter>COMPLEXITY</counter>
|
||||
<value>COVEREDRATIO</value>
|
||||
<minimum>0.10</minimum>
|
||||
</limit>
|
||||
</limits>
|
||||
</rule>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!-- Confirm why there is a NPE -->
|
||||
<!-- <execution>-->
|
||||
<!-- <id>default-report-integration</id>-->
|
||||
<!-- <phase>verify</phase>-->
|
||||
<!-- <goals>-->
|
||||
<!-- <goal>report-integration</goal>-->
|
||||
<!-- </goals>-->
|
||||
<!-- </execution>-->
|
||||
<execution>
|
||||
<id>default-report</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
@ -459,6 +528,9 @@
|
||||
<version>9.4.34.v20201102</version>
|
||||
<configuration>
|
||||
<stopKey>foo</stopKey>
|
||||
<httpConnector>
|
||||
<port>8080</port>
|
||||
</httpConnector>
|
||||
<stopPort>9999</stopPort>
|
||||
<war>${project.build.directory}/wisemapping.war</war>
|
||||
<reload>automatic</reload>
|
||||
@ -488,9 +560,15 @@
|
||||
<goal>run-forked</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<useTestClasspath>true</useTestClasspath>
|
||||
<useTestScope>true</useTestScope>
|
||||
<scanIntervalSeconds>0</scanIntervalSeconds>
|
||||
<daemon>true</daemon>
|
||||
<waitForChild>false</waitForChild>
|
||||
<jvmArgs>-Ddatabase.base.url=${project.build.directory}</jvmArgs>
|
||||
<maxStartupLines>200</maxStartupLines>
|
||||
<jvmArgs>${integrationTestArgLine} -Ddatabase.base.url=${project.build.directory}
|
||||
-Djetty.port=8080
|
||||
</jvmArgs>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
@ -499,6 +577,9 @@
|
||||
<goals>
|
||||
<goal>stop</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<stopWait>1</stopWait>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
@ -514,6 +595,7 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
@ -29,16 +29,8 @@ public interface MindmapManager {
|
||||
|
||||
Collaborator findCollaborator(@NotNull String email);
|
||||
|
||||
Collaborator findCollaborator(int id);
|
||||
|
||||
List<Collaboration> findCollaboration(final int collaboratorId);
|
||||
|
||||
List<Collaboration> findCollaboration(final CollaborationRole userRole);
|
||||
|
||||
Collaboration findCollaboration(final int mindmapId, final User user);
|
||||
|
||||
List<Mindmap> getAllMindmaps();
|
||||
|
||||
@Nullable
|
||||
Mindmap getMindmapById(int mindmapId);
|
||||
|
||||
|
@ -116,6 +116,7 @@ public class MindmapManagerImpl
|
||||
|
||||
@Override
|
||||
public List<Mindmap> findMindmapByUser(@NotNull User user) {
|
||||
|
||||
final Mindmap collaborator;
|
||||
final Query query = currentSession()
|
||||
.createQuery("from com.wisemapping.model.Mindmap m where m.id in (select c.mindMap.id from com.wisemapping.model.Collaboration as c where c.collaborator.id=:collabId )");
|
||||
@ -147,23 +148,11 @@ public class MindmapManagerImpl
|
||||
final SimpleExpression descriptionRestriction = Restrictions.like("description", "%" + criteria.getDescription() + "%");
|
||||
junction.add(descriptionRestriction);
|
||||
}
|
||||
if (criteria.getTags().size() > 0) {
|
||||
for (String tag : criteria.getTags()) {
|
||||
final SimpleExpression tagRestriction = Restrictions.like("tags", "%" + tag + "%");
|
||||
junction.add(tagRestriction);
|
||||
}
|
||||
}
|
||||
|
||||
hibernateCriteria.add(junction);
|
||||
}
|
||||
return hibernateCriteria.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collaborator findCollaborator(int id) {
|
||||
return getHibernateTemplate().get(Collaborator.class, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Collaboration> findCollaboration(final int collaboratorId) {
|
||||
Query query = currentSession().createQuery("from com.wisemapping.model.Collaboration c where c.collaborator.id=:collaboratorId");
|
||||
@ -171,32 +160,6 @@ public class MindmapManagerImpl
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Collaboration> findCollaboration(final CollaborationRole collaborationRole) {
|
||||
Query query = currentSession().createQuery("from com.wisemapping.model.Collaboration c where c.role=:roleId");
|
||||
query.setParameter("roleId", collaborationRole.ordinal());
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collaboration findCollaboration(final int mindmapId, final User user) {
|
||||
final Collaboration result;
|
||||
|
||||
Query query = currentSession().createQuery("from com.wisemapping.model.Collaboration c where c.mindMap.id=:mindmapId and c.id=:collaboratorId");
|
||||
query.setParameter("mindmapId", mindmapId);
|
||||
query.setParameter("collaboratorId", user.getId());
|
||||
|
||||
final List<Collaboration> mindMaps = query.getResultList();
|
||||
|
||||
if (mindMaps != null && !mindMaps.isEmpty()) {
|
||||
result = mindMaps.get(0);
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollaborator(@NotNull Collaborator collaborator) {
|
||||
assert collaborator != null : "ADD MINDMAP COLLABORATOR: Collaborator is required!";
|
||||
@ -213,12 +176,6 @@ public class MindmapManagerImpl
|
||||
getHibernateTemplate().delete(collaborator);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Mindmap> getAllMindmaps() {
|
||||
return currentSession().createQuery("from com.wisemapping.model.Mindmap wisemapping").list();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Mindmap getMindmapById(int id) {
|
||||
@ -263,15 +220,18 @@ public class MindmapManagerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMindmap(@NotNull final Mindmap mindMap) {
|
||||
public void removeMindmap(@NotNull final Mindmap mindmap) {
|
||||
// Delete history first ...
|
||||
final Criteria hibernateCriteria = currentSession().createCriteria(MindMapHistory.class);
|
||||
hibernateCriteria.add(Restrictions.eq("mindmapId", mindMap.getId()));
|
||||
List list = hibernateCriteria.list();
|
||||
hibernateCriteria.add(Restrictions.eq("mindmapId", mindmap.getId()));
|
||||
final List list = hibernateCriteria.list();
|
||||
getHibernateTemplate().deleteAll(list);
|
||||
|
||||
// Remove collaborations ...
|
||||
mindmap.removedCollaboration(mindmap.getCollaborations());
|
||||
|
||||
// Delete mindmap ....
|
||||
getHibernateTemplate().delete(mindMap);
|
||||
getHibernateTemplate().delete(mindmap);
|
||||
}
|
||||
|
||||
private void saveHistory(@NotNull final Mindmap mindMap) {
|
||||
|
@ -34,6 +34,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
public class UserManagerImpl
|
||||
extends HibernateDaoSupport
|
||||
@ -109,27 +110,22 @@ public class UserManagerImpl
|
||||
assert user != null : "Trying to store a null user";
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Delete old collaboration
|
||||
final HibernateTemplate template = getHibernateTemplate();
|
||||
collaborations.forEach(c -> template.delete(c));
|
||||
template.delete(collaborator);
|
||||
collaborator.setEmail(collaborator.getEmail() + "_toRemove");
|
||||
template.saveOrUpdate(collaborator);
|
||||
template.flush();
|
||||
|
||||
// Save all new...
|
||||
this.createUser(user);
|
||||
newCollabs.forEach(c -> template.saveOrUpdate(c));
|
||||
|
||||
// Update mindmap ...
|
||||
final Set<Collaboration> collaborations = new CopyOnWriteArraySet<>(collaborator.getCollaborations());
|
||||
for (Collaboration collabs : collaborations) {
|
||||
collabs.setCollaborator(user);
|
||||
}
|
||||
|
||||
// Delete old user ...
|
||||
template.delete(collaborator);
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@ -20,13 +20,13 @@ package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CollabChangeException
|
||||
public class OwnerCannotChangeException
|
||||
extends ClientException
|
||||
{
|
||||
|
||||
private static final String MSG_KEY = "OWNER_ROLE_CAN_NOT_BE_CHANGED";
|
||||
|
||||
public CollabChangeException(@NotNull String email)
|
||||
public OwnerCannotChangeException(@NotNull String email)
|
||||
{
|
||||
super("Collab email can not be change. " + email + " is the the owner.",Severity.WARNING);
|
||||
}
|
@ -24,8 +24,10 @@ 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.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
@ -34,7 +36,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);
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public void sessionCreated(@NotNull HttpSessionEvent event) {
|
||||
|
@ -24,7 +24,8 @@ import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestLogItem;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -42,7 +43,7 @@ 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 Logger logger = LogManager.getLogger();
|
||||
private ResourceBundleMessageSource messageSource;
|
||||
|
||||
@Autowired
|
||||
|
@ -19,9 +19,12 @@
|
||||
package com.wisemapping.model;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "COLLABORATION")
|
||||
@ -43,7 +46,7 @@ public class Collaboration implements Serializable {
|
||||
private Collaborator collaborator;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "properties_id", nullable = false, unique = true)
|
||||
@JoinColumn(name = "properties_id", nullable = true, unique = true)
|
||||
private CollaborationProperties collaborationProperties = new CollaborationProperties();
|
||||
|
||||
public Collaboration() {
|
||||
@ -100,12 +103,13 @@ public class Collaboration implements Serializable {
|
||||
this.collaborator = collaborator;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@Nullable
|
||||
public CollaborationProperties getCollaborationProperties() {
|
||||
return this.collaborationProperties;
|
||||
}
|
||||
|
||||
public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) {
|
||||
public void setCollaborationProperties(@Nullable CollaborationProperties collaborationProperties) {
|
||||
this.collaborationProperties = collaborationProperties;
|
||||
}
|
||||
|
||||
@ -122,16 +126,14 @@ public class Collaboration implements Serializable {
|
||||
Collaboration that = (Collaboration) o;
|
||||
|
||||
if (id != that.id) return false;
|
||||
if (collaborator != null ? !collaborator.equals(that.collaborator) : that.collaborator != null) return false;
|
||||
if (mindMap != null ? !mindMap.equals(that.mindMap) : that.mindMap != null) return false;
|
||||
if (!Objects.equals(collaborator, that.collaborator)) return false;
|
||||
if (!Objects.equals(mindMap, that.mindMap)) return false;
|
||||
return role == that.role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id ^ (id >>> 32);
|
||||
result = 31 * result + (role != null ? role.hashCode() : 0);
|
||||
result = 31 * result + (mindMap != null ? mindMap.hashCode() : 0);
|
||||
return result;
|
||||
//https://thorben-janssen.com/ultimate-guide-to-implementing-equals-and-hashcode-with-hibernate/
|
||||
return 13;
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.model;
|
||||
|
||||
@ -32,18 +32,18 @@ import java.util.Set;
|
||||
@Entity
|
||||
@Table(name = "COLLABORATOR")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
//@Cacheable
|
||||
//@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class Collaborator implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
private String email;
|
||||
|
||||
@Column(name = "creation_date")
|
||||
private Calendar creationDate;
|
||||
|
||||
@OneToMany(mappedBy="collaborator")
|
||||
@OneToMany(mappedBy = "collaborator")
|
||||
private Set<Collaboration> collaborations = new HashSet<>();
|
||||
|
||||
public Collaborator() {
|
||||
@ -105,19 +105,26 @@ public class Collaborator implements Serializable {
|
||||
int id = this.getId();
|
||||
String email = this.getEmail();
|
||||
|
||||
int result = (int) (id ^ (id >>> 32));
|
||||
int result = id ^ (id >>> 32);
|
||||
result = 31 * result + (email != null ? email.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public boolean identityEquality(@Nullable Collaborator that) {
|
||||
if (this == that) return true;
|
||||
if (that == null) return false;
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id != that.getId()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id != that.getId()) return false;
|
||||
return email != null ? email.equals(that.getEmail()) : that.getEmail() == null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "LABEL")
|
||||
@ -34,17 +35,22 @@ public class Label implements Serializable {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
@NotNull private String title;
|
||||
@NotNull private String color;
|
||||
@Nullable private String iconName;
|
||||
@NotNull
|
||||
private String title;
|
||||
@NotNull
|
||||
private String color;
|
||||
@Nullable
|
||||
private String iconName;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name="creator_id",nullable = true,unique = true)
|
||||
@NotNull private User creator;
|
||||
@JoinColumn(name = "creator_id", nullable = true, unique = true)
|
||||
@NotNull
|
||||
private User creator;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name="parent_label_id",nullable = true)
|
||||
@Nullable private Label parent;
|
||||
@JoinColumn(name = "parent_label_id", nullable = true)
|
||||
@Nullable
|
||||
private Label parent;
|
||||
|
||||
public void setParent(@Nullable Label parent) {
|
||||
this.parent = parent;
|
||||
@ -104,17 +110,15 @@ public class Label implements Serializable {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Label)) return false;
|
||||
|
||||
Label label = (Label) o;
|
||||
|
||||
final Label label = (Label) o;
|
||||
return id == label.id && creator.getId() == label.creator.getId()
|
||||
&& !(parent != null ? !parent.equals(label.parent) : label.parent != null);
|
||||
&& Objects.equals(parent, label.parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
long result = id;
|
||||
result = 31 * result + title.hashCode();
|
||||
result = 31 * result + (creator!=null?creator.hashCode():0);
|
||||
long result = title.hashCode();
|
||||
result = 31 * result + (creator != null ? creator.hashCode() : 0);
|
||||
result = 31 * result + (parent != null ? parent.hashCode() : 0);
|
||||
return (int) result;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import java.util.List;
|
||||
public class MindMapCriteria {
|
||||
private String title;
|
||||
private String description;
|
||||
private List<String> tags = new ArrayList<String>();
|
||||
private boolean orConnector = false;
|
||||
private int pageNro = 0;
|
||||
|
||||
@ -41,18 +40,9 @@ public class MindMapCriteria {
|
||||
this.pageNro = page;
|
||||
}
|
||||
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(List<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
@ -78,8 +68,7 @@ public class MindMapCriteria {
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return !(getTags() != null && !getTags().isEmpty() || getTitle() != null || getDescription() != null);
|
||||
return getTitle() != null || getDescription() != null;
|
||||
}
|
||||
|
||||
public static MindMapCriteria EMPTY_CRITERIA = new MindMapCriteria();
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ 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.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -63,10 +65,12 @@ 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}, fetch = FetchType.LAZY)
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private Set<Collaboration> collaborations = new HashSet<>();
|
||||
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE})
|
||||
@Fetch(FetchMode.JOIN)
|
||||
@JoinTable(
|
||||
name = "R_LABEL_MINDMAP",
|
||||
joinColumns = @JoinColumn(name = "mindmap_id"),
|
||||
@ -79,13 +83,9 @@ public class Mindmap implements Serializable {
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
private byte[] zippedXml;
|
||||
|
||||
//~ Constructors .........................................................................................
|
||||
|
||||
public Mindmap() {
|
||||
}
|
||||
|
||||
//~ Methods ..............................................................................................
|
||||
|
||||
public void setUnzipXml(@NotNull byte[] value) {
|
||||
try {
|
||||
final byte[] zip = ZipUtils.bytesToZip(value);
|
||||
@ -142,7 +142,13 @@ public class Mindmap implements Serializable {
|
||||
}
|
||||
|
||||
public void removedCollaboration(@NotNull Collaboration collaboration) {
|
||||
collaborations.add(collaboration);
|
||||
// https://stackoverflow.com/questions/25125210/hibernate-persistentset-remove-operation-not-working
|
||||
this.collaborations.remove(collaboration);
|
||||
collaboration.setMindMap(null);
|
||||
}
|
||||
|
||||
public void removedCollaboration(@NotNull Set<Collaboration> collaborations) {
|
||||
this.collaborations.removeAll(collaborations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@ -177,15 +183,14 @@ public class Mindmap implements Serializable {
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isCreator(@NotNull User user) {
|
||||
return this.getCreator() != null && this.getCreator().identityEquality(user);
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
//@Todo: This is a hack to overcome some problem with JS EL. For some reason, ${mindmap.public} fails as not supported.
|
||||
// More research is needed...
|
||||
public boolean isAccessible() {
|
||||
return isPublic();
|
||||
}
|
||||
|
||||
public void setPublic(boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
@ -309,11 +314,20 @@ public class Mindmap implements Serializable {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
result.append("<map version=\"tango\">");
|
||||
result.append("<topic central=\"true\" text=\"");
|
||||
result.append(StringEscapeUtils.escapeXml(title));
|
||||
result.append(escapeXmlAttribute(title));
|
||||
result.append("\"/></map>");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
static private String escapeXmlAttribute(String attValue) {
|
||||
// Hack: Find out of the box function.
|
||||
String result = attValue.replace("&", "&");
|
||||
result = result.replace("<", "<");
|
||||
result = result.replace("gt", ">");
|
||||
result = result.replace("\"", """);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Mindmap shallowClone() {
|
||||
final Mindmap result = new Mindmap();
|
||||
result.setDescription(this.getDescription());
|
||||
@ -344,18 +358,6 @@ public class Mindmap implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Label findLabel(int labelId) {
|
||||
Label result = null;
|
||||
for (Label label : this.labels) {
|
||||
if (label.getId() == labelId) {
|
||||
result = label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void removeLabel(@NotNull final Label label) {
|
||||
this.labels.remove(label);
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ import java.util.Set;
|
||||
@Entity
|
||||
@Table(name = "USER")
|
||||
@PrimaryKeyJoinColumn(name = "colaborator_id")
|
||||
//@Cacheable
|
||||
//@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class User
|
||||
extends Collaborator
|
||||
implements Serializable {
|
||||
@ -57,22 +55,9 @@ public class User
|
||||
@Column(name = "authenticator_uri")
|
||||
private String authenticatorUri;
|
||||
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "TAG", joinColumns = @JoinColumn(name = "user_id"))
|
||||
@Column(name = "name")
|
||||
private Set<String> tags = new HashSet<>();
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public void setTags(Set<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public Set<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return this.getFirstname() + " " + this.getLastname();
|
||||
}
|
||||
|
@ -24,14 +24,11 @@ import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestLogItem;
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.LabelService;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.UserService;
|
||||
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;
|
||||
@ -41,7 +38,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@ -129,7 +125,7 @@ public class AccountController extends BaseController {
|
||||
}
|
||||
|
||||
// Delete labels ....
|
||||
List<Label> labels = labelService.getAll(user);
|
||||
final List<Label> labels = labelService.getAll(user);
|
||||
labels.forEach(l -> {
|
||||
try {
|
||||
labelService.removeLabel(l, user);
|
||||
|
@ -24,7 +24,8 @@ import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestErrors;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.RegistrationException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@ -42,7 +43,7 @@ import java.util.Locale;
|
||||
|
||||
public class BaseController {
|
||||
|
||||
final private Logger logger = Logger.getLogger(BaseController.class);
|
||||
final private Logger logger = LogManager.getLogger();
|
||||
|
||||
@Qualifier("messageSource")
|
||||
@Autowired
|
||||
|
@ -25,7 +25,8 @@ 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.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@ -46,7 +47,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
public class MindmapController extends BaseController {
|
||||
final Logger logger = Logger.getLogger(MindmapController.class);
|
||||
final Logger logger = LogManager.getLogger();
|
||||
|
||||
private static final String LATEST_HISTORY_REVISION = "latest";
|
||||
|
||||
@ -74,7 +75,7 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/", produces = {"application/json"})
|
||||
public RestMindmapList retrieveList(@RequestParam(required = false) String q) throws IOException {
|
||||
public RestMindmapList retrieveList(@RequestParam(required = false) String q) {
|
||||
final User user = Utils.getUser();
|
||||
|
||||
final MindmapFilter filter = MindmapFilter.parse(q);
|
||||
@ -299,7 +300,7 @@ public class MindmapController extends BaseController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs/", consumes = {"application/json"}, produces = {"application/json"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void addCollab(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException, InvalidEmailException, TooManyInactiveAccountsExceptions, CollabChangeException {
|
||||
public void addCollab(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException, InvalidEmailException, TooManyInactiveAccountsExceptions, OwnerCannotChangeException {
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
|
||||
// Only owner can change collaborators...
|
||||
@ -346,12 +347,12 @@ public class MindmapController extends BaseController {
|
||||
|
||||
// Are we trying to change the owner ...
|
||||
if (currentCollab != null && currentCollab.getRole() == CollaborationRole.OWNER) {
|
||||
throw new CollabChangeException(collabEmail);
|
||||
throw new OwnerCannotChangeException(collabEmail);
|
||||
}
|
||||
|
||||
// Role can not be changed ...
|
||||
if (newRole == CollaborationRole.OWNER) {
|
||||
throw new CollabChangeException(collabEmail);
|
||||
throw new OwnerCannotChangeException(collabEmail);
|
||||
}
|
||||
|
||||
// This is collaboration that with different newRole, try to change it ...
|
||||
@ -462,6 +463,20 @@ public class MindmapController extends BaseController {
|
||||
mindmapService.updateCollaboration(user, collaboration.get());
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/starred", produces = {"text/plain"})
|
||||
@ResponseBody
|
||||
public String fetchStarred(@PathVariable int id) throws WiseMappingException {
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
final Optional<Collaboration> collaboration = mindmap.findCollaboration(user);
|
||||
if (!collaboration.isPresent()) {
|
||||
throw new WiseMappingException("No enough permissions.");
|
||||
}
|
||||
boolean result = collaboration.get().getCollaborationProperties().getStarred();
|
||||
return Boolean.toString(result);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/maps/batch")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void batchDelete(@RequestParam() String ids) throws IOException, WiseMappingException {
|
||||
|
@ -26,7 +26,8 @@ import com.wisemapping.rest.model.RestUserRegistration;
|
||||
import com.wisemapping.service.*;
|
||||
import com.wisemapping.validator.Messages;
|
||||
import com.wisemapping.validator.UserValidator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@ -57,7 +58,7 @@ public class UserController extends BaseController {
|
||||
@Value("${accounts.exclusion.domain:''}")
|
||||
private String domainBanExclusion;
|
||||
|
||||
private static final Logger logger = Logger.getLogger(UserController.class);
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final String REAL_IP_ADDRESS_HEADER = "X-Real-IP";
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/users", produces = {"application/json"})
|
||||
|
@ -40,15 +40,18 @@ import java.util.TimeZone;
|
||||
public class RestMindmapHistory {
|
||||
|
||||
static private final SimpleDateFormat sdf;
|
||||
private final int id;
|
||||
private final Calendar creation;
|
||||
private final String creator;
|
||||
private int id;
|
||||
private Calendar creation;
|
||||
private String creator;
|
||||
|
||||
static {
|
||||
sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
public RestMindmapHistory() {
|
||||
}
|
||||
|
||||
public RestMindmapHistory(@NotNull MindMapHistory history) {
|
||||
this.id = history.getId();
|
||||
this.creation = history.getCreationTime();
|
||||
@ -61,18 +64,18 @@ public class RestMindmapHistory {
|
||||
}
|
||||
|
||||
public void setCreationTime() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator() {
|
||||
// Do nothing ...
|
||||
public void setCreator(String creator) {
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id=id;
|
||||
}
|
||||
|
||||
private String toISO8601(@NotNull Date date) {
|
||||
|
@ -46,10 +46,10 @@ public class RestMindmapInfo {
|
||||
@JsonIgnore
|
||||
private final Mindmap mindmap;
|
||||
@JsonIgnore
|
||||
private Set<RestLabel> restLabels;
|
||||
private Set<RestLabel> restLabels;
|
||||
|
||||
@JsonIgnore
|
||||
private int mapId = -1;
|
||||
private int mapId = -1;
|
||||
|
||||
private final Collaborator collaborator;
|
||||
|
||||
@ -91,9 +91,9 @@ public class RestMindmapInfo {
|
||||
public Set<RestLabel> getLabels() {
|
||||
// Support test deserialization...
|
||||
Set<RestLabel> result = this.restLabels;
|
||||
if(result==null) {
|
||||
if (result == null) {
|
||||
final User me = Utils.getUser();
|
||||
result = mindmap.getLabels().
|
||||
result = mindmap.getLabels().
|
||||
stream()
|
||||
.filter(l -> l.getCreator().equals(me))
|
||||
.map(RestLabel::new)
|
||||
@ -107,8 +107,8 @@ public class RestMindmapInfo {
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
int result = this.mapId;
|
||||
if(mapId==-1) {
|
||||
int result = this.mapId;
|
||||
if (mapId == -1) {
|
||||
result = mindmap.getId();
|
||||
}
|
||||
return result;
|
||||
@ -132,8 +132,10 @@ public class RestMindmapInfo {
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
final Optional<Collaboration> collaboration = mindmap.findCollaboration(Utils.getUser());
|
||||
return collaboration.map(value -> value.getRole().getLabel()).orElse(ROLE_NONE);
|
||||
final User user = Utils.getUser();
|
||||
String result;
|
||||
final Optional<Collaboration> collaboration = mindmap.findCollaboration(user);
|
||||
return collaboration.map(value -> value.getRole().getLabel()).orElse(ROLE_NONE);
|
||||
}
|
||||
|
||||
public void setRole(String value) {
|
||||
|
@ -24,11 +24,7 @@ import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -45,7 +41,7 @@ public class RestMindmapList {
|
||||
this(Collections.emptyList(), null);
|
||||
}
|
||||
|
||||
public RestMindmapList(@NotNull List<Mindmap> mindmaps, @NotNull Collaborator collaborator) {
|
||||
public RestMindmapList(@NotNull List<Mindmap> mindmaps, Collaborator collaborator) {
|
||||
this.mindmapsInfo = mindmaps.stream()
|
||||
.map(m->new RestMindmapInfo(m, collaborator))
|
||||
.collect(Collectors.toList());
|
||||
|
@ -18,7 +18,9 @@
|
||||
|
||||
package com.wisemapping.security;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import org.springframework.security.crypto.codec.Base64;
|
||||
import org.springframework.security.crypto.codec.Hex;
|
||||
import org.springframework.security.crypto.codec.Utf8;
|
||||
@ -29,7 +31,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
|
||||
|
||||
public class LegacyPasswordEncoder implements PasswordEncoder {
|
||||
final private static Logger logger = Logger.getLogger(LegacyPasswordEncoder.class);
|
||||
final private static Logger logger = LogManager.getLogger();
|
||||
|
||||
public static final String ENC_PREFIX = "ENC:";
|
||||
private final ShaPasswordEncoder sha1Encoder = new ShaPasswordEncoder();
|
||||
|
@ -23,18 +23,21 @@ import com.wisemapping.exceptions.LockException;
|
||||
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 org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
class LockManagerImpl implements LockManager {
|
||||
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);
|
||||
final private static Logger logger = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public boolean isLocked(@NotNull Mindmap mindmap) {
|
||||
|
@ -68,6 +68,4 @@ public interface MindmapService {
|
||||
LockManager getLockManager();
|
||||
|
||||
boolean isAdmin(@Nullable User user);
|
||||
|
||||
void purgeHistory(int mapId) throws IOException;
|
||||
}
|
||||
|
@ -91,11 +91,6 @@ public class MindmapServiceImpl
|
||||
return user != null && user.getEmail() != null && user.getEmail().equals(adminUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeHistory(int mapId) throws IOException {
|
||||
mindmapManager.purgeHistory(mapId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mindmap getMindmapByTitle(String title, User user) {
|
||||
return mindmapManager.getMindmapByTitle(title, user);
|
||||
@ -148,15 +143,13 @@ public class MindmapServiceImpl
|
||||
public void removeCollaboration(@NotNull Mindmap mindmap, @NotNull Collaboration collaboration) throws CollaborationException {
|
||||
// remove collaborator association
|
||||
final Mindmap mindMap = collaboration.getMindMap();
|
||||
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
||||
|
||||
final User creator = mindMap.getCreator();
|
||||
if (creator.identityEquality(collaboration.getCollaborator())) {
|
||||
throw new CollaborationException("User is the creator and must have ownership permissions.Creator Email:" + mindMap.getCreator().getEmail() + ",Collaborator:" + collaboration.getCollaborator().getEmail());
|
||||
}
|
||||
|
||||
// When you delete an object from hibernate you have to delete it from *all* collections it exists in...
|
||||
collaborations.remove(collaboration);
|
||||
mindMap.removedCollaboration(collaboration);
|
||||
mindmapManager.removeCollaboration(collaboration);
|
||||
}
|
||||
|
||||
@ -254,7 +247,7 @@ public class MindmapServiceImpl
|
||||
|
||||
@Override
|
||||
public void revertChange(@NotNull Mindmap mindmap, int historyId)
|
||||
throws WiseMappingException, IOException {
|
||||
throws WiseMappingException {
|
||||
final MindMapHistory history = mindmapManager.getHistory(historyId);
|
||||
mindmap.setZippedXml(history.getZippedXml());
|
||||
updateMindmap(mindmap, true);
|
||||
|
@ -17,13 +17,15 @@
|
||||
*/
|
||||
package com.wisemapping.service;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
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;
|
||||
import org.apache.http.client.fluent.Request;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
@ -35,7 +37,7 @@ import java.util.Map;
|
||||
|
||||
public class RecaptchaService {
|
||||
|
||||
final private static Logger logger = Logger.getLogger(RecaptchaService.class);
|
||||
final private static Logger logger = LogManager.getLogger();
|
||||
final private static String GOOGLE_RECAPTCHA_VERIFY_URL =
|
||||
"https://www.google.com/recaptcha/api/siteverify";
|
||||
|
||||
|
@ -24,7 +24,7 @@ public interface Messages {
|
||||
String FIELD_REQUIRED = "FIELD_REQUIRED";
|
||||
String MAP_TITLE_ALREADY_EXISTS = "MAP_TITLE_ALREADY_EXISTS";
|
||||
String LABEL_TITLE_ALREADY_EXISTS = "LABEL_TITLE_ALREADY_EXISTS";
|
||||
String PASSWORD_MISMATCH = "PASSWORD_MISMATCH";
|
||||
|
||||
String CAPTCHA_LOADING_ERROR = "CAPTCHA_LOADING_ERROR";
|
||||
|
||||
String CAPTCHA_TIMEOUT_OUT_DUPLICATE = "CAPTCHA_TIMEOUT_OUT_DUPLICATE";
|
||||
|
@ -4,7 +4,6 @@ SITE.TITLE=WiseMapping
|
||||
FIELD_REQUIRED=Ein benötigtes Feld kann icht leer gelassen werden
|
||||
EMAIL_ALREADY_EXIST=Die email Adresse existiert bereits.
|
||||
NO_VALID_EMAIL_ADDRESS=Ungültige email Adresse
|
||||
PASSWORD_MISMATCH=Ihre Passwort Angaben sind nicht identisch
|
||||
CREATOR=Urheber
|
||||
WELCOME=Willkommen
|
||||
SHARE=Veröffentlichen
|
||||
|
@ -5,7 +5,6 @@ FIELD_REQUIRED=Required field cannot be left blank
|
||||
EMAIL_ALREADY_EXIST=There is an account already with this email.
|
||||
NO_VALID_EMAIL_ADDRESS=Invalid email address
|
||||
INVALID_EMAIL_ADDRESS=Invalid email address. Please, verify that your entered valid email address.
|
||||
PASSWORD_MISMATCH=Your password entries did not match
|
||||
CREATOR=Creator
|
||||
WELCOME=Welcome
|
||||
SHARE=Share
|
||||
|
@ -4,7 +4,6 @@ SITE.TITLE = WiseMapping
|
||||
FIELD_REQUIRED = Campo requerido
|
||||
EMAIL_ALREADY_EXIST = E-mail ya existente.
|
||||
NO_VALID_EMAIL_ADDRESS = E-mail invalido
|
||||
PASSWORD_MISMATCH = La contraseña no concuerda
|
||||
CREATOR = Creador
|
||||
WELCOME = Bienvenido/a
|
||||
SHARE = Compartir
|
||||
|
@ -4,7 +4,6 @@ SITE.TITLE=WiseMapping
|
||||
FIELD_REQUIRED=Ce champ ne peut pas rester vide
|
||||
EMAIL_ALREADY_EXIST=Cet email est déjà utilisé
|
||||
NO_VALID_EMAIL_ADDRESS=Email non valide
|
||||
PASSWORD_MISMATCH=Le mot de passe saisi ne correspond pas
|
||||
CREATOR=Créateur
|
||||
WELCOME=Bienvenue
|
||||
SHARE=Partager
|
||||
|
@ -4,7 +4,6 @@ SITE.TITLE=WiseMapping
|
||||
FIELD_REQUIRED=Это поле обязательно для заполненияю
|
||||
EMAIL_ALREADY_EXIST=Аккаунт с таким e-mail уже существует.
|
||||
NO_VALID_EMAIL_ADDRESS=Некорректный адрес электронной почты.
|
||||
PASSWORD_MISMATCH=Пароли не совпадают
|
||||
CREATOR=Создатель
|
||||
WELCOME=Добро пожаловать
|
||||
SHARE=Поделиться
|
||||
|
@ -4,7 +4,6 @@ SITE.TITLE=WiseMapping
|
||||
FIELD_REQUIRED=必填字段不能为空
|
||||
EMAIL_ALREADY_EXIST=已经有一个账号使用此电子邮件。
|
||||
NO_VALID_EMAIL_ADDRESS=无效的电子邮件地址
|
||||
PASSWORD_MISMATCH=您输入的密码不一致
|
||||
CREATOR=创建人
|
||||
WELCOME=欢迎
|
||||
SHARE=分享
|
||||
|
@ -135,6 +135,6 @@
|
||||
</welcome-file>
|
||||
</welcome-file-list>
|
||||
<session-config>
|
||||
<session-timeout>180</session-timeout>
|
||||
<session-timeout>1440</session-timeout>
|
||||
</session-config>
|
||||
</web-app>
|
@ -14,6 +14,8 @@
|
||||
<value>linkLabel</value>
|
||||
<value>find*</value>
|
||||
<value>filter*</value>
|
||||
<!-- Remove can be performed in view only maps -->
|
||||
<value>removeMindmap</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
@ -26,19 +28,18 @@
|
||||
<value>save*</value>
|
||||
<value>update*</value>
|
||||
<value>add*</value>
|
||||
<value>remove*</value>
|
||||
<value>purge*</value>
|
||||
<value>revert*</value>
|
||||
<value>removeCollaboration</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="updateSecurityAdvice" class="com.wisemapping.security.aop.UpdateSecurityAdvise">
|
||||
<property name="mindmapService" ref="mindmapService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="viewSecurityAdvice" class="com.wisemapping.security.aop.ViewBaseSecurityAdvise">
|
||||
<property name="mindmapService" ref="mindmapService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="updateSecurityAdvice" class="com.wisemapping.security.aop.UpdateSecurityAdvise">
|
||||
<property name="mindmapService" ref="mindmapService"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
@ -24,12 +24,14 @@
|
||||
<prop key="hibernate.cache.use_second_level_cache">true</prop>
|
||||
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
|
||||
<prop key="hibernate.default_batch_fetch_size">200</prop>
|
||||
<prop key="hibernate.nestedTransactionAllowed">true</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
|
||||
<property name="sessionFactory" ref="mindmapSessionFactory"/>
|
||||
<property name="nestedTransactionAllowed" value="true"/>
|
||||
</bean>
|
||||
|
||||
<!-- Hibernate Template Definition -->
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,7 +1,6 @@
|
||||
/********************************************************************************/
|
||||
/* Header & Toolbar Styles */
|
||||
/********************************************************************************/
|
||||
@import "bootstrap.min.css";
|
||||
body {
|
||||
margin: 0;
|
||||
font-family:Arial;
|
||||
@ -57,30 +56,32 @@ div#mindplot {
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
div#position {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
#position-button {
|
||||
cursor: pointer;
|
||||
border: solid black 1px;
|
||||
border: solid white 1px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 40px 40px;
|
||||
background-color: #FFF;
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#position-button>img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#zoom-button {
|
||||
width: 40px;
|
||||
border: 0;
|
||||
box-shadow: 0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);
|
||||
}
|
||||
|
||||
#zoom-plus,
|
||||
#zoom-minus {
|
||||
border: solid black 1px;
|
||||
border: solid white 1px;
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
background-repeat: no-repeat;
|
||||
@ -88,14 +89,13 @@ div#position {
|
||||
background-position: center;
|
||||
cursor: pointer;
|
||||
background-color: #FFF;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#zoom-plus {
|
||||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
|
||||
#zoom-minus {
|
||||
border-radius: 0 0 8px 8px;
|
||||
#zoom-plus,
|
||||
#zoom-minus
|
||||
>img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
div#footerLogo {
|
||||
|
@ -14,8 +14,9 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta charset="utf-8" />
|
||||
<base href="${requestScope['site.baseurl']}/static/webapp/">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;600&display=swap" rel="stylesheet" />
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
|
||||
<link rel="stylesheet" media="print" onload="this.onload=null;this.removeAttribute('media');" href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;600&display=swap"/>
|
||||
|
||||
<%@ include file="/jsp/pageHeaders.jsf" %>
|
||||
|
||||
@ -36,9 +37,9 @@
|
||||
var mindmapLocked = ${mindmapLocked};
|
||||
var mindmapLockedMsg = '<spring:message code="MINDMAP_LOCKED" arguments="${lockInfo.user.fullName},${lockInfo.user.email}"/>';
|
||||
var userOptions = ${mindmap.properties};
|
||||
var accountName = '${principal.fullName}';
|
||||
var accountName = '${fn:replace(principal.fullName,'\'','\\\'')}';
|
||||
var accountEmail = '${principal.email}';
|
||||
var mapTitle = '${mindmap.title}';
|
||||
var mapTitle = '${fn:replace(mindmap.title,'\'','\\\'')}';
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
@ -10,9 +10,14 @@
|
||||
<meta name="viewport" content="initial-scale=1">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<base href="${requestScope['site.baseurl']}/static/mindplot/">
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
|
||||
<link rel="stylesheet" media="print" onload="this.onload=null;this.removeAttribute('media');" href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;600&display=swap"/>
|
||||
|
||||
<title>${mindmap.title} | <spring:message code="SITE.TITLE"/></title>
|
||||
<link rel="stylesheet" href="../../css/viewonly.css"/>
|
||||
<%@ include file="/jsp/pageHeaders.jsf" %>
|
||||
|
||||
<script type="text/javascript">
|
||||
var mapId = '${mindmap.id}';
|
||||
var historyId = '${hid}';
|
||||
@ -20,6 +25,7 @@
|
||||
var locale = '${locale}';
|
||||
var isAuth = ${principal != null};
|
||||
</script>
|
||||
|
||||
<c:if test="${requestScope['google.analytics.enabled']}">
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=${requestScope['google.analytics.account']}"></script>
|
||||
@ -34,6 +40,23 @@
|
||||
</script>
|
||||
</c:if>
|
||||
|
||||
<c:if test="${requestScope['google.analytics.enabled']}">
|
||||
<!-- Google Ads Sense Config. Lazy loading optimization -->
|
||||
<script type="text/javascript">
|
||||
function downloadJsAtOnload() {
|
||||
setTimeout(function downloadJs() {
|
||||
var element = document.createElement("script");
|
||||
element.setAttribute("data-ad-client", "ca-pub-4996113942657337");
|
||||
element.async = true;
|
||||
element.src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";
|
||||
document.body.appendChild(element);
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
window.addEventListener("load", downloadJsAtOnload, false);
|
||||
</script>
|
||||
</c:if>
|
||||
|
||||
<style>
|
||||
body {
|
||||
height: 100vh;
|
||||
@ -53,8 +76,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="root" class="mindplot-root">
|
||||
<div id="mindplot" style={mindplotStyle} className="wise-editor"></div>
|
||||
<div id="mindplot-tooltips" className="wise-editor"></div>
|
||||
<mindplot-component id="mindmap-comp"></mindplot-component>
|
||||
<div id="mindplot-tooltips" className="wise-editor"></div>
|
||||
|
||||
|
||||
<a href="${requestScope['site.homepage']}" target="new">
|
||||
@ -70,15 +93,15 @@
|
||||
|
||||
<div id="floating-panel">
|
||||
<div id="zoom-button">
|
||||
<button id="zoom-plus">
|
||||
<img src="../../images/add.svg" />
|
||||
<button id="zoom-plus" title="Zoom Out">
|
||||
<img src="../../images/add.svg" width="24" height="24"/>
|
||||
</button>
|
||||
<button id="zoom-minus">
|
||||
<img src="../../images/minus.svg" />
|
||||
<button id="zoom-minus" title="Zoom In">
|
||||
<img src="../../images/minus.svg" width="24" height="24"/>
|
||||
</button>
|
||||
<div id="position">
|
||||
<button id="position-button">
|
||||
<img src="../../images/center_focus.svg" />
|
||||
<button id="position-button" title="Center">
|
||||
<img src="../../images/center_focus.svg" width="24" height="24"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -6,8 +6,10 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta charset="utf-8" />
|
||||
<base href="${requestScope['site.baseurl']}/static/webapp/">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;600&display=swap" rel="stylesheet" />
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
|
||||
<link rel="stylesheet" media="print" onload="this.onload=null;this.removeAttribute('media');" href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;600&display=swap"/>
|
||||
|
||||
<%@ include file="/jsp/pageHeaders.jsf" %>
|
||||
|
||||
<title>Loading | WiseMapping</title>
|
||||
@ -23,8 +25,20 @@
|
||||
|
||||
</script>
|
||||
<c:if test="${requestScope['google.analytics.enabled']}">
|
||||
<!-- Google Ads Sense Config-->
|
||||
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4996113942657337" crossorigin="anonymous"></script>
|
||||
<!-- Google Ads Sense Config. Lazy loading optimization -->
|
||||
<script type="text/javascript">
|
||||
function downloadJsAtOnload() {
|
||||
setTimeout(function downloadJs() {
|
||||
var element = document.createElement("script");
|
||||
element.setAttribute("data-ad-client", "ca-pub-4996113942657337");
|
||||
element.async = true;
|
||||
element.src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";
|
||||
document.body.appendChild(element);
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
window.addEventListener("load", downloadJsAtOnload, false);
|
||||
</script>
|
||||
</c:if>
|
||||
</head>
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class RestAdminITCase {
|
||||
}
|
||||
}
|
||||
|
||||
public String createNewUser(final @NotNull MediaType mediaType) {
|
||||
public RestUser createNewUserAndGetUser(final @NotNull MediaType mediaType) {
|
||||
|
||||
// Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
@ -99,6 +99,13 @@ public class RestAdminITCase {
|
||||
ResponseEntity<RestUser> result = findUser(requestHeaders, templateRest, location);
|
||||
assertEquals(result.getBody().getEmail(), restUser.getEmail(), "Returned object object seems not be the same.");
|
||||
|
||||
return result.getBody();
|
||||
}
|
||||
|
||||
public String createNewUser(final @NotNull MediaType mediaType) {
|
||||
|
||||
// Fill user data ...
|
||||
final RestUser restUser = createNewUserAndGetUser(mediaType);
|
||||
// Find by email and check ...
|
||||
// @todo: review find by email... It's failing with 406
|
||||
// findUser(requestHeaders, templateRest, location);
|
||||
@ -119,7 +126,7 @@ public class RestAdminITCase {
|
||||
return templateRest.exchange(url, HttpMethod.GET, findUserEntity, RestUser.class);
|
||||
}
|
||||
|
||||
private ResponseEntity<RestUser> findUserByEmail(HttpHeaders requestHeaders, RestTemplate templateRest, final String email) {
|
||||
public ResponseEntity<RestUser> findUserByEmail(HttpHeaders requestHeaders, RestTemplate templateRest, final String email) {
|
||||
HttpEntity<RestUser> findUserEntity = new HttpEntity<>(requestHeaders);
|
||||
|
||||
// Add extension only to avoid the fact that the last part is extracted ...
|
||||
|
@ -78,6 +78,7 @@ public class RestLabelITCase {
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void createLabelWithoutRequiredField(final @NotNull MediaType mediaType) throws IOException, WiseMappingException {
|
||||
final HttpHeaders requestHeaders = RestHelper.createHeaders(mediaType);
|
||||
requestHeaders.set(HttpHeaders.ACCEPT_LANGUAGE, "en");
|
||||
final RestTemplate template = RestHelper.createTemplate(userEmail + ":" + "admin");
|
||||
|
||||
try {
|
||||
|
@ -14,10 +14,19 @@ import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.wisemapping.test.rest.RestHelper.*;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.web.client.RestClientException;
|
||||
|
||||
import static com.wisemapping.test.rest.RestHelper.createHeaders;
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
@Test
|
||||
@ -25,11 +34,11 @@ public class RestMindmapITCase {
|
||||
|
||||
private String userEmail = "admin@wisemapping.com";
|
||||
private static final String ICON = "glyphicon glyphicon-tag";
|
||||
final RestAdminITCase restAdminITCase = new RestAdminITCase();
|
||||
|
||||
@BeforeClass
|
||||
void createUser() {
|
||||
|
||||
final RestAdminITCase restAdminITCase = new RestAdminITCase();
|
||||
userEmail = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
|
||||
userEmail += ":" + "admin";
|
||||
}
|
||||
@ -46,12 +55,8 @@ public class RestMindmapITCase {
|
||||
final String title2 = "List Maps 2 - " + mediaType;
|
||||
addNewMap(template, title2);
|
||||
|
||||
// Check that the map has been created ...
|
||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||
final ResponseEntity<RestMindmapList> response = template.exchange(BASE_REST_URL + "/maps/", HttpMethod.GET, findMapEntity, RestMindmapList.class);
|
||||
|
||||
// Validate that the two maps are there ...
|
||||
final RestMindmapList body = response.getBody();
|
||||
final RestMindmapList body = fetchMaps(requestHeaders, template);
|
||||
final List<RestMindmapInfo> mindmaps = body.getMindmapsInfo();
|
||||
|
||||
boolean found1 = false;
|
||||
@ -96,11 +101,7 @@ public class RestMindmapITCase {
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(template, "Map to change title - " + mediaType);
|
||||
|
||||
// Change map title ...
|
||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||
final String newTitle = "New map to change title - " + mediaType;
|
||||
final HttpEntity<String> updateEntity = new HttpEntity<>(newTitle, requestHeaders);
|
||||
template.put(HOST_PORT + resourceUri + "/title", updateEntity);
|
||||
String newTitle = changeMapTitle(requestHeaders, mediaType, template, resourceUri);
|
||||
|
||||
// Load map again ..
|
||||
final RestMindmap map = findMap(requestHeaders, template, resourceUri);
|
||||
@ -110,6 +111,7 @@ public class RestMindmapITCase {
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void validateMapsCreation(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
requestHeaders.set(HttpHeaders.ACCEPT_LANGUAGE, "en");
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
@ -160,16 +162,25 @@ public class RestMindmapITCase {
|
||||
|
||||
// Update map xml content ...
|
||||
final String resourceUrl = HOST_PORT + resourceUri.toString();
|
||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||
final String newXmlContent = "<map>this is not valid</map>";
|
||||
HttpEntity<String> updateEntity = new HttpEntity<>(newXmlContent, requestHeaders);
|
||||
template.put(resourceUrl + "/document/xml", updateEntity);
|
||||
String newXmlContent = updateMapDocument(requestHeaders, template, resourceUrl);
|
||||
|
||||
// Check that the map has been updated ...
|
||||
final RestMindmap response = findMap(requestHeaders, template, resourceUri);
|
||||
assertEquals(response.getXml(), newXmlContent);
|
||||
}
|
||||
|
||||
private String updateMapDocument(final HttpHeaders requestHeaders, final RestTemplate template, final String resourceUrl, String content) throws RestClientException {
|
||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||
final String newXmlContent = content != null ? content : "<map>this is not valid</map>";
|
||||
HttpEntity<String> updateEntity = new HttpEntity<>(newXmlContent, requestHeaders);
|
||||
template.put(resourceUrl + "/document/xml", updateEntity);
|
||||
return newXmlContent;
|
||||
}
|
||||
|
||||
private String updateMapDocument(final HttpHeaders requestHeaders, final RestTemplate template, final String resourceUrl) throws RestClientException {
|
||||
return updateMapDocument(requestHeaders, template, resourceUrl, null);
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void cloneMap(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
@ -194,9 +205,67 @@ public class RestMindmapITCase {
|
||||
assertEquals(response.getXml(), xml);
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void updateStarred(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String title1 = "Stared Map user 1";
|
||||
URI mapUri = addNewMap(template, title1);
|
||||
|
||||
// Update starred ...
|
||||
final String resourceUrl = HOST_PORT + mapUri.toString() + "/starred";
|
||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
final HttpHeaders textContentType = new HttpHeaders();
|
||||
textContentType.setContentType(MediaType.TEXT_PLAIN);
|
||||
final HttpEntity<String> updateEntity = new HttpEntity<>("true", textContentType);
|
||||
template.put(resourceUrl, updateEntity);
|
||||
|
||||
// Has been updated ?.
|
||||
|
||||
final HttpEntity findLabelEntity = new HttpEntity(createHeaders(MediaType.TEXT_PLAIN));
|
||||
final ResponseEntity<String> response = template.exchange(resourceUrl, HttpMethod.GET, findLabelEntity, String.class);
|
||||
|
||||
assertTrue(Boolean.parseBoolean(response.getBody()), "Starred has been updated");
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void verifyMapOwnership(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||
throw new SkipException("missing test: removeUserShouldOnlyDeleteOnwedMap");
|
||||
final RestAdminITCase restAdminITCase = new RestAdminITCase();
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String title1 = "verifyMapOwnership Map user 1";
|
||||
addNewMap(template, title1);
|
||||
|
||||
//create another user
|
||||
RestUser secondUser = restAdminITCase.createNewUserAndGetUser(MediaType.APPLICATION_JSON);
|
||||
final RestTemplate secondTemplate = createTemplate(secondUser.getEmail() + ":admin");
|
||||
|
||||
final String title2 = "verifyMapOwnership Map user 2";
|
||||
addNewMap(secondTemplate, title2);
|
||||
|
||||
// Delete user ...
|
||||
String authorisation = "admin@wisemapping.org" + ":" + "test";
|
||||
RestTemplate superadminTemplate = createTemplate(authorisation);
|
||||
|
||||
superadminTemplate.delete(BASE_REST_URL + "/admin/users/" + secondUser.getId());
|
||||
|
||||
// Validate that the two maps are there ...
|
||||
final RestMindmapList body = fetchMaps(requestHeaders, template);
|
||||
final List<RestMindmapInfo> mindmaps = body.getMindmapsInfo();
|
||||
|
||||
boolean found1 = false;
|
||||
for (RestMindmapInfo mindmap : mindmaps) {
|
||||
if (mindmap.getTitle().equals(title1)) {
|
||||
found1 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(found1, "Map could not be found");
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
@ -242,25 +311,10 @@ public class RestMindmapITCase {
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(template, "Map for addCollabs - " + mediaType);
|
||||
|
||||
// Add a new collaboration ...
|
||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
final RestCollaborationList collabs = new RestCollaborationList();
|
||||
collabs.setMessage("Adding new permission");
|
||||
|
||||
final String newCollab = "new-collab@example.com";
|
||||
String role = "editor";
|
||||
|
||||
final RestCollaboration collab = new RestCollaboration();
|
||||
collab.setEmail(newCollab);
|
||||
collab.setRole(role);
|
||||
collabs.addCollaboration(collab);
|
||||
|
||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||
String newCollab = addNewCollaboration(requestHeaders, template, resourceUri);
|
||||
|
||||
// Has been added ?
|
||||
final ResponseEntity<RestCollaborationList> response = fetchCollabs(requestHeaders, template, resourceUri);
|
||||
RestCollaborationList responseCollbs = response.getBody();
|
||||
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
||||
|
||||
// Has been added ?
|
||||
assertEquals(responseCollbs.getCount(), 2);
|
||||
@ -286,17 +340,13 @@ public class RestMindmapITCase {
|
||||
final String newCollab = "new-collab@example.com";
|
||||
String role = "editor";
|
||||
|
||||
final RestCollaboration collab = new RestCollaboration();
|
||||
collab.setEmail(newCollab);
|
||||
collab.setRole(role);
|
||||
collabs.addCollaboration(collab);
|
||||
final RestCollaboration collab = addCollabToList(newCollab, role, collabs);
|
||||
|
||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||
|
||||
// Has been added ?
|
||||
final ResponseEntity<RestCollaborationList> response = fetchCollabs(requestHeaders, template, resourceUri);
|
||||
RestCollaborationList responseCollbs = response.getBody();
|
||||
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
||||
assertEquals(responseCollbs.getCount(), 2);
|
||||
|
||||
// Update the collaboration type ...
|
||||
@ -318,25 +368,10 @@ public class RestMindmapITCase {
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(template, "Map for deleteCollabs - " + mediaType);
|
||||
|
||||
// Add a new collaboration ...
|
||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
final RestCollaborationList collabs = new RestCollaborationList();
|
||||
collabs.setMessage("Adding new permission");
|
||||
|
||||
final String newCollab = "new-collab@example.com";
|
||||
String role = "editor";
|
||||
|
||||
final RestCollaboration collab = new RestCollaboration();
|
||||
collab.setEmail(newCollab);
|
||||
collab.setRole(role);
|
||||
collabs.addCollaboration(collab);
|
||||
|
||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||
String newCollab = addNewCollaboration(requestHeaders, template, resourceUri);
|
||||
|
||||
// Has been added ?
|
||||
final ResponseEntity<RestCollaborationList> response = fetchCollabs(requestHeaders, template, resourceUri);
|
||||
RestCollaborationList responseCollbs = response.getBody();
|
||||
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
||||
|
||||
// Has been added ?
|
||||
assertEquals(responseCollbs.getCount(), 2);
|
||||
@ -349,6 +384,82 @@ public class RestMindmapITCase {
|
||||
assertEquals(afterDeleteResponse.getBody().getCollaborations().size(), 1);
|
||||
}
|
||||
|
||||
private String addNewCollaboration(final HttpHeaders requestHeaders, final RestTemplate template, final URI resourceUri) throws RestClientException {
|
||||
// Add a new collaboration ...
|
||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
final RestCollaborationList collabs = new RestCollaborationList();
|
||||
collabs.setMessage("Adding new permission");
|
||||
final String newCollab = "new-collab@example.com";
|
||||
String role = "editor";
|
||||
addCollabToList(newCollab, role, collabs);
|
||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||
return newCollab;
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void deleteCollabsWithInvalidEmail(final @NotNull MediaType mediaType) {
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(template, "deleteCollabsWithInvalidEmail");
|
||||
|
||||
// Remove with invalid email ...
|
||||
try {
|
||||
|
||||
template.delete(HOST_PORT + resourceUri + "/collabs?email=invalidEmail");
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(e.getRawStatusCode(), 400);
|
||||
assertTrue(e.getMessage().contains("Invalid email exception:"));
|
||||
}
|
||||
|
||||
// Check that it has been removed ...
|
||||
final ResponseEntity<RestCollaborationList> afterDeleteResponse = fetchCollabs(requestHeaders, template, resourceUri);
|
||||
assertEquals(afterDeleteResponse.getBody().getCollaborations().size(), 1);
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void deleteCollabsWithoutOwnerPermission(final @NotNull MediaType mediaType) {
|
||||
|
||||
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(template, "deleteWithoutOwnerPermission");
|
||||
|
||||
final String newCollab = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
|
||||
template = createTemplate(newCollab + ":admin");
|
||||
|
||||
// Remove with invalid email ...
|
||||
try {
|
||||
|
||||
template.delete(HOST_PORT + resourceUri + "/collabs?email=" + newCollab);
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(e.getRawStatusCode(), 400);
|
||||
assertTrue(e.getMessage().contains("No enough permissions"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void deleteOwnerCollab(final @NotNull MediaType mediaType) {
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(template, "Map for deleteOwnerCollab");
|
||||
|
||||
// Now, remove owner collab ...
|
||||
try {
|
||||
template.delete(HOST_PORT + resourceUri + "/collabs?email=" + userEmail.replace(":admin", ""));
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(e.getRawStatusCode(), 400);
|
||||
assertTrue(e.getMessage().contains("Can not remove owner collab"));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ResponseEntity<RestCollaborationList> fetchCollabs(HttpHeaders requestHeaders, RestTemplate template, URI resourceUri) {
|
||||
final HttpEntity findCollabs = new HttpEntity(requestHeaders);
|
||||
@ -361,7 +472,7 @@ public class RestMindmapITCase {
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
// Create a sample map ...fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
||||
final URI resourceUri = addNewMap(template, "Map for Collaboration - " + mediaType);
|
||||
|
||||
// Add a new collaboration ...
|
||||
@ -370,19 +481,48 @@ public class RestMindmapITCase {
|
||||
collabs.setMessage("Adding new permission");
|
||||
|
||||
// Validate that owner can not be added.
|
||||
final RestCollaboration collab = new RestCollaboration();
|
||||
final String newCollab = "new-collab@example.com";
|
||||
collab.setEmail(newCollab);
|
||||
collab.setRole("owner");
|
||||
collabs.addCollaboration(collab);
|
||||
addCollabToList("newCollab@example", "owner", collabs);
|
||||
|
||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void removeLabelFromMindmap(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||
throw new SkipException("missing test: label removal from map");
|
||||
public void removeLabelFromMindmap(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a new label
|
||||
final String titleLabel = "removeLabelFromMindmap";
|
||||
final URI labelUri = RestLabelITCase.addNewLabel(requestHeaders, template, titleLabel, COLOR, ICON);
|
||||
|
||||
// Create a sample map ...
|
||||
final String mapTitle = "removeLabelFromMindmap";
|
||||
final URI mindmapUri = addNewMap(template, mapTitle);
|
||||
final String mapId = mindmapUri.getPath().replace("/service/maps/", "");
|
||||
|
||||
// Assign label to map ...
|
||||
String labelId = labelUri.getPath().replace("/service/labels/", "");
|
||||
HttpEntity<String> labelEntity = new HttpEntity<>(labelId, requestHeaders);
|
||||
template.postForLocation(BASE_REST_URL + "/maps/" + mapId + "/labels", labelEntity);
|
||||
|
||||
// Remove label from map
|
||||
template.delete(BASE_REST_URL + "/maps/" + mapId + "/labels/" + labelId);
|
||||
|
||||
Optional<RestMindmapInfo> mindmapInfo = fetchMap(requestHeaders, template, mapId);
|
||||
assertTrue(mindmapInfo.get().getLabels().size() == 0);
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Optional<RestMindmapInfo> fetchMap(HttpHeaders requestHeaders, RestTemplate template, @NotNull String mapId) {
|
||||
// Check that the label has been removed ...
|
||||
final List<RestMindmapInfo> mindmapsInfo = fetchMaps(requestHeaders, template).getMindmapsInfo();
|
||||
Optional<RestMindmapInfo> mindmapInfo = mindmapsInfo
|
||||
.stream()
|
||||
.filter(m -> m.getId() == Integer.parseInt(mapId))
|
||||
.findAny();
|
||||
return mindmapInfo;
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
@ -410,18 +550,266 @@ public class RestMindmapITCase {
|
||||
template.postForLocation(BASE_REST_URL + "/maps/" + mapId + "/labels", labelEntity);
|
||||
|
||||
// Check that the label has been assigned ...
|
||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||
final ResponseEntity<RestMindmapList> mindmapList = template.exchange(BASE_REST_URL + "/maps/", HttpMethod.GET, findMapEntity, RestMindmapList.class);
|
||||
|
||||
final List<RestMindmapInfo> mindmapsInfo = mindmapList.getBody().getMindmapsInfo();
|
||||
Optional<RestMindmapInfo> mindmapInfo = mindmapsInfo
|
||||
.stream()
|
||||
.filter(m -> m.getId() == Integer.parseInt(mapId))
|
||||
.findAny();
|
||||
Optional<RestMindmapInfo> mindmapInfo = fetchMap(requestHeaders, template, mapId);
|
||||
|
||||
assertTrue(mindmapInfo.get().getLabels().size() == 1);
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void updateCollabs(final @NotNull MediaType mediaType) {
|
||||
|
||||
// Create a sample map ...
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
final URI resourceUri = addNewMap(template, "Map for updateCollabs - " + mediaType);
|
||||
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
// Add a new collaboration ...
|
||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
RestCollaborationList collabs = new RestCollaborationList();
|
||||
collabs.setMessage("Adding new permission");
|
||||
|
||||
String newCollab = "new-collab@example.com";
|
||||
String role = "editor";
|
||||
|
||||
addCollabToList(newCollab, role, collabs);
|
||||
|
||||
HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||
|
||||
collabs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
||||
|
||||
//delete one collab
|
||||
collabs.setCollaborations(collabs.getCollaborations().stream().filter(c -> c.getRole().equals("owner")).collect(Collectors.toList()));
|
||||
|
||||
//Add another collaborationMediaType
|
||||
newCollab = "another-collab@example.com";
|
||||
addCollabToList(newCollab, role, collabs);
|
||||
|
||||
//add owner to list
|
||||
addCollabToList(userEmail.replace(":admin", ""), "owner", collabs);
|
||||
|
||||
updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||
template.postForLocation(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||
|
||||
|
||||
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
||||
|
||||
// Has been another-collaboration list updated ?
|
||||
assertTrue(responseCollbs.getCollaborations().stream().anyMatch(x -> x.getEmail().equals("another-collab@example.com")));
|
||||
assertEquals(responseCollbs.getCount(), 2);
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void updateProperties(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String title = "updateProperties map";
|
||||
final URI resourceUri = addNewMap(template, title);
|
||||
|
||||
// Build map to update ...
|
||||
final RestMindmap mapToUpdate = new RestMindmap();
|
||||
mapToUpdate.setXml("<map>this is not valid</map>");
|
||||
mapToUpdate.setProperties("{zoom:x}");
|
||||
mapToUpdate.setTitle("new title for map");
|
||||
mapToUpdate.setDescription("updated map description");
|
||||
|
||||
// Update map ...
|
||||
final String resourceUrl = HOST_PORT + resourceUri.toString();
|
||||
final HttpEntity<RestMindmap> updateEntity = new HttpEntity<>(mapToUpdate, requestHeaders);
|
||||
template.put(resourceUrl, updateEntity);
|
||||
|
||||
// Check that the map has been updated ...
|
||||
HttpEntity<RestUser> findMapEntity = new HttpEntity<>(requestHeaders);
|
||||
final ResponseEntity<RestMindmap> response = template.exchange(HOST_PORT + resourceUri, HttpMethod.GET, findMapEntity, RestMindmap.class);
|
||||
assertEquals(response.getBody().getTitle(), mapToUpdate.getTitle());
|
||||
assertEquals(response.getBody().getDescription(), mapToUpdate.getDescription());
|
||||
assertEquals(response.getBody().getXml(), mapToUpdate.getXml());
|
||||
assertEquals(response.getBody().getProperties(), mapToUpdate.getProperties());
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void batchDelete(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String title1 = "Batch delete map 1";
|
||||
addNewMap(template, title1);
|
||||
|
||||
final String title2 = "Batch delete map 2";
|
||||
addNewMap(template, title2);
|
||||
|
||||
|
||||
String maps;
|
||||
maps = fetchMaps(requestHeaders, template).getMindmapsInfo().stream().map(map -> {
|
||||
return String.valueOf(map.getId());
|
||||
}).collect(Collectors.joining(","));
|
||||
|
||||
|
||||
template.delete(BASE_REST_URL + "/maps/batch?ids=" + maps);
|
||||
|
||||
// Validate that the two maps are there ...
|
||||
final RestMindmapList body = fetchMaps(requestHeaders, template);
|
||||
assertEquals(body.getMindmapsInfo().size(), 0);
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void updatePublishState(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final String mapTitle = "updatePublishState";
|
||||
final URI mindmapUri = addNewMap(template, mapTitle);
|
||||
final String mapId = mindmapUri.getPath().replace("/service/maps/", "");
|
||||
|
||||
// Change map status ...
|
||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||
//final String newPublicState = "true";
|
||||
final HttpEntity<String> updateEntity = new HttpEntity<>(Boolean.TRUE.toString(), requestHeaders);
|
||||
template.put(HOST_PORT + mindmapUri + "/publish", updateEntity);
|
||||
|
||||
//fetch public view
|
||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||
ResponseEntity<String> publicView = template.exchange(HOST_PORT + "/c/" + mapId + "/public", HttpMethod.GET, findMapEntity, String.class);
|
||||
assertNotNull(publicView.getBody());
|
||||
assertEquals(publicView.getStatusCodeValue(), 200);
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void fetchMapHistory(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(template, "Map to change title - " + mediaType);
|
||||
|
||||
updateMapDocument(requestHeaders, template, HOST_PORT + resourceUri.toString());
|
||||
|
||||
//fetch map history
|
||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||
final ResponseEntity<RestMindmapHistoryList> maps = template.exchange(HOST_PORT + resourceUri + "/history/", HttpMethod.GET, findMapEntity, RestMindmapHistoryList.class);
|
||||
assertEquals(maps.getBody().getCount(), 1);
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void updateRevertMindmap(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(template, "map to test revert changes");
|
||||
updateMapDocument(requestHeaders, template, HOST_PORT + resourceUri.toString(), "<map><node text='this is an xml to test revert changes service'></map>");
|
||||
|
||||
updateMapDocument(requestHeaders, template, HOST_PORT + resourceUri.toString(), "<map><node text='this is an xml with modification to be reverted'></map>");
|
||||
|
||||
//fetch map history
|
||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||
final ResponseEntity<RestMindmapHistoryList> mapHistories = template.exchange(HOST_PORT + resourceUri + "/history/", HttpMethod.GET, findMapEntity, RestMindmapHistoryList.class);
|
||||
|
||||
//aply revert
|
||||
final HttpEntity<String> cloneEntity = new HttpEntity<>(requestHeaders);
|
||||
template.postForLocation(HOST_PORT + resourceUri + "/history/latest", cloneEntity);
|
||||
final RestMindmap latestStoredMap = findMap(requestHeaders, template, resourceUri);
|
||||
template.postForLocation(HOST_PORT + resourceUri + "/history/" + mapHistories.getBody().getChanges().get(1).getId(), cloneEntity);
|
||||
final RestMindmap firstVersionMap = findMap(requestHeaders, template, resourceUri);
|
||||
|
||||
//verify revert
|
||||
assertEquals(firstVersionMap.getXml(), "<map><node text='this is an xml to test revert changes service'></map>");
|
||||
assertEquals(latestStoredMap.getXml(), "<map><node text='this is an xml with modification to be reverted'></map>");
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void addCollabWhitoutOwnerPermission(final @NotNull MediaType mediaType) {
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(template, "MaddCollabWhitoutOwnerPermission");
|
||||
|
||||
// Add a new collaboration ...
|
||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
final RestCollaborationList collabs = new RestCollaborationList();
|
||||
collabs.setMessage("Adding new permission");
|
||||
|
||||
final String newCollab = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
|
||||
String role = "editor";
|
||||
|
||||
addCollabToList(newCollab, role, collabs);
|
||||
|
||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||
|
||||
template = createTemplate(newCollab + ":admin");
|
||||
//add collab again with the new user expecting the Exception
|
||||
try {
|
||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(e.getRawStatusCode(), 400);
|
||||
assertTrue(e.getMessage().contains("User must be owner to share mindmap"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||
public void addCollabWhitOwnerRole(final @NotNull MediaType mediaType) {
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a sample map ...
|
||||
final URI resourceUri = addNewMap(template, "addCollabWhitOwnerRole");
|
||||
|
||||
// Add a new collaboration ...
|
||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
final RestCollaborationList collabs = new RestCollaborationList();
|
||||
collabs.setMessage("Adding new permission");
|
||||
|
||||
final String newCollab = "new-collaborator@mail.com";
|
||||
String role = "owner";
|
||||
|
||||
addCollabToList(newCollab, role, collabs);
|
||||
|
||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||
try {
|
||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||
} catch (HttpClientErrorException e) {
|
||||
assertEquals(e.getRawStatusCode(), 400);
|
||||
assertTrue(e.getMessage().contains("Collab email can not be change"));
|
||||
}
|
||||
}
|
||||
|
||||
private String changeMapTitle(final HttpHeaders requestHeaders, final MediaType mediaType, final RestTemplate template, final URI resourceUri) throws RestClientException {
|
||||
// Change map title ...
|
||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||
final String newTitle = "New map to change title - " + mediaType;
|
||||
final HttpEntity<String> updateEntity = new HttpEntity<>(newTitle, requestHeaders);
|
||||
template.put(HOST_PORT + resourceUri + "/title", updateEntity);
|
||||
return newTitle;
|
||||
}
|
||||
|
||||
private RestMindmapList fetchMaps(final HttpHeaders requestHeaders, final RestTemplate template) throws RestClientException {
|
||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||
final ResponseEntity<RestMindmapList> maps = template.exchange(BASE_REST_URL + "/maps/", HttpMethod.GET, findMapEntity, RestMindmapList.class);
|
||||
return maps.getBody();
|
||||
}
|
||||
|
||||
private RestCollaborationList fetchAndGetCollabs(final HttpHeaders requestHeaders, final RestTemplate template, final URI resourceUri) {
|
||||
final ResponseEntity<RestCollaborationList> response = fetchCollabs(requestHeaders, template, resourceUri);
|
||||
RestCollaborationList responseCollbs = response.getBody();
|
||||
return responseCollbs;
|
||||
}
|
||||
|
||||
private RestCollaboration addCollabToList(String newCollab, String role, RestCollaborationList collabs) {
|
||||
RestCollaboration collab = new RestCollaboration();
|
||||
collab.setEmail(newCollab);
|
||||
collab.setRole(role);
|
||||
collabs.addCollaboration(collab);
|
||||
return collab;
|
||||
}
|
||||
|
||||
private RestMindmap findMap(HttpHeaders requestHeaders, RestTemplate template, URI resourceUri) {
|
||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||
final ResponseEntity<RestMindmap> response = template.exchange(HOST_PORT + resourceUri.toString(), HttpMethod.GET, findMapEntity, RestMindmap.class);
|
||||
|
Loading…
Reference in New Issue
Block a user