Compare commits
459 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d6a60636ed | ||
|
9ca2f6bb1e | ||
|
b886a5888a | ||
|
cec140b1fd | ||
|
84cffac713 | ||
|
754d4b3dcf | ||
|
7ee577c400 | ||
|
c854c1b377 | ||
|
bfe24b7dfb | ||
|
85c7e3ce5c | ||
|
27304ea385 | ||
|
8a994ee6f5 | ||
|
5ec3b6cce1 | ||
|
8cd05ec37e | ||
|
5a00229390 | ||
|
4b01f7c8ee | ||
|
edb91b92bd | ||
|
c6ae7be255 | ||
|
86ba19c120 | ||
|
183ab33729 | ||
|
9e992a8f61 | ||
|
5d18283285 | ||
|
d66666010d | ||
|
bddf867b63 | ||
|
d0d161e8ab | ||
|
64c7198d50 | ||
|
2fae012fd9 | ||
|
e8ee76c5f8 | ||
|
3d6df8a143 | ||
|
dec0fb7aef | ||
|
980a984499 | ||
|
1f8e251009 | ||
|
4729022d6a | ||
|
eb9a28603c | ||
|
d191aa9075 | ||
|
e585686bd2 | ||
|
44b3707005 | ||
|
251f0eca46 | ||
|
1bdf75e295 | ||
|
ccdab5257b | ||
|
797a4adfd4 | ||
|
3b64577d15 | ||
|
06fc95c454 | ||
|
0c15789c4b | ||
|
ae31613fdd | ||
|
6432fefa67 | ||
|
29037e60d8 | ||
|
29894a276e | ||
|
db0595ac7e | ||
|
bf8345908b | ||
|
d111c54f15 | ||
|
6a5eb910b5 | ||
|
8462e54293 | ||
|
7b45b4b633 | ||
|
b7051d56c0 | ||
|
8be0f19792 | ||
|
44dbce0801 | ||
|
878fe464ea | ||
|
68fd71d300 | ||
|
73e955afac | ||
|
ea4684d9c8 | ||
|
0b021c7602 | ||
|
1de1a9f55f | ||
|
60d75b6f2d | ||
|
ae71b1331f | ||
|
c56698d085 | ||
|
7299c7d506 | ||
|
9e8f73df99 | ||
|
572eb44e7a | ||
|
1d6e3ec4bf | ||
|
83e51a6501 | ||
|
5733dbf45e | ||
|
b110d338af | ||
|
08a066271b | ||
|
8996df4cbb | ||
|
c5932dc0f8 | ||
|
832fb6ce52 | ||
|
bbc380366f | ||
|
95d9414ae3 | ||
|
1a31e5ee99 | ||
|
d48abe6121 | ||
|
f564b4b34a | ||
|
147a4ec06a | ||
|
c81439cae8 | ||
|
06d3f0cd25 | ||
|
2a37167b01 | ||
|
2b89fdccca | ||
|
6624abb9ed | ||
|
726ffcd817 | ||
|
356ab4b1c1 | ||
|
a9c1d42925 | ||
|
08a9289893 | ||
|
3df00e9e0e | ||
|
b3e2e37929 | ||
|
7f6d575c16 | ||
|
10b9a4ceb2 | ||
|
d23595a75c | ||
|
a3c6ce10c2 | ||
|
1444be36ce | ||
|
ba90addad2 | ||
|
cfa669fe2e | ||
|
efb7e0cc3b | ||
|
668506ceb8 | ||
|
105c0544e1 | ||
|
29acc46d34 | ||
|
6fe9dcf578 | ||
|
d555309c22 | ||
|
d089b471fc | ||
|
7525ba4820 | ||
|
58390dfb92 | ||
|
b765a21369 | ||
|
560ceffaaf | ||
|
f3cc90d9d0 | ||
|
434fb4c8f5 | ||
|
57e5fcac3a | ||
|
b99cb2f8a3 | ||
|
ea95ba0ec7 | ||
|
3cf726f928 | ||
|
460d8270c6 | ||
|
079606c4e7 | ||
|
d67a16f550 | ||
|
8db7f5015f | ||
|
734463d233 | ||
|
fdf041e8b1 | ||
|
23611c8d54 | ||
|
729d2e98f7 | ||
|
baa8adacda | ||
|
7a535b1dca | ||
|
632a9a6e00 | ||
|
a4aa1c5436 | ||
|
9a19e2a5eb | ||
|
6d1a00291e | ||
|
d6656dffc0 | ||
|
3b23fead8e | ||
|
94b043ecf5 | ||
|
c8286c26aa | ||
|
f567513468 | ||
|
472bb38342 | ||
|
10fb98cdaa | ||
|
f65149c948 | ||
|
b4857ed99e | ||
|
131a501508 | ||
|
37e9676687 | ||
|
6ed7bc9154 | ||
|
d535fcc381 | ||
|
d28b439e62 | ||
|
0738804d88 | ||
|
f248a8c099 | ||
|
0891beeecd | ||
|
4646ae15c4 | ||
|
54fb696090 | ||
|
e5d9380699 | ||
|
5fe892abfd | ||
|
12ec295fe0 | ||
|
8936ef5008 | ||
|
0eaa8c8638 | ||
|
28010a85aa | ||
|
f1e4b1c8c0 | ||
|
1a2ba04b76 | ||
|
1ead555e09 | ||
|
cf246f00c8 | ||
|
4200d85cc0 | ||
|
a4ae253ae3 | ||
|
640b8d7ed0 | ||
|
5429178a1c | ||
|
163bc960b3 | ||
|
b79930394d | ||
|
c8e0b92ef5 | ||
|
7d0e4dc35a | ||
|
5f9b98324d | ||
|
95fcbb5888 | ||
|
2f4efde017 | ||
|
a62a053533 | ||
|
2d6a0c3e24 | ||
|
9897e69ee2 | ||
|
01fa9def4a | ||
|
71bba1c5ab | ||
|
708b8eb355 | ||
|
3e7ed53a2d | ||
|
136dc1154b | ||
|
301048ecad | ||
|
26138188ea | ||
|
558aa31516 | ||
|
f0e056c298 | ||
|
ccd5eb8e15 | ||
|
43d5779d5f | ||
|
148b56aecb | ||
|
684c412e95 | ||
|
7d9ccaec91 | ||
|
b4c69133f5 | ||
|
9edea47dbd | ||
|
ed55fd824f | ||
|
eff063ca37 | ||
|
a74f4158c6 | ||
|
d601a2818f | ||
|
81e9b5f59d | ||
|
f048d0adb7 | ||
|
2ec941e1a0 | ||
|
72a46367d6 | ||
|
b19ac2c4c3 | ||
|
acb3782561 | ||
|
c7b193f43f | ||
|
154db9d9e8 | ||
|
deb6c4be4d | ||
|
8b6ef7536e | ||
|
d0e07269c4 | ||
|
81e3cb590c | ||
|
a70dd1e52e | ||
|
194a7f200e | ||
|
306a2a2ada | ||
|
0c43bb4ad3 | ||
|
829815f9e9 | ||
|
93a8647c6a | ||
|
6ac7948312 | ||
|
0dc426487d | ||
|
b9e64e20e3 | ||
|
561fb00ac2 | ||
|
b774052e1d | ||
|
367bcf084d | ||
|
fe2b7225ef | ||
|
49d9820a44 | ||
|
3f2c687643 | ||
|
c68b4c90da | ||
|
1b480b566a | ||
|
504e3e18e6 | ||
|
f2be251c8b | ||
|
cedd12314b | ||
|
02cb53d082 | ||
|
0acd0c097f | ||
|
9a9dabc0ab | ||
|
99be712a5f | ||
|
ed4d50724a | ||
|
94812cd96a | ||
|
f39e82b016 | ||
|
2f994be98d | ||
|
40907bc479 | ||
|
d4f9fb1756 | ||
|
14d688b9bf | ||
|
a745167c75 | ||
|
2cb7ec9afb | ||
|
540b575e54 | ||
|
7e5b3c51a8 | ||
|
5d4da27842 | ||
|
20a786460c | ||
|
07b18d9527 | ||
|
adfc6c08f2 | ||
|
9a1c0fe46d | ||
|
a8f7d28c11 | ||
|
5b1fb27ca2 | ||
|
cf0b3cf80d | ||
|
0493d66daa | ||
|
f66c476187 | ||
|
9b3f1c79a6 | ||
|
5e62eb3279 | ||
|
2ccb4bfb83 | ||
|
686e011f9b | ||
|
f610bfdfb3 | ||
|
f0c6d944a8 | ||
|
ebf4603889 | ||
|
706031a641 | ||
|
25e6e4de4f | ||
|
ae604b1c70 | ||
|
0d11dee06c | ||
|
00773ae3b9 | ||
|
88fed0af0a | ||
|
31aab0bd48 | ||
|
4f40431d55 | ||
|
d1004f2919 | ||
|
7151aa4e2c | ||
|
c3d2739293 | ||
|
091955255b | ||
|
2aa68c3d4b | ||
|
f4fb008f1b | ||
|
da2594292b | ||
|
f30106ab39 | ||
|
8a684519f0 | ||
|
24417d4fd0 | ||
|
9c4dfb7f25 | ||
|
7d6c26539d | ||
|
8bdc5f6b05 | ||
|
91b5a08b11 | ||
|
c0b8eb7176 | ||
|
871d89a304 | ||
|
0933786525 | ||
|
0968549e55 | ||
|
bec5a087aa | ||
|
2528ceb8df | ||
|
f5c7d63528 | ||
|
af0a62aee9 | ||
|
8e402431b8 | ||
|
e34f5ce45a | ||
|
b401a53a21 | ||
|
0c103fc3a2 | ||
|
2e7aa144b2 | ||
|
4eec745296 | ||
|
947fd30fa2 | ||
|
52cac830ae | ||
|
808660cfbb | ||
|
9d2cf7e1ff | ||
|
5d231249c7 | ||
|
242827f7e6 | ||
|
3736f48efa | ||
|
9639b9e113 | ||
|
531be52c5b | ||
|
2e24032d1c | ||
|
cc9fa543cb | ||
|
541d07c46c | ||
|
52d3838094 | ||
|
3828a1afdb | ||
|
d288787fdc | ||
|
c6aed4bf6e | ||
|
2c26c3cdc0 | ||
|
7eda354f8f | ||
|
9b133468e4 | ||
|
f20b3a7a46 | ||
|
953e473ef0 | ||
|
abede3c010 | ||
|
f2a5221cbd | ||
|
e165bbbff6 | ||
|
3d948a1419 | ||
|
cd02cdb1ce | ||
|
1e90a74ac7 | ||
|
ae587a037a | ||
|
703414266e | ||
|
22c102917e | ||
|
970e5bd2ed | ||
|
0001dff347 | ||
|
c525acbad4 | ||
|
a50a96492f | ||
|
83d80cadb5 | ||
|
63c063933d | ||
|
b2adb4f6a6 | ||
|
59a57e0b34 | ||
|
94915bc8e4 | ||
|
80dfab3ef4 | ||
|
fd73564be2 | ||
|
3679db819a | ||
|
50adfa0053 | ||
|
a2db34ae61 | ||
|
5f29024559 | ||
|
9a77ff3bb8 | ||
|
94ac039390 | ||
|
805f5eed7f | ||
|
e4d5425a7d | ||
|
914e3b508c | ||
|
86324c6873 | ||
|
5e4c1e4357 | ||
|
896e299f8f | ||
|
c87424ae80 | ||
|
751157815e | ||
|
fc6b573f86 | ||
|
9f6ba0b19c | ||
|
175b2f8921 | ||
|
711b673e31 | ||
|
f8b25f949a | ||
|
fd6d23c513 | ||
|
55ab430cfe | ||
|
1dce163782 | ||
|
4d3d8daa37 | ||
|
efd285eb10 | ||
|
128052102d | ||
|
8f2f9da3da | ||
|
84c96287f3 | ||
|
f75124233b | ||
|
26bd9f8840 | ||
|
da8f474c64 | ||
|
5e8c1960e7 | ||
|
35d76ea56f | ||
|
a230dd104c | ||
|
31fb342ef1 | ||
|
65283a0edc | ||
|
9686431874 | ||
|
96cb014a6e | ||
|
8915e7eddf | ||
|
fd021de86d | ||
|
f5b4cc9ea7 | ||
|
8e66c97aa3 | ||
|
bd80d95d22 | ||
|
4d46864388 | ||
|
3696e126e3 | ||
|
65ee33a09f | ||
|
dce29eda19 | ||
|
81d3d591fa | ||
|
2a2dc7c57f | ||
|
2c355205d0 | ||
|
ed508d646c | ||
|
fcb99490d8 | ||
|
fd00a5e0fc | ||
|
f9d1e869b0 | ||
|
06210ab95b | ||
|
3137f78cce | ||
|
dcd59efc12 | ||
|
2b8972a35a | ||
|
f961ae578c | ||
|
0188e15a92 | ||
|
c12b73c1ff | ||
|
a60f001f2c | ||
|
04d58533cf | ||
|
ed6d89fb7e | ||
|
3b47ed2e52 | ||
|
abfc06c7d5 | ||
|
712cc2c60b | ||
|
057d5bc01f | ||
|
e36b0b8b52 | ||
|
4dd7a82e32 | ||
|
580d977aa9 | ||
|
45c67d6b57 | ||
|
0b6c8a5977 | ||
|
811cc8a668 | ||
|
f136240591 | ||
|
e0a6d15ad0 | ||
|
617abd9d90 | ||
|
c2e74cb2d4 | ||
|
db70db49a5 | ||
|
4cc6382043 | ||
|
c8d3d99224 | ||
|
645402e691 | ||
|
8ed1a18280 | ||
|
0d81db52f1 | ||
|
67398fe07e | ||
|
9b21c77485 | ||
|
94356a5773 | ||
|
2f8df725c9 | ||
|
b9e508424c | ||
|
48e211cc2d | ||
|
3578d6e624 | ||
|
8356906791 | ||
|
9e7f289a9e | ||
|
9e67329703 | ||
|
8489eaea6d | ||
|
9fb0ebd8f6 | ||
|
e03f5f632b | ||
|
b6ee7e61b8 | ||
|
202c3f28a3 | ||
|
a1a28efe49 | ||
|
0e5592a0d3 | ||
|
52efdf729b | ||
|
ef3e8ae772 | ||
|
1c1fc2ca96 | ||
|
bf3bd5c1c7 | ||
|
9cabfb14a5 | ||
|
def2034fa0 | ||
|
b5a7a11920 | ||
|
6155a70c04 | ||
|
846ad24bf3 | ||
|
9ab0637690 | ||
|
fe331a5170 | ||
|
f4969e11b9 | ||
|
312f5447b8 | ||
|
879fa4c926 | ||
|
5e0c879654 | ||
|
9049ca25aa | ||
|
76ccc5e6b2 | ||
|
8aa733158c | ||
|
0eef3b3251 | ||
|
965ba4edaa | ||
|
7960c0a419 | ||
|
99a3fa64ec | ||
|
a7316d516c |
@@ -1,34 +0,0 @@
|
||||
# Compiling and Running
|
||||
|
||||
## Prerequisites
|
||||
|
||||
The following products must be installed:
|
||||
|
||||
* Java Development Kit 6 or higher (http://java.sun.com/javase/downloads/index.jsp)
|
||||
* Maven 3.x or higher (http://maven.apache.org/)
|
||||
|
||||
## Compiling
|
||||
|
||||
WiseMapping uses Maven as packaging and project management. The project is composed of 4 maven sub-modules:
|
||||
|
||||
* core-js: Utilities JavaScript libraries
|
||||
* web2d: JavaScript 2D VML/SVG abstraction library used by the mind map editor
|
||||
* mindplot: JavaScript mind map designer core
|
||||
* wise-editor: Mindmap Editor standalone distribution
|
||||
* wise-webapp: J2EE web application
|
||||
|
||||
Full compilation of the project can be done executing within <project-dir>:
|
||||
|
||||
`mvn package`
|
||||
|
||||
Once this command is execute, the file <project-dir>/wise-webapp/target/wisemapping*.war will be generated.
|
||||
|
||||
## Testing
|
||||
The previously generated war can be deployed locally executing within the directory <project-dir>/wise-webapp the following command:
|
||||
|
||||
`mvn jetty:run-war`
|
||||
|
||||
This will start the application on the URL: http://localhost:8080/wise-webapp/. Additionally, a file based database is automatically populated with a test user.
|
||||
|
||||
User: test@wisemapping.org
|
||||
Password: test
|
22
Home.textile
22
Home.textile
@@ -1,22 +0,0 @@
|
||||
h1. What is WiseMapping Open Source?
|
||||
|
||||
WiseMapping is a free web based mindmapping application. The goal of this project is to provide a high quality product that can be deployed by educational and academic institutions, private and public companies and anyone who needs to have a mindmapping application. WiseMapping is based on the same code source supporting WiseMapping.com.
|
||||
|
||||
|
||||
h1. Why Open Source ?
|
||||
|
||||
In the last years, we have received hundred of mails from different persons asking for:
|
||||
Integrating wisemapping.com with their sites
|
||||
Deploying a private instance of wisemapping.com
|
||||
Participating in the development of the site
|
||||
All this make us wonder "Why if we share our product to all this people and invite them to participate with us in this journey ?" .
|
||||
|
||||
h1. Who are we ?
|
||||
|
||||
We’re a couple of friends working on an idea: “Create the best on-line collaborative mind mapping tool ever created”. This has been our idea since the first day we started.
|
||||
|
||||
h1. [[Documentation]]
|
||||
|
||||
h1. [[Compiling and Running]]
|
||||
|
||||
h1. [[FAQ]]
|
108
README.md
108
README.md
@@ -1,6 +1,4 @@
|
||||
# WiseMapping: a Web based mindmapping application
|
||||
|
||||
## Project Information
|
||||
# Project Information
|
||||
|
||||
The goal of this project is to provide a high quality product that can be deployed by educational and academic institutions, private and public companies and anyone who needs to have a mindmapping application. WiseMapping is based on the same code source supporting WiseMapping.com. More info: www.wisemapping.org
|
||||
|
||||
@@ -9,116 +7,66 @@ The goal of this project is to provide a high quality product that can be deploy
|
||||
### Prerequisites
|
||||
|
||||
The following products must be installed:
|
||||
* Java Development Kit 6 or higher (http://java.sun.com/javase/downloads/index.jsp)
|
||||
* Maven 2.2.1 or higher (http://maven.apache.org/)
|
||||
|
||||
* Java Development Kit 7 or higher ([http://www.oracle.com/technetwork/java/javase/downloads/index.html])
|
||||
* Maven 3.x or higher ([http://maven.apache.org/])
|
||||
|
||||
### Compiling
|
||||
|
||||
WiseMapping uses Maven as packaging and project management. The project is composed of 4 maven sub-modules:
|
||||
* core-js: Utilities JavaScript libraries
|
||||
WiseMapping uses Maven as packaging and project management. It's composed of 5 maven sub-modules:
|
||||
|
||||
* core-js: Utilities JavaScript classes
|
||||
* web2d: JavaScript 2D SVG abstraction library used by the mind map editor
|
||||
* mindplot: JavaScript mind map designer core
|
||||
* mindplot: JavaScript mindmap designer core
|
||||
* wise-editor: Mindmap Editor standalone distribution
|
||||
* wise-webapp: J2EE web application
|
||||
|
||||
Full compilation of the project can be done executing within <project-dir>:
|
||||
The full compilation of the project can be performed executing within <project-dir>:
|
||||
|
||||
`mvn install`
|
||||
`mvn package`
|
||||
|
||||
Once this command is execute, the file <project-dir>/wise-webapp/target/wisemapping.war will be generated.
|
||||
Once this command is execute, the file <project-dir>/wise-webapp/target/wisemapping*.war will be generated.
|
||||
|
||||
### Testing
|
||||
|
||||
The previously generated war can be deployed locally executing within the directory <project-dir>/wise-webapp the following command:
|
||||
|
||||
`mvn jetty:run-war`
|
||||
`cd wise-webapp;mvn jetty:run-war`
|
||||
|
||||
This will start the application on the URL: http://localhost:8080/wise-webapp/. Additionally, a file based database is automatically populated with a test user.
|
||||
This will start the application on the URL: [http://localhost:8080/wise-webapp/]. Additionally, a file based database is automatically populated with a test user.
|
||||
|
||||
User: test@wisemapping.org
|
||||
|
||||
Password: test
|
||||
|
||||
## Running the JS only version
|
||||
|
||||
Start by creating the .zip file:
|
||||
Start by creating the .zip file:
|
||||
|
||||
`mvn assembly:assembly -Dmaven.test.skip=true`
|
||||
|
||||
To test the javascript frontend you then do:
|
||||
|
||||
unzip target/wisemapping-3.0-SNAPSHOT-editor.zip
|
||||
cd target/wisemapping-3.0-SNAPSHOT-editor
|
||||
ruby -rwebrick -e 'WEBrick::HTTPServer.new(:Port=>8000,:DocumentRoot=>".").start'
|
||||
ruby -rwebrick -e 'WEBrick::HTTPServer.new(:Port=>8000,:DocumentRoot=>".").start'
|
||||
|
||||
Now open a browser using the URL http://localhost:8000/
|
||||
Now open a browser using the URL http://localhost:8000/wise-editor/src/main/webapp/
|
||||
|
||||
### Attaching drag and drop events.
|
||||
## Members
|
||||
|
||||
1) Support for dragging TextNodes:
|
||||
### Founders
|
||||
|
||||
The following code is an example of how to add attach to the div dragImageNode the support for node dragging.
|
||||
|
||||
$("dragTextNode").addEvent('mousedown', function(event) {
|
||||
event.preventDefault();
|
||||
* Pablo Luna <pveiga@wisemapping.com>
|
||||
* Paulo Veiga <pablo@wisemapping.com>
|
||||
|
||||
// Create a image node ...
|
||||
var mindmap = designer.getMindmap();
|
||||
var node = mindmap.createNode();
|
||||
node.setText("Node Text !!!!");
|
||||
node.setMetadata("{'media':'test'}");
|
||||
node.setShapeType(mindplot.model.TopicShape.RECTANGLE);
|
||||
### Individual Controbutors
|
||||
|
||||
// Add link ...
|
||||
var link = node.createFeature(mindplot.TopicFeature.Link.id, {url:"http://www.wisemapping.com"});
|
||||
node.addFeature(link);
|
||||
* Ezequiel Bergamaschi <ezequielbergamaschi@gmail.com>
|
||||
* Claudio Barril <claudiobarril@gmail.com>
|
||||
|
||||
// Add Note ...
|
||||
var note = node.createFeature(mindplot.TopicFeature.Note.id, {text:"This is a note"});
|
||||
node.addFeature(note);
|
||||
### Past Individual Contributors
|
||||
|
||||
designer.addDraggedNode(event, node);
|
||||
});
|
||||
|
||||
In the example, a new node is created with text "Node Text !!!!" and a note and a link associated to it when the user drop the node. Something to pay attention is the node.setMetadata("{}"), this delegated will be persisted during the serialization. Here you can store all the data you need.
|
||||
|
||||
2) Support for dragging Images: Similar to the point 1,drag support is registered to the div dragImageNode.
|
||||
|
||||
$("dragImageNode").addEvent('mousedown', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// Create a image node ...
|
||||
var mindmap = designer.getMindmap();
|
||||
var node = mindmap.createNode();
|
||||
node.setImageSize(80, 43);
|
||||
node.setMetadata("{'media':'video,'url':'http://www.youtube.com/watch?v=P3FrXftyuzw&feature=g-vrec&context=G2b4ab69RVAAAAAAAAAA'}");
|
||||
node.setImageUrl("images/logo-small.png");
|
||||
node.setShapeType(mindplot.model.TopicShape.IMAGE);
|
||||
|
||||
designer.addDraggedNode(event, node);
|
||||
});
|
||||
|
||||
The node.setShapeType(mindplot.model.TopicShape.IMAGE) defines a image node. This makes mandatory the set of setImageUrl and setImageSize properties in the node.
|
||||
|
||||
3) An event registration mechanism for Image nodes edit events: The next snipped show how to register a custom edition handler.
|
||||
|
||||
designer.addEvent("editnode", function(event) {
|
||||
var node = event.model;
|
||||
|
||||
alert("Node Id:" + node.getId());
|
||||
alert("Node Metadata:" + node.getMetadata());
|
||||
alert("Is Read Only:" + event.readOnly);
|
||||
} });
|
||||
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
* Pablo Luna
|
||||
* Paulo Veiga
|
||||
* Ignacio Manzano
|
||||
* Nicolas Damonte
|
||||
|
||||
|
||||
## License
|
||||
|
||||
The source code is Licensed under the WiseMapping Open License, Version 1.0 (the “License”);
|
||||
|
||||
You may obtain a copy of the License at: http://www.wisemapping.org/license
|
||||
You may obtain a copy of the License at: [https://wisemapping.atlassian.net/wiki/display/WS/License]
|
||||
|
47
config/database/hsql/apopulate-schemas.sql
Normal file
47
config/database/hsql/apopulate-schemas.sql
Normal file
@@ -0,0 +1,47 @@
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (2, 'Admin', 'User', 'admin', 1237, CURDATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (3, 'homer@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (3, 'Homer', 'Simpson', 'homer', 1237, CURDATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (4, 'marge@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (4, 'Marge', 'Bouvier', 'marge', 1237, CURDATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (5, 'bart@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (5, 'Bart', 'Simpson', 'bart', 1237, CURDATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (6, 'lisa@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (6, 'Lisa', 'Simpson', 'lisa', 1237, CURDATE(), 1, 'D');
|
||||
|
||||
INSERT INTO MINDMAP (id, title, xml, description, public, creation_date, edition_date, creator_id, tags, last_editor_id)
|
||||
VALUES (1, 'Welcome Test', x'504B0304140008080800ED036F4400000000000000000000000007000000636F6E74656E74AD57DD8EDA3814BEEF53B8E9452F360CF985B0C0542C43D5B960355259ED45558D9CC464AC3176E43843A76FB3CFD0479817DB1393F0938442871A09417EFC7DE7F83BDFB1472B9C228E57646CE4194E88819E88CCA8E06343619E08E3FA0D82315222A5118A08571233B827737854916F6A6C4CC54A20F822FC3B96E88381683C366C032D05579FD53383A987C377448FE17068A030990A26E4D8786761F8042586C6A191E07A828C26FCFE81B0D4E8EEDDDED048454695E668F76DB3E3590612322630A35591BA93F02489714C321413B478F9012F8AAC24D760E7E95163E7F856485C638B5E8E506EE90796EF0FF6E8B78410611E11B61F446B20CEC0373B03671B885D053249244920AF7F0B854BFAAE5D83D43372A1C8F5E8ED97E9CD6431F932CB9440107BCEB17E15BDFDFAF57AD4D50F1D32E96A2A27E8B90EE4D9B68366A22B7E33CE70048018DDE184729CA17F49B8E1DB3F9EED963818E58F289720B207A5D23FBBDDF57A7D9508913072158915E03EA7855A6533A9E785625B108AB78DC4AD2299E74CD194410C903CCA8416CEC71C244F1A1A28865E0AA72D843AA46739ED2AD5422A17D5AD6769B9B4601459EA9E8B61BB4D0195C194287E0D65180A160FA9C28C46E70259A6BD13AA53E12C687A90B20D5EEF006F4157241BF6862D419DB97810A5BB53A157817F14720592BBA14B220B7408377BC0854E24891406ED6CF804AD2B794C9DA78B36303BBD5E3317B7600155CA3DB74D225B935842D5DCAF41F32713D2BC50E7D3B18343423B11C434A22F3F38FA27C33C0667606841228663B121E938C76BB4E17F5B83C4716C2FFB47FDEF01CBF8FE913C87027E9C4C66C7F582C26306FB65A2B9F57EC93F8A80773E38174F4411702725775D00BA15473386A6B9CC84D4C6A8DF7A85203BAE0FCE18047B296F53D8B653D2A24B8249CEB248D2904A704B09FF62A84009660DABF24D556BE2FD56B102D3BED9290CA06E7C7792141DBF303E281D89D28252E5EB05A74DDAD0270245C6C5513374EAE6F24BECFA60CBBD165F29D96134559275E744E13FDA697ECEC38AEA718ACD767E614EA16DB7F8D1FCE5BF0C7DB8429FA0BA5104DEFA882847EF2711B4C8C22569614B227B8FB00419E0CD82FBD6C15EE764B9DBAE670E5A32063283DC285A76969F94CF5E2DC35E295C2EEBB5DC703CDF357B7EB391DDF22750309AAC68228A3D00CC8A4321714961F07A61384ECF6CDB17CD562109410584A3BF9848AA9D9D750112D4C7BEFDEC149887B08218A91CCD715AEDC2ECF3D47E8E6BF703B36F37EB529BB6D87AF65CE459D9C65EE5D6F120F4EDE0E76EBDD218A765EFF44DC7A91BB577814FDF88901134D595024BBAE73AE99E416A77BCD0AF3DDBF4FBFB7AD2FB94DF475DF39D4A52D02DFBCD858C21D98765AECDE202C61329710607B95D43D4A4EF00B3101CBEB425BA3DD821BA4D418390F5CE43081656D6E0F48F56CBE11F49182E00B2079AA24C468BE2DE6DB97781639EDA5D30101C22C8429F13009CF0182216EBEAD89A819454796589D946F0A32E9C84AFDFFC0F504B070890C15C185C040000100F0000504B01021400140008080800ED036F4490C15C185C040000100F0000070000000000000000000000000000000000636F6E74656E74504B0506000000000100010035000000910400000000', '', 0, now(), now(), 1, NULL, 1);
|
||||
INSERT INTO COLLABORATION_PROPERTIES (id, starred, mindmap_properties) VALUES (1, 0, '{zoom:0.8}');
|
||||
INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_id) VALUES (1, 1, 1, 1, 0);
|
||||
|
||||
INSERT INTO COLLABORATION_PROPERTIES (id, starred, mindmap_properties) VALUES (2, 1, '{zoom:0.8}');
|
||||
INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_id) VALUES (2, 2, 2, 1, 1);
|
||||
|
||||
INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, iconName) VALUES (1, 'test label', 1, NULL, '#ff0000', 'glyphicon glyphicon-tag');
|
||||
INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (1,1);
|
||||
|
||||
INSERT INTO MINDMAP (id, title, xml, description, public, creation_date, edition_date, creator_id, tags, last_editor_id)
|
||||
VALUES (2, 'Welcome Admin', x'504B0304140008080800ED036F4400000000000000000000000007000000636F6E74656E74AD57DD8EDA3814BEEF53B8E9452F360CF985B0C0542C43D5B960355259ED45558D9CC464AC3176E43843A76FB3CFD0479817DB1393F0938442871A09417EFC7DE7F83BDFB1472B9C228E57646CE4194E88819E88CCA8E06343619E08E3FA0D82315222A5118A08571233B827737854916F6A6C4CC54A20F822FC3B96E88381683C366C032D05579FD53383A987C377448FE17068A030990A26E4D8786761F8042586C6A191E07A828C26FCFE81B0D4E8EEDDDED048454695E668F76DB3E3590612322630A35591BA93F02489714C321413B478F9012F8AAC24D760E7E95163E7F856485C638B5E8E506EE90796EF0FF6E8B78410611E11B61F446B20CEC0373B03671B885D053249244920AF7F0B854BFAAE5D83D43372A1C8F5E8ED97E9CD6431F932CB9440107BCEB17E15BDFDFAF57AD4D50F1D32E96A2A27E8B90EE4D9B68366A22B7E33CE70048018DDE184729CA17F49B8E1DB3F9EED963818E58F289720B207A5D23FBBDDF57A7D9508913072158915E03EA7855A6533A9E785625B108AB78DC4AD2299E74CD194410C903CCA8416CEC71C244F1A1A28865E0AA72D843AA46739ED2AD5422A17D5AD6769B9B4601459EA9E8B61BB4D0195C194287E0D65180A160FA9C28C46E70259A6BD13AA53E12C687A90B20D5EEF006F4157241BF6862D419DB97810A5BB53A157817F14720592BBA14B220B7408377BC0854E24891406ED6CF804AD2B794C9DA78B36303BBD5E3317B7600155CA3DB74D225B935842D5DCAF41F32713D2BC50E7D3B18343423B11C434A22F3F38FA27C33C0667606841228663B121E938C76BB4E17F5B83C4716C2FFB47FDEF01CBF8FE913C87027E9C4C66C7F582C26306FB65A2B9F57EC93F8A80773E38174F4411702725775D00BA15473386A6B9CC84D4C6A8DF7A85203BAE0FCE18047B296F53D8B653D2A24B8249CEB248D2904A704B09FF62A84009660DABF24D556BE2FD56B102D3BED9290CA06E7C7792141DBF303E281D89D28252E5EB05A74DDAD0270245C6C5513374EAE6F24BECFA60CBBD165F29D96134559275E744E13FDA697ECEC38AEA718ACD767E614EA16DB7F8D1FCE5BF0C7DB8429FA0BA5104DEFA882847EF2711B4C8C22569614B227B8FB00419E0CD82FBD6C15EE764B9DBAE670E5A32063283DC285A76969F94CF5E2DC35E295C2EEBB5DC703CDF357B7EB391DDF22750309AAC68228A3D00CC8A4321714961F07A61384ECF6CDB17CD562109410584A3BF9848AA9D9D750112D4C7BEFDEC149887B08218A91CCD715AEDC2ECF3D47E8E6BF703B36F37EB529BB6D87AF65CE459D9C65EE5D6F120F4EDE0E76EBDD218A765EFF44DC7A91BB577814FDF88901134D595024BBAE73AE99E416A77BCD0AF3DDBF4FBFB7AD2FB94DF475DF39D4A52D02DFBCD858C21D98765AECDE202C61329710607B95D43D4A4EF00B3101CBEB425BA3DD821BA4D418390F5CE43081656D6E0F48F56CBE11F49182E00B2079AA24C468BE2DE6DB97781639EDA5D30101C22C8429F13009CF0182216EBEAD89A819454796589D946F0A32E9C84AFDFFC0F504B070890C15C185C040000100F0000504B01021400140008080800ED036F4490C15C185C040000100F0000070000000000000000000000000000000000636F6E74656E74504B0506000000000100010035000000910400000000', 'This is a short description', 0, now(), now(), 2, NULL, 2);
|
||||
INSERT INTO COLLABORATION_PROPERTIES (id, starred, mindmap_properties) VALUES (3, 1, '{zoom:0.8}');
|
||||
INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_id) VALUES (3, 2, 3, 2, 0);
|
||||
|
||||
INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, iconName) VALUES (2, 'admin label', 2, NULL, '#0000ff', 'glyphicon glyphicon-star');
|
||||
INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (2,2);
|
||||
INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, iconName) VALUES (3, 'mindmap shared', 2, NULL, '#00ff00', 'glyphicon glyphicon-share');
|
||||
INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (3,1);
|
||||
|
||||
COMMIT;
|
||||
SHUTDOWN;
|
96
config/database/hsql/create-schemas.sql
Normal file
96
config/database/hsql/create-schemas.sql
Normal file
@@ -0,0 +1,96 @@
|
||||
CREATE TABLE COLLABORATOR (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
creation_date DATE
|
||||
);
|
||||
|
||||
CREATE TABLE USER (
|
||||
colaborator_id INTEGER NOT NULL IDENTITY,
|
||||
authentication_type CHAR(1) NOT NULL,
|
||||
authenticator_uri VARCHAR(255) NULL,
|
||||
firstname VARCHAR(255) NOT NULL,
|
||||
lastname VARCHAR(255) NOT NULL,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
activation_code BIGINT NOT NULL,
|
||||
activation_date DATE,
|
||||
allow_send_email CHAR(1) NOT NULL,
|
||||
locale VARCHAR(5),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255) NOT NULL,
|
||||
xml LONGVARBINARY NOT NULL,
|
||||
public BOOLEAN NOT NULL,
|
||||
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)
|
||||
);
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY IDENTITY,
|
||||
title VARCHAR(30),
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
iconName VARCHAR(50) NOT NULL
|
||||
--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_HISTORY (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
xml LONGVARBINARY NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date DATETIME,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
);
|
||||
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
starred BOOLEAN NOT NULL,
|
||||
mindmap_properties VARCHAR(512)
|
||||
);
|
||||
|
||||
CREATE TABLE COLLABORATION (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
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,
|
||||
login_date DATE,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
COMMIT;
|
11
config/database/hsql/drop-schemas.sql
Normal file
11
config/database/hsql/drop-schemas.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
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;
|
||||
DROP TABLE IF EXISTS R_LABEL_MINDMAP;
|
||||
DROP TABLE IF EXISTS LABEL;
|
||||
DROP TABLE IF EXISTS MINDMAP;
|
||||
DROP TABLE IF EXISTS USER;
|
||||
DROP TABLE IF EXISTS COLLABORATOR;
|
||||
COMMIT;
|
50
config/database/mysql/apopulate-schemas.sql
Normal file
50
config/database/mysql/apopulate-schemas.sql
Normal file
@@ -0,0 +1,50 @@
|
||||
#
|
||||
# Command: mysql -u root -p < apopulate_schemas.sql
|
||||
#
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (2, 'Admin', 'User', 'admin', 1237, CURRENT_DATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (3, 'homer@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (3, 'Homer', 'Simpson', 'homer', 1237, CURRENT_DATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (4, 'marge@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (4, 'Marge', 'Bouvier', 'marge', 1237, CURRENT_DATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (5, 'bart@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (5, 'Bart', 'Simpson', 'bart', 1237, CURRENT_DATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (6, 'lisa@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (6, 'Lisa', 'Simpson', 'lisa', 1237, CURRENT_DATE(), 1, 'D');
|
||||
|
||||
INSERT INTO MINDMAP (id, title, xml, description, public, creation_date, edition_date, creator_id, tags, last_editor_id)
|
||||
VALUES (1, 'Welcome Test', 0x504B0304140008080800ED036F4400000000000000000000000007000000636F6E74656E74AD57DD8EDA3814BEEF53B8E9452F360CF985B0C0542C43D5B960355259ED45558D9CC464AC3176E43843A76FB3CFD0479817DB1393F0938442871A09417EFC7DE7F83BDFB1472B9C228E57646CE4194E88819E88CCA8E06343619E08E3FA0D82315222A5118A08571233B827737854916F6A6C4CC54A20F822FC3B96E88381683C366C032D05579FD53383A987C377448FE17068A030990A26E4D8786761F8042586C6A191E07A828C26FCFE81B0D4E8EEDDDED048454695E668F76DB3E3590612322630A35591BA93F02489714C321413B478F9012F8AAC24D760E7E95163E7F856485C638B5E8E506EE90796EF0FF6E8B78410611E11B61F446B20CEC0373B03671B885D053249244920AF7F0B854BFAAE5D83D43372A1C8F5E8ED97E9CD6431F932CB9440107BCEB17E15BDFDFAF57AD4D50F1D32E96A2A27E8B90EE4D9B68366A22B7E33CE70048018DDE184729CA17F49B8E1DB3F9EED963818E58F289720B207A5D23FBBDDF57A7D9508913072158915E03EA7855A6533A9E785625B108AB78DC4AD2299E74CD194410C903CCA8416CEC71C244F1A1A28865E0AA72D843AA46739ED2AD5422A17D5AD6769B9B4601459EA9E8B61BB4D0195C194287E0D65180A160FA9C28C46E70259A6BD13AA53E12C687A90B20D5EEF006F4157241BF6862D419DB97810A5BB53A157817F14720592BBA14B220B7408377BC0854E24891406ED6CF804AD2B794C9DA78B36303BBD5E3317B7600155CA3DB74D225B935842D5DCAF41F32713D2BC50E7D3B18343423B11C434A22F3F38FA27C33C0667606841228663B121E938C76BB4E17F5B83C4716C2FFB47FDEF01CBF8FE913C87027E9C4C66C7F582C26306FB65A2B9F57EC93F8A80773E38174F4411702725775D00BA15473386A6B9CC84D4C6A8DF7A85203BAE0FCE18047B296F53D8B653D2A24B8249CEB248D2904A704B09FF62A84009660DABF24D556BE2FD56B102D3BED9290CA06E7C7792141DBF303E281D89D28252E5EB05A74DDAD0270245C6C5513374EAE6F24BECFA60CBBD165F29D96134559275E744E13FDA697ECEC38AEA718ACD767E614EA16DB7F8D1FCE5BF0C7DB8429FA0BA5104DEFA882847EF2711B4C8C22569614B227B8FB00419E0CD82FBD6C15EE764B9DBAE670E5A32063283DC285A76969F94CF5E2DC35E295C2EEBB5DC703CDF357B7EB391DDF22750309AAC68228A3D00CC8A4321714961F07A61384ECF6CDB17CD562109410584A3BF9848AA9D9D750112D4C7BEFDEC149887B08218A91CCD715AEDC2ECF3D47E8E6BF703B36F37EB529BB6D87AF65CE459D9C65EE5D6F120F4EDE0E76EBDD218A765EFF44DC7A91BB577814FDF88901134D595024BBAE73AE99E416A77BCD0AF3DDBF4FBFB7AD2FB94DF475DF39D4A52D02DFBCD858C21D98765AECDE202C61329710607B95D43D4A4EF00B3101CBEB425BA3DD821BA4D418390F5CE43081656D6E0F48F56CBE11F49182E00B2079AA24C468BE2DE6DB97781639EDA5D30101C22C8429F13009CF0182216EBEAD89A819454796589D946F0A32E9C84AFDFFC0F504B070890C15C185C040000100F0000504B01021400140008080800ED036F4490C15C185C040000100F0000070000000000000000000000000000000000636F6E74656E74504B0506000000000100010035000000910400000000, '', 0, now(), now(), 1, NULL, 1);
|
||||
INSERT INTO COLLABORATION_PROPERTIES (id, starred, mindmap_properties) VALUES (1, 0, '{zoom:0.8}');
|
||||
INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_id) VALUES (1, 1, 1, 1, 0);
|
||||
|
||||
INSERT INTO COLLABORATION_PROPERTIES (id, starred, mindmap_properties) VALUES (2, 1, '{zoom:0.8}');
|
||||
INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_id) VALUES (2, 2, 2, 1, 1);
|
||||
|
||||
INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, iconName) VALUES (1, 'test label', 1, NULL, '#ff0000', 'glyphicon glyphicon-tag');
|
||||
INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (1,1);
|
||||
|
||||
INSERT INTO MINDMAP (id, title, xml, description, public, creation_date, edition_date, creator_id, tags, last_editor_id)
|
||||
VALUES (2, 'Welcome Admin', 0x504B0304140008080800ED036F4400000000000000000000000007000000636F6E74656E74AD57DD8EDA3814BEEF53B8E9452F360CF985B0C0542C43D5B960355259ED45558D9CC464AC3176E43843A76FB3CFD0479817DB1393F0938442871A09417EFC7DE7F83BDFB1472B9C228E57646CE4194E88819E88CCA8E06343619E08E3FA0D82315222A5118A08571233B827737854916F6A6C4CC54A20F822FC3B96E88381683C366C032D05579FD53383A987C377448FE17068A030990A26E4D8786761F8042586C6A191E07A828C26FCFE81B0D4E8EEDDDED048454695E668F76DB3E3590612322630A35591BA93F02489714C321413B478F9012F8AAC24D760E7E95163E7F856485C638B5E8E506EE90796EF0FF6E8B78410611E11B61F446B20CEC0373B03671B885D053249244920AF7F0B854BFAAE5D83D43372A1C8F5E8ED97E9CD6431F932CB9440107BCEB17E15BDFDFAF57AD4D50F1D32E96A2A27E8B90EE4D9B68366A22B7E33CE70048018DDE184729CA17F49B8E1DB3F9EED963818E58F289720B207A5D23FBBDDF57A7D9508913072158915E03EA7855A6533A9E785625B108AB78DC4AD2299E74CD194410C903CCA8416CEC71C244F1A1A28865E0AA72D843AA46739ED2AD5422A17D5AD6769B9B4601459EA9E8B61BB4D0195C194287E0D65180A160FA9C28C46E70259A6BD13AA53E12C687A90B20D5EEF006F4157241BF6862D419DB97810A5BB53A157817F14720592BBA14B220B7408377BC0854E24891406ED6CF804AD2B794C9DA78B36303BBD5E3317B7600155CA3DB74D225B935842D5DCAF41F32713D2BC50E7D3B18343423B11C434A22F3F38FA27C33C0667606841228663B121E938C76BB4E17F5B83C4716C2FFB47FDEF01CBF8FE913C87027E9C4C66C7F582C26306FB65A2B9F57EC93F8A80773E38174F4411702725775D00BA15473386A6B9CC84D4C6A8DF7A85203BAE0FCE18047B296F53D8B653D2A24B8249CEB248D2904A704B09FF62A84009660DABF24D556BE2FD56B102D3BED9290CA06E7C7792141DBF303E281D89D28252E5EB05A74DDAD0270245C6C5513374EAE6F24BECFA60CBBD165F29D96134559275E744E13FDA697ECEC38AEA718ACD767E614EA16DB7F8D1FCE5BF0C7DB8429FA0BA5104DEFA882847EF2711B4C8C22569614B227B8FB00419E0CD82FBD6C15EE764B9DBAE670E5A32063283DC285A76969F94CF5E2DC35E295C2EEBB5DC703CDF357B7EB391DDF22750309AAC68228A3D00CC8A4321714961F07A61384ECF6CDB17CD562109410584A3BF9848AA9D9D750112D4C7BEFDEC149887B08218A91CCD715AEDC2ECF3D47E8E6BF703B36F37EB529BB6D87AF65CE459D9C65EE5D6F120F4EDE0E76EBDD218A765EFF44DC7A91BB577814FDF88901134D595024BBAE73AE99E416A77BCD0AF3DDBF4FBFB7AD2FB94DF475DF39D4A52D02DFBCD858C21D98765AECDE202C61329710607B95D43D4A4EF00B3101CBEB425BA3DD821BA4D418390F5CE43081656D6E0F48F56CBE11F49182E00B2079AA24C468BE2DE6DB97781639EDA5D30101C22C8429F13009CF0182216EBEAD89A819454796589D946F0A32E9C84AFDFFC0F504B070890C15C185C040000100F0000504B01021400140008080800ED036F4490C15C185C040000100F0000070000000000000000000000000000000000636F6E74656E74504B0506000000000100010035000000910400000000, 'This is a short description', 0, now(), now(), 2, NULL, 2);
|
||||
INSERT INTO COLLABORATION_PROPERTIES (id, starred, mindmap_properties) VALUES (3, 1, '{zoom:0.8}');
|
||||
INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_id) VALUES (3, 2, 3, 2, 0);
|
||||
|
||||
INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, iconName) VALUES (2, 'admin label', 2, NULL, '#0000ff', 'glyphicon glyphicon-star');
|
||||
INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (2,2);
|
||||
INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, iconName) VALUES (3, 'mindmap shared', 2, NULL, '#00ff00', 'glyphicon glyphicon-share');
|
||||
INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (3,1);
|
||||
|
||||
COMMIT;
|
10
config/database/mysql/create-database.sql
Normal file
10
config/database/mysql/create-database.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# Command: mysql -u root -p < create_database.sql
|
||||
#
|
||||
DROP DATABASE IF EXISTS wisemapping;
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS wisemapping
|
||||
CHARACTER SET = 'utf8'
|
||||
COLLATE = 'utf8_unicode_ci';
|
||||
GRANT ALL ON wisemapping.* TO 'wisemapping'@'localhost';
|
||||
SET PASSWORD FOR 'wisemapping'@'localhost' = PASSWORD('password');
|
137
config/database/mysql/create-schemas.sql
Normal file
137
config/database/mysql/create-schemas.sql
Normal file
@@ -0,0 +1,137 @@
|
||||
#
|
||||
# Command: mysql -u root -p < create_schemas.sql
|
||||
#
|
||||
|
||||
USE wisemapping;
|
||||
|
||||
CREATE TABLE COLLABORATOR (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
email VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL UNIQUE,
|
||||
creation_date DATE
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE USER (
|
||||
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
authentication_type CHAR(1)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
authenticator_uri VARCHAR(255)
|
||||
CHARACTER SET utf8,
|
||||
firstname VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
lastname VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
password VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
activation_code BIGINT(20) NOT NULL,
|
||||
activation_date DATE,
|
||||
allow_send_email CHAR(1) CHARACTER SET utf8 NOT NULL DEFAULT 0,
|
||||
locale VARCHAR(5),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
description VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
xml MEDIUMBLOB NOT NULL,
|
||||
public BOOL NOT NULL DEFAULT 0,
|
||||
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
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
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,
|
||||
iconName VARCHAR(50) 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;
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY
|
||||
(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
xml MEDIUMBLOB NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date DATETIME,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
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;
|
||||
|
||||
CREATE TABLE COLLABORATION (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION,
|
||||
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
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
login_date DATE,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
COMMIT;
|
11
config/database/mysql/drop-schemas.sql
Normal file
11
config/database/mysql/drop-schemas.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
DROP TABLE IF EXISTS TAG;
|
||||
DROP TABLE IF EXISTS ACCESS_AUDITORY;
|
||||
DROP TABLE IF EXISTS COLLABORATION;
|
||||
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
|
||||
DROP TABLE IF EXISTS MINDMAP_HISTORY;
|
||||
DROP TABLE IF EXISTS LABEL;
|
||||
DROP TABLE IF EXISTS MINDMAP;
|
||||
DROP TABLE IF EXISTS R_LABEL_MINDMAP
|
||||
DROP TABLE IF EXISTS USER;
|
||||
DROP TABLE IF EXISTS COLLABORATOR;
|
||||
COMMIT;
|
57
config/database/mysql/v2.0-to-v3.0.sql
Normal file
57
config/database/mysql/v2.0-to-v3.0.sql
Normal file
@@ -0,0 +1,57 @@
|
||||
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;
|
5
config/database/mysql/v3.0-to-v3.1.sql
Normal file
5
config/database/mysql/v3.0-to-v3.1.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
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`;
|
34
config/database/mysql/v3.1-to-v3.3.sql
Normal file
34
config/database/mysql/v3.1-to-v3.3.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
|
||||
|
3
config/database/postgres/create-database.sql
Normal file
3
config/database/postgres/create-database.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
CREATE DATABASE wisemapping;
|
||||
CREATE USER wisemapping WITH PASSWORD 'password';
|
||||
GRANT ALL PRIVILEGES ON DATABASE wisemapping TO wisemapping;
|
96
config/database/postgres/create-schemas.sql
Normal file
96
config/database/postgres/create-schemas.sql
Normal file
@@ -0,0 +1,96 @@
|
||||
CREATE TABLE COLLABORATOR (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
email VARCHAR(255) NOT NULL UNIQUE,
|
||||
creation_date DATE
|
||||
);
|
||||
|
||||
CREATE TABLE "user" (
|
||||
authentication_type TEXT NOT NULL,
|
||||
authenticator_uri VARCHAR(255),
|
||||
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
firstname VARCHAR(255) NOT NULL,
|
||||
lastname VARCHAR(255) NOT NULL,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
activation_code BIGINT NOT NULL,
|
||||
activation_date DATE,
|
||||
allow_send_email TEXT NOT NULL DEFAULT 0,
|
||||
locale VARCHAR(5),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
title VARCHAR(255),
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL
|
||||
--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,
|
||||
description VARCHAR(255) NOT NULL,
|
||||
xml BYTEA NOT NULL,
|
||||
public BOOL NOT NULL DEFAULT FALSE,
|
||||
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 MINDMAP_HISTORY
|
||||
(id SERIAL NOT NULL PRIMARY KEY,
|
||||
xml BYTEA NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date TIMESTAMP,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
starred BOOL NOT NULL DEFAULT FALSE,
|
||||
mindmap_properties VARCHAR(512)
|
||||
);
|
||||
|
||||
CREATE TABLE COLLABORATION (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id) ON DELETE CASCADE ON UPDATE NO ACTION,
|
||||
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,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES "user" (colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
|
||||
COMMIT;
|
@@ -1,9 +1,11 @@
|
||||
DROP TABLE TAG;
|
||||
DROP TABLE ACCESS_AUDITORY;
|
||||
DROP TABLE COLLABORATION;
|
||||
DROP TABLE COLLABORATION_PROPERTIES;
|
||||
DROP TABLE MINDMAP_HISTORY;
|
||||
DROP TABLE MINDMAP;
|
||||
DROP TABLE USER;
|
||||
DROP TABLE COLLABORATOR;
|
||||
DROP TABLE TAG;
|
||||
DROP TABLE ACCESS_AUDITORY;
|
||||
DROP TABLE COLLABORATION;
|
||||
DROP TABLE COLLABORATION_PROPERTIES;
|
||||
DROP TABLE MINDMAP_HISTORY;
|
||||
DROP TABLE R_LABEL_MINDMAP;
|
||||
DROP TABLE LABEL;
|
||||
DROP TABLE MINDMAP;
|
||||
DROP TABLE "user";
|
||||
DROP TABLE COLLABORATOR;
|
||||
COMMIT;
|
@@ -9,7 +9,7 @@
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<version>3.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<files>
|
||||
<file>
|
||||
<file>
|
||||
<source>core-js/target/classes/core.js</source>
|
||||
<outputDirectory>/js</outputDirectory>
|
||||
</file>
|
||||
@@ -14,10 +14,6 @@
|
||||
<source>mindplot/target/classes/mindplot-min.js</source>
|
||||
<outputDirectory>/js</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>mindplot/target/classes/mindplot.js</source>
|
||||
<outputDirectory>/js</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
|
@@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
WISE_VERSION=$1
|
||||
SERVER_DOWNLOAD_DIR=/var/www/wisemapping.org/stable
|
||||
|
||||
WISE_BIN_FILE_NAME=wisemapping-${WISE_VERSION}.zip
|
||||
WISE_BIN_FILE_PATH=./target/${WISE_BIN_FILE_NAME}
|
||||
|
||||
#WISE_SRC_FILE_NAME=wisemapping-${WISE_VERSION}-src.tar.gz
|
||||
#WISE_SRC_FILE_PATH=./target/${WISE_SRC_FILE_NAME}
|
||||
|
||||
#scp ${WISE_SRC_FILE_PATH} thecrow@wisemapping.com:${SERVER_DOWNLOAD_DIR}/
|
||||
scp ${WISE_BIN_FILE_PATH} thecrow@wisemapping.com:${SERVER_DOWNLOAD_DIR}
|
||||
|
||||
# It's there ?
|
||||
cd target
|
||||
wget -S http://downloads.wisemapping.org/stable/${WISE_BIN_FILE_NAME}
|
||||
#wget -S http://downloads.wisemapping.org/stable/${WISE_SRC_FILE_NAME}
|
@@ -8,7 +8,7 @@ BASE_DIR=`pwd`
|
||||
TARGET_DIR=$BASE_DIR/target
|
||||
JETTY_DIR=$TARGET_DIR/wisemapping-$WISE_VERSION
|
||||
WISE_WEBAPP_DIR=$JETTY_DIR/webapps/wisemapping
|
||||
JETTY_VERSION=8.1.8.v20121106
|
||||
JETTY_VERSION=8.1.14.v20131031
|
||||
JETTY_DIST_DIR=jetty-distribution-${JETTY_VERSION}
|
||||
JETTY_ZIP=${JETTY_DIST_DIR}.zip
|
||||
|
||||
@@ -51,7 +51,7 @@ cp $BASE_DIR/wisemapping.xml $JETTY_DIR/contexts/
|
||||
|
||||
|
||||
# Distribute scripts
|
||||
cp -r $BASE_DIR/../wise-webapp/src/test/sql $TARGET_DIR/wisemapping-$WISE_VERSION/config
|
||||
cp -r $BASE_DIR/../config/ $TARGET_DIR/wisemapping-$WISE_VERSION/config
|
||||
cp ./start.sh ${JETTY_DIR}/
|
||||
|
||||
# Store version
|
||||
|
@@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
WISE_VERSION=$1
|
||||
TMP_DIR=/tmp/wise-src/wisemapping-src
|
||||
TAR_FILE_NAME=wisemapping-${WISE_VERSION}-src.tar.gz
|
||||
OUTPUT_DIR=`pwd`"/target"
|
||||
OUTPUT_FILE=${OUTPUT_DIR}/${TAR_FILE_NAME}
|
||||
|
||||
|
||||
# Clean all.
|
||||
cd ..
|
||||
rm -rf ${TMP_DIR}/../
|
||||
mvn clean
|
||||
|
||||
# Prepare copy
|
||||
mkdir -p ${TMP_DIR}
|
||||
rsync -aCv --exclude ".git" --exclude "wisemapping.i*" --exclude "**/*/Brix*" --exclude "**/brix" --exclude "*/*.iml" --exclude "*/wisemapping.log*" --exclude "**/.DS_Store" --exclude "*.textile" --exclude "**/.gitignore" --exclude "installer" --exclude "*/target" . ${TMP_DIR}
|
||||
|
||||
# Zip file
|
||||
[ ! -e ${OUTPUT_DIR} ] && mkdir ${OUTPUT_DIR}
|
||||
rm -f ${OUTPUT_FILE}
|
||||
|
||||
cd ${TMP_DIR}/..
|
||||
tar -cvzf ${OUTPUT_FILE} .
|
||||
|
||||
echo
|
||||
echo "#################################################################"
|
||||
echo "Zip file generated on:"${OUTPUT_FILE}
|
||||
echo "#################################################################"
|
14
java.iml
14
java.iml
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
Copyright [2012] [wisemapping]
|
||||
Copyright [2014] [wisemapping]
|
||||
|
||||
Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<version>3.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@@ -193,9 +193,6 @@
|
||||
<include>commands/AddFeatureToTopicCommand.js</include>
|
||||
<include>commands/AddRelationshipCommand.js</include>
|
||||
<include>commands/MoveControlPointCommand.js</include>
|
||||
<include>collaboration/CollaborationManager.js</include>
|
||||
<include>collaboration/framework/AbstractCollaborativeFramework.js</include>
|
||||
<include>collaboration/framework/AbstractCollaborativeModelFactory.js</include>
|
||||
<include>widget/ModalDialogNotifier.js</include>
|
||||
<include>widget/ToolbarNotifier.js</include>
|
||||
<include>widget/ToolbarItem.js</include>
|
||||
@@ -233,6 +230,7 @@
|
||||
<include>MessageBundle_pt_BR.js</include>
|
||||
<include>MessageBundle_zh_CN.js</include>
|
||||
<include>MessageBundle_zh_TW.js</include>
|
||||
<include>MessageBundle_ca.js</include>
|
||||
<include>footer.js</include>
|
||||
</includes>
|
||||
</aggregation>
|
||||
|
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* Copyright [2012] [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.
|
||||
*/
|
||||
|
||||
mindplot.BrixActionDispatcher = new Class({
|
||||
Extends: mindplot.ActionDispatcher,
|
||||
initialize: function(commandContext, fireOnChange) {
|
||||
this.parent(commandContext, fireOnChange);
|
||||
this._commandContext = commandContext;
|
||||
},
|
||||
|
||||
dragTopic: function(topicId, position, order, parentTopic) {
|
||||
var framework = this._getFramework();
|
||||
var node = framework.getTopic(topicId);
|
||||
|
||||
// Set node order ...
|
||||
if (order != null) {
|
||||
node.setOrder(order);
|
||||
} else if (position != null) {
|
||||
// Set position ...
|
||||
node.setPosition(position);
|
||||
} else {
|
||||
$assert("Illegal commnand state exception.");
|
||||
}
|
||||
// Finally, connect node ...
|
||||
if ($defined(this._parentId)) {
|
||||
var parentNode = topic.findTopics([this._parentId])[0];
|
||||
node.disconnect();
|
||||
node.connect(parentNode);
|
||||
}
|
||||
},
|
||||
|
||||
changeTextToTopic : function(topicsIds, text) {
|
||||
var framework = this._getFramework();
|
||||
var topicId;
|
||||
if (!(topicsIds instanceof Array)) {
|
||||
topicId = topicsIds;
|
||||
} else {
|
||||
topicId = topicsIds[0];
|
||||
}
|
||||
var node = framework.getTopic(topicId);
|
||||
node.setText(text);
|
||||
|
||||
},
|
||||
|
||||
_getFramework:function () {
|
||||
return mindplot.collaboration.CollaborationManager.getInstance().getCollaborativeFramework();
|
||||
},
|
||||
|
||||
addTopics : function(nodeModel, parentTopicId) {
|
||||
var framework = this._getFramework();
|
||||
var cmindmap = framework.getModel();
|
||||
|
||||
var cparent = $defined(parentTopicId) ? framework.getTopic(parentTopicId) : cmindmap.getCentralTopic();
|
||||
var cnode = cmindmap.createNode(nodeModel.getType(), nodeModel.getId());
|
||||
nodeModel.copyTo(cnode);
|
||||
|
||||
cnode.connectTo(cparent);
|
||||
},
|
||||
|
||||
changeFontSizeToTopic : function(topicsIds, size) {
|
||||
topicsIds.each(function(topicId) {
|
||||
var framework = this._getFramework();
|
||||
var topic = framework.getTopic(topicId);
|
||||
topic.setFontSize(size, true);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
changeFontColorToTopic : function(topicsIds, color) {
|
||||
topicsIds.each(function(topicId) {
|
||||
var framework = this._getFramework();
|
||||
var topic = framework.getTopic(topicId);
|
||||
topic.setFontColor(color, true);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
changeFontFamilyToTopic : function(topicsIds, family) {
|
||||
topicsIds.each(function(topicId) {
|
||||
var framework = this._getFramework();
|
||||
var topic = framework.getTopic(topicId);
|
||||
topic.setFontFamily(family, true);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
changeFontStyleToTopic : function(topicsIds) {
|
||||
topicsIds.each(function(topicId) {
|
||||
var framework = this._getFramework();
|
||||
var topic = framework.getTopic(topicId);
|
||||
var style = ( topic.getFontStyle() == "italic") ? "normal" : "italic";
|
||||
topic.setFontStyle(style, true);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
changeShapeTypeToTopic : function(topicsIds, shapeType) {
|
||||
topicsIds.each(function(topicId) {
|
||||
var framework = this._getFramework();
|
||||
var topic = framework.getTopic(topicId);
|
||||
topic.setShapeType(shapeType);
|
||||
}.bind(this))
|
||||
},
|
||||
|
||||
changeFontWeightToTopic : function(topicsIds) {
|
||||
topicsIds.each(function(topicId) {
|
||||
var framework = this._getFramework();
|
||||
var topic = framework.getTopic(topicId);
|
||||
var weight = (topic.getFontWeight() == "bold") ? "normal" : "bold";
|
||||
topic.setFontWeight(weight, true);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
changeBackgroundColorToTopic : function(topicsIds, color) {
|
||||
topicsIds.each(function(topicId) {
|
||||
var framework = this._getFramework();
|
||||
var topic = framework.getTopic(topicId);
|
||||
topic.setBackgroundColor(color, true);
|
||||
}.bind(this));
|
||||
|
||||
},
|
||||
|
||||
changeBorderColorToTopic : function(topicsIds, color) {
|
||||
topicsIds.each(function(topicId) {
|
||||
var framework = this._getFramework();
|
||||
var topic = framework.getTopic(topicId);
|
||||
topic.setBorderColor(color);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
deleteEntities : function(topicsIds, relIds) {
|
||||
$assert(topicsIds, "topicsIds can not be null");
|
||||
var framework = this._getFramework();
|
||||
var mindmap = framework.getModel();
|
||||
|
||||
topicsIds.each(function(topicId) {
|
||||
var topic = framework.getTopic(topicId);
|
||||
topic.deleteNode();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@@ -33,11 +33,7 @@ mindplot.Designer = new Class({
|
||||
|
||||
// Dispatcher manager ...
|
||||
var commandContext = new mindplot.CommandContext(this);
|
||||
if (!$defined(options.collab) || options.collab == 'standalone') {
|
||||
this._actionDispatcher = new mindplot.StandaloneActionDispatcher(commandContext);
|
||||
} else {
|
||||
this._actionDispatcher = new mindplot.BrixActionDispatcher(commandContext);
|
||||
}
|
||||
this._actionDispatcher = new mindplot.StandaloneActionDispatcher(commandContext);
|
||||
|
||||
this._actionDispatcher.addEvent("modelUpdate", function (event) {
|
||||
this.fireEvent("modelUpdate", event);
|
||||
@@ -470,10 +466,52 @@ mindplot.Designer = new Class({
|
||||
|
||||
},
|
||||
|
||||
_copyNodeProps: function(sourceModel,targetModel){
|
||||
|
||||
// I don't copy the font size if the target is the source is the central topic.
|
||||
if(sourceModel.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE)
|
||||
{
|
||||
var fontSize = sourceModel.getFontSize();
|
||||
if(fontSize){
|
||||
targetModel.setFontSize(fontSize)
|
||||
}
|
||||
}
|
||||
|
||||
var fontFamily = sourceModel.getFontFamily();
|
||||
if(fontFamily){
|
||||
targetModel.setFontFamily(fontFamily)
|
||||
}
|
||||
|
||||
var fontColor = sourceModel.getFontColor();
|
||||
if(fontColor){
|
||||
targetModel.setFontColor(fontColor)
|
||||
}
|
||||
|
||||
var fontWeight = sourceModel.getFontWeight();
|
||||
if(fontWeight){
|
||||
targetModel.setFontWeight(fontWeight)
|
||||
}
|
||||
|
||||
var fontStyle = sourceModel.getFontStyle();
|
||||
if(fontStyle){
|
||||
targetModel.setFontStyle(fontStyle)
|
||||
}
|
||||
|
||||
var shape = sourceModel.getShapeType();
|
||||
if(shape){
|
||||
targetModel.setShapeType(shape)
|
||||
}
|
||||
|
||||
var borderColor = sourceModel.getBorderColor();
|
||||
if(borderColor){
|
||||
targetModel.setBorderColor(borderColor)
|
||||
}
|
||||
},
|
||||
|
||||
_createChildModel:function (topic, mousePos) {
|
||||
// Create a new node ...
|
||||
var model = topic.getModel();
|
||||
var mindmap = model.getMindmap();
|
||||
var parentModel = topic.getModel();
|
||||
var mindmap = parentModel.getMindmap();
|
||||
var childModel = mindmap.createNode();
|
||||
|
||||
// Create a new node ...
|
||||
@@ -484,6 +522,8 @@ mindplot.Designer = new Class({
|
||||
var position = result.position;
|
||||
childModel.setPosition(position.x, position.y);
|
||||
|
||||
this._copyNodeProps(parentModel,childModel);
|
||||
|
||||
return childModel;
|
||||
},
|
||||
|
||||
@@ -548,8 +588,11 @@ mindplot.Designer = new Class({
|
||||
// Create a new node ...
|
||||
var order = topic.getOrder() + 1;
|
||||
result.setOrder(order);
|
||||
result.setPosition(10, 10); // Set a dummy pisition ...
|
||||
result.setPosition(10, 10); // Set a dummy position ...
|
||||
}
|
||||
|
||||
this._copyNodeProps(model,result);
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
|
@@ -102,7 +102,7 @@ mindplot.RESTPersistenceManager = new Class({
|
||||
persistence.onSave = false;
|
||||
},
|
||||
|
||||
headers:{"Content-Type":"application/json", "Accept":"application/json"},
|
||||
headers:{"Content-Type":"application/json; charset=utf-8", "Accept":"application/json"},
|
||||
emulation:false,
|
||||
urlEncoded:false
|
||||
});
|
||||
@@ -121,7 +121,7 @@ mindplot.RESTPersistenceManager = new Class({
|
||||
},
|
||||
onFailure:function () {
|
||||
},
|
||||
headers:{"Content-Type":"application/json", "Accept":"application/json"},
|
||||
headers:{"Content-Type":"application/json; charset=utf-8", "Accept":"application/json"},
|
||||
emulation:false,
|
||||
urlEncoded:false
|
||||
});
|
||||
|
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright [2012] [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.
|
||||
*/
|
||||
|
||||
mindplot.collaboration.CollaborationManager = new Class({
|
||||
initialize:function() {
|
||||
this.collaborativeModelReady = false;
|
||||
this.collaborativeModelReady = null;
|
||||
},
|
||||
|
||||
setCollaborativeFramework : function(framework) {
|
||||
this._collaborativeFramework = framework;
|
||||
},
|
||||
|
||||
buildMindmap: function() {
|
||||
return this._collaborativeFramework.buildMindmap();
|
||||
},
|
||||
|
||||
getCollaborativeFramework:function() {
|
||||
return this._collaborativeFramework;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.collaboration.CollaborationManager.getInstance = function() {
|
||||
if (!$defined(mindplot.collaboration.CollaborationManager.__collaborationManager)) {
|
||||
mindplot.collaboration.CollaborationManager.__collaborationManager = new mindplot.collaboration.CollaborationManager();
|
||||
}
|
||||
return mindplot.collaboration.CollaborationManager.__collaborationManager;
|
||||
};
|
||||
mindplot.collaboration.CollaborationManager.getInstance();
|
@@ -1,54 +0,0 @@
|
||||
mindplot.collaboration.framework.AbstractCollaborativeFramework = new Class({
|
||||
initialize: function(model) {
|
||||
$assert(model, "model can not be null");
|
||||
this._model = model;
|
||||
this._actionDispatcher = null;
|
||||
},
|
||||
|
||||
getModel : function() {
|
||||
return this._model;
|
||||
},
|
||||
|
||||
buildMindmap : function() {
|
||||
|
||||
var cmind = this.getModel();
|
||||
var mmind = new mindplot.model.Mindmap();
|
||||
cmind.copyTo(mmind);
|
||||
return mmind;
|
||||
},
|
||||
|
||||
_findTopic : function(nodes, id) {
|
||||
var result;
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var node = nodes[i];
|
||||
if (node.getId() == id) {
|
||||
result = node;
|
||||
} else {
|
||||
var children = node.getChildren();
|
||||
result = this._findTopic(children, id)
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getTopic:function(id) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
var branches = this.getModel().getBranches();
|
||||
var result = this._findTopic(branches, id);
|
||||
$assert(result, "Could not find topic:" + id);
|
||||
return result;
|
||||
},
|
||||
|
||||
getActionDispatcher:function() {
|
||||
if (this._actionDispatcher == null) {
|
||||
var context = mindplot.ActionDispatcher.getInstance()._commandContext;
|
||||
this._actionDispatcher = new mindplot.StandaloneActionDispatcher(context);
|
||||
}
|
||||
return this._actionDispatcher;
|
||||
}
|
||||
|
||||
});
|
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright [2012] [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.
|
||||
*/
|
||||
|
||||
mindplot.collaboration.framework.AbstractCollaborativeModelFactory = new Class({
|
||||
createNewMindmap:function() {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
buildMindmap:function(model) {
|
||||
throw "Unsupported operation";
|
||||
}
|
||||
});
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright [2012] [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.
|
||||
*/
|
||||
|
||||
mindplot.collaboration.framework.brix.BrixCollaborativeModelFactory = new Class({
|
||||
Extends:mindplot.collaboration.framework.AbstractCollaborativeModelFactory,
|
||||
initialize:function(brixFramework) {
|
||||
$assert(brixFramework, 'brixFramework can not be null');
|
||||
this._brixFramework = brixFramework;
|
||||
},
|
||||
|
||||
createNewMindmap : function() {
|
||||
var mindmap = new mindplot.collaboration.framework.brix.model.Mindmap(this._brixFramework);
|
||||
var node = mindmap.createNode(mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, 0);
|
||||
mindmap.setVersion('pela-brix');
|
||||
mindmap.addBranch(node);
|
||||
return mindmap;
|
||||
},
|
||||
|
||||
buildMindmap : function(model) {
|
||||
return new mindplot.collaboration.framework.brix.model.Mindmap(this._brixFramework, model);
|
||||
}
|
||||
});
|
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright [2012] [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.
|
||||
*/
|
||||
|
||||
mindplot.collaboration.framework.brix.BrixFramework = new Class({
|
||||
Extends: mindplot.collaboration.framework.AbstractCollaborativeFramework,
|
||||
initialize: function(model, app) {
|
||||
this._app = app;
|
||||
var factory = new mindplot.collaboration.framework.brix.BrixCollaborativeModelFactory(this);
|
||||
var root = this.getBrixModel().getRoot();
|
||||
var cmodel = null;
|
||||
var brixMap = root.get("mindmap");
|
||||
if (brixMap != null) {
|
||||
cmodel = factory.buildMindmap(brixMap);
|
||||
} else {
|
||||
cmodel = factory.createNewMindmap();
|
||||
root.put("mindmap", cmodel.getBrixModel());
|
||||
}
|
||||
this.parent(cmodel);
|
||||
console.log("cmodel:" + cmodel.inspect());
|
||||
},
|
||||
|
||||
getBrixModel:function() {
|
||||
return this._app.getModel();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
instanciated = false;
|
||||
mindplot.collaboration.framework.brix.BrixFramework.init = function(onload) {
|
||||
$assert(onload, "load function can not be null");
|
||||
|
||||
if (!instanciated) {
|
||||
var app = new goog.collab.CollaborativeApp();
|
||||
mindplot.collaboration.framework.brix.BrixFramework.buildMenu(app);
|
||||
app.start();
|
||||
|
||||
app.addListener('modelLoad', function(model) {
|
||||
var framework = new mindplot.collaboration.framework.brix.BrixFramework(model, app);
|
||||
mindplot.collaboration.CollaborationManager.getInstance().setCollaborativeFramework(framework);
|
||||
onload();
|
||||
}.bind(this));
|
||||
instanciated = true;
|
||||
}
|
||||
};
|
||||
|
||||
mindplot.collaboration.framework.brix.BrixFramework.buildMenu = function(app) {
|
||||
var menuBar = new goog.collab.ui.MenuBar();
|
||||
|
||||
// Configure toolbar menu ...
|
||||
var fileMenu = menuBar.addSubMenu("File");
|
||||
fileMenu.addItem("Save", function() {
|
||||
});
|
||||
fileMenu.addItem("Export", function() {
|
||||
});
|
||||
|
||||
var editMenu = menuBar.addSubMenu("Edit");
|
||||
editMenu.addItem("Undo", function() {
|
||||
});
|
||||
editMenu.addItem("Redo", function() {
|
||||
});
|
||||
|
||||
var formatMenu = menuBar.addSubMenu("Format");
|
||||
formatMenu.addItem("Bold", function() {
|
||||
});
|
||||
|
||||
var helpMenu = menuBar.addSubMenu("Help");
|
||||
helpMenu.addItem("Shortcuts", function() {
|
||||
});
|
||||
|
||||
app.setMenuBar(menuBar);
|
||||
};
|
||||
|
||||
|
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright [2012] [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.
|
||||
*/
|
||||
mindplot.collaboration.framework.brix.model.Mindmap = new Class({
|
||||
Extends:mindplot.model.IMindmap,
|
||||
initialize:function(brixFramework, brixModel) {
|
||||
$assert(brixFramework, 'brixFramework can not be null');
|
||||
|
||||
this._brixFramework = brixFramework;
|
||||
if (!$defined(brixModel)) {
|
||||
this._brixModel = this._createBrixModel();
|
||||
} else {
|
||||
this._brixModel = brixModel;
|
||||
}
|
||||
},
|
||||
|
||||
getVersion: function() {
|
||||
return this._brixModel.get('version');
|
||||
},
|
||||
|
||||
setVersion: function(value) {
|
||||
this._brixModel.put('version', value);
|
||||
},
|
||||
|
||||
getDescription: function() {
|
||||
return this._brixModel.get('description');
|
||||
},
|
||||
|
||||
setDescription: function(value) {
|
||||
this._brixModel.put('description', value);
|
||||
},
|
||||
|
||||
_createBrixModel:function() {
|
||||
var model = this._brixFramework.getBrixModel().create("Map");
|
||||
var branches = this._brixFramework.getBrixModel().create("List");
|
||||
model.put("branches", branches);
|
||||
return model;
|
||||
},
|
||||
|
||||
getBrixModel:function() {
|
||||
return this._brixModel;
|
||||
},
|
||||
|
||||
getBranches : function() {
|
||||
var result = [];
|
||||
var branches = this._brixModel.get("branches");
|
||||
for (var i = 0; i < branches.size(); i++) {
|
||||
var node = branches.get(i);
|
||||
if (node != null) {
|
||||
var nodeModel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, node, this);
|
||||
result.push(nodeModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
addBranch : function(nodeModel) {
|
||||
$assert(nodeModel, "nodeModel can not be null");
|
||||
var branches = this._brixModel.get("branches");
|
||||
|
||||
// @Todo: Hack ?
|
||||
var newModel = mindplot.collaboration.framework.brix.model.NodeModel.create(this._brixFramework, this, nodeModel.getType(), nodeModel.getId());
|
||||
nodeModel.copyTo(newModel);
|
||||
|
||||
branches.add(newModel);
|
||||
},
|
||||
|
||||
removeBranch : function(nodeModel) {
|
||||
$assert(nodeModel, "nodeModel can not be null");
|
||||
$assert(nodeModel.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, "central topic can not be removed");
|
||||
|
||||
var branches = this._brixModel.get("branches");
|
||||
for (var i = 0; i < branches.size(); i++) {
|
||||
|
||||
// @Todo: remove should remove null elements ...
|
||||
var branch = branches.get(i);
|
||||
if (branch != null) {
|
||||
if (branch == nodeModel.getBrixModel()) {
|
||||
branches.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
createNode : function(type, id) {
|
||||
return mindplot.collaboration.framework.brix.model.NodeModel.create(this._brixFramework, this, type, id);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright [2012] [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.
|
||||
*/
|
||||
|
||||
mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
||||
Extends: mindplot.model.INodeModel,
|
||||
initialize : function(brixFramework, brixModel, mindmap) {
|
||||
$assert(brixFramework, "brixFramework can not null");
|
||||
$assert(brixModel, "brixModel can not null");
|
||||
$assert(mindmap && mindmap.getBranches, "mindmap can not null");
|
||||
|
||||
this.parent(mindmap);
|
||||
this._brixModel = brixModel;
|
||||
this._brixFramework = brixFramework;
|
||||
this._addBrixListeners();
|
||||
},
|
||||
|
||||
_addBrixListeners : function() {
|
||||
|
||||
// Nodes creation should be cached ...
|
||||
if (!this._brixModel.__registered) {
|
||||
// Register listener for properties changes ....
|
||||
var actionDispatcher = this._brixFramework.getActionDispatcher();
|
||||
this._brixModel.addListener("valueChanged", function(event) {
|
||||
var key = event.getProperty();
|
||||
var value = event.getNewValue();
|
||||
|
||||
var funName = 'change' + key.capitalize() + 'ToTopic';
|
||||
if (!$defined(actionDispatcher[funName])) {
|
||||
throw "No implementation for:" + funName;
|
||||
}
|
||||
console.log("This action dispatcher:" + funName);
|
||||
|
||||
actionDispatcher[funName]([this.getId()], value);
|
||||
}.bind(this));
|
||||
|
||||
var children = this._brixModel.get("children");
|
||||
children.addListener("valuesAdded", function(event) {
|
||||
try {
|
||||
|
||||
var brixChildren = event.getValues();
|
||||
for (var i = 0; i < brixChildren.size(); i++) {
|
||||
var brixNodeModel = brixChildren.get(0);
|
||||
|
||||
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, brixNodeModel, this.getMindmap());
|
||||
|
||||
// @Todo: This is not ok. Is using designer global variable.
|
||||
var model = new mindplot.model.NodeModel(cmodel.getType(), designer.getMindmap(), this.getId());
|
||||
cmodel.copyTo(model);
|
||||
|
||||
actionDispatcher.addTopics([model], [this.getId()]);
|
||||
}
|
||||
} catch(e) {
|
||||
console.trace();
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
|
||||
children.addListener("valuesRemoved", function(event) {
|
||||
try {
|
||||
var brixChildren = event.getValues();
|
||||
for (var i = 0; i < brixChildren.size(); i++) {
|
||||
var brixNodeModel = brixChildren.get(i);
|
||||
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, brixNodeModel, this.getMindmap());
|
||||
actionDispatcher.deleteEntities([cmodel.getId()]);
|
||||
}
|
||||
} catch(e) {
|
||||
console.trace();
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
this._brixModel.__registered = true;
|
||||
}
|
||||
},
|
||||
|
||||
getChildren : function() {
|
||||
var result = [];
|
||||
var children = this._brixModel.get("children");
|
||||
for (var i = 0; i < children.size(); i++) {
|
||||
var node = children.get(i);
|
||||
var nodeModel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, node, this.getMindmap());
|
||||
nodeModel.setParent(this);
|
||||
result.push(nodeModel);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
getBrixModel:function() {
|
||||
return this._brixModel;
|
||||
},
|
||||
|
||||
putProperty : function(key, value) {
|
||||
$defined(key, 'key can not be null');
|
||||
this._brixModel.put(key, value);
|
||||
},
|
||||
|
||||
getProperty : function(key) {
|
||||
$defined(key, 'key can not be null');
|
||||
return this._brixModel.get(key);
|
||||
},
|
||||
|
||||
getPropertiesKeys : function() {
|
||||
var keys = this._brixModel.getKeys();
|
||||
keys.erase('children');
|
||||
keys.erase('icons');
|
||||
keys.erase('links');
|
||||
keys.erase('notes');
|
||||
return keys;
|
||||
},
|
||||
|
||||
getParent : function() {
|
||||
return this._brixModel._parent;
|
||||
},
|
||||
|
||||
setParent : function(parent) {
|
||||
this._brixModel._parent = parent;
|
||||
},
|
||||
|
||||
appendChild : function(node) {
|
||||
$assert(node && node.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||
var children = this._brixModel.get("children");
|
||||
children.add(node.getBrixModel());
|
||||
this.setParent(this);
|
||||
},
|
||||
|
||||
removeChild : function(child) {
|
||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
|
||||
var children = this._brixModel.get("children");
|
||||
for (var i = 0; i < children.size(); i++) {
|
||||
if (children.get(i) == child.getBrixModel()) {
|
||||
children.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.setParent(null);
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.collaboration.framework.brix.model.NodeModel.create = function(brixFramework, mindmap, type, id) {
|
||||
$assert(brixFramework, 'brixFramework can not be null');
|
||||
$assert(mindmap, 'mindmap can not be null');
|
||||
$assert(type, 'type can not be null');
|
||||
$assert($defined(id), 'id can not be null');
|
||||
|
||||
var brixModel = brixFramework.getBrixModel().create("Map");
|
||||
brixModel.put("type", type);
|
||||
brixModel.put("id", id);
|
||||
|
||||
var children = brixFramework.getBrixModel().create("List");
|
||||
brixModel.put("children", children);
|
||||
|
||||
return new mindplot.collaboration.framework.brix.model.NodeModel(brixFramework, brixModel, mindmap);
|
||||
};
|
@@ -57,12 +57,20 @@ mindplot.commands.AddTopicCommand = new Class({
|
||||
},
|
||||
|
||||
undoExecute:function (commandContext) {
|
||||
// Finally, delete the topic from the workspace ...
|
||||
// Delete disconnected the nodes. Create a copy of the topics ...
|
||||
var clonedModel = [];
|
||||
this._models.each(function (model) {
|
||||
clonedModel.push(model.clone());
|
||||
});
|
||||
|
||||
// Finally, remove the nodes ...
|
||||
this._models.each(function (model) {
|
||||
|
||||
var topicId = model.getId();
|
||||
var topic = commandContext.findTopics(topicId)[0];
|
||||
commandContext.deleteTopic(topic);
|
||||
}.bind(this));
|
||||
|
||||
this._models = clonedModel;
|
||||
}
|
||||
});
|
@@ -167,7 +167,7 @@ mindplot.persistence.XMLSerializer_Beta = new Class({
|
||||
$assert(documentElement.nodeName != "parsererror", "Error while parsing: '" + documentElement.childNodes[0].nodeValue);
|
||||
|
||||
// Is a wisemap?.
|
||||
$assert(documentElement.tagName == mindplot.persistence.XMLSerializer_Beta.MAP_ROOT_NODE, "This seem not to be a map document. Root Tag: '" + documentElement.tagName);
|
||||
$assert(documentElement.tagName == mindplot.persistence.XMLSerializer_Beta.MAP_ROOT_NODE, "This seem not to be a map document. Root Tag: '" + documentElement.tagName + ",',HTML:" +dom.innerHTML + ",XML:"+ core.Utils.innerXML(dom));
|
||||
|
||||
// Start the loading process ...
|
||||
var version = documentElement.getAttribute("version");
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
|
||||
toXML:function (mindmap) {
|
||||
toXML: function (mindmap) {
|
||||
$assert(mindmap, "Can not save a null mindmap");
|
||||
|
||||
var document = core.Utils.createDocument();
|
||||
@@ -27,7 +27,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
var mapElem = document.createElement("map");
|
||||
var name = mindmap.getId();
|
||||
if ($defined(name)) {
|
||||
mapElem.setAttribute('name', name);
|
||||
mapElem.setAttribute('name', this.rmXmlInv(name));
|
||||
}
|
||||
var version = mindmap.getVersion();
|
||||
if ($defined(version)) {
|
||||
@@ -61,7 +61,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
return document;
|
||||
},
|
||||
|
||||
_topicToXML:function (document, topic) {
|
||||
_topicToXML: function (document, topic) {
|
||||
var parentTopic = document.createElement("topic");
|
||||
|
||||
// Set topic attributes...
|
||||
@@ -149,10 +149,10 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
for (var key in attributes) {
|
||||
var value = attributes[key];
|
||||
if (key == 'text') {
|
||||
var cdata = document.createCDATASection(value);
|
||||
var cdata = document.createCDATASection(this.rmXmlInv(value));
|
||||
featureDom.appendChild(cdata);
|
||||
} else {
|
||||
featureDom.setAttribute(key, value);
|
||||
featureDom.setAttribute(key, this.rmXmlInv(value));
|
||||
}
|
||||
}
|
||||
parentTopic.appendChild(featureDom);
|
||||
@@ -169,18 +169,18 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
return parentTopic;
|
||||
},
|
||||
|
||||
_noteTextToXML:function (document, elem, text) {
|
||||
_noteTextToXML: function (document, elem, text) {
|
||||
if (text.indexOf('\n') == -1) {
|
||||
elem.setAttribute('text', text);
|
||||
elem.setAttribute('text', this.rmXmlInv(text));
|
||||
} else {
|
||||
var textDom = document.createElement("text");
|
||||
var cdata = document.createCDATASection(text);
|
||||
var cdata = document.createCDATASection(this.rmXmlInv(text));
|
||||
textDom.appendChild(cdata);
|
||||
elem.appendChild(textDom);
|
||||
}
|
||||
},
|
||||
|
||||
_relationshipToXML:function (document, relationship) {
|
||||
_relationshipToXML: function (document, relationship) {
|
||||
var result = document.createElement("relationship");
|
||||
result.setAttribute("srcTopicId", relationship.getFromNode());
|
||||
result.setAttribute("destTopicId", relationship.getToNode());
|
||||
@@ -203,7 +203,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
return result;
|
||||
},
|
||||
|
||||
loadFromDom:function (dom, mapId) {
|
||||
loadFromDom: function (dom, mapId) {
|
||||
$assert(dom, "dom can not be null");
|
||||
$assert(mapId, "mapId can not be null");
|
||||
|
||||
@@ -239,7 +239,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
return mindmap;
|
||||
},
|
||||
|
||||
_deserializeNode:function (domElem, mindmap) {
|
||||
_deserializeNode: function (domElem, mindmap) {
|
||||
var type = (domElem.getAttribute('central') != null) ? mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE : mindplot.model.INodeModel.MAIN_TOPIC_TYPE;
|
||||
|
||||
// Load attributes...
|
||||
@@ -320,7 +320,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
|
||||
var isShrink = domElem.getAttribute('shrink');
|
||||
// Hack: Some production maps has been stored with the central topic collapsed. This is a bug.
|
||||
if ($defined(isShrink) && type!=mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
if ($defined(isShrink) && type != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
topic.setChildrenShrunken(isShrink);
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
return topic;
|
||||
},
|
||||
|
||||
_deserializeTextAttr:function (domElem) {
|
||||
_deserializeTextAttr: function (domElem) {
|
||||
var value = domElem.getAttribute("text");
|
||||
if (!$defined(value)) {
|
||||
var children = domElem.childNodes;
|
||||
@@ -396,7 +396,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
return value;
|
||||
},
|
||||
|
||||
_deserializeNodeText:function (domElem) {
|
||||
_deserializeNodeText: function (domElem) {
|
||||
var children = domElem.childNodes;
|
||||
var value = null;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
@@ -408,7 +408,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
return value;
|
||||
},
|
||||
|
||||
_deserializeRelationship:function (domElement, mindmap) {
|
||||
_deserializeRelationship: function (domElement, mindmap) {
|
||||
var srcId = domElement.getAttribute("srcTopicId");
|
||||
var destId = domElement.getAttribute("destTopicId");
|
||||
var lineType = domElement.getAttribute("lineType");
|
||||
@@ -437,6 +437,36 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
model.setStartArrow('true');
|
||||
return model;
|
||||
}
|
||||
/*
|
||||
* This method ensures that the output String has only
|
||||
* valid XML unicode characters as specified by the
|
||||
* XML 1.0 standard. For reference, please see
|
||||
* <a href="http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char">the
|
||||
* standard</a>. This method will return an empty
|
||||
* String if the input is null or empty.
|
||||
*
|
||||
* @param in The String whose non-valid characters we want to remove.
|
||||
* @return The in String, stripped of non-valid characters.
|
||||
*/,
|
||||
rmXmlInv: function (str) {
|
||||
|
||||
if (str == null || str == undefined)
|
||||
return null;
|
||||
|
||||
var result = "";
|
||||
for (var i=0;i<str.length;i++){
|
||||
var c = str.charCodeAt(i);
|
||||
if ((c == 0x9) || (c == 0xA) || (c == 0xD)
|
||||
|| ((c >= 0x20) && (c <= 0xD7FF))
|
||||
|| ((c >= 0xE000) && (c <= 0xFFFD))
|
||||
|| ((c >= 0x10000) && (c <= 0x10FFFF))) {
|
||||
result = result + str.charAt(i);
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.persistence.XMLSerializer_Pela.MAP_ROOT_NODE = 'map';
|
@@ -66,7 +66,7 @@ mindplot.widget.FloatingTip = new Class({
|
||||
},
|
||||
|
||||
show:function (element) {
|
||||
var old = element.retrieve('floatingtip');
|
||||
var old = $(element).retrieve('floatingtip');
|
||||
if (old){
|
||||
if (old.getStyle('opacity') == 1) {
|
||||
clearTimeout(old.retrieve('timeout'));
|
||||
|
@@ -67,7 +67,7 @@ mindplot.widget.LinkIconTooltip = new Class({
|
||||
});
|
||||
|
||||
var img = new Element('img', {
|
||||
src:'http://open.thumbshots.org/image.pxf?url=' + linkIcon.getModel().getUrl(),
|
||||
src:'http://immediatenet.com/t/m?Size=1024x768&URL=' + linkIcon.getModel().getUrl(),
|
||||
img:linkIcon.getModel().getUrl(),
|
||||
alt:linkIcon.getModel().getUrl()
|
||||
}
|
||||
|
60
mindplot/src/main/resources/messages_ca.properties
Normal file
60
mindplot/src/main/resources/messages_ca.properties
Normal file
@@ -0,0 +1,60 @@
|
||||
DISCARD_CHANGES=Descartar els canvis
|
||||
SAVE=Desar
|
||||
INSERT=Inserir
|
||||
ZOOM_IN=Apropar
|
||||
ZOOM_OUT=Allunyar
|
||||
|
||||
TOPIC_BORDER_COLOR=Color del bord
|
||||
TOPIC_SHAPE=Forma del Tòpic
|
||||
TOPIC_ADD=Afegir Tòpic
|
||||
TOPIC_DELETE=Esborrar Tòpic
|
||||
TOPIC_ICON=Afegir Icona
|
||||
TOPIC_LINK=Afegir Enllaç
|
||||
TOPIC_NOTE=Afegir Nota
|
||||
TOPIC_COLOR=Color del Tòpic
|
||||
TOPIC_RELATIONSHIP=Relació
|
||||
FONT_FAMILY=Tipus de font
|
||||
|
||||
FONT_SIZE=Mida del text
|
||||
FONT_BOLD=Negreta
|
||||
FONT_ITALIC=Itàlica
|
||||
FONT_COLOR=Color del Text
|
||||
|
||||
UNDO=Refer
|
||||
NOTE=Nota
|
||||
LOADING=Carregant ...
|
||||
PRINT=Imprimir
|
||||
PUBLISH=Publicar
|
||||
REDO=Desfer
|
||||
ADD_TOPIC=Afegir Tòpic
|
||||
COLLABORATE=Compartir
|
||||
EXPORT=Exportar
|
||||
HISTORY=Història
|
||||
SAVE_COMPLETE=Desat completat
|
||||
SAVING=Gravant ...
|
||||
ONE_TOPIC_MUST_BE_SELECTED=No ha estat possible crear un nou tòpic. Com a mínim ha de seleccionar un tòpic.
|
||||
ONLY_ONE_TOPIC_MUST_BE_SELECTED=No ha estar possible crear un nou tòpic. Només un tòpic ha d'estar seleccionat.
|
||||
SAVE_COULD_NOT_BE_COMPLETED=No s'ha pogut desar. Provi més tard.
|
||||
UNEXPECTED_ERROR_LOADING=Ho sentim, un error ha esdevingut inesperadament. Provi recarregant l'editor, si el problema continua contacti a support@wisemapping.com.
|
||||
ZOOM_ERROR=No es pot fer més zoom.
|
||||
ZOOM_IN_ERROR=El zoom és massa creixent.
|
||||
MAIN_TOPIC=Tòpic principal
|
||||
SUB_TOPIC=Tòpic secundari
|
||||
ISOLATED_TOPIC=Tòpic aïllat
|
||||
CENTRAL_TOPIC=Tòpic central
|
||||
ONLY_ONE_TOPIC_MUST_BE_SELECTED_COLLAPSE=Els tòpics fills no es poden col·lapsar. Només un tòpic ha d'estar seleccionat.
|
||||
SHORTCUTS=Accessos directes
|
||||
ENTITIES_COULD_NOT_BE_DELETED=El tòpic o la relució no poden ser esborrats. Com a mínim ha de seleccionar un.
|
||||
AT_LEAST_ONE_TOPIC_MUST_BE_SELECTED=Com a mínim ha de seleccionar un tòpic.
|
||||
CLIPBOARD_IS_EMPTY=Res a copiar.
|
||||
CENTRAL_TOPIC_CAN_NOT_BE_DELETED=El tòpic central no pot esborrar-se.
|
||||
RELATIONSHIP_COULD_NOT_BE_CREATED=La relució no s'ha pout drear. Primer has de seleccionar una relució pare.
|
||||
SELECTION_COPIED_TO_CLIPBOARD=Tòpics copiats
|
||||
|
||||
WRITE_YOUR_TEXT_HERE=Escriu aquí la teva nota ...
|
||||
REMOVE=Esborrar
|
||||
ACCEPT=Acceptar
|
||||
CANCEL=Cancel·lar
|
||||
LINK=Enllaç
|
||||
OPEN_LINK=Obrir Enllaç
|
||||
SESSION_EXPIRED=La seva sessió ha finalitzat. Si us plau, torni a connectar-se.
|
18
pom.xml
18
pom.xml
@@ -4,14 +4,15 @@
|
||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<properties>
|
||||
<com.wisemapping.version>3.0-SNAPSHOT</com.wisemapping.version>
|
||||
<com.wisemapping.version>3.1-SNAPSHOT</com.wisemapping.version>
|
||||
<superpom.dir>${project.basedir}/wise-webapps</superpom.dir>
|
||||
</properties>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<name>WiseMapping Project</name>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<version>3.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<licenses>
|
||||
@@ -47,17 +48,17 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12</version>
|
||||
<version>2.16</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<version>2.6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -101,12 +102,11 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<inherited>true</inherited>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
3
setup.sh
Normal file
3
setup.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
export MAVEN_OPTS="-XX:MaxPermSize=128M"
|
@@ -9,7 +9,7 @@
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<version>3.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -153,11 +153,21 @@ web2d.peer.svg.TextPeer = new Class({
|
||||
},
|
||||
|
||||
getWidth : function () {
|
||||
var computedWidth;
|
||||
// Firefox hack for this issue:http://stackoverflow.com/questions/6390065/doing-ajax-updates-in-svg-breaks-getbbox-is-there-a-workaround
|
||||
try {
|
||||
var computedWidth = this._native.getBBox().width;
|
||||
|
||||
computedWidth = this._native.getBBox().width;
|
||||
// Chrome bug is producing this error, oly during page loading. Remove the hack if it works. The issue seems to be
|
||||
// caused when the element is hidden. I don't know why, but it works ...
|
||||
if(computedWidth==0){
|
||||
var bbox = this._native.getBBox();
|
||||
computedWidth = bbox.width;
|
||||
}
|
||||
|
||||
} catch(e) {
|
||||
computedWidth = 10;
|
||||
|
||||
}
|
||||
|
||||
var width = parseInt(computedWidth);
|
||||
|
71
wise-editor/doc/Integration.md
Normal file
71
wise-editor/doc/Integration.md
Normal file
@@ -0,0 +1,71 @@
|
||||
JS Editor Integration
|
||||
---------------------
|
||||
|
||||
## Running the JS only version
|
||||
|
||||
Start by creating the .zip file:
|
||||
|
||||
`mvn assembly:assembly -Dmaven.test.skip=true`
|
||||
|
||||
To test the javascript frontend you then do:
|
||||
|
||||
ruby -rwebrick -e 'WEBrick::HTTPServer.new(:Port=>8000,:DocumentRoot=>".").start'
|
||||
|
||||
Now open a browser using the URL http://localhost:8000/wise-editor/src/main/webapp/
|
||||
|
||||
### Attaching drag and drop events.
|
||||
|
||||
1) Support for dragging TextNodes:
|
||||
|
||||
The following code is an example of how to add attach to the div dragImageNode the support for node dragging.
|
||||
|
||||
$("dragTextNode").addEvent('mousedown', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// Create a image node ...
|
||||
var mindmap = designer.getMindmap();
|
||||
var node = mindmap.createNode();
|
||||
node.setText("Node Text !!!!");
|
||||
node.setMetadata("{'media':'test'}");
|
||||
node.setShapeType(mindplot.model.TopicShape.RECTANGLE);
|
||||
|
||||
// Add link ...
|
||||
var link = node.createFeature(mindplot.TopicFeature.Link.id, {url:"http://www.wisemapping.com"});
|
||||
node.addFeature(link);
|
||||
|
||||
// Add Note ...
|
||||
var note = node.createFeature(mindplot.TopicFeature.Note.id, {text:"This is a note"});
|
||||
node.addFeature(note);
|
||||
|
||||
designer.addDraggedNode(event, node);
|
||||
});
|
||||
|
||||
In the example, a new node is created with text "Node Text !!!!" and a note and a link associated to it when the user drop the node. Something to pay attention is the node.setMetadata("{}"), this delegated will be persisted during the serialization. Here you can store all the data you need.
|
||||
|
||||
2) Support for dragging Images: Similar to the point 1,drag support is registered to the div dragImageNode.
|
||||
|
||||
$("dragImageNode").addEvent('mousedown', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// Create a image node ...
|
||||
var mindmap = designer.getMindmap();
|
||||
var node = mindmap.createNode();
|
||||
node.setImageSize(80, 43);
|
||||
node.setMetadata("{'media':'video,'url':'http://www.youtube.com/watch?v=P3FrXftyuzw&feature=g-vrec&context=G2b4ab69RVAAAAAAAAAA'}");
|
||||
node.setImageUrl("images/logo-small.png");
|
||||
node.setShapeType(mindplot.model.TopicShape.IMAGE);
|
||||
|
||||
designer.addDraggedNode(event, node);
|
||||
});
|
||||
|
||||
The node.setShapeType(mindplot.model.TopicShape.IMAGE) defines a image node. This makes mandatory the set of setImageUrl and setImageSize properties in the node.
|
||||
|
||||
3) An event registration mechanism for Image nodes edit events: The next snipped show how to register a custom edition handler.
|
||||
|
||||
designer.addEvent("editnode", function(event) {
|
||||
var node = event.model;
|
||||
|
||||
alert("Node Id:" + node.getId());
|
||||
alert("Node Metadata:" + node.getMetadata());
|
||||
alert("Is Read Only:" + event.readOnly);
|
||||
} });
|
@@ -9,7 +9,7 @@
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<version>3.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@@ -27,62 +27,5 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>maven-jetty-plugin</artifactId>
|
||||
<version>6.1.26</version>
|
||||
<configuration>
|
||||
<connectors>
|
||||
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
|
||||
<port>8080</port>
|
||||
<maxIdleTime>60000</maxIdleTime>
|
||||
</connector>
|
||||
</connectors>
|
||||
<webApp>${project.build.directory}/wise-editor-${com.wisemapping.version}.war</webApp>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<configuration>
|
||||
<warSourceExcludes>js/mindplot-min.js</warSourceExcludes>
|
||||
<overlays>
|
||||
<overlay>
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>core-js</artifactId>
|
||||
<type>jar</type>
|
||||
<targetPath>js</targetPath>
|
||||
<includes>
|
||||
<include>*.js</include>
|
||||
</includes>
|
||||
</overlay>
|
||||
<overlay>
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>mindplot</artifactId>
|
||||
<type>jar</type>
|
||||
<targetPath>css</targetPath>
|
||||
<includes>
|
||||
<include>**/*.css</include>
|
||||
<include>**/*.html</include>
|
||||
</includes>
|
||||
</overlay>
|
||||
<overlay>
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>mindplot</artifactId>
|
||||
<type>jar</type>
|
||||
<targetPath>js</targetPath>
|
||||
<includes>
|
||||
<include>*.js</include>
|
||||
</includes>
|
||||
</overlay>
|
||||
</overlays>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
@@ -1,48 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" src="http://docs.google.com/brix/static/api/js/jsapi.nocache.js"></script>
|
||||
<script type="text/javascript">
|
||||
var collabOnLoad = function() {
|
||||
app = new goog.collab.CollaborativeApp();
|
||||
app.start();
|
||||
|
||||
app.addListener('modelLoad', function(model) {
|
||||
var root = app.getModel().getRoot();
|
||||
var myList = root.get("myList");
|
||||
if (!myList) {
|
||||
myList = app.getModel().create("List");
|
||||
root.put("myList", myList);
|
||||
}
|
||||
|
||||
myList.addListener('valuesAdded', function(event) {
|
||||
console.log("value added:" + myList.size());
|
||||
});
|
||||
|
||||
myList.addListener('valuesRemoved', function(event) {
|
||||
console.log("value removed:" + myList.size());
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
removedAction = function() {
|
||||
var root = app.getModel().getRoot();
|
||||
var myList = root.get("myList");
|
||||
myList.remove(myList.size() - 1);
|
||||
};
|
||||
|
||||
addAction = function() {
|
||||
var root = app.getModel().getRoot();
|
||||
var myList = root.get("myList");
|
||||
myList.add("Some elem " + myList.size());
|
||||
console.log("Click on adding...");
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
Funca?
|
||||
|
||||
<input style="font-size:20px;width:50px;height:50px;" type="button" value="Add" id="a2" onclick="addAction(this)"/>
|
||||
<input style="font-size:20px;width:50px;height:50px;" type="button" value="Remove" id="a2"
|
||||
onclick="removedAction(this)"/>
|
||||
</body>
|
||||
</html>
|
@@ -1,5 +1,5 @@
|
||||
@import "compatibility.less";
|
||||
@import "css/libraries/moodialog/css/MooDialog.css";
|
||||
@import "libraries/moodialog/css/MooDialog.css";
|
||||
/********************************************************************************/
|
||||
/* Header & Toolbar Styles */
|
||||
/********************************************************************************/
|
||||
|
1
wise-webapp/config
Symbolic link
1
wise-webapp/config
Symbolic link
@@ -0,0 +1 @@
|
||||
../config/
|
@@ -5,14 +5,22 @@ Introduction
|
||||
-------------
|
||||
|
||||
All WiseMapping services are exposed as REST services. Those services are the same used by the WiseMapping when you are using it.
|
||||
In the following section, all supported services are listed. The following variables should be replaced:
|
||||
In the following section, all supported services are listed.
|
||||
|
||||
REST Console
|
||||
-------------
|
||||
|
||||
You can learn how what are WiseMapping REST API's from using our interactive console. You can access it from here: http://localhost:8080/doc/rest/index.html.
|
||||
Important: Don't forget to configure your server host url in /WEB-INF/app.properties. By default it's configure to http://localhost:8080/wisemapping/</p>
|
||||
|
||||
CURL Usage Examples
|
||||
-------------
|
||||
|
||||
The following variables should be replaced:
|
||||
|
||||
- host.name: Host name where WiseMapping is deployed. Default Value: localhost
|
||||
- host.post: Post number where WiseMapping is deployed. Default Value: 8080
|
||||
- context.path: Context Path name where the application is deployed. Default Value: wisemapping
|
||||
|
||||
Supported Operations
|
||||
----------------------
|
||||
- context.path: Context Path name where the application is deployed. Default Value: wisemapping
|
||||
|
||||
Obtaining user information by email:
|
||||
* Template Path: /service/admin/users/email/{user.email}.json
|
||||
@@ -25,3 +33,10 @@ Deleting a based on the user id:
|
||||
Changing Password:
|
||||
Template Path: /service/admin/users/{userId}/password
|
||||
* curl "http://{host.name}:{host.port}/{context.path}/service/admin/users/{userId}/password" --request put --basic -u "admin@wisemapping.org:admin" -H "Content-Type:text/plain" --data "<new_password>"
|
||||
|
||||
Creating a new user:
|
||||
* Template Path: /service/admin/users/
|
||||
* Method: Post
|
||||
* curl "http://{host.name}:{host.port}/{context.path}/service/admin/users" --request post --basic -u "admin@wisemapping.org:admin" -H "Content-Type:application/json" --data '{"email": "te2@mydomain.de", "lastname": "lastname", "firstname":"myfirstname","password":"password"}'
|
||||
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<version>3.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
@@ -83,6 +83,12 @@
|
||||
<version>${org.springframework.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-openid</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
@@ -113,16 +119,6 @@
|
||||
<version>${org.springframework.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jsr173_api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlgraphics</groupId>
|
||||
<artifactId>fop</artifactId>
|
||||
@@ -182,12 +178,6 @@
|
||||
<version>${org.springframework.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.transaction</groupId>
|
||||
<artifactId>jta</artifactId>
|
||||
<version>1.0.1B</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
@@ -230,21 +220,15 @@
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.4</version>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<version>6.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
@@ -282,7 +266,6 @@
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
<version>1.9.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
@@ -313,86 +296,156 @@
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mangofactory</groupId>
|
||||
<artifactId>swagger-springmvc</artifactId>
|
||||
<version>0.6.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.wordnik</groupId>
|
||||
<artifactId>swagger-annotations_2.9.1</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>coverage</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.6.4.201312101107</version>
|
||||
<executions>
|
||||
<!--
|
||||
Prepares the property pointing to the JaCoCo runtime agent which
|
||||
is passed as VM argument when Maven the Surefire plugin is executed.
|
||||
-->
|
||||
<execution>
|
||||
<id>pre-unit-test</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<!--
|
||||
Ensures that the code coverage report for unit tests is created after
|
||||
unit tests have been run.
|
||||
-->
|
||||
<execution>
|
||||
<id>post-unit-test</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>hsqldb</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>sql-maven-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
|
||||
<configuration>
|
||||
<driver>org.hsqldb.jdbc.JDBCDriver</driver>
|
||||
<url>jdbc:hsqldb:file:${project.build.directory}/db/wisemapping</url>
|
||||
<username>sa</username>
|
||||
</configuration>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>2.2.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>drop-schemas</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<onError>continue</onError>
|
||||
<orderFile>descending</orderFile>
|
||||
<fileset>
|
||||
<basedir>${project.basedir}</basedir>
|
||||
<includes>
|
||||
<include>config/database/hsql/drop-schemas.sql</include>
|
||||
<include>config/database/hsql/create-schemas.sql</include>
|
||||
<include>config/database/hsql/apopulate-schemas.sql</include>
|
||||
</includes>
|
||||
</fileset>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>mysqldb</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>sql-maven-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>init-schema</id>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<phase>prepare-package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<driver>com.mysql.jdbc.Driver</driver>
|
||||
<username>root</username>
|
||||
<password></password>
|
||||
<url>jdbc:mysql://127.0.0.1:3306/?useUnicode=true&characterEncoding=UTF-8</url>
|
||||
<autocommit>false</autocommit>
|
||||
<srcFiles>
|
||||
<srcFile>config/database/mysql/create-database.sql</srcFile>
|
||||
<srcFile>config/database/mysql/create-schemas.sql</srcFile>
|
||||
<srcFile>config/database/mysql/apopulate-schemas.sql</srcFile>
|
||||
</srcFiles>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>sql-maven-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
|
||||
<configuration>
|
||||
<driver>org.hsqldb.jdbc.JDBCDriver</driver>
|
||||
<url>jdbc:hsqldb:file:${project.build.directory}/db/wisemapping</url>
|
||||
<username>sa</username>
|
||||
</configuration>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>2.2.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>drop-schemas</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<onError>continue</onError>
|
||||
<orderFile>ascending</orderFile>
|
||||
<fileset>
|
||||
<basedir>${project.basedir}</basedir>
|
||||
<includes>
|
||||
<include>src/test/sql/hsql/drop-schemas.sql</include>
|
||||
</includes>
|
||||
</fileset>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>create-schema</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<orderFile>ascending</orderFile>
|
||||
<fileset>
|
||||
<basedir>${project.basedir}</basedir>
|
||||
<includes>
|
||||
<include>src/test/sql/hsql/create-schemas.sql</include>
|
||||
</includes>
|
||||
</fileset>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>create-data</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<orderFile>ascending</orderFile>
|
||||
<fileset>
|
||||
<basedir>${project.basedir}</basedir>
|
||||
<includes>
|
||||
<include>src/test/sql/hsql/test-data.sql</include>
|
||||
</includes>
|
||||
</fileset>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>native2ascii-maven-plugin</artifactId>
|
||||
@@ -410,8 +463,6 @@
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.1.1</version>
|
||||
@@ -475,16 +526,30 @@
|
||||
</webResources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<groupId>org.apache.tomcat.maven</groupId>
|
||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||
<version>2.0</version>
|
||||
<configuration>
|
||||
<path>/wisemapping</path>
|
||||
<warFile>${project.build.directory}/wisemapping.war</warFile>
|
||||
<mode>war</mode>
|
||||
<update>true</update>
|
||||
<systemProperties>
|
||||
<database.base.url>${project.build.directory}</database.base.url>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>8.1.4.v20120524</version>
|
||||
<version>9.1.1.v20140108</version>
|
||||
<configuration>
|
||||
<stopKey>foo</stopKey>
|
||||
<stopPort>9999</stopPort>
|
||||
@@ -494,20 +559,11 @@
|
||||
<overrideDescriptor>${project.basedir}/webdefault.xml</overrideDescriptor>
|
||||
</webAppConfig>
|
||||
<systemProperties>
|
||||
<systemProperty>
|
||||
<name>org.mortbay.util.FileResource.checkAliases</name>
|
||||
<value>false</value>
|
||||
</systemProperty>
|
||||
<systemProperty>
|
||||
<name>org.mortbay.util.FileResource.checkAliases</name>
|
||||
<value>false</value>
|
||||
</systemProperty>
|
||||
<systemProperty>
|
||||
<name>database.base.url</name>
|
||||
<value>${project.build.directory}</value>
|
||||
</systemProperty>
|
||||
</systemProperties>
|
||||
<!--<scanIntervalSeconds>10</scanIntervalSeconds>-->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -530,7 +586,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
@@ -543,9 +598,9 @@
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-runner</artifactId>
|
||||
<version>7.4.5.v20110725</version>
|
||||
<version>9.1.3.v20140225</version>
|
||||
<destFileName>jetty-runner.jar</destFileName>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
|
@@ -0,0 +1,26 @@
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LabelManager {
|
||||
|
||||
void addLabel(@NotNull final Label label);
|
||||
|
||||
void saveLabel(@NotNull final Label label);
|
||||
|
||||
@NotNull
|
||||
List<Label> getAllLabels(@NotNull final User user);
|
||||
|
||||
@Nullable
|
||||
Label getLabelById(int id, @NotNull final User user);
|
||||
|
||||
@Nullable
|
||||
Label getLabelByTitle(@NotNull final String title, @NotNull final User user);
|
||||
|
||||
void removeLabel(@NotNull final Label label);
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LabelManagerImpl extends HibernateDaoSupport
|
||||
implements LabelManager {
|
||||
|
||||
@Override
|
||||
public void addLabel(@NotNull final Label label) {
|
||||
saveLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveLabel(@NotNull final Label label) {
|
||||
getSession().save(label);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Label> getAllLabels(@NotNull final User user) {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.Label wisemapping where creator_id=?", user.getId());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Label getLabelById(int id, @NotNull final User user) {
|
||||
List<Label> labels = getHibernateTemplate().find("from com.wisemapping.model.Label wisemapping where id=? and creator=?", new Object[]{id, user});
|
||||
return getFirst(labels);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Label getLabelByTitle(@NotNull String title, @NotNull final User user) {
|
||||
final List<Label> labels = getHibernateTemplate().find("from com.wisemapping.model.Label wisemapping where title=? and creator=?", new Object[]{title, user});
|
||||
return getFirst(labels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLabel(@NotNull Label label) {
|
||||
getHibernateTemplate().delete(label);
|
||||
}
|
||||
|
||||
@Nullable private Label getFirst(List<Label> labels) {
|
||||
Label result = null;
|
||||
if (labels != null && !labels.isEmpty()) {
|
||||
result = labels.get(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -22,6 +22,7 @@ import com.wisemapping.model.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface MindmapManager {
|
||||
@@ -38,7 +39,7 @@ public interface MindmapManager {
|
||||
|
||||
List<Mindmap> getAllMindmaps();
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
Mindmap getMindmapById(int mindmapId);
|
||||
|
||||
Mindmap getMindmapByTitle(final String name, final User user);
|
||||
@@ -66,4 +67,6 @@ public interface MindmapManager {
|
||||
public MindMapHistory getHistory(int historyId);
|
||||
|
||||
void updateCollaboration(@NotNull Collaboration collaboration);
|
||||
|
||||
void purgeHistory(int mapId) throws IOException;
|
||||
}
|
||||
|
@@ -19,7 +19,9 @@
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.*;
|
||||
import com.wisemapping.util.ZipUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.criterion.SimpleExpression;
|
||||
@@ -27,6 +29,7 @@ import org.hibernate.criterion.Junction;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.Criteria;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Calendar;
|
||||
|
||||
@@ -57,9 +60,10 @@ public class MindmapManagerImpl
|
||||
final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class);
|
||||
hibernateCriteria.add(Restrictions.eq("mindmapId", mindmapId));
|
||||
hibernateCriteria.addOrder(Order.desc("creationTime"));
|
||||
|
||||
// This line throws errors in some environments, so getting all history and taking firsts 10 records
|
||||
hibernateCriteria.setMaxResults(30);
|
||||
return hibernateCriteria.list();
|
||||
return hibernateCriteria.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,6 +76,38 @@ public class MindmapManagerImpl
|
||||
getHibernateTemplate().save(collaboration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeHistory(int mapId) throws IOException {
|
||||
final Criteria hibernateCriteria = getSession().createCriteria(MindMapHistory.class);
|
||||
hibernateCriteria.add(Restrictions.eq("mindmapId", mapId));
|
||||
hibernateCriteria.addOrder(Order.desc("creationTime"));
|
||||
|
||||
final List<MindMapHistory> historyList = hibernateCriteria.list();
|
||||
|
||||
final Mindmap mindmap = this.getMindmapById(mapId);
|
||||
if (mindmap != null) {
|
||||
final Calendar yearAgo = Calendar.getInstance();
|
||||
yearAgo.add(Calendar.MONTH, -12);
|
||||
|
||||
// If the map has not been modified in the last months, it means that I don't need to keep all the history ...
|
||||
int max = mindmap.getLastModificationTime().before(yearAgo) ? 10 : 25;
|
||||
|
||||
for (MindMapHistory history : historyList) {
|
||||
byte[] zippedXml = history.getZippedXml();
|
||||
if (new String(zippedXml).startsWith("<map")) {
|
||||
history.setZippedXml(ZipUtils.bytesToZip(zippedXml));
|
||||
getHibernateTemplate().update(history);
|
||||
}
|
||||
}
|
||||
|
||||
if (historyList.size() > max) {
|
||||
for (int i = max; i < historyList.size(); i++) {
|
||||
getHibernateTemplate().delete(historyList.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mindmap> search(MindMapCriteria criteria, int maxResult) {
|
||||
final Criteria hibernateCriteria = getSession().createCriteria(Mindmap.class);
|
||||
@@ -162,7 +198,7 @@ public class MindmapManagerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@Nullable
|
||||
public Mindmap getMindmapById(int id) {
|
||||
return getHibernateTemplate().get(Mindmap.class, id);
|
||||
}
|
||||
@@ -214,7 +250,7 @@ public class MindmapManagerImpl
|
||||
private void saveHistory(@NotNull final Mindmap mindMap) {
|
||||
final MindMapHistory history = new MindMapHistory();
|
||||
|
||||
history.setXml(mindMap.getXml());
|
||||
history.setZippedXml(mindMap.getZippedXml());
|
||||
history.setCreationTime(Calendar.getInstance());
|
||||
history.setEditor(mindMap.getLastEditor());
|
||||
history.setMindmapId(mindMap.getId());
|
||||
|
@@ -45,6 +45,6 @@ public interface UserManager {
|
||||
|
||||
public User createUser(User user, Collaborator col);
|
||||
|
||||
public void deleteUser(User user);
|
||||
public void removeUser(@NotNull User user);
|
||||
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@ import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.AccessAuditory;
|
||||
import org.hibernate.ObjectNotFoundException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
import org.springframework.security.authentication.encoding.PasswordEncoder;
|
||||
//import org.acegisecurity.providers.encoding.PasswordEncoder;
|
||||
@@ -69,8 +71,15 @@ public class UserManagerImpl
|
||||
return cola;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public User getUserBy(long id) {
|
||||
return getHibernateTemplate().get(User.class, id);
|
||||
User user = null;
|
||||
try{
|
||||
user = getHibernateTemplate().get(User.class, id);
|
||||
} catch (ObjectNotFoundException e){
|
||||
// Ignore ...
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,11 +110,8 @@ public class UserManagerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser(@NotNull User user) {
|
||||
final Collaborator collaborator = this.getCollaboratorBy(user.getEmail());
|
||||
getHibernateTemplate().delete(collaborator);
|
||||
public void removeUser(@NotNull final User user) {
|
||||
getHibernateTemplate().delete(user);
|
||||
getHibernateTemplate().flush();
|
||||
}
|
||||
|
||||
public void auditLogin(@NotNull AccessAuditory accessAuditory) {
|
||||
|
@@ -18,7 +18,11 @@ abstract public class ClientException extends WiseMappingException {
|
||||
String getMsgBundleKey();
|
||||
|
||||
public String getMessage(@NotNull final MessageSource messageSource, final @NotNull Locale locale) {
|
||||
return messageSource.getMessage(this.getMsgBundleKey(), this.getMsgBundleArgs(), locale);
|
||||
String message = messageSource.getMessage(this.getMsgBundleKey(), this.getMsgBundleArgs(), locale);
|
||||
if(message==null){
|
||||
message = this.getMessage();
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
protected Object[] getMsgBundleArgs(){
|
||||
|
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class EditionSessionExpiredException
|
||||
extends ClientException
|
||||
{
|
||||
public static final String MSG_KEY = "MINDMAP_TIMESTAMP_OUTDATED";
|
||||
private static final String MSG_KEY = "MINDMAP_TIMESTAMP_OUTDATED";
|
||||
|
||||
public EditionSessionExpiredException(@NotNull String msg)
|
||||
{
|
||||
|
@@ -0,0 +1,19 @@
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LabelCouldNotFoundException extends ClientException {
|
||||
|
||||
private static final String MSG_KEY = "LABEL_CAN_NOT_BE_FOUND";
|
||||
|
||||
public LabelCouldNotFoundException(@NotNull String msg)
|
||||
{
|
||||
super(msg,Severity.FATAL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
}
|
@@ -20,9 +20,11 @@ package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class LockException
|
||||
extends ClientException
|
||||
{
|
||||
private static final String MSG_KEY = "MINDMAP_IS_LOCKED";
|
||||
public LockException(@NotNull String message) {
|
||||
super(message,Severity.INFO);
|
||||
}
|
||||
@@ -30,6 +32,6 @@ public class LockException
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return MSG_KEY;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MapCouldNotFoundException
|
||||
extends ClientException
|
||||
{
|
||||
private static final String MSG_KEY = "MAP_CAN_NOT_BE_FOUND";
|
||||
|
||||
public MapCouldNotFoundException(@NotNull String msg)
|
||||
{
|
||||
super(msg,Severity.FATAL);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
}
|
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class MultipleSessionsOpenException
|
||||
extends ClientException
|
||||
{
|
||||
public static final String MSG_KEY = "MINDMAP_OUTDATED_BY_YOU";
|
||||
private static final String MSG_KEY = "MINDMAP_OUTDATED_BY_YOU";
|
||||
|
||||
public MultipleSessionsOpenException(@NotNull String techInfo)
|
||||
{
|
||||
|
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SessionExpiredException
|
||||
extends ClientException {
|
||||
public static final String MSG_KEY = "MINDMAP_TIMESTAMP_OUTDATED";
|
||||
private static final String MSG_KEY = "MINDMAP_TIMESTAMP_OUTDATED";
|
||||
private User lastUpdater;
|
||||
|
||||
public SessionExpiredException(@NotNull String debugInfo, @NotNull User lastUpdater) {
|
||||
|
@@ -26,6 +26,11 @@ public enum ExportFormat {
|
||||
PNG("image/png", "png"),
|
||||
PDF("application/pdf", "pdf"),
|
||||
FREEMIND("application/freemind", "mm"),
|
||||
TEXT("text/plain", "txt"),
|
||||
MICROSOFT_EXCEL("application/vnd.ms-excel", "xls"),
|
||||
MICROSOFT_WORD("application/msword", "doc"),
|
||||
OPEN_OFFICE_WRITER("application/vnd.oasis.opendocument.text", "odt"),
|
||||
MINDJET("application/vnd.mindjet.mindmanager", "mmap"),
|
||||
WISEMAPPING("application/wisemapping+xml", "wxml");
|
||||
|
||||
|
||||
|
@@ -19,10 +19,11 @@
|
||||
package com.wisemapping.exporter;
|
||||
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
public interface Exporter {
|
||||
public void export(byte[] xml, OutputStream outputStream) throws ExportException;
|
||||
public void export(@NotNull byte[] xml, @NotNull OutputStream outputStream) throws ExportException;
|
||||
public void export(Mindmap map, OutputStream outputStream) throws ExportException;
|
||||
}
|
||||
|
@@ -54,6 +54,7 @@ public class ExporterFactory {
|
||||
private static final String GROUP_NODE_NAME = "g";
|
||||
private static final String IMAGE_NODE_NAME = "image";
|
||||
public static final int MARGING = 50;
|
||||
public static final String UTF_8_CHARSET_NAME = "UTF-8";
|
||||
private File baseImgDir;
|
||||
|
||||
public ExporterFactory(@NotNull final ServletContext servletContext) throws ParserConfigurationException {
|
||||
@@ -121,12 +122,32 @@ public class ExporterFactory {
|
||||
}
|
||||
case SVG: {
|
||||
final String svgString = normalizeSvg(mapSvg, true);
|
||||
output.write(svgString.getBytes("UTF-8"));
|
||||
output.write(svgString.getBytes(UTF_8_CHARSET_NAME));
|
||||
break;
|
||||
}
|
||||
case TEXT: {
|
||||
final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.TEXT);
|
||||
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output);
|
||||
break;
|
||||
}
|
||||
case OPEN_OFFICE_WRITER: {
|
||||
final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.OPEN_OFFICE);
|
||||
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output);
|
||||
break;
|
||||
}
|
||||
case MICROSOFT_EXCEL: {
|
||||
final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.MICROSOFT_EXCEL);
|
||||
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output);
|
||||
break;
|
||||
}
|
||||
case FREEMIND: {
|
||||
final FreemindExporter exporter = new FreemindExporter();
|
||||
exporter.export(xml.getBytes("UTF-8"), output);
|
||||
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output);
|
||||
break;
|
||||
}
|
||||
case MINDJET: {
|
||||
final Exporter exporter = XSLTExporter.create(XSLTExporter.Type.MINDJET);
|
||||
exporter.export(xml.getBytes(UTF_8_CHARSET_NAME), output);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -140,9 +161,7 @@ public class ExporterFactory {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
final DocumentBuilder documentBuilder = factory.newDocumentBuilder();
|
||||
|
||||
if (!svgXml.trim().startsWith("<svg xmlns=\"http://www.w3.org/2000/svg\"")) {
|
||||
svgXml = svgXml.replaceFirst("<svg ", "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
|
||||
} else {
|
||||
if (!svgXml.contains("xmlns:xlink=\"http://www.w3.org/1999/xlink\"")) {
|
||||
svgXml = svgXml.replaceFirst("<svg ", "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
|
||||
}
|
||||
|
||||
@@ -222,30 +241,32 @@ public class ExporterFactory {
|
||||
|
||||
Element elem = (Element) node;
|
||||
|
||||
// Cook image href ...
|
||||
// If the image is a external URL, embeed it...
|
||||
String imgUrl = elem.getAttribute("href");
|
||||
elem.removeAttribute("href");
|
||||
if (!imgUrl.startsWith("image/png;base64") ||!imgUrl.startsWith("data:image/png;base64") ) {
|
||||
elem.removeAttribute("href");
|
||||
|
||||
if (imgUrl == null || imgUrl.isEmpty()) {
|
||||
imgUrl = elem.getAttribute("xlink:href"); // Do not support namespaces ...
|
||||
elem.removeAttribute("xlink:href");
|
||||
}
|
||||
FileInputStream fis = null;
|
||||
if (imgUrl == null || imgUrl.isEmpty()) {
|
||||
imgUrl = elem.getAttribute("xlink:href"); // Do not support namespaces ...
|
||||
elem.removeAttribute("xlink:href");
|
||||
}
|
||||
FileInputStream fis = null;
|
||||
|
||||
// Obtains file name ...
|
||||
try {
|
||||
final File iconFile = iconFile(imgUrl);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
fis = new FileInputStream(iconFile);
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
encoder.encode(fis, bos);
|
||||
// Obtains file name ...
|
||||
try {
|
||||
final File iconFile = iconFile(imgUrl);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
fis = new FileInputStream(iconFile);
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
encoder.encode(fis, bos);
|
||||
|
||||
elem.setAttribute("xlink:href", "data:image/png;base64," + bos.toString("8859_1"));
|
||||
elem.appendChild(document.createTextNode(" "));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
close(fis);
|
||||
elem.setAttribute("xlink:href", "data:image/png;base64," + bos.toString("8859_1"));
|
||||
elem.appendChild(document.createTextNode(" "));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
close(fis);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ public class FreemindExporter
|
||||
private Map<String, Node> nodesMap = null;
|
||||
|
||||
public void export(Mindmap map, OutputStream outputStream) throws ExportException {
|
||||
export(map.getXml(), outputStream);
|
||||
export(map.getUnzipXml(), outputStream);
|
||||
}
|
||||
|
||||
public void export(byte[] xml, @NotNull OutputStream outputStream) throws ExportException {
|
||||
@@ -267,7 +267,6 @@ public class FreemindExporter
|
||||
/*
|
||||
* MindmapFont format : fontName ; size ; color ; bold; italic;
|
||||
* eg: Verdana;10;#ffffff;bold;italic;
|
||||
*
|
||||
*/
|
||||
private void addFontNode(@NotNull com.wisemapping.jaxb.freemind.Node freemindNode, com.wisemapping.jaxb.wisemap.TopicType mindmapTopic) {
|
||||
final String fontStyle = mindmapTopic.getFontStyle();
|
||||
@@ -289,15 +288,22 @@ public class FreemindExporter
|
||||
|
||||
// Font size
|
||||
if (idx < countParts && part[idx].length() != 0) {
|
||||
String size = part[idx];
|
||||
font.setSIZE(new BigInteger(size));
|
||||
updated = true;
|
||||
final String size = part[idx];
|
||||
if (size != null && !size.isEmpty()) {
|
||||
int freeSize = Integer.parseInt(size);
|
||||
Integer fsize = wiseToFreeFontSize.get(freeSize);
|
||||
if(fsize!=null){
|
||||
font.setSIZE(BigInteger.valueOf(fsize));
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
idx++;
|
||||
|
||||
// Font Color
|
||||
if (idx < countParts && part[idx].length() != 0) {
|
||||
freemindNode.setCOLOR(part[idx]);
|
||||
updated = true;
|
||||
}
|
||||
idx++;
|
||||
|
||||
@@ -319,4 +325,21 @@ public class FreemindExporter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Freemind size goes from 10 to 28
|
||||
// WiseMapping:
|
||||
// 6 Small
|
||||
// 8 Normal
|
||||
// 10 Large
|
||||
// 15 Huge
|
||||
static private Map<Integer, Integer> wiseToFreeFontSize = new HashMap<Integer, Integer>();
|
||||
|
||||
static {
|
||||
wiseToFreeFontSize.put(6, 10);
|
||||
wiseToFreeFontSize.put(8, 12);
|
||||
wiseToFreeFontSize.put(10, 18);
|
||||
wiseToFreeFontSize.put(15, 24);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,84 @@
|
||||
package com.wisemapping.exporter;
|
||||
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import java.io.*;
|
||||
|
||||
public class XSLTExporter implements Exporter {
|
||||
|
||||
private Type type;
|
||||
|
||||
public XSLTExporter(@NotNull Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export(@NotNull byte[] xml, @NotNull OutputStream outputStream) throws ExportException {
|
||||
final ByteArrayOutputStream mmos = new ByteArrayOutputStream();
|
||||
|
||||
// Convert to freemind ...
|
||||
final FreemindExporter exporter = new FreemindExporter();
|
||||
exporter.export(xml, mmos);
|
||||
|
||||
// Convert to xslt transform ...
|
||||
final InputStream xsltis = this.getClass().getResourceAsStream("/com/wisemapping/export/xslt/" + type.getXsltName());
|
||||
if (xsltis == null) {
|
||||
throw new IllegalStateException("XSLT could not be resolved.");
|
||||
}
|
||||
|
||||
try {
|
||||
final TransformerFactory factory = TransformerFactory.newInstance();
|
||||
final Source xslt = new StreamSource(xsltis);
|
||||
Transformer transformer = factory.newTransformer(xslt);
|
||||
|
||||
final CharArrayReader reader = new CharArrayReader(mmos.toString("iso-8859-1").toCharArray());
|
||||
final Source mmSource = new StreamSource(reader);
|
||||
transformer.transform(mmSource, new StreamResult(outputStream));
|
||||
} catch (TransformerException e) {
|
||||
throw new ExportException(e);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new ExportException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export(@NotNull Mindmap map, OutputStream outputStream) throws ExportException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Exporter create(@NotNull Type type) {
|
||||
return new XSLTExporter(type);
|
||||
}
|
||||
|
||||
public static enum Type {
|
||||
TEXT("mm2text.xsl"),
|
||||
WORD("mm2wordml_utf8.xsl"),
|
||||
CSV("mm2csv.xsl"),
|
||||
LATEX("mm2latex.xsl"),
|
||||
MICROSOFT_EXCEL("mm2xls_utf8.xsl"),
|
||||
MINDJET("mm2mj.xsl"),
|
||||
OPEN_OFFICE("mm2oowriter.xsl");
|
||||
|
||||
public String getXsltName() {
|
||||
return xsltName;
|
||||
}
|
||||
|
||||
private String xsltName;
|
||||
|
||||
Type(@NotNull String xstFile) {
|
||||
this.xsltName = xstFile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -45,6 +45,9 @@ public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter {
|
||||
@Value("${security.type}")
|
||||
private String securityType;
|
||||
|
||||
@Value("${security.openid.enabled}")
|
||||
private Boolean openIdEnabled;
|
||||
|
||||
public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception {
|
||||
|
||||
request.setAttribute("google.analytics.enabled", analyticsEnabled);
|
||||
@@ -52,6 +55,7 @@ public class RequestPropertiesInterceptor extends HandlerInterceptorAdapter {
|
||||
request.setAttribute("google.ads.enabled", adsEnabled);
|
||||
request.setAttribute("site.homepage", siteHomepage);
|
||||
request.setAttribute("security.type", securityType);
|
||||
request.setAttribute("security.openid.enabled", openIdEnabled);
|
||||
|
||||
|
||||
// If the property could not be resolved, try to infer one from the request...
|
||||
|
@@ -46,7 +46,8 @@ public class SupportedUserAgent implements Serializable {
|
||||
final int majorVersion = version != null ? Integer.parseInt(version.getMajorVersion()) : -1;
|
||||
|
||||
boolean result = browser == Browser.FIREFOX && majorVersion >= 10;
|
||||
result = result || browser == Browser.IE8 || browser == Browser.IE9;
|
||||
result = result || browser == Browser.FIREFOX2 && majorVersion >= 17;
|
||||
result = result || browser == Browser.IE8 || browser == Browser.IE9 || browser == Browser.IE11 ;
|
||||
result = result || browser == Browser.IE && majorVersion >= 8;
|
||||
result = result || browser == Browser.OPERA10 && majorVersion >= 11;
|
||||
result = result || browser == Browser.CHROME && majorVersion >= 18;
|
||||
|
@@ -0,0 +1,44 @@
|
||||
package com.wisemapping.listener;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
||||
import com.wisemapping.exceptions.LockException;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.LockManager;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
public class UnlockOnExpireListener implements HttpSessionListener {
|
||||
|
||||
@Override
|
||||
public void sessionCreated(@NotNull HttpSessionEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sessionDestroyed(@NotNull HttpSessionEvent event) {
|
||||
|
||||
final ServletContext servletContext = event.getSession().getServletContext();
|
||||
final WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
|
||||
final MindmapService mindmapService = (MindmapService) wc.getBean("mindmapService");
|
||||
final LockManager lockManager = mindmapService.getLockManager();
|
||||
|
||||
final User user = Utils.getUser(false);
|
||||
if (user != null) {
|
||||
try {
|
||||
lockManager.unlockAll(user);
|
||||
} catch (LockException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AccessDeniedSecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -154,12 +154,12 @@ final public class NotificationService {
|
||||
// }
|
||||
}
|
||||
|
||||
public void reportJavascriptException(@NotNull Mindmap mindmap, @Nullable User user, @Nullable String jsErrorMsg, @NotNull HttpServletRequest request) {
|
||||
public void reportJavascriptException(@Nullable Mindmap mindmap, @Nullable User user, @Nullable String jsErrorMsg, @NotNull HttpServletRequest request) {
|
||||
|
||||
final Map<String, String> model = new HashMap<String, String>();
|
||||
model.put("errorMsg", jsErrorMsg);
|
||||
try {
|
||||
model.put("mapXML", StringEscapeUtils.escapeXml(mindmap.getXmlStr()));
|
||||
model.put("mapXML", StringEscapeUtils.escapeXml(mindmap == null ? "map not found" : mindmap.getXmlStr()));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Ignore ...
|
||||
}
|
||||
|
@@ -19,9 +19,11 @@ public class NotifierFilter {
|
||||
|
||||
final StringBuilder buff = new StringBuilder();
|
||||
for (String key : model.keySet()) {
|
||||
buff.append(key);
|
||||
buff.append("=");
|
||||
buff.append(model.get(key));
|
||||
if (!key.equals("mapXML")) {
|
||||
buff.append(key);
|
||||
buff.append("=");
|
||||
buff.append(model.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
final String digest = DigestUtils.md5DigestAsHex(buff.toString().getBytes());
|
||||
|
@@ -0,0 +1,37 @@
|
||||
package com.wisemapping.model;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum AuthenticationType {
|
||||
DATABASE('D'),
|
||||
LDAP('L'),
|
||||
OPENID('O');
|
||||
private final char schemaCode;
|
||||
|
||||
AuthenticationType(char schemaCode) {
|
||||
this.schemaCode = schemaCode;
|
||||
}
|
||||
|
||||
public char getCode() {
|
||||
return schemaCode;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AuthenticationType valueOf(char code) {
|
||||
AuthenticationType result = null;
|
||||
AuthenticationType[] values = AuthenticationType.values();
|
||||
for (AuthenticationType value : values) {
|
||||
if (value.getCode() == code) {
|
||||
result = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
throw new IllegalStateException("Could not find auth with code:" + code);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ package com.wisemapping.model;
|
||||
public class Constants {
|
||||
|
||||
public static final int MAX_MAP_NAME_LENGTH = 512;
|
||||
public static final int MAX_LABEL_NAME_LENGTH = 30;
|
||||
public static final int MAX_MAP_DESCRIPTION_LENGTH = 512;
|
||||
public static final int MAX_USER_LASTNAME_LENGTH = 255;
|
||||
public static final int MAX_USER_FIRSTNAME_LENGTH = 255;
|
||||
|
90
wise-webapp/src/main/java/com/wisemapping/model/Label.java
Normal file
90
wise-webapp/src/main/java/com/wisemapping/model/Label.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package com.wisemapping.model;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Label {
|
||||
|
||||
//~ Instance fields ......................................................................................
|
||||
private int id;
|
||||
@NotNull private String title;
|
||||
@NotNull private User creator;
|
||||
@Nullable private Label parent;
|
||||
@NotNull private String color;
|
||||
@NotNull private String iconName;
|
||||
|
||||
public void setParent(@Nullable Label parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Label getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setCreator(@NotNull User creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public User getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(@NotNull String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(@NotNull String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getIconName() {
|
||||
return iconName;
|
||||
}
|
||||
|
||||
public void setIconName(@NotNull String iconName) {
|
||||
this.iconName = iconName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Label)) return false;
|
||||
|
||||
Label label = (Label) o;
|
||||
|
||||
return id == label.id && creator.getId() == label.creator.getId()
|
||||
&& !(parent != null ? !parent.equals(label.parent) : label.parent != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + title.hashCode();
|
||||
result = 31 * result + creator.hashCode();
|
||||
result = 31 * result + (parent != null ? parent.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -19,6 +19,7 @@
|
||||
package com.wisemapping.model;
|
||||
|
||||
import com.wisemapping.util.ZipUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -29,7 +30,7 @@ public class MindMapHistory {
|
||||
private int id;
|
||||
private Calendar creationTime;
|
||||
private User editor;
|
||||
private byte[] xml;
|
||||
private byte[] zippedXml;
|
||||
private int mindmapId;
|
||||
|
||||
public MindMapHistory() {
|
||||
@@ -52,6 +53,7 @@ public class MindMapHistory {
|
||||
this.mindmapId = id;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Calendar getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
@@ -69,15 +71,15 @@ public class MindMapHistory {
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
public byte[] getXml() {
|
||||
return xml;
|
||||
public byte[] getZippedXml() {
|
||||
return zippedXml;
|
||||
}
|
||||
|
||||
public void setXml(byte[] value) {
|
||||
xml = value;
|
||||
public void setZippedXml(byte[] value) {
|
||||
zippedXml = value;
|
||||
}
|
||||
|
||||
public byte[] getUnzipXml() throws IOException {
|
||||
return ZipUtils.zipToBytes(xml);
|
||||
return ZipUtils.zipToBytes(getZippedXml());
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Mindmap {
|
||||
@@ -44,11 +45,12 @@ public class Mindmap {
|
||||
private User lastEditor;
|
||||
|
||||
private Set<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||
private Set<Label> labels = new LinkedHashSet<>();
|
||||
|
||||
private User creator;
|
||||
private String tags;
|
||||
private String title;
|
||||
private byte[] xml;
|
||||
private byte[] zippedXml;
|
||||
|
||||
//~ Constructors .........................................................................................
|
||||
|
||||
@@ -57,39 +59,49 @@ public class Mindmap {
|
||||
|
||||
//~ Methods ..............................................................................................
|
||||
|
||||
public void setXml(byte[] xml) {
|
||||
this.xml = xml;
|
||||
public void setUnzipXml(@NotNull byte[] value) {
|
||||
try {
|
||||
final byte[] zip = ZipUtils.bytesToZip(value);
|
||||
this.setZippedXml(zip);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setXmlStr(@NotNull String xml)
|
||||
throws IOException {
|
||||
this.xml = xml.getBytes(UTF_8);
|
||||
public void setXmlStr(@NotNull String xml) {
|
||||
try {
|
||||
this.setUnzipXml(xml.getBytes(UTF_8));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getXml() {
|
||||
return xml;
|
||||
@NotNull
|
||||
public byte[] getUnzipXml() {
|
||||
byte[] result = new byte[]{};
|
||||
if (zippedXml != null) {
|
||||
try {
|
||||
final byte[] zip = this.getZippedXml();
|
||||
result = ZipUtils.zipToBytes(zip);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getXmlStr() throws UnsupportedEncodingException {
|
||||
String result = null;
|
||||
if (this.xml != null) {
|
||||
result = new String(this.xml, UTF_8);
|
||||
}
|
||||
return result;
|
||||
return new String(this.getUnzipXml(), UTF_8);
|
||||
}
|
||||
|
||||
public byte[] getZippedXml()
|
||||
throws IOException {
|
||||
byte[] result = this.xml;
|
||||
if (result != null) {
|
||||
result = ZipUtils.bytesToZip(result);
|
||||
}
|
||||
return result;
|
||||
@NotNull
|
||||
public byte[] getZippedXml() {
|
||||
return zippedXml;
|
||||
}
|
||||
|
||||
public void setZippedXml(byte[] xml)
|
||||
throws IOException {
|
||||
this.xml = ZipUtils.zipToBytes(xml);
|
||||
public void setZippedXml(@NotNull byte[] value) {
|
||||
this.zippedXml = value;
|
||||
}
|
||||
|
||||
public Set<Collaboration> getCollaborations() {
|
||||
@@ -108,6 +120,18 @@ public class Mindmap {
|
||||
collaborations.add(collaboration);
|
||||
}
|
||||
|
||||
@NotNull public Set<Label> getLabels() {
|
||||
return labels;
|
||||
}
|
||||
|
||||
public void setLabels(@NotNull final Set<Label> labels) {
|
||||
this.labels = labels;
|
||||
}
|
||||
|
||||
public void addLabel(@NotNull final Label label) {
|
||||
this.labels.add(label);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Collaboration findCollaboration(@NotNull Collaborator collaborator) {
|
||||
Collaboration result = null;
|
||||
@@ -140,6 +164,7 @@ public class Mindmap {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Calendar getLastModificationTime() {
|
||||
return lastModificationTime;
|
||||
}
|
||||
@@ -218,9 +243,6 @@ public class Mindmap {
|
||||
}
|
||||
|
||||
public void setCreator(@NotNull User creator) {
|
||||
if (creator == null) {
|
||||
throw new IllegalArgumentException("Owner can not be null");
|
||||
}
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
@@ -279,7 +301,7 @@ public class Mindmap {
|
||||
final Mindmap result = new Mindmap();
|
||||
result.setDescription(this.getDescription());
|
||||
result.setTitle(this.getTitle());
|
||||
result.setXml(this.getXml());
|
||||
result.setUnzipXml(this.getUnzipXml());
|
||||
result.setTags(this.getTags());
|
||||
|
||||
return result;
|
||||
@@ -296,4 +318,28 @@ public class Mindmap {
|
||||
return result;
|
||||
|
||||
}
|
||||
//creo que no se usa mas
|
||||
public boolean hasLabel(@NotNull final String name) {
|
||||
for (Label label : this.labels) {
|
||||
if (label.getTitle().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.wisemapping.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -37,8 +38,11 @@ public class User
|
||||
private Set<String> tags = new HashSet<String>();
|
||||
private boolean allowSendEmail = false;
|
||||
private String locale;
|
||||
private AuthenticationType authenticationType;
|
||||
|
||||
|
||||
private String authenticatorUri;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
@@ -114,4 +118,35 @@ public class User
|
||||
public void setLocale(@Nullable String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public char getAutheticationTypeCode() {
|
||||
// Default authentication is database ....
|
||||
return this.authenticationType != null ? this.authenticationType.getCode() : AuthenticationType.DATABASE.getCode();
|
||||
}
|
||||
|
||||
public void setAutheticationTypeCode(char code) {
|
||||
this.authenticationType = AuthenticationType.valueOf(code);
|
||||
}
|
||||
|
||||
public AuthenticationType getAuthenticationType() {
|
||||
return authenticationType;
|
||||
}
|
||||
|
||||
public void setAuthenticationType(@NotNull AuthenticationType authenticationType) {
|
||||
this.authenticationType = authenticationType;
|
||||
}
|
||||
|
||||
public boolean isDatabaseSchema(){
|
||||
return this.authenticationType == AuthenticationType.DATABASE;
|
||||
}
|
||||
|
||||
public String getAuthenticatorUri() {
|
||||
return authenticatorUri;
|
||||
}
|
||||
|
||||
public void setAuthenticatorUri(String authenticatorUri) {
|
||||
this.authenticatorUri = authenticatorUri;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -18,23 +18,32 @@
|
||||
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.mangofactory.swagger.annotations.ApiIgnore;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.mail.NotificationService;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestLogItem;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.UserService;
|
||||
import com.wordnik.swagger.annotations.Api;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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;
|
||||
|
||||
@Api(value="UserApi",description = "Account Account Related Objects.")
|
||||
@Controller
|
||||
public class AccountController extends BaseController {
|
||||
@Qualifier("userService")
|
||||
@@ -58,7 +67,7 @@ public class AccountController extends BaseController {
|
||||
throw new IllegalArgumentException("Password can not be null");
|
||||
}
|
||||
|
||||
final User user = Utils.getUser();
|
||||
final User user = Utils.getUser(true);
|
||||
user.setPassword(password);
|
||||
userService.changePassword(user);
|
||||
}
|
||||
@@ -70,7 +79,7 @@ public class AccountController extends BaseController {
|
||||
throw new IllegalArgumentException("Firstname can not be null");
|
||||
}
|
||||
|
||||
final User user = Utils.getUser();
|
||||
final User user = Utils.getUser(true);
|
||||
user.setFirstname(firstname);
|
||||
userService.updateUser(user);
|
||||
}
|
||||
@@ -82,7 +91,7 @@ public class AccountController extends BaseController {
|
||||
throw new IllegalArgumentException("lastname can not be null");
|
||||
|
||||
}
|
||||
final User user = Utils.getUser();
|
||||
final User user = Utils.getUser(true);
|
||||
user.setLastname(lastname);
|
||||
userService.updateUser(user);
|
||||
}
|
||||
@@ -95,14 +104,30 @@ public class AccountController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
final User user = Utils.getUser();
|
||||
final User user = Utils.getUser(true);
|
||||
user.setLocale(language);
|
||||
userService.updateUser(user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "account")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void deleteUser() throws WiseMappingException
|
||||
|
||||
{
|
||||
final User user = Utils.getUser(true);
|
||||
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
final Mindmap mindmap = collaboration.getMindMap();
|
||||
mindmapService.removeMindmap(mindmap,user);
|
||||
}
|
||||
userService.removeUser(user);
|
||||
}
|
||||
|
||||
|
||||
@ApiIgnore
|
||||
@RequestMapping(method = RequestMethod.POST, value = "logger/editor", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void changePassword(@RequestBody RestLogItem item, @NotNull HttpServletRequest request) {
|
||||
public void logError(@RequestBody RestLogItem item, @NotNull HttpServletRequest request) {
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(item.getMapId());
|
||||
final User user = Utils.getUser();
|
||||
logger.error("Unexpected editor error - " + item.getJsErrorMsg());
|
||||
|
@@ -18,50 +18,74 @@
|
||||
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.ClientException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.UserService;
|
||||
import com.wordnik.swagger.annotations.Api;
|
||||
import com.wordnik.swagger.annotations.ApiOperation;
|
||||
import com.wordnik.swagger.annotations.ApiParam;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Api(value = "AdminApi", description = "Administrative Related Objects.")
|
||||
@Controller
|
||||
public class AdminController extends BaseController {
|
||||
@Qualifier("userService")
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/json", "text/html", "application/xml"})
|
||||
@Qualifier("mindmapService")
|
||||
@Autowired
|
||||
private MindmapService mindmapService;
|
||||
|
||||
@ApiOperation("Note: Administration permissions required.")
|
||||
@RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/json", "application/xml"})
|
||||
@ResponseBody
|
||||
public ModelAndView getUserById(@PathVariable long id) throws IOException {
|
||||
public RestUser getUserById(@PathVariable @ApiParam(required = true, value = "User Id", allowableValues = "range[1," + Long.MAX_VALUE + "]") long id) throws IOException {
|
||||
final User userBy = userService.getUserBy(id);
|
||||
if (userBy == null) {
|
||||
throw new IllegalArgumentException("User could not be found");
|
||||
}
|
||||
return new ModelAndView("userView", "user", new RestUser(userBy));
|
||||
return new RestUser(userBy);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "admin/users/email/{email}", produces = {"application/json", "text/html", "application/xml"})
|
||||
@ApiOperation("Note: Administration permissions required.")
|
||||
@RequestMapping(method = RequestMethod.GET, value = "admin/users/email/{email}", produces = {"application/json", "application/xml"})
|
||||
@ResponseBody
|
||||
public ModelAndView getUserByEmail(@PathVariable String email) throws IOException {
|
||||
public RestUser getUserByEmail(@PathVariable String email) throws IOException {
|
||||
final User user = userService.getUserBy(email);
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User '" + email + "' could not be found");
|
||||
}
|
||||
return new ModelAndView("userView", "user", new RestUser(user));
|
||||
return new RestUser(user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "admin/users", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@ApiOperation("Note: Administration permissions required.")
|
||||
@RequestMapping(method = RequestMethod.POST, value = "admin/users", consumes = {"application/xml", "application/json"}, produces = {"application/json", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.CREATED)
|
||||
public void createUser(@RequestBody RestUser user, HttpServletResponse response) throws WiseMappingException {
|
||||
public void createUser(@RequestBody @ApiParam(required = true) RestUser user, HttpServletResponse response) throws WiseMappingException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User could not be found");
|
||||
}
|
||||
@@ -85,13 +109,15 @@ public class AdminController extends BaseController {
|
||||
}
|
||||
|
||||
// Finally create the user ...
|
||||
userService.createUser(delegated, false,true);
|
||||
delegated.setAuthenticationType(AuthenticationType.DATABASE);
|
||||
userService.createUser(delegated, false, true);
|
||||
response.setHeader("Location", "/service/admin/users/" + user.getId());
|
||||
}
|
||||
|
||||
@ApiOperation("Note: Administration permissions required.")
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "admin/users/{id}/password", consumes = {"text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void changePassword(@RequestBody String password, @PathVariable long id) throws WiseMappingException {
|
||||
public void changePassword(@RequestBody @ApiParam(required = true) String password, @PathVariable @ApiParam(required = true, value = "User Id", allowableValues = "range[1," + Long.MAX_VALUE + "]") long id) throws WiseMappingException {
|
||||
if (password == null) {
|
||||
throw new IllegalArgumentException("Password can not be null");
|
||||
}
|
||||
@@ -104,14 +130,96 @@ public class AdminController extends BaseController {
|
||||
userService.changePassword(user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE,value = "admin/users/{id}")
|
||||
@ApiOperation("Note: Administration permissions required.")
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "admin/users/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void getUserByEmail(@PathVariable long id) throws WiseMappingException {
|
||||
public void deleteUserByEmail(@PathVariable long id) throws WiseMappingException {
|
||||
final User user = userService.getUserBy(id);
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User '" + id + "' could not be found");
|
||||
}
|
||||
userService.deleteUser(user);
|
||||
|
||||
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
final Mindmap mindmap = collaboration.getMindMap();
|
||||
mindmapService.removeMindmap(mindmap,user);
|
||||
}
|
||||
|
||||
userService.removeUser(user);
|
||||
}
|
||||
|
||||
@ApiOperation("Note: Administration permissions required.")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
@RequestMapping(method = RequestMethod.GET, value = "admin/database/purge")
|
||||
public void purgeDB(@RequestParam(required = true) Integer minUid, @RequestParam(required = true) Integer maxUid, @RequestParam(required = true) Boolean apply) throws WiseMappingException, UnsupportedEncodingException {
|
||||
|
||||
for (int i = minUid; i < maxUid; i++) {
|
||||
|
||||
try {
|
||||
System.out.println("Looking for user:" + i);
|
||||
final User user = userService.getUserBy(i);
|
||||
if (user != null) {
|
||||
// Do not process admin accounts ...
|
||||
if (user.getEmail().contains("wisemapping")) {
|
||||
continue;
|
||||
}
|
||||
// Iterate over the list of maps ...
|
||||
final List<Collaboration> collaborations = mindmapService.findCollaborations(user);
|
||||
for (Collaboration collaboration : collaborations) {
|
||||
final Mindmap mindmap = collaboration.getMindMap();
|
||||
if (MindmapFilter.MY_MAPS.accept(mindmap, user)) {
|
||||
|
||||
final Calendar yearAgo = Calendar.getInstance();
|
||||
yearAgo.add(Calendar.MONTH, -4);
|
||||
|
||||
// The use has only two maps... When they have been modified ..
|
||||
System.out.println("Checking map id:" + mindmap.getId());
|
||||
if (mindmap.getLastModificationTime().before(yearAgo) && !mindmap.isPublic()) {
|
||||
System.out.println("Old map months map:" + mindmap.getId());
|
||||
|
||||
if (isWelcomeMap(mindmap) || isSimpleMap(mindmap)) {
|
||||
System.out.println("Purged map id:" + mindmap.getId() + ", userId:" + user.getId());
|
||||
if (apply) {
|
||||
mindmapService.removeMindmap(mindmap, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Purge history ...
|
||||
mindmapService.purgeHistory(mindmap.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
} catch (WiseMappingException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("Note: Administration permissions required.")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
@RequestMapping(method = RequestMethod.GET, value = "admin/database/purge/history")
|
||||
public void purgeHistory(@RequestParam(required = true) Integer mapId) throws WiseMappingException, IOException {
|
||||
|
||||
mindmapService.purgeHistory(mapId);
|
||||
}
|
||||
|
||||
private boolean isWelcomeMap(@NotNull Mindmap mindmap) throws UnsupportedEncodingException {
|
||||
// Is welcome map ?
|
||||
final String xmlStr = mindmap.getXmlStr();
|
||||
boolean oldWelcomeMap = xmlStr.contains("Welcome to WiseMapping") && xmlStr.contains("My Wisemaps");
|
||||
return oldWelcomeMap;
|
||||
}
|
||||
|
||||
public boolean isSimpleMap(@NotNull Mindmap mindmap) throws UnsupportedEncodingException {
|
||||
String xmlStr = mindmap.getXmlStr();
|
||||
String[] topics = xmlStr.split(Pattern.quote("<topic"));
|
||||
return topics.length <= 3;
|
||||
}
|
||||
}
|
||||
|
@@ -60,16 +60,6 @@ public class BaseController {
|
||||
return new RestErrors(ex.getMessage(),Severity.WARNING);
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ResponseBody
|
||||
public RestErrors handleServerErrors(@NotNull Exception ex, @NotNull HttpServletRequest request) {
|
||||
final User user = Utils.getUser();
|
||||
notificationService.reportJavaException(ex, user, request);
|
||||
return new RestErrors(ex.getMessage(),Severity.SEVERE);
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(ImportUnexpectedException.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ResponseBody
|
||||
@@ -110,4 +100,16 @@ public class BaseController {
|
||||
final Locale locale = LocaleContextHolder.getLocale();
|
||||
return new RestErrors(ex.getMessage(messageSource, locale),ex.getSeverity(),ex.getTechInfo());
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ResponseBody
|
||||
public RestErrors handleServerErrors(@NotNull Exception ex, @NotNull HttpServletRequest request) {
|
||||
final User user = Utils.getUser(false);
|
||||
notificationService.reportJavaException(ex, user, request);
|
||||
ex.printStackTrace();
|
||||
return new RestErrors(ex.getMessage(),Severity.SEVERE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,96 @@
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.LabelCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.MapCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestLabel;
|
||||
import com.wisemapping.rest.model.RestLabelList;
|
||||
import com.wisemapping.rest.model.RestMindmapInfo;
|
||||
import com.wisemapping.rest.model.RestMindmapList;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.LabelService;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.validator.LabelValidator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class LabelController extends BaseController {
|
||||
|
||||
@Qualifier("labelService")
|
||||
@Autowired
|
||||
private LabelService labelService;
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/labels", consumes = {"application/json", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.CREATED)
|
||||
public void createLabel(@RequestBody RestLabel restLabel, @NotNull HttpServletResponse response, @RequestParam(required = false) String title) throws WiseMappingException {
|
||||
// Overwrite title if it was specified by parameter.
|
||||
if (title != null && !title.isEmpty()) {
|
||||
restLabel.setTitle(title);
|
||||
}
|
||||
|
||||
// Validate ...
|
||||
validate(restLabel);
|
||||
|
||||
final Label label = createLabel(restLabel);
|
||||
|
||||
// Return the new created label ...
|
||||
response.setHeader("Location", "/service/labels/" + label.getId());
|
||||
response.setHeader("ResourceId", Integer.toString(label.getId()));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/labels", produces = {"application/json", "application/xml"})
|
||||
public RestLabelList retrieveList() {
|
||||
final User user = Utils.getUser();
|
||||
assert user != null;
|
||||
final List<Label> all = labelService.getAll(user);
|
||||
return new RestLabelList(all);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/labels/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void deleteLabelById(@PathVariable int id) throws WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final Label label = labelService.getLabelById(id, user);
|
||||
if (label == null) {
|
||||
throw new LabelCouldNotFoundException("Label could not be found. Id: " + id);
|
||||
}
|
||||
assert user != null;
|
||||
labelService.removeLabel(label, user);
|
||||
}
|
||||
|
||||
@NotNull private Label createLabel(@NotNull final RestLabel restLabel) throws WiseMappingException {
|
||||
final Label label = restLabel.getDelegated();
|
||||
// Add new label ...
|
||||
final User user = Utils.getUser();
|
||||
assert user != null;
|
||||
labelService.addLabel(label, user);
|
||||
return label;
|
||||
}
|
||||
|
||||
private void validate(@NotNull final RestLabel restLabel) throws ValidationException {
|
||||
final BindingResult result = new BeanPropertyBindingResult(restLabel, "");
|
||||
new LabelValidator(labelService).validate(restLabel.getDelegated(), result);
|
||||
if (result.hasErrors()) {
|
||||
throw new ValidationException(result);
|
||||
}
|
||||
}
|
||||
}
|
@@ -18,20 +18,41 @@
|
||||
|
||||
package com.wisemapping.rest;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.*;
|
||||
import com.mangofactory.swagger.annotations.ApiIgnore;
|
||||
import com.wisemapping.exceptions.ImportUnexpectedException;
|
||||
import com.wisemapping.exceptions.LabelCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.MapCouldNotFoundException;
|
||||
import com.wisemapping.exceptions.MultipleSessionsOpenException;
|
||||
import com.wisemapping.exceptions.SessionExpiredException;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.importer.ImportFormat;
|
||||
import com.wisemapping.importer.Importer;
|
||||
import com.wisemapping.importer.ImporterException;
|
||||
import com.wisemapping.importer.ImporterFactory;
|
||||
import com.wisemapping.model.*;
|
||||
import com.wisemapping.rest.model.*;
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.CollaborationProperties;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.MindMapHistory;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestCollaboration;
|
||||
import com.wisemapping.rest.model.RestCollaborationList;
|
||||
import com.wisemapping.rest.model.RestLabel;
|
||||
import com.wisemapping.rest.model.RestMindmap;
|
||||
import com.wisemapping.rest.model.RestMindmapHistory;
|
||||
import com.wisemapping.rest.model.RestMindmapHistoryList;
|
||||
import com.wisemapping.rest.model.RestMindmapInfo;
|
||||
import com.wisemapping.rest.model.RestMindmapList;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.CollaborationException;
|
||||
import com.wisemapping.service.LabelService;
|
||||
import com.wisemapping.service.LockInfo;
|
||||
import com.wisemapping.service.LockManager;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.validator.MapInfoValidator;
|
||||
import com.wordnik.swagger.annotations.Api;
|
||||
import com.wordnik.swagger.annotations.ApiParam;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -39,15 +60,28 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@Api(value = "mindmap", description = "User Mindmap Objects.")
|
||||
@Controller
|
||||
public class MindmapController extends BaseController {
|
||||
|
||||
@@ -56,20 +90,22 @@ public class MindmapController extends BaseController {
|
||||
@Autowired
|
||||
private MindmapService mindmapService;
|
||||
|
||||
@Qualifier("labelService")
|
||||
@Autowired
|
||||
private LabelService labelService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/json", "application/xml", "text/html"})
|
||||
@ResponseBody
|
||||
public ModelAndView retrieve(@PathVariable int id) throws WiseMappingException {
|
||||
public RestMindmap retrieve(@PathVariable int id) throws WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final Mindmap mindMap = mindmapService.findMindmapById(id);
|
||||
final RestMindmap map = new RestMindmap(mindMap, user);
|
||||
|
||||
return new ModelAndView("mapView", "map", map);
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
return new RestMindmap(mindMap, user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/wisemapping+xml"}, params = {"download=wxml"})
|
||||
@ResponseBody
|
||||
public ModelAndView retrieveAsWise(@PathVariable int id) throws WiseMappingException {
|
||||
final Mindmap mindMap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
final Map<String, Object> values = new HashMap<String, Object>();
|
||||
|
||||
final User user = Utils.getUser();
|
||||
@@ -80,16 +116,56 @@ public class MindmapController extends BaseController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/freemind"}, params = {"download=mm"})
|
||||
@ResponseBody
|
||||
public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id) throws IOException {
|
||||
final Mindmap mindMap = mindmapService.findMindmapById(id);
|
||||
public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id) throws IOException, MapCouldNotFoundException {
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
final Map<String, Object> values = new HashMap<String, Object>();
|
||||
values.put("content", mindMap.getXmlStr());
|
||||
values.put("filename", mindMap.getTitle());
|
||||
return new ModelAndView("transformViewFreemind", values);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/", produces = {"application/json", "text/html", "application/xml"})
|
||||
public ModelAndView retrieveList(@RequestParam(required = false) String q) throws IOException {
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"text/plain"}, params = {"download=txt"})
|
||||
@ResponseBody
|
||||
public ModelAndView retrieveDocumentAsText(@PathVariable int id) throws IOException, MapCouldNotFoundException {
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
final Map<String, Object> values = new HashMap<String, Object>();
|
||||
values.put("content", mindMap.getXmlStr());
|
||||
values.put("filename", mindMap.getTitle());
|
||||
return new ModelAndView("transformViewTxt", values);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/vnd.mindjet.mindmanager"}, params = {"download=mmap"})
|
||||
@ResponseBody
|
||||
public ModelAndView retrieveDocumentAsMindJet(@PathVariable int id) throws IOException, MapCouldNotFoundException {
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
final Map<String, Object> values = new HashMap<String, Object>();
|
||||
values.put("content", mindMap.getXmlStr());
|
||||
values.put("filename", mindMap.getTitle());
|
||||
return new ModelAndView("transformViewMMap", values);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/vnd.ms-excel"}, params = {"download=xls"})
|
||||
@ResponseBody
|
||||
public ModelAndView retrieveDocumentAsExcel(@PathVariable int id) throws IOException, MapCouldNotFoundException {
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
final Map<String, Object> values = new HashMap<String, Object>();
|
||||
values.put("content", mindMap.getXmlStr());
|
||||
values.put("filename", mindMap.getTitle());
|
||||
return new ModelAndView("transformViewXls", values);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/vnd.oasis.opendocument.text"}, params = {"download=odt"})
|
||||
@ResponseBody
|
||||
public ModelAndView retrieveDocumentAsOdt(@PathVariable int id) throws IOException, MapCouldNotFoundException {
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
final Map<String, Object> values = new HashMap<String, Object>();
|
||||
values.put("content", mindMap.getXmlStr());
|
||||
values.put("filename", mindMap.getTitle());
|
||||
return new ModelAndView("transformViewOdt", values);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/", produces = {"application/json", "application/xml"})
|
||||
public RestMindmapList retrieveList(@RequestParam(required = false) String q) throws IOException {
|
||||
final User user = Utils.getUser();
|
||||
|
||||
final MindmapFilter filter = MindmapFilter.parse(q);
|
||||
@@ -102,26 +178,23 @@ public class MindmapController extends BaseController {
|
||||
mindmaps.add(mindmap);
|
||||
}
|
||||
}
|
||||
final RestMindmapList restMindmapList = new RestMindmapList(mindmaps, user);
|
||||
return new ModelAndView("mapsView", "list", restMindmapList);
|
||||
return new RestMindmapList(mindmaps, user);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/history", produces = {"application/json", "text/html", "application/xml"})
|
||||
public ModelAndView retrieveHistory(@PathVariable int id) throws IOException {
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/history", produces = {"application/json", "application/xml"})
|
||||
public RestMindmapHistoryList retrieveHistory(@PathVariable int id) throws IOException {
|
||||
final List<MindMapHistory> histories = mindmapService.findMindmapHistory(id);
|
||||
final RestMindmapHistoryList result = new RestMindmapHistoryList();
|
||||
for (MindMapHistory history : histories) {
|
||||
result.addHistory(new RestMindmapHistory(history));
|
||||
}
|
||||
return new ModelAndView("historyView", "list", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "maps/{id}/history/{hid}", method = RequestMethod.POST)
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateRevertMindmap(@PathVariable int id, @PathVariable String hid) throws WiseMappingException, IOException {
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
if (LATEST_HISTORY_REVISION.equals(hid)) {
|
||||
@@ -129,7 +202,7 @@ public class MindmapController extends BaseController {
|
||||
List<MindMapHistory> mindmapHistory = mindmapService.findMindmapHistory(id);
|
||||
if (mindmapHistory.size() > 0) {
|
||||
final MindMapHistory mindMapHistory = mindmapHistory.get(0);
|
||||
mindmap.setZippedXml(mindMapHistory.getXml());
|
||||
mindmap.setZippedXml(mindMapHistory.getZippedXml());
|
||||
saveMindmapDocument(true, mindmap, user);
|
||||
}
|
||||
} else {
|
||||
@@ -137,11 +210,11 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "application/xml"})
|
||||
@ResponseBody
|
||||
public long updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor, @RequestParam(required = false) Long timestamp, @RequestParam(required = false) Long session) throws WiseMappingException, IOException {
|
||||
public Long updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor, @RequestParam(required = false) Long timestamp, @RequestParam(required = false) Long session) throws WiseMappingException, IOException {
|
||||
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
// Validate arguments ...
|
||||
@@ -151,14 +224,16 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
|
||||
// Could the map be updated ?
|
||||
verifyLock(mindmap, user, session, timestamp);
|
||||
if (session != null) {
|
||||
verifyLock(mindmap, user, session, timestamp);
|
||||
}
|
||||
|
||||
// Update collaboration properties ...
|
||||
final CollaborationProperties collaborationProperties = mindmap.findCollaborationProperties(user);
|
||||
collaborationProperties.setMindmapProperties(properties);
|
||||
|
||||
// Validate content ...
|
||||
final String xml = restMindmap.getXml();
|
||||
String xml = restMindmap.getXml();
|
||||
if (xml == null) {
|
||||
throw new IllegalArgumentException("Map xml can not be null");
|
||||
}
|
||||
@@ -169,29 +244,51 @@ public class MindmapController extends BaseController {
|
||||
|
||||
// Update edition timeout ...
|
||||
final LockManager lockManager = mindmapService.getLockManager();
|
||||
final LockInfo lockInfo = lockManager.updateExpirationTimeout(mindmap, user);
|
||||
return lockInfo.getTimestamp();
|
||||
long result = -1;
|
||||
if (session != null) {
|
||||
final LockInfo lockInfo = lockManager.updateExpirationTimeout(mindmap, user);
|
||||
result = lockInfo.getTimestamp();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/maps/{id}/document/xml","/maps/{id}/document/xml-pub"},consumes = {"text/plain"}, produces = {"application/xml"})
|
||||
@ApiIgnore
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/maps/{id}/document/xml", "/maps/{id}/document/xml-pub"}, consumes = {"text/plain"}, produces = {"application/xml"})
|
||||
@ResponseBody
|
||||
public byte[] retrieveDocument(@PathVariable int id, @NotNull HttpServletResponse response) throws WiseMappingException, IOException {
|
||||
// I should not return byte, but there is some encoding issue here. Further research needed.
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(id);
|
||||
return mindmap.getXmlStr().getBytes("UTF-8");
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
|
||||
String xmlStr = mindmap.getXmlStr();
|
||||
return xmlStr.getBytes("UTF-8");
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/maps/{id}/{hid}/document/xml"},consumes = {"text/plain"}, produces = {"application/xml"})
|
||||
@ApiIgnore
|
||||
@RequestMapping(method = RequestMethod.PUT, value = {"/maps/{id}/document/xml"}, consumes = {"text/plain"})
|
||||
@ResponseBody
|
||||
public byte[] retrieveDocument(@PathVariable int id, @PathVariable int hid,@NotNull HttpServletResponse response) throws WiseMappingException, IOException {
|
||||
public void updateDocument(@PathVariable int id, @RequestBody String xmlDoc) throws WiseMappingException, IOException {
|
||||
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
if (xmlDoc != null && !xmlDoc.isEmpty()) {
|
||||
mindmap.setXmlStr(xmlDoc);
|
||||
}
|
||||
|
||||
mindmap.setXmlStr(xmlDoc);
|
||||
saveMindmapDocument(false,mindmap,user);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/maps/{id}/{hid}/document/xml"}, consumes = {"text/plain"}, produces = {"application/xml"})
|
||||
@ResponseBody
|
||||
public byte[] retrieveDocument(@PathVariable int id, @PathVariable int hid, @NotNull HttpServletResponse response) throws WiseMappingException, IOException {
|
||||
// I should not return byte, but there is some encoding issue here. Further research needed.
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
final MindMapHistory mindmapHistory = mindmapService.findMindmapHistory(id, hid);
|
||||
return mindmapHistory.getUnzipXml();
|
||||
}
|
||||
|
||||
|
||||
private void verifyLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws WiseMappingException {
|
||||
|
||||
// The lock was lost, reclaim as the ownership of it.
|
||||
@@ -222,15 +319,15 @@ public class MindmapController extends BaseController {
|
||||
/**
|
||||
* The intention of this method is the update of several properties at once ...
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}", consumes = {"application/xml", "application/json"}, produces = {"application/json", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void update(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||
public void updateProperties(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
final String xml = restMindmap.getXml();
|
||||
if (xml != null) {
|
||||
if (xml != null && !xml.isEmpty()) {
|
||||
mindmap.setXmlStr(xml);
|
||||
}
|
||||
|
||||
@@ -265,12 +362,20 @@ public class MindmapController extends BaseController {
|
||||
saveMindmapDocument(minor, mindmap, user);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Mindmap findMindmapById(int id) throws MapCouldNotFoundException {
|
||||
Mindmap result = mindmapService.findMindmapById(id);
|
||||
if (result == null) {
|
||||
throw new MapCouldNotFoundException("Map could not be found. Id:" + id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/title", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/title", consumes = {"text/plain"}, produces = {"application/json", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateTitle(@RequestBody String title, @PathVariable int id) throws WiseMappingException {
|
||||
|
||||
final Mindmap mindMap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
// Is there a map with the same name ?
|
||||
@@ -280,15 +385,15 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
|
||||
// Update map ...
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
mindmap.setTitle(title);
|
||||
mindmapService.updateMindmap(mindMap, !true);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs", consumes = {"application/json", "application/xml"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs", consumes = {"application/json", "application/xml"}, produces = {"application/json", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException {
|
||||
final Mindmap mindMap = mindmapService.findMindmapById(id);
|
||||
public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException {
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
|
||||
// Only owner can change collaborators...
|
||||
final User user = Utils.getUser();
|
||||
@@ -325,10 +430,9 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/collabs", produces = {"application/json", "text/html", "application/xml"})
|
||||
public ModelAndView retrieveList(@PathVariable int id) {
|
||||
final Mindmap mindMap = mindmapService.findMindmapById(id);
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/collabs", produces = {"application/json", "application/xml"})
|
||||
public RestCollaborationList retrieveList(@PathVariable int id) throws MapCouldNotFoundException {
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
|
||||
final Set<Collaboration> collaborations = mindMap.getCollaborations();
|
||||
final List<RestCollaboration> collabs = new ArrayList<RestCollaboration>();
|
||||
@@ -336,31 +440,30 @@ public class MindmapController extends BaseController {
|
||||
collabs.add(new RestCollaboration(collaboration));
|
||||
}
|
||||
|
||||
final RestCollaborationList restCollaborationList = new RestCollaborationList();
|
||||
restCollaborationList.setCollaborations(collabs);
|
||||
final RestCollaborationList result = new RestCollaborationList();
|
||||
result.setCollaborations(collabs);
|
||||
|
||||
return new ModelAndView("collabsView", "list", restCollaborationList);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/description", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/description", consumes = {"text/plain"}, produces = {"application/json", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateDescription(@RequestBody String description, @PathVariable int id) throws WiseMappingException {
|
||||
|
||||
final Mindmap mindMap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
// Update map ...
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
mindmap.setDescription(description);
|
||||
mindmapService.updateMindmap(mindMap, !true);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/publish", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/publish", consumes = {"text/plain"}, produces = {"application/json", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updatePublishState(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
|
||||
|
||||
final Mindmap mindMap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
|
||||
final User user = Utils.getUser();
|
||||
if (!mindMap.hasPermissions(user, CollaborationRole.OWNER)) {
|
||||
@@ -377,15 +480,15 @@ public class MindmapController extends BaseController {
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void deleteMapById(@PathVariable int id) throws IOException, WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
mindmapService.removeMindmap(mindmap, user);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/starred", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/starred", consumes = {"text/plain"}, produces = {"application/json", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateStarredState(@RequestBody String value, @PathVariable int id) throws WiseMappingException {
|
||||
public void updateStarredState(@RequestBody @ApiParam(defaultValue = "false", allowableValues = "true,false") String value, @PathVariable int id) throws WiseMappingException {
|
||||
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
// Update map status ...
|
||||
@@ -398,12 +501,13 @@ public class MindmapController extends BaseController {
|
||||
mindmapService.updateCollaboration(user, collaboration);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/lock", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@ApiIgnore
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/lock", consumes = {"text/plain"}, produces = {"application/json", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateMapLock(@RequestBody String value, @PathVariable int id) throws IOException, WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final LockManager lockManager = mindmapService.getLockManager();
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
|
||||
final boolean lock = Boolean.parseBoolean(value);
|
||||
if (!lock) {
|
||||
@@ -413,13 +517,14 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/maps/batch")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void batchDelete(@RequestParam(required = true) String ids) throws IOException, WiseMappingException {
|
||||
final User user = Utils.getUser();
|
||||
final String[] mapsIds = ids.split(",");
|
||||
for (final String mapId : mapsIds) {
|
||||
final Mindmap mindmap = mindmapService.findMindmapById(Integer.parseInt(mapId));
|
||||
final Mindmap mindmap = findMindmapById(Integer.parseInt(mapId));
|
||||
mindmapService.removeMindmap(mindmap, user);
|
||||
}
|
||||
}
|
||||
@@ -481,7 +586,7 @@ public class MindmapController extends BaseController {
|
||||
createMap(new RestMindmap(mindMap, null), response, title, description);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"})
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"},produces = {"application/xml", "application/json","text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.CREATED)
|
||||
public void createDuplicate(@RequestBody RestMindmapInfo restMindmap, @PathVariable int id, @NotNull HttpServletResponse response) throws IOException, WiseMappingException {
|
||||
// Validate ...
|
||||
@@ -495,7 +600,7 @@ public class MindmapController extends BaseController {
|
||||
final User user = Utils.getUser();
|
||||
|
||||
// Create a shallowCopy of the map ...
|
||||
final Mindmap mindMap = mindmapService.findMindmapById(id);
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
final Mindmap clonedMap = mindMap.shallowClone();
|
||||
clonedMap.setTitle(restMindmap.getTitle());
|
||||
clonedMap.setDescription(restMindmap.getDescription());
|
||||
@@ -520,4 +625,37 @@ public class MindmapController extends BaseController {
|
||||
result.rejectValue(fieldName, "error.not-specified", null, message);
|
||||
return new ValidationException(result);
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/labels/maps/{id}")
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void removeLabel(@RequestBody RestLabel restLabel, @PathVariable int id) throws WiseMappingException {
|
||||
final Mindmap mindmap = findMindmapById(id);
|
||||
final User currentUser = Utils.getUser();
|
||||
final Label delegated = restLabel.getDelegated();
|
||||
assert currentUser != null;
|
||||
delegated.setCreator(currentUser);
|
||||
mindmapService.removeLabel(mindmap, delegated);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/labels/maps", consumes = { "application/xml","application/json"})
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public void addLabel(@RequestBody RestLabel restLabel, @RequestParam(required = true) String ids) throws WiseMappingException {
|
||||
int labelId = restLabel.getId();
|
||||
final User user = Utils.getUser();
|
||||
final Label delegated = restLabel.getDelegated();
|
||||
delegated.setCreator(user);
|
||||
final Label found = labelService.getLabelById(labelId, user);
|
||||
if (found == null) {
|
||||
throw new LabelCouldNotFoundException("Label could not be found. Id: " + labelId);
|
||||
}
|
||||
for (String id : ids.split(",")) {
|
||||
final int mindmapId = Integer.parseInt(id);
|
||||
final Mindmap mindmap = findMindmapById(mindmapId);
|
||||
final Label label = mindmap.findLabel(labelId);
|
||||
if (label == null) {
|
||||
mindmapService.linkLabel(mindmap, delegated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -25,57 +25,77 @@ import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public enum MindmapFilter {
|
||||
ALL("all") {
|
||||
public abstract class MindmapFilter {
|
||||
|
||||
public static final MindmapFilter ALL = new MindmapFilter("all") {
|
||||
@Override
|
||||
public boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return true;
|
||||
}
|
||||
|
||||
},
|
||||
MY_MAPS("my_maps") {
|
||||
};
|
||||
public static final MindmapFilter MY_MAPS = new MindmapFilter("my_maps") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return mindmap.getCreator().identityEquality(user);
|
||||
}
|
||||
},
|
||||
STARRED("starred") {
|
||||
};
|
||||
public static final MindmapFilter STARRED = new MindmapFilter("starred") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return mindmap.isStarred(user);
|
||||
}
|
||||
},
|
||||
SHARED_WITH_ME("shared_with_me") {
|
||||
};
|
||||
public static final MindmapFilter SHARED_WITH_ME = new MindmapFilter("shared_with_me") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return !MY_MAPS.accept(mindmap, user);
|
||||
}
|
||||
},
|
||||
PUBLIC("public") {
|
||||
};
|
||||
public static final MindmapFilter PUBLIC = new MindmapFilter("public") {
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return mindmap.isPublic();
|
||||
}
|
||||
};
|
||||
|
||||
private String id;
|
||||
protected String id;
|
||||
private static MindmapFilter[] values = {ALL, MY_MAPS, PUBLIC, STARRED, SHARED_WITH_ME};
|
||||
|
||||
MindmapFilter(@NotNull String id) {
|
||||
private MindmapFilter(@NotNull String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
static public MindmapFilter parse(@Nullable String valueStr) {
|
||||
MindmapFilter result = ALL;
|
||||
final MindmapFilter[] values = MindmapFilter.values();
|
||||
for (MindmapFilter value : values) {
|
||||
if (value.id.equals(valueStr)) {
|
||||
result = value;
|
||||
break;
|
||||
static public MindmapFilter parse(@Nullable final String valueStr) {
|
||||
MindmapFilter result = null;
|
||||
if (valueStr != null) {
|
||||
for (MindmapFilter value : MindmapFilter.values) {
|
||||
if (value.id.equals(valueStr)) {
|
||||
result = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// valueStr is not a default filter
|
||||
if (result == null) {
|
||||
result = new LabelFilter(valueStr);
|
||||
}
|
||||
} else {
|
||||
result = ALL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
abstract boolean accept(@NotNull Mindmap mindmap, @NotNull User user);
|
||||
|
||||
private static final class LabelFilter extends MindmapFilter {
|
||||
|
||||
private LabelFilter(@NotNull String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean accept(@NotNull Mindmap mindmap, @NotNull User user) {
|
||||
return mindmap.hasLabel(this.id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -131,7 +131,9 @@ public class TransformerController extends BaseController {
|
||||
throw new IllegalArgumentException("Unsupported export format");
|
||||
|
||||
}
|
||||
result.getModelMap().put("filename", filename);
|
||||
if (filename != null) {
|
||||
result.getModelMap().put("filename", filename);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ public class ValidationException extends WiseMappingException{
|
||||
private Errors errors;
|
||||
|
||||
public ValidationException(@NotNull Errors errors) {
|
||||
super("Validation Exceptions");
|
||||
super("Validation Exceptions:"+errors);
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,84 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
import com.wisemapping.model.Label;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
|
||||
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
|
||||
|
||||
@XmlRootElement(name = "label")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = NONE,
|
||||
setterVisibility = PUBLIC_ONLY,
|
||||
isGetterVisibility = NONE,
|
||||
getterVisibility = PUBLIC_ONLY
|
||||
)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RestLabel {
|
||||
|
||||
@JsonIgnore
|
||||
private Label label;
|
||||
|
||||
public RestLabel() {
|
||||
this(new Label());
|
||||
}
|
||||
|
||||
public RestLabel(@NotNull final Label label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public void setParent(@NotNull final Label parent) {
|
||||
this.label.setParent(parent);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Label getParent() {
|
||||
return this.label.getParent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return this.label.getTitle();
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return label.getId();
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
label.setId(id);
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
label.setTitle(title);
|
||||
}
|
||||
|
||||
public void setColor(@NotNull final String color) {
|
||||
label.setColor(color);
|
||||
}
|
||||
|
||||
public void setIconName(@NotNull final String iconName) {
|
||||
label.setIconName(iconName);
|
||||
}
|
||||
|
||||
@Nullable public String getColor() {
|
||||
return label.getColor();
|
||||
}
|
||||
|
||||
@Nullable public String getIconName() {
|
||||
return label.getIconName();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Label getDelegated() {
|
||||
return label;
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
import com.wisemapping.model.Label;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
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.List;
|
||||
|
||||
@XmlRootElement(name = "labels")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
public class RestLabelList {
|
||||
|
||||
@NotNull private final List<RestLabel> restLabels;
|
||||
|
||||
public RestLabelList(){
|
||||
this.restLabels = new ArrayList<>();
|
||||
}
|
||||
|
||||
public RestLabelList(@NotNull final List<Label> labels) {
|
||||
this.restLabels = new ArrayList<>(labels.size());
|
||||
for (Label label : labels) {
|
||||
this.restLabels.add(new RestLabel(label));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull @XmlElement(name = "label")
|
||||
public List<RestLabel> getLabels() {
|
||||
return restLabels;
|
||||
}
|
||||
|
||||
}
|
@@ -20,18 +20,23 @@ package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.*;
|
||||
import com.wisemapping.model.CollaborationProperties;
|
||||
import com.wisemapping.model.CollaborationRole;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.util.TimeUtils;
|
||||
import org.codehaus.jackson.annotate.*;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@XmlRootElement(name = "map")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@@ -65,6 +70,9 @@ public class RestMindmap {
|
||||
}
|
||||
}
|
||||
|
||||
public void setCreationTime(final String creationTime){
|
||||
// Ignore
|
||||
}
|
||||
|
||||
public String getCreationTime() {
|
||||
final Calendar creationTime = mindmap.getCreationTime();
|
||||
@@ -79,22 +87,43 @@ public class RestMindmap {
|
||||
return mindmap.getDescription();
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
mindmap.setDescription(description);
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
return mindmap.getTags();
|
||||
}
|
||||
|
||||
public void setTags(String tags) {
|
||||
mindmap.setTags(tags);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return mindmap.getTitle();
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
mindmap.setTitle(title);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return mindmap.getId();
|
||||
}
|
||||
|
||||
public String getCreator() {
|
||||
return mindmap.getCreator().getEmail();
|
||||
public void setId(int id) {
|
||||
mindmap.setId(id);
|
||||
}
|
||||
|
||||
public String getCreator() {
|
||||
final User creator = mindmap.getCreator();
|
||||
return creator != null ? creator.getEmail() : null;
|
||||
}
|
||||
|
||||
public void setCreator(String creatorUser) {
|
||||
}
|
||||
|
||||
|
||||
public RestCollaborator getLastModifierUser() {
|
||||
final User lastEditor = mindmap.getLastEditor();
|
||||
|
||||
@@ -105,6 +134,9 @@ public class RestMindmap {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setLastModifierUser(RestUser lastModifierUser) {
|
||||
}
|
||||
|
||||
public String getLastModificationTime() {
|
||||
final Calendar date = mindmap.getLastModificationTime();
|
||||
String result = null;
|
||||
@@ -114,11 +146,13 @@ public class RestMindmap {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setLastModificationTime(final String value) {
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return mindmap.isPublic();
|
||||
}
|
||||
|
||||
|
||||
public void setPublic(boolean value) {
|
||||
// return mindmap.isPublic();
|
||||
}
|
||||
@@ -127,50 +161,19 @@ public class RestMindmap {
|
||||
return mindmap.getXmlStr();
|
||||
}
|
||||
|
||||
|
||||
public void setXml(@Nullable String xml) throws IOException {
|
||||
|
||||
if (xml != null)
|
||||
mindmap.setXmlStr(xml);
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
mindmap.setId(id);
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
mindmap.setTitle(title);
|
||||
}
|
||||
|
||||
public void setTags(String tags) {
|
||||
mindmap.setTags(tags);
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
mindmap.setDescription(description);
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
final User owner = mindmap.getCreator();
|
||||
return owner != null ? owner.getEmail() : null;
|
||||
}
|
||||
|
||||
public void setCreator(String creatorUser) {
|
||||
}
|
||||
public void setOwner(String owner) {
|
||||
|
||||
|
||||
public void setProperties(@Nullable String properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public void setLastModificationTime(final String value) {
|
||||
}
|
||||
|
||||
public void setLastModifierUser(String lastModifierUser) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -178,6 +181,10 @@ public class RestMindmap {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(@Nullable String properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public boolean getStarred() {
|
||||
boolean result = false;
|
||||
if (collaborator != null) {
|
||||
|
@@ -21,21 +21,24 @@ package com.wisemapping.rest.model;
|
||||
|
||||
import com.wisemapping.model.Collaboration;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.util.TimeUtils;
|
||||
import org.codehaus.jackson.annotate.*;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@XmlRootElement(name = "map")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@@ -62,28 +65,63 @@ public class RestMindmapInfo {
|
||||
this.collaborator = collaborator;
|
||||
}
|
||||
|
||||
public void setCreationTime(String value){
|
||||
// Ignore
|
||||
}
|
||||
|
||||
public String getCreationTime() {
|
||||
return TimeUtils.toISO8601(mindmap.getCreationTime().getTime());
|
||||
final Calendar creationTime = mindmap.getCreationTime();
|
||||
return creationTime != null ? TimeUtils.toISO8601(creationTime.getTime()) : null;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return mindmap.getDescription();
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
mindmap.setDescription(description);
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
return mindmap.getTags();
|
||||
}
|
||||
|
||||
public void setTags(String tags) {
|
||||
mindmap.setTags(tags);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return mindmap.getTitle();
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
mindmap.setTitle(title);
|
||||
}
|
||||
public Set<RestLabel> getLabels() {
|
||||
final Set<RestLabel> result = new LinkedHashSet<>();
|
||||
final User me = Utils.getUser();
|
||||
for (Label label : mindmap.getLabels()) {
|
||||
if (label.getCreator().equals(me)) {
|
||||
result.add(new RestLabel(label));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return mindmap.getId();
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
}
|
||||
|
||||
public String getCreator() {
|
||||
return mindmap.getCreator().getFullName();
|
||||
final User creator = mindmap.getCreator();
|
||||
return creator!=null?creator.getFullName():null;
|
||||
}
|
||||
|
||||
public void setCreator(String email) {
|
||||
|
||||
}
|
||||
|
||||
public void setCreator() {
|
||||
@@ -95,7 +133,7 @@ public class RestMindmapInfo {
|
||||
return collaboration != null ? collaboration.getRole().getLabel() : "none";
|
||||
}
|
||||
|
||||
public void setRole() {
|
||||
public void setRole(String value) {
|
||||
// Do nothing ...
|
||||
}
|
||||
|
||||
@@ -104,48 +142,29 @@ public class RestMindmapInfo {
|
||||
return user != null ? user.getFullName() : "unknown";
|
||||
}
|
||||
|
||||
public void setLastModifierUser(String value) {
|
||||
}
|
||||
|
||||
public String getLastModificationTime() {
|
||||
final Calendar calendar = mindmap.getLastModificationTime();
|
||||
return TimeUtils.toISO8601(calendar.getTime());
|
||||
return calendar!=null?TimeUtils.toISO8601(calendar.getTime()):null;
|
||||
}
|
||||
|
||||
public void setLastModificationTime(String value) {
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return mindmap.isPublic();
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
}
|
||||
|
||||
public boolean getStarred() {
|
||||
return mindmap.isStarred(collaborator);
|
||||
}
|
||||
|
||||
public void setStarred(int value) {
|
||||
public void setStarred(boolean value) {
|
||||
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
mindmap.setTitle(title);
|
||||
}
|
||||
|
||||
public void setTags(String tags) {
|
||||
mindmap.setTags(tags);
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
mindmap.setDescription(description);
|
||||
}
|
||||
|
||||
public void setCreator(String email) {
|
||||
|
||||
}
|
||||
|
||||
public void setLastModificationTime(String value) {
|
||||
}
|
||||
|
||||
public void setLastModifierUser(String value) {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Mindmap getDelegated() {
|
||||
return this.mindmap;
|
||||
|
@@ -48,7 +48,7 @@ public class RestMindmapList {
|
||||
}
|
||||
|
||||
public RestMindmapList(@NotNull List<Mindmap> mindmaps, @NotNull Collaborator collaborator) {
|
||||
this.mindmapsInfo = new ArrayList<RestMindmapInfo>();
|
||||
this.mindmapsInfo = new ArrayList<>(mindmaps.size());
|
||||
for (Mindmap mindMap : mindmaps) {
|
||||
this.mindmapsInfo.add(new RestMindmapInfo(mindMap, collaborator));
|
||||
}
|
||||
|
@@ -31,6 +31,8 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Calendar;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
|
||||
@XmlRootElement(name = "user")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(
|
||||
|
@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImportTransformationView extends AbstractView {
|
||||
@@ -53,15 +54,32 @@ public class ImportTransformationView extends AbstractView {
|
||||
final InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
|
||||
final Mindmap mindMap = importer.importMap("filename", "filename", is);
|
||||
|
||||
// Set file name...
|
||||
// Set file name...:http://stackoverflow.com/questions/5325322/java-servlet-download-filename-special-characters/13359949#13359949
|
||||
final String fileName = (filename != null ? filename : "map") + "." + "xwise";
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
||||
setContentDisposition(request, response, fileName);
|
||||
|
||||
// Write the conversion content ...
|
||||
final ServletOutputStream outputStream = response.getOutputStream();
|
||||
outputStream.print(mindMap.getXmlStr());
|
||||
}
|
||||
|
||||
private void setContentDisposition(HttpServletRequest request, HttpServletResponse response, String fileName) {
|
||||
final String userAgent = request.getHeader("user-agent");
|
||||
String disposition = fileName;
|
||||
boolean isInternetExplorer = (userAgent.contains("MSIE"));
|
||||
try {
|
||||
byte[] fileNameBytes = fileName.getBytes((isInternetExplorer) ? ("windows-1250") : ("utf-8"));
|
||||
String dispositionFileName = "";
|
||||
for (byte b : fileNameBytes) {
|
||||
dispositionFileName += (char) (b & 0xff);
|
||||
}
|
||||
disposition = "attachment; filename=\"" + dispositionFileName + "\"";
|
||||
} catch (UnsupportedEncodingException ence) {
|
||||
// ... handle exception ...
|
||||
}
|
||||
response.setHeader("Content-disposition", disposition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
|
@@ -33,6 +33,7 @@ import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
|
||||
public class TransformView extends AbstractView {
|
||||
@@ -67,9 +68,9 @@ public class TransformView extends AbstractView {
|
||||
final String contentType = exportFormat.getContentType();
|
||||
response.setContentType(contentType);
|
||||
|
||||
// Set file name...
|
||||
// Set file name...:http://stackoverflow.com/questions/5325322/java-servlet-download-filename-special-characters/13359949#13359949
|
||||
final String fileName = (filename != null ? filename : "map") + "." + exportFormat.getFileExtension();
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
||||
setContentDisposition(request, response, fileName);
|
||||
|
||||
// Change image link URL.
|
||||
final ServletContext servletContext = request.getSession().getServletContext();
|
||||
@@ -85,6 +86,9 @@ public class TransformView extends AbstractView {
|
||||
final Object mindmap = viewMap.get("mindmap");
|
||||
final StreamResult result = new StreamResult(outputStream);
|
||||
jaxbMarshaller.marshal(mindmap, result);
|
||||
} else if (exportFormat == ExportFormat.MICROSOFT_EXCEL || exportFormat == ExportFormat.TEXT || exportFormat == ExportFormat.OPEN_OFFICE_WRITER || exportFormat == ExportFormat.MINDJET) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
factory.export(properties, content, outputStream, null);
|
||||
} else {
|
||||
factory.export(properties, null, outputStream, content);
|
||||
}
|
||||
@@ -93,6 +97,24 @@ public class TransformView extends AbstractView {
|
||||
}
|
||||
}
|
||||
|
||||
private void setContentDisposition(HttpServletRequest request, HttpServletResponse response, String fileName) {
|
||||
final String userAgent = request.getHeader("user-agent");
|
||||
boolean isInternetExplorer = (userAgent.contains("MSIE"));
|
||||
|
||||
String disposition = fileName;
|
||||
try {
|
||||
byte[] fileNameBytes = fileName.getBytes((isInternetExplorer) ? ("windows-1250") : ("utf-8"));
|
||||
String dispositionFileName = "";
|
||||
for (byte b : fileNameBytes) {
|
||||
dispositionFileName += (char) (b & 0xff);
|
||||
}
|
||||
disposition = "attachment; filename=\"" + dispositionFileName + "\"";
|
||||
} catch (UnsupportedEncodingException ence) {
|
||||
// ... handle exception ...
|
||||
}
|
||||
response.setHeader("Content-disposition", disposition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
|
@@ -19,6 +19,8 @@
|
||||
package com.wisemapping.security;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.service.UserService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -26,17 +28,22 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.openid.OpenIDAttribute;
|
||||
import org.springframework.security.openid.OpenIDAuthenticationToken;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class UserDetailsService
|
||||
implements org.springframework.security.core.userdetails.UserDetailsService {
|
||||
implements org.springframework.security.core.userdetails.UserDetailsService, org.springframework.security.core.userdetails.AuthenticationUserDetailsService<OpenIDAuthenticationToken> {
|
||||
private UserService userService;
|
||||
private String adminUser;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(@NotNull String email) throws UsernameNotFoundException, DataAccessException {
|
||||
final User user = userService.getUserBy(email);
|
||||
|
||||
|
||||
if (user != null) {
|
||||
return new UserDetails(user, isAdmin(email));
|
||||
} else {
|
||||
@@ -44,6 +51,77 @@ public class UserDetailsService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public UserDetails loadUserDetails(@NotNull OpenIDAuthenticationToken token) throws UsernameNotFoundException {
|
||||
|
||||
final User tUser = buildUserFromToken(token);
|
||||
final User dbUser = userService.getUserBy(tUser.getEmail());
|
||||
|
||||
final User result;
|
||||
if (dbUser != null) {
|
||||
if (!token.getIdentityUrl().equals(dbUser.getAuthenticatorUri())) {
|
||||
throw new IllegalStateException("Identity url for this user can not change:" + token.getIdentityUrl());
|
||||
}
|
||||
result = dbUser;
|
||||
} else {
|
||||
try {
|
||||
tUser.setAuthenticationType(AuthenticationType.OPENID);
|
||||
tUser.setAuthenticatorUri(token.getIdentityUrl());
|
||||
|
||||
result = userService.createUser(tUser, false, false);
|
||||
} catch (WiseMappingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
}
|
||||
return new UserDetails(result, isAdmin(result.getEmail()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private User buildUserFromToken(@NotNull OpenIDAuthenticationToken token) {
|
||||
final User result = new User();
|
||||
|
||||
String lastName = null;
|
||||
String firstName = null;
|
||||
String email = null;
|
||||
String fullName = null;
|
||||
|
||||
final List<OpenIDAttribute> attributes = token.getAttributes();
|
||||
for (OpenIDAttribute attribute : attributes) {
|
||||
if (attribute.getName().equals("email")) {
|
||||
email = attribute.getValues().get(0);
|
||||
}
|
||||
|
||||
if (attribute.getName().equals("firstname")) {
|
||||
firstName = attribute.getValues().get(0);
|
||||
|
||||
}
|
||||
|
||||
if (attribute.getName().equals("lastname")) {
|
||||
lastName = attribute.getValues().get(0);
|
||||
}
|
||||
|
||||
if (attribute.getName().equals("fullname")) {
|
||||
fullName = attribute.getValues().get(0);
|
||||
}
|
||||
|
||||
}
|
||||
if (lastName == null || firstName == null) {
|
||||
result.setFirstname(fullName);
|
||||
result.setLastname("");
|
||||
} else {
|
||||
result.setLastname(lastName);
|
||||
result.setFirstname(firstName);
|
||||
}
|
||||
result.setEmail(email);
|
||||
result.setPassword("");
|
||||
|
||||
final Calendar now = Calendar.getInstance();
|
||||
result.setActivationDate(now);
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isAdmin(@Nullable String email) {
|
||||
return email != null && adminUser != null && email.trim().endsWith(adminUser);
|
||||
}
|
||||
@@ -63,4 +141,5 @@ public class UserDetailsService
|
||||
public void setAdminUser(String adminUser) {
|
||||
this.adminUser = adminUser;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,23 +21,20 @@ package com.wisemapping.security;
|
||||
import com.wisemapping.model.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
final public class Utils {
|
||||
private Utils() {
|
||||
}
|
||||
|
||||
@SuppressWarnings({"ConstantConditions"})
|
||||
@NotNull
|
||||
@Nullable
|
||||
public static User getUser() {
|
||||
return getUser(false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
public static User getUser(boolean forceCheck) {
|
||||
User result = null;
|
||||
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
@@ -24,6 +24,7 @@ import com.wisemapping.model.User;
|
||||
import com.wisemapping.exceptions.AccessDeniedSecurityException;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.MindmapServiceImpl;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -36,12 +37,12 @@ public abstract class BaseSecurityAdvice {
|
||||
boolean isAllowed;
|
||||
|
||||
if (argument instanceof Mindmap) {
|
||||
isAllowed = isAllowed(user, (Mindmap) argument);
|
||||
isAllowed = isAllowed(user, (Mindmap) argument) || mindmapService.isAdmin(user);
|
||||
} else if (argument instanceof Integer) {
|
||||
isAllowed = isAllowed(user, ((Integer) argument));
|
||||
isAllowed = isAllowed(user, ((Integer) argument)) || mindmapService.isAdmin(user);
|
||||
} else if (argument instanceof Collaborator) {
|
||||
// Read operation find on the user are allowed ...
|
||||
isAllowed = user.identityEquality((Collaborator) argument);
|
||||
isAllowed = user.identityEquality((Collaborator) argument) || mindmapService.isAdmin(user);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Argument " + argument);
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package com.wisemapping.security.ldap;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.AuthenticationType;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.UserDetails;
|
||||
import com.wisemapping.service.UserService;
|
||||
@@ -19,6 +20,8 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
||||
|
||||
private UserService userService;
|
||||
private String adminUser;
|
||||
private String ldapAttributeFirstName;
|
||||
private String ldapAttributeLastName;
|
||||
|
||||
|
||||
public UserService getUserService() {
|
||||
@@ -51,10 +54,10 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
||||
user = new User();
|
||||
user.setEmail(email);
|
||||
|
||||
final String firstName = userData.getStringAttribute("givenName");
|
||||
final String firstName = userData.getStringAttribute(ldapAttributeFirstName);
|
||||
user.setFirstname(firstName);
|
||||
|
||||
final String lastName = userData.getStringAttribute("sn");
|
||||
final String lastName = userData.getStringAttribute(ldapAttributeLastName);
|
||||
user.setLastname(lastName);
|
||||
|
||||
user.setPassword(email);
|
||||
@@ -62,7 +65,8 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
||||
user.setActivationDate(now);
|
||||
|
||||
try {
|
||||
userService.createUser(user, false,false);
|
||||
user.setAuthenticationType(AuthenticationType.LDAP);
|
||||
user = userService.createUser(user, false, false);
|
||||
} catch (WiseMappingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
@@ -70,6 +74,22 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
||||
return new UserDetails(user, isAdmin(email));
|
||||
}
|
||||
|
||||
public String getLdapAttributeLastName() {
|
||||
return ldapAttributeLastName;
|
||||
}
|
||||
|
||||
public void setLdapAttributeLastName(String ldapAttributLastName) {
|
||||
this.ldapAttributeLastName = ldapAttributLastName;
|
||||
}
|
||||
|
||||
public String getLdapAttrbutFirstName() {
|
||||
return ldapAttributeFirstName;
|
||||
}
|
||||
|
||||
public void setLdapAttributeFirstName(String ldapAttributeFirstName) {
|
||||
this.ldapAttributeFirstName = ldapAttributeFirstName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapUserToContext(org.springframework.security.core.userdetails.UserDetails userDetails, DirContextAdapter dirContextAdapter) {
|
||||
// To be implemented ...
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user