mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Change symblink to moootols
Add editor issue.
This commit is contained in:
parent
9f0557b851
commit
f52f01a6b1
@ -64,8 +64,6 @@
|
|||||||
<include>
|
<include>
|
||||||
${basedir}/../mindplot/src/main/javascript/libraries/moodialog/MooDialog.Fx.js
|
${basedir}/../mindplot/src/main/javascript/libraries/moodialog/MooDialog.Fx.js
|
||||||
</include>
|
</include>
|
||||||
<include>${basedir}/target/tmp/footer-min.js</include>
|
|
||||||
|
|
||||||
</includes>
|
</includes>
|
||||||
</aggregation>
|
</aggregation>
|
||||||
</aggregations>
|
</aggregations>
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2011] [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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//// Init default logger level ...
|
|
||||||
//var wLogger = new Log4js.getLogger("WiseMapping");
|
|
||||||
//wLogger.setLevel(Log4js.Level.ALL);
|
|
||||||
////wLogger.addAppender(new Log4js.BrowserConsoleAppender());
|
|
||||||
//
|
|
||||||
//// Is logger service available ?
|
|
||||||
//if ($defined(window.LoggerService))
|
|
||||||
//{
|
|
||||||
// Log4js.WiseServerAppender = function()
|
|
||||||
// {
|
|
||||||
// this.layout = new Log4js.SimpleLayout();
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// Log4js.WiseServerAppender.prototype = Log4js.extend(new Log4js.Appender(), {
|
|
||||||
// /**
|
|
||||||
// * @see Log4js.Appender#doAppend
|
|
||||||
// */
|
|
||||||
// doAppend: function(loggingEvent) {
|
|
||||||
// try {
|
|
||||||
// var message = this.layout.format(loggingEvent);
|
|
||||||
// var level = this.levelCode(loggingEvent);
|
|
||||||
//
|
|
||||||
// window.LoggerService.logError(level, message);
|
|
||||||
//
|
|
||||||
// } catch (e) {
|
|
||||||
// alert(e);
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * toString
|
|
||||||
// */
|
|
||||||
// toString: function() {
|
|
||||||
// return "Log4js.WiseServerAppender";
|
|
||||||
// },
|
|
||||||
//
|
|
||||||
// levelCode: function(loggingEvent)
|
|
||||||
// {
|
|
||||||
// var retval;
|
|
||||||
// switch (loggingEvent.level) {
|
|
||||||
// case Log4js.Level.FATAL:
|
|
||||||
// retval = 3;
|
|
||||||
// break;
|
|
||||||
// case Log4js.Level.ERROR:
|
|
||||||
// retval = 3;
|
|
||||||
// break;
|
|
||||||
// case Log4js.Level.WARN:
|
|
||||||
// retval = 2;
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// retval = 1;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return retval;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// wLogger.addAppender(new Log4js.WiseServerAppender());
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
|
|
||||||
//// Handle error events ...
|
|
||||||
//window.onerror = function(sMsg, sUrl, sLine)
|
|
||||||
//{
|
|
||||||
// window.hasUnexpectedErrors = true;
|
|
||||||
// var msg = sMsg + ' (' + sUrl + ', line ' + sLine + ')';
|
|
||||||
// wLogger.fatal(msg);
|
|
||||||
//
|
|
||||||
// $(window).fireEvent("error",null,0);
|
|
||||||
// return false;
|
|
||||||
//};
|
|
@ -22,7 +22,7 @@ var Overlay = new Class({
|
|||||||
|
|
||||||
options: {
|
options: {
|
||||||
id: 'overlay',
|
id: 'overlay',
|
||||||
color: '#000',
|
color: '#000000',
|
||||||
duration: 500,
|
duration: 500,
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
zIndex: 5000/*,
|
zIndex: 5000/*,
|
||||||
|
@ -191,7 +191,7 @@ mindplot.widget.Menu = new Class({
|
|||||||
this._registerTooltip('fontColor', "Text color");
|
this._registerTooltip('fontColor', "Text color");
|
||||||
|
|
||||||
|
|
||||||
this._addButton('export', false, false, "Export", function() {
|
this._addButton('export', false, false, function() {
|
||||||
var reqDialog = new MooDialog.Request('c/export.htm?mapId=' + mapId, null,
|
var reqDialog = new MooDialog.Request('c/export.htm?mapId=' + mapId, null,
|
||||||
{'class': 'exportModalDialog',
|
{'class': 'exportModalDialog',
|
||||||
closeButton:true,
|
closeButton:true,
|
||||||
|
117
wise-editor/src/main/webapp/c/map/export.htm
Normal file
117
wise-editor/src/main/webapp/c/map/export.htm
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<div class="modalDialog">
|
||||||
|
<h1>Export</h1>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<form method="POST" id="exportForm" name="exportForm" action="http://localhost:8080/service/transform"
|
||||||
|
style="height:100%;" enctype="application/x-www-form-urlencoded">
|
||||||
|
<input name="svgXml" value="" type="hidden"/>
|
||||||
|
<input name="mapXml" value="" type="hidden"/>
|
||||||
|
<input name="filename" value="welcome" type="hidden"/>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="radio" id="svg" name="exportFormat" value="svg">
|
||||||
|
<b> Scalable Vector Graphics (SVG)</b>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Scalable Vector Graphics (SVG) is an XML markup language for describing two-dimensional
|
||||||
|
vector graphics. This format will enable you to print your maps without quality lost at any
|
||||||
|
resolution.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="radio" name="exportFormat" value="PDF" id="pdf">
|
||||||
|
<b>Portable Document Format (PDF)</b>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Get your map as Portable Document Format(PDF) to share use in your presentations.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="radio" id="freemind" name="exportFormat" value="FREEMIND" checked="checked">
|
||||||
|
<b>Freemind (version 0.9.0)</b>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
FreeMind is a nice desktop mind mapping application that has the great benefit of being
|
||||||
|
free.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="radio" name="exportFormat" id="img" value="IMG_EXPORT_FORMAT">
|
||||||
|
<b>Image File</b>
|
||||||
|
<select name="imgFormat" id="imgFormat" style="visibility:hidden;margin-left:5px;">
|
||||||
|
<option>PNG</option>
|
||||||
|
<option>JPEG</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Get a graphic representation of your map including all colors and shapes to reuse in
|
||||||
|
documents or for archiving
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="text-align:center;margin-top:10px;">
|
||||||
|
<input type="button" id="ok" value="Ok" class="btn-primary">
|
||||||
|
<input type="button" value="Cancel" class="btn-secondary"
|
||||||
|
onclick="MooDialog.Request.active.close();">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$('img').addEvent('click', function(event) {
|
||||||
|
$('imgFormat').setStyle('visibility', 'visible');
|
||||||
|
});
|
||||||
|
$('pdf').addEvent('click', function(event) {
|
||||||
|
$('imgFormat').setStyle('visibility', 'hidden');
|
||||||
|
});
|
||||||
|
$('svg').addEvent('click', function(event) {
|
||||||
|
$('imgFormat').setStyle('visibility', 'hidden');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('ok').addEvent('click', function(event) {
|
||||||
|
|
||||||
|
var form = $('exportForm');
|
||||||
|
|
||||||
|
// Look for the selected format and append export suffix...
|
||||||
|
var value = $$('input[name=exportFormat]:checked')[0].get('value');
|
||||||
|
var suffix;
|
||||||
|
if (value == 'IMG_EXPORT_FORMAT') {
|
||||||
|
var selected = $('imgFormat');
|
||||||
|
suffix = selected.options[selected.selectedIndex].value;
|
||||||
|
} else {
|
||||||
|
suffix = value;
|
||||||
|
}
|
||||||
|
suffix = suffix.toLowerCase();
|
||||||
|
form.action = form.action + "." + suffix;
|
||||||
|
|
||||||
|
// Store SVG o native map...
|
||||||
|
if (suffix == "freemind") {
|
||||||
|
var mindmap = designer.getMindmap();
|
||||||
|
var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||||
|
var domMap = serializer.toXML(mindmap);
|
||||||
|
form.mapXml.value = core.Utils.innerXML(domMap);
|
||||||
|
} else {
|
||||||
|
form.svgXml.value = $("workspaceContainer").innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, submit map ...
|
||||||
|
form.submit();
|
||||||
|
|
||||||
|
|
||||||
|
MooDialog.Request.active.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
@ -26,13 +26,15 @@ function buildDesigner(options) {
|
|||||||
// Register load events ...
|
// Register load events ...
|
||||||
designer = new mindplot.Designer(options, container);
|
designer = new mindplot.Designer(options, container);
|
||||||
designer.addEvent('loadSuccess', function() {
|
designer.addEvent('loadSuccess', function() {
|
||||||
window.waitDialog.close();
|
window.waitDialog.close.delay(1000,window.waitDialog);
|
||||||
window.waitDialog.destroy();
|
window.waitDialog = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
window.onerror = function(e) {
|
window.onerror = function(e) {
|
||||||
window.waitDialog.close();
|
if (window.waitDialog) {
|
||||||
window.waitDialog.destroy();
|
window.waitDialog.close.delay(1000,window.waitDialog);
|
||||||
|
window.waitDialog = null;
|
||||||
|
}
|
||||||
errorDialog.show();
|
errorDialog.show();
|
||||||
console.log(e);
|
console.log(e);
|
||||||
};
|
};
|
||||||
@ -117,12 +119,12 @@ editor.WaitDialog = new Class({
|
|||||||
duration: 100,
|
duration: 100,
|
||||||
transition: Fx.Transitions.Bounce.easeOut
|
transition: Fx.Transitions.Bounce.easeOut
|
||||||
});
|
});
|
||||||
this.overlay = new Overlay(this.options.inject, {
|
|
||||||
duration: this.options.duration
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onBeforeOpen: function() {
|
onBeforeOpen: function() {
|
||||||
|
this.overlay = new Overlay(this.options.inject, {
|
||||||
|
duration: this.options.duration
|
||||||
|
});
|
||||||
this.overlay.open();
|
this.overlay.open();
|
||||||
this.fx.start({
|
this.fx.start({
|
||||||
'margin-top': [-200, -100],
|
'margin-top': [-200, -100],
|
||||||
@ -142,7 +144,6 @@ editor.WaitDialog = new Class({
|
|||||||
}).chain(function() {
|
}).chain(function() {
|
||||||
this.fireEvent('hide');
|
this.fireEvent('hide');
|
||||||
this.wrapper.setStyle('display', 'none');
|
this.wrapper.setStyle('display', 'none');
|
||||||
this.overlay.destroy();
|
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}}
|
}}
|
||||||
@ -163,6 +164,11 @@ editor.WaitDialog = new Class({
|
|||||||
|
|
||||||
show : function() {
|
show : function() {
|
||||||
this.open();
|
this.open();
|
||||||
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
this.parent();
|
||||||
|
this.overlay.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -211,7 +217,6 @@ editor.FatalErrorDialog = new Class({
|
|||||||
}).chain(function() {
|
}).chain(function() {
|
||||||
this.wrapper.setStyle('display', 'none');
|
this.wrapper.setStyle('display', 'none');
|
||||||
this.fireEvent('hide');
|
this.fireEvent('hide');
|
||||||
this.overlay.destroy();
|
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}}
|
}}
|
||||||
@ -219,6 +224,11 @@ editor.FatalErrorDialog = new Class({
|
|||||||
this.setContent(panel);
|
this.setContent(panel);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
this.parent();
|
||||||
|
this.overlay.destroy();
|
||||||
|
},
|
||||||
|
|
||||||
_buildPanel : function () {
|
_buildPanel : function () {
|
||||||
var result = new Element('div');
|
var result = new Element('div');
|
||||||
result.setStyles({
|
result.setStyles({
|
||||||
|
@ -38,17 +38,6 @@ public abstract class BaseMultiActionController
|
|||||||
private MindmapService mindmapService;
|
private MindmapService mindmapService;
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
protected List<MindmapUser> getMindmapUsersFromRequest(HttpServletRequest request) {
|
|
||||||
List<MindmapUser> result = new ArrayList<MindmapUser>();
|
|
||||||
final String mindmapIds = request.getParameter("mindmapIds");
|
|
||||||
|
|
||||||
final String ids[] = mindmapIds.split(",");
|
|
||||||
for (String id : ids)
|
|
||||||
if (mindmapIds.length()!=0){
|
|
||||||
result.add(getMindmapUser(Integer.parseInt(id), request));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<MindMap> getMindmapsFromRequest(HttpServletRequest request) {
|
protected List<MindMap> getMindmapsFromRequest(HttpServletRequest request) {
|
||||||
List<MindMap> result = new ArrayList<MindMap>();
|
List<MindMap> result = new ArrayList<MindMap>();
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
package com.wisemapping.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
|
||||||
import com.wisemapping.model.User;
|
|
||||||
import com.wisemapping.rest.BaseController;
|
|
||||||
import com.wisemapping.rest.model.RestUser;
|
|
||||||
import com.wisemapping.service.UserService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class ExportController extends BaseController {
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/json", "text/html", "application/xml"})
|
|
||||||
@ResponseBody
|
|
||||||
public ModelAndView getUserById(@PathVariable 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "admin/users/email/{email}", produces = {"application/json", "text/html", "application/xml"})
|
|
||||||
@ResponseBody
|
|
||||||
public ModelAndView 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "admin/users/username/{username}", produces = {"application/json", "text/html", "application/xml"})
|
|
||||||
@ResponseBody
|
|
||||||
public ModelAndView getUserByUsername(@PathVariable String username) throws IOException {
|
|
||||||
final User user = userService.getUserByUsername(username);
|
|
||||||
if (user == null) {
|
|
||||||
throw new IllegalArgumentException("User '" + username + "' could not be found");
|
|
||||||
}
|
|
||||||
return new ModelAndView("userView", "user", new RestUser(user));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "admin/users", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
|
||||||
@ResponseStatus(value = HttpStatus.CREATED)
|
|
||||||
public void createUser(@RequestBody RestUser user, HttpServletResponse response) throws IOException, WiseMappingException {
|
|
||||||
if (user == null) {
|
|
||||||
throw new IllegalArgumentException("User could not be found");
|
|
||||||
}
|
|
||||||
|
|
||||||
// User already exists ?
|
|
||||||
final String email = user.getEmail();
|
|
||||||
if (userService.getUserBy(email) != null) {
|
|
||||||
throw new IllegalArgumentException("User already exists with this email.");
|
|
||||||
}
|
|
||||||
|
|
||||||
final String username = user.getUsername();
|
|
||||||
if (username == null || username.isEmpty()) {
|
|
||||||
throw new IllegalArgumentException("username can not be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userService.getUserByUsername(username) != null) {
|
|
||||||
throw new IllegalArgumentException("User already exists with this username.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run some other validations ...
|
|
||||||
final User delegated = user.getDelegated();
|
|
||||||
final String lastname = delegated.getLastname();
|
|
||||||
if (lastname == null || lastname.isEmpty()) {
|
|
||||||
throw new IllegalArgumentException("lastname can not be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
final String firstName = delegated.getFirstname();
|
|
||||||
if (firstName == null || firstName.isEmpty()) {
|
|
||||||
throw new IllegalArgumentException("firstname can not be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally create the user ...
|
|
||||||
userService.createUser(delegated, false);
|
|
||||||
response.setHeader("Location", "/service/admin/users/" + user.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 IOException, WiseMappingException {
|
|
||||||
if (password == null) {
|
|
||||||
throw new IllegalArgumentException("Password can not be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
final User user = userService.getUserBy(id);
|
|
||||||
if (user == null) {
|
|
||||||
throw new IllegalArgumentException("User '" + id + "' could not be found");
|
|
||||||
}
|
|
||||||
user.setPassword(password);
|
|
||||||
userService.changePassword(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.DELETE)
|
|
||||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
|
||||||
public void getUserByEmail(@PathVariable long id) throws IOException, WiseMappingException {
|
|
||||||
final User user = userService.getUserBy(id);
|
|
||||||
if (user == null) {
|
|
||||||
throw new IllegalArgumentException("User '" + id + "' could not be found");
|
|
||||||
}
|
|
||||||
userService.deleteUser(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2011] [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.controller;
|
|
||||||
|
|
||||||
import com.wisemapping.model.MindMap;
|
|
||||||
import com.wisemapping.model.MindmapUser;
|
|
||||||
import com.wisemapping.model.User;
|
|
||||||
import com.wisemapping.security.Utils;
|
|
||||||
import com.wisemapping.view.MindMapBean;
|
|
||||||
import com.wisemapping.filter.UserAgent;
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MindmapController extends BaseMultiActionController {
|
|
||||||
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
|
|
||||||
return list(httpServletRequest, httpServletResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView list(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
logger.info("Mindmap Controller: myMindmap action");
|
|
||||||
final HttpSession session = request.getSession(false);
|
|
||||||
|
|
||||||
// Try to loaded from the request ...
|
|
||||||
UserAgent userAgent = null;
|
|
||||||
if (session != null) {
|
|
||||||
userAgent = (UserAgent) session.getAttribute(USER_AGENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// I could not loaded. I will create a new one...
|
|
||||||
if (userAgent == null) {
|
|
||||||
userAgent = UserAgent.create(request);
|
|
||||||
if (session != null) {
|
|
||||||
session.setAttribute(USER_AGENT, userAgent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// It's a supported browser ?.
|
|
||||||
final UserAgent.OS os = userAgent.getOs();
|
|
||||||
|
|
||||||
final User user = Utils.getUser(request);
|
|
||||||
final ModelAndView view = new ModelAndView("mindmapList", "wisemapsList", getMindMapBeanList(user));
|
|
||||||
view.addObject("isMAC", os == UserAgent.OS.MAC);
|
|
||||||
view.addObject("user", user);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView edit(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
logger.info("Mindmap Controller: EDIT action");
|
|
||||||
final MindMap mindmap = getMindmapFromRequest(request);
|
|
||||||
return new ModelAndView("mindmapEditor", "wisemapsList", new MindMapBean(mindmap));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView collaborator(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
logger.info("Mindmap Controller: COLLABORATE action");
|
|
||||||
final MindMap mindmap = getMindmapFromRequest(request);
|
|
||||||
return new ModelAndView("mindmapCollaborator", "mindmap", new MindMapBean(mindmap));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView viewer(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
logger.info("Mindmap Controller: VIEWER action");
|
|
||||||
final MindMap mindmap = getMindmapFromRequest(request);
|
|
||||||
return new ModelAndView("mindmapViewer", "wisemapsList", new MindMapBean(mindmap));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView delete(HttpServletRequest request, HttpServletResponse response) throws WiseMappingException {
|
|
||||||
logger.info("Mindmap Controller: DELETE action");
|
|
||||||
final User user = Utils.getUser(request);
|
|
||||||
|
|
||||||
final MindMap mindmap = getMindmapFromRequest(request);
|
|
||||||
getMindmapService().removeCollaboratorFromMindmap(mindmap, user.getId());
|
|
||||||
|
|
||||||
return list(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView deleteAll(HttpServletRequest request, HttpServletResponse response) throws WiseMappingException {
|
|
||||||
logger.info("Mindmap Controller: DELETE ALL action");
|
|
||||||
|
|
||||||
final List<MindmapUser> mindmaps = getMindmapUsersFromRequest(request);
|
|
||||||
final User user = Utils.getUser(request);
|
|
||||||
for (MindmapUser mindmap : mindmaps)
|
|
||||||
getMindmapService().removeMindmap(mindmap.getMindMap(), user);
|
|
||||||
return list(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView detail(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
logger.info("Mindmap Controller: DETAIL action");
|
|
||||||
final MindMap mindMap = getMindmapFromRequest(request);
|
|
||||||
final ModelAndView view = new ModelAndView("mindmapDetail", "wisemapDetail", new MindMapBean(mindMap));
|
|
||||||
view.addObject("user", Utils.getUser());
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView changeStatus(HttpServletRequest request, HttpServletResponse response) throws WiseMappingException {
|
|
||||||
final MindMap mindmap = getMindmapFromRequest(request);
|
|
||||||
boolean isPublic = !mindmap.isPublic();
|
|
||||||
mindmap.setPublic(isPublic);
|
|
||||||
getMindmapService().updateMindmap(mindmap, false);
|
|
||||||
return new ModelAndView("mindmapDetail", "wisemapDetail", new MindMapBean(mindmap));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView editMindmap(HttpServletRequest request, HttpServletResponse response) throws WiseMappingException {
|
|
||||||
final MindMap mindmap = getMindmapFromRequest(request);
|
|
||||||
final ModelAndView view = new ModelAndView("editMindmap", "mindmap", new MindMapBean(mindmap));
|
|
||||||
view.addObject("user", Utils.getUser());
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModelAndView updateMindmap(HttpServletRequest request, HttpServletResponse response) throws WiseMappingException {
|
|
||||||
final MindMap mindmap = getMindmapFromRequest(request);
|
|
||||||
|
|
||||||
final String title = request.getParameter("title");
|
|
||||||
final String description = request.getParameter("description");
|
|
||||||
|
|
||||||
mindmap.setTitle(title);
|
|
||||||
mindmap.setDescription(description);
|
|
||||||
|
|
||||||
getMindmapService().updateMindmap(mindmap, false);
|
|
||||||
return list(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String USER_AGENT = "wisemapping.userAgent";
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2011] [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.dwr;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
public class JavaScriptErrorLoggerService
|
|
||||||
{
|
|
||||||
final Log logger = LogFactory.getLog(JavaScriptErrorLoggerService.class);
|
|
||||||
private static final int ERROR_MESSAGE = 3;
|
|
||||||
private static final int FATAL_MESSAGE = 4;
|
|
||||||
private static final String USER_AGENT = "User-Agent";
|
|
||||||
|
|
||||||
JavaScriptErrorLoggerService() {
|
|
||||||
LogFactory.getLog(JavaScriptErrorLoggerService.class);
|
|
||||||
}
|
|
||||||
//~ Methods ..............................................................................................
|
|
||||||
|
|
||||||
public void logError(final int severity, final String logMsg)
|
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
// final User user = getUser();
|
|
||||||
|
|
||||||
|
|
||||||
// final String userAgent = request.getHeader(USER_AGENT);
|
|
||||||
// synchronized (logger) {
|
|
||||||
// // Log user info ...
|
|
||||||
// if (user != null) {
|
|
||||||
// log(severity, "UserId:" + user.getId() + ", UserEmail:" + user.getEmail());
|
|
||||||
// } else {
|
|
||||||
// log(severity, "Anonymous user");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Log browser details ...
|
|
||||||
// log(severity, "Browser:" + userAgent);
|
|
||||||
//
|
|
||||||
// // Log error message ...
|
|
||||||
// log(severity, logMsg);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
void log(final int severity, final String msg) {
|
|
||||||
// Log error message ...
|
|
||||||
if (severity == ERROR_MESSAGE && logger.isErrorEnabled()) {
|
|
||||||
logger.error(msg);
|
|
||||||
} else if (severity == FATAL_MESSAGE && logger.isFatalEnabled()) {
|
|
||||||
logger.fatal(msg);
|
|
||||||
} else if (logger.isInfoEnabled()) {
|
|
||||||
logger.info(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -222,7 +222,7 @@ public class MindMap {
|
|||||||
public static String getDefaultMindmapXml(@NotNull final String title) {
|
public static String getDefaultMindmapXml(@NotNull final String title) {
|
||||||
|
|
||||||
final StringBuilder result = new StringBuilder();
|
final StringBuilder result = new StringBuilder();
|
||||||
result.append("<result version='tango'>");
|
result.append("<map version=\"tango\">");
|
||||||
result.append("<topic central=\"true\" text=\"");
|
result.append("<topic central=\"true\" text=\"");
|
||||||
result.append(title);
|
result.append(title);
|
||||||
result.append("\"/></result>");
|
result.append("\"/></result>");
|
||||||
|
@ -131,4 +131,5 @@ public class User
|
|||||||
public void setUsername(String username) {
|
public void setUsername(String username) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,148 @@
|
|||||||
|
package com.wisemapping.ncontroller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
|
import com.wisemapping.filter.UserAgent;
|
||||||
|
import com.wisemapping.model.MindMap;
|
||||||
|
import com.wisemapping.model.MindmapUser;
|
||||||
|
import com.wisemapping.model.User;
|
||||||
|
import com.wisemapping.security.Utils;
|
||||||
|
import com.wisemapping.service.MindmapService;
|
||||||
|
import com.wisemapping.view.MindMapBean;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/c/")
|
||||||
|
public class MindmapController {
|
||||||
|
@Autowired
|
||||||
|
private MindmapService mindmapService;
|
||||||
|
|
||||||
|
@RequestMapping(value = "export")
|
||||||
|
public ModelAndView export(@RequestParam(required = true) long mapId) throws IOException {
|
||||||
|
final MindMapBean modelObject = findMindmapBean(mapId);
|
||||||
|
return new ModelAndView("mindmapExport", "mindmap", modelObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "edit")
|
||||||
|
public ModelAndView edit(@RequestParam(required = true) long mapId) {
|
||||||
|
final MindMapBean modelObject = findMindmapBean(mapId);
|
||||||
|
return new ModelAndView("mindmapEditor", "wisemapsList", modelObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "collaborator")
|
||||||
|
public ModelAndView collaborator(@RequestParam(required = true) long mapId) {
|
||||||
|
final MindMapBean modelObject = findMindmapBean(mapId);
|
||||||
|
return new ModelAndView("mindmapCollaborator", "mindmap", modelObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "viewer")
|
||||||
|
public ModelAndView viewer(@RequestParam(required = true) long mapId) {
|
||||||
|
final MindMapBean modelObject = findMindmapBean(mapId);
|
||||||
|
return new ModelAndView("mindmapViewer", "wisemapsList", modelObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "detail")
|
||||||
|
public ModelAndView detail(@RequestParam(required = true) long mapId) {
|
||||||
|
final MindMapBean modelObject = findMindmapBean(mapId);
|
||||||
|
final ModelAndView view = new ModelAndView("mindmapDetail", "wisemapDetail", modelObject);
|
||||||
|
view.addObject("user", Utils.getUser());
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "changeStatus")
|
||||||
|
public ModelAndView changeStatus(@RequestParam(required = true) long mapId) throws WiseMappingException {
|
||||||
|
final MindMap mindmap = findMindmap(mapId);
|
||||||
|
boolean isPublic = !mindmap.isPublic();
|
||||||
|
mindmap.setPublic(isPublic);
|
||||||
|
mindmapService.updateMindmap(mindmap, false);
|
||||||
|
return new ModelAndView("mindmapDetail", "wisemapDetail", new MindMapBean(mindmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "editMindmap")
|
||||||
|
public ModelAndView editMindmap(@RequestParam(required = true) long mapId) throws WiseMappingException {
|
||||||
|
final MindMapBean mindmap = findMindmapBean(mapId);
|
||||||
|
final ModelAndView view = new ModelAndView("editMindmap", "mindmap", mindmap);
|
||||||
|
view.addObject("user", Utils.getUser());
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "mymaps")
|
||||||
|
public ModelAndView list(@NotNull HttpServletRequest request) {
|
||||||
|
final HttpSession session = request.getSession(false);
|
||||||
|
|
||||||
|
// Try to loaded from the request ...
|
||||||
|
UserAgent userAgent = null;
|
||||||
|
if (session != null) {
|
||||||
|
userAgent = (UserAgent) session.getAttribute(USER_AGENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// I could not loaded. I will create a new one...
|
||||||
|
if (userAgent == null) {
|
||||||
|
userAgent = UserAgent.create(request);
|
||||||
|
if (session != null) {
|
||||||
|
session.setAttribute(USER_AGENT, userAgent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's a supported browser ?.
|
||||||
|
final UserAgent.OS os = userAgent.getOs();
|
||||||
|
|
||||||
|
final User user = Utils.getUser();
|
||||||
|
final ModelAndView view = new ModelAndView("mindmapList", "wisemapsList", findMindMapBeanList(user));
|
||||||
|
view.addObject("isMAC", os == UserAgent.OS.MAC);
|
||||||
|
view.addObject("user", user);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "delete")
|
||||||
|
public ModelAndView delete(@RequestParam(required = true) long mapId, @NotNull HttpServletRequest request) throws WiseMappingException {
|
||||||
|
final User user = Utils.getUser();
|
||||||
|
final MindMap mindmap = findMindmap(mapId);
|
||||||
|
mindmapService.removeCollaboratorFromMindmap(mindmap, user.getId());
|
||||||
|
return list(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "updateMindmap")
|
||||||
|
public ModelAndView updateMindmap(@RequestParam(required = true) long mapId, @RequestParam(required = true) String title, @RequestParam(required = true) String description, @NotNull HttpServletRequest request) throws WiseMappingException {
|
||||||
|
final MindMap mindmap = findMindmap(mapId);
|
||||||
|
mindmap.setTitle(title);
|
||||||
|
mindmap.setDescription(description);
|
||||||
|
|
||||||
|
mindmapService.updateMindmap(mindmap, false);
|
||||||
|
return list(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MindMap findMindmap(long mapId) {
|
||||||
|
final MindMap mindmap = mindmapService.getMindmapById((int) mapId);
|
||||||
|
if (mindmap == null) {
|
||||||
|
throw new IllegalArgumentException("Mindmap could not be found");
|
||||||
|
}
|
||||||
|
return mindmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MindMapBean> findMindMapBeanList(@NotNull User user) {
|
||||||
|
final List<MindmapUser> userMindmaps = mindmapService.getMindmapUserByUser(user);
|
||||||
|
|
||||||
|
final List<MindMapBean> mindMapBeans = new ArrayList<MindMapBean>(userMindmaps.size());
|
||||||
|
for (MindmapUser mindmap : userMindmaps) {
|
||||||
|
mindMapBeans.add(new MindMapBean(mindmap.getMindMap()));
|
||||||
|
}
|
||||||
|
return mindMapBeans;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MindMapBean findMindmapBean(long mapId) {
|
||||||
|
return new MindMapBean(findMindmap(mapId));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String USER_AGENT = "wisemapping.userAgent";
|
||||||
|
}
|
@ -1,31 +0,0 @@
|
|||||||
package com.wisemapping.ncontroller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.wisemapping.model.User;
|
|
||||||
import com.wisemapping.rest.model.RestUser;
|
|
||||||
import com.wisemapping.service.UserService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class NMindmapController {
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/json", "text/html", "application/xml"})
|
|
||||||
@ResponseBody
|
|
||||||
public ModelAndView getUserById(@PathVariable 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));
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,43 +29,35 @@ import org.aopalliance.intercept.MethodInvocation;
|
|||||||
public abstract class BaseSecurityAdvice {
|
public abstract class BaseSecurityAdvice {
|
||||||
private MindmapService mindmapService = null;
|
private MindmapService mindmapService = null;
|
||||||
|
|
||||||
public void checkRole(MethodInvocation methodInvocation) throws UnexpectedArgumentException,AccessDeniedSecurityException
|
public void checkRole(MethodInvocation methodInvocation) throws UnexpectedArgumentException, AccessDeniedSecurityException {
|
||||||
{
|
|
||||||
final User user = Utils.getUser();
|
final User user = Utils.getUser();
|
||||||
|
|
||||||
final Object argument = methodInvocation.getArguments()[0];
|
final Object argument = methodInvocation.getArguments()[0];
|
||||||
|
|
||||||
boolean isAllowed;
|
boolean isAllowed;
|
||||||
|
|
||||||
if (argument instanceof MindMap)
|
if (argument instanceof MindMap) {
|
||||||
{
|
|
||||||
isAllowed = isAllowed(user, (MindMap) argument);
|
isAllowed = isAllowed(user, (MindMap) argument);
|
||||||
}
|
} else if (argument instanceof Integer) {
|
||||||
else if (argument instanceof Integer)
|
|
||||||
{
|
|
||||||
isAllowed = isAllowed(user, ((Integer) argument));
|
isAllowed = isAllowed(user, ((Integer) argument));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new UnexpectedArgumentException("Argument " + argument);
|
throw new UnexpectedArgumentException("Argument " + argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAllowed)
|
if (!isAllowed) {
|
||||||
{
|
throw new AccessDeniedSecurityException("User '" + user.getEmail() + "' not allowed to invoke:" + methodInvocation);
|
||||||
throw new AccessDeniedSecurityException("User not allowed to invoke:" + methodInvocation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean isAllowed(User user, MindMap map);
|
protected abstract boolean isAllowed(User user, MindMap map);
|
||||||
|
|
||||||
protected abstract boolean isAllowed(User user, int mapId);
|
protected abstract boolean isAllowed(User user, int mapId);
|
||||||
|
|
||||||
protected MindmapService getMindmapService()
|
protected MindmapService getMindmapService() {
|
||||||
{
|
|
||||||
return mindmapService;
|
return mindmapService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMindmapService(MindmapService service)
|
public void setMindmapService(MindmapService service) {
|
||||||
{
|
|
||||||
this.mindmapService = service;
|
this.mindmapService = service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,25 +23,23 @@ import org.aopalliance.intercept.MethodInvocation;
|
|||||||
import com.wisemapping.model.UserRole;
|
import com.wisemapping.model.UserRole;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
import com.wisemapping.model.MindMap;
|
import com.wisemapping.model.MindMap;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ViewBaseSecurityAdvise
|
public class ViewBaseSecurityAdvise
|
||||||
extends BaseSecurityAdvice
|
extends BaseSecurityAdvice
|
||||||
implements MethodInterceptor
|
implements MethodInterceptor {
|
||||||
{
|
|
||||||
private UserRole grantedRole = UserRole.VIEWER;
|
private UserRole grantedRole = UserRole.VIEWER;
|
||||||
|
|
||||||
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
|
public Object invoke(@NotNull MethodInvocation methodInvocation) throws Throwable {
|
||||||
checkRole(methodInvocation);
|
checkRole(methodInvocation);
|
||||||
return methodInvocation.proceed();
|
return methodInvocation.proceed();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAllowed(User user, MindMap map)
|
protected boolean isAllowed(User user, MindMap map) {
|
||||||
{
|
|
||||||
return getMindmapService().isAllowedToView(user, map, grantedRole);
|
return getMindmapService().isAllowedToView(user, map, grantedRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAllowed(User user, int mapId)
|
protected boolean isAllowed(User user, int mapId) {
|
||||||
{
|
|
||||||
return getMindmapService().isAllowedToView(user, mapId, grantedRole);
|
return getMindmapService().isAllowedToView(user, mapId, grantedRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,16 +47,15 @@ public class MindmapServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowedToView(User user, MindMap map, UserRole grantedRole) {
|
public boolean isAllowedToView(User user, MindMap map, UserRole grantedRole) {
|
||||||
boolean isAllowed = false;
|
boolean result = false;
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
|
|
||||||
if (map.isPublic()) {
|
if (map.isPublic()) {
|
||||||
isAllowed = true;
|
result = true;
|
||||||
} else if (user != null) {
|
} else if (user != null) {
|
||||||
isAllowed = isAllowedToCollaborate(user, map, grantedRole);
|
result = isAllowedToCollaborate(user, map, grantedRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isAllowed;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowedToCollaborate(@NotNull User user, @Nullable MindMap map, UserRole grantedRole) {
|
public boolean isAllowedToCollaborate(@NotNull User user, @Nullable MindMap map, UserRole grantedRole) {
|
||||||
|
@ -90,6 +90,7 @@
|
|||||||
<init-param>
|
<init-param>
|
||||||
<param-name>contextConfigLocation</param-name>
|
<param-name>contextConfigLocation</param-name>
|
||||||
<param-value>
|
<param-value>
|
||||||
|
/WEB-INF/wisemapping-nservlet.xml
|
||||||
/WEB-INF/wisemapping-servlet.xml
|
/WEB-INF/wisemapping-servlet.xml
|
||||||
</param-value>
|
</param-value>
|
||||||
</init-param>
|
</init-param>
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
<value>update*</value>
|
<value>update*</value>
|
||||||
<value>add*</value>
|
<value>add*</value>
|
||||||
<value>remove*</value>
|
<value>remove*</value>
|
||||||
<value>remove*</value>
|
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
91
wise-webapp/src/main/webapp/WEB-INF/wisemapping-nservlet.xml
Normal file
91
wise-webapp/src/main/webapp/WEB-INF/wisemapping-nservlet.xml
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||||
|
xsi:schemaLocation="
|
||||||
|
http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||||
|
http://www.springframework.org/schema/context
|
||||||
|
http://www.springframework.org/schema/context/spring-context-3.1.xsd
|
||||||
|
http://www.springframework.org/schema/mvc
|
||||||
|
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
|
||||||
|
|
||||||
|
<context:component-scan base-package="com.wisemapping.ncontroller"/>
|
||||||
|
<context:annotation-config/>
|
||||||
|
<mvc:annotation-driven/>
|
||||||
|
|
||||||
|
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||||
|
<property name="location" value="/WEB-INF/app.properties"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="exceptionHandlerResolver"
|
||||||
|
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
|
||||||
|
<property name="defaultStatusCode" value="500"/>
|
||||||
|
<property name="defaultErrorView" value="unexpectedError"/>
|
||||||
|
<property name="exceptionMappings">
|
||||||
|
<props>
|
||||||
|
<prop key="com.wisemapping.exceptions.UnsupportedBrowserException">browserNotSupported</prop>
|
||||||
|
<!-- Security exceptions are wrapped in this exceptions -->
|
||||||
|
<prop key="java.lang.reflect.UndeclaredThrowableException">securityError</prop>
|
||||||
|
<prop key="com.wisemapping.exceptions.EmailNotExistsException">emailNotExistsError</prop>
|
||||||
|
</props>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||||
|
<property name="viewClass" value="org.springframework.web.servlet.view.tiles.TilesJstlView"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles.TilesConfigurer">
|
||||||
|
<property name="definitions">
|
||||||
|
<list>
|
||||||
|
<value>/WEB-INF/defs/definitions.xml</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="localeResolver"
|
||||||
|
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
|
||||||
|
<property name="defaultLocale" value="en"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="localeChangeInterceptor"
|
||||||
|
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
|
||||||
|
<property name="paramName" value="language"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="reCaptcha" class="net.tanesha.recaptcha.ReCaptchaImpl">
|
||||||
|
<property name="privateKey" value="${registration.recaptcha.privateKey}"/>
|
||||||
|
<property name="publicKey" value="${registration.recaptcha.publicKey}"/>
|
||||||
|
<property name="includeNoscript" value="false"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="browserSupportInterceptor" class="com.wisemapping.filter.BrowserSupportInterceptor">
|
||||||
|
<property name="exclude">
|
||||||
|
<list>
|
||||||
|
<value>/</value>
|
||||||
|
<value>/index.jsp</value>
|
||||||
|
<value>/c/home.htm</value>
|
||||||
|
<value>/c/login.htm</value>
|
||||||
|
<value>/c/userRegistration.htm</value>
|
||||||
|
<value>/c/captcha.htm</value>
|
||||||
|
<value>/c/publicView.htm</value>
|
||||||
|
<value>/service/*</value>
|
||||||
|
<value>/c/search.htm</value>
|
||||||
|
<value>/c/keyboard.htm</value>
|
||||||
|
<value>/c/renameMap.htm</value>
|
||||||
|
<value>/c/embeddedView.htm</value>
|
||||||
|
<value>/c/forgotPassword.htm</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
||||||
|
<property name="basenames">
|
||||||
|
<list>
|
||||||
|
<value>messages</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
</beans>
|
@ -2,43 +2,6 @@
|
|||||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||||
|
|
||||||
<beans>
|
<beans>
|
||||||
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
|
||||||
<property name="location" value="/WEB-INF/app.properties"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="browserSupportInterceptor" class="com.wisemapping.filter.BrowserSupportInterceptor">
|
|
||||||
<property name="exclude">
|
|
||||||
<list>
|
|
||||||
<value>/</value>
|
|
||||||
<value>/index.jsp</value>
|
|
||||||
<value>/c/home.htm</value>
|
|
||||||
<value>/c/login.htm</value>
|
|
||||||
<value>/c/userRegistration.htm</value>
|
|
||||||
<value>/c/captcha.htm</value>
|
|
||||||
<value>/c/publicView.htm</value>
|
|
||||||
<value>/service/*</value>
|
|
||||||
<value>/c/search.htm</value>
|
|
||||||
<value>/c/keyboard.htm</value>
|
|
||||||
<value>/c/renameMap.htm</value>
|
|
||||||
<value>/c/embeddedView.htm</value>
|
|
||||||
<value>/c/forgotPassword.htm</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="exceptionHadlerResolver"
|
|
||||||
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
|
|
||||||
<property name="defaultStatusCode" value="500"/>
|
|
||||||
<property name="defaultErrorView" value="unexpectedError"/>
|
|
||||||
<property name="exceptionMappings">
|
|
||||||
<props>
|
|
||||||
<prop key="com.wisemapping.exceptions.UnsupportedBrowserException">browserNotSupported</prop>
|
|
||||||
<!-- Security exceptions are wrapped in this exceptions -->
|
|
||||||
<prop key="java.lang.reflect.UndeclaredThrowableException">securityError</prop>
|
|
||||||
<prop key="com.wisemapping.exceptions.EmailNotExistsException">emailNotExistsError</prop>
|
|
||||||
</props>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="paramResolverByAction"
|
<bean id="paramResolverByAction"
|
||||||
class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
|
class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
|
||||||
@ -50,19 +13,6 @@
|
|||||||
<property name="paramName" value="actionId"/>
|
<property name="paramName" value="actionId"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="mindmapController" class="com.wisemapping.controller.MindmapController">
|
|
||||||
<property name="methodNameResolver" ref="paramResolverByAction"/>
|
|
||||||
<property name="mindmapService" ref="mindmapService"/>
|
|
||||||
<property name="userService" ref="userService"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
|
||||||
<property name="basenames">
|
|
||||||
<list>
|
|
||||||
<value>messages</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!--<bean id="localeResolver"
|
<!--<bean id="localeResolver"
|
||||||
class="org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver">
|
class="org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver">
|
||||||
@ -286,7 +236,6 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="mappings">
|
<property name="mappings">
|
||||||
<props>
|
<props>
|
||||||
<prop key="/c/mymaps.htm">mindmapController</prop>
|
|
||||||
<prop key="/c/userRegistration.htm">userController</prop>
|
<prop key="/c/userRegistration.htm">userController</prop>
|
||||||
<prop key="/c/sharing.htm">sharingController</prop>
|
<prop key="/c/sharing.htm">sharingController</prop>
|
||||||
<prop key="/c/home.htm">homeController</prop>
|
<prop key="/c/home.htm">homeController</prop>
|
||||||
@ -312,32 +261,4 @@
|
|||||||
</props>
|
</props>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
|
||||||
<property name="viewClass" value="org.springframework.web.servlet.view.tiles.TilesJstlView"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles.TilesConfigurer">
|
|
||||||
<property name="definitions">
|
|
||||||
<list>
|
|
||||||
<value>/WEB-INF/defs/definitions.xml</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="localeResolver"
|
|
||||||
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
|
|
||||||
<property name="defaultLocale" value="en"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="localeChangeInterceptor"
|
|
||||||
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
|
|
||||||
<property name="paramName" value="language"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="reCaptcha" class="net.tanesha.recaptcha.ReCaptchaImpl">
|
|
||||||
<property name="privateKey" value="${registration.recaptcha.privateKey}"/>
|
|
||||||
<property name="publicKey" value="${registration.recaptcha.publicKey}"/>
|
|
||||||
<property name="includeNoscript" value="false"/>
|
|
||||||
</bean>
|
|
||||||
</beans>
|
</beans>
|
@ -1 +1 @@
|
|||||||
../../../../../mindplot/src/main/javascript/libraries/mootools/mootools-core-1.3.2-full-compress.js
|
../../../../../mindplot/src/main/javascript/libraries/mootools/mootools-core-1.4.5-full-nocompat-yc.js
|
@ -1 +1 @@
|
|||||||
../../../../../mindplot/src/main/javascript/libraries/mootools/mootools-more-1.3.2.1-yui.js
|
../../../../../mindplot/src/main/javascript/libraries/mootools/mootools-more-1.4.0.1.js
|
@ -1,7 +1,8 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
|
||||||
<%--@elvariable id="mindmap" type="com.wisemapping.model.MindMap"--%>
|
<%--@elvariable id="mindmap" type="com.wisemapping.model.MindMap"--%>
|
||||||
<%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%>
|
<%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%>
|
||||||
<%--@elvariable id="user" type="com.wisemapping.model.User"--%>
|
<%--@elvariable id="user" type="com.wisemapping.model.User"--%>
|
||||||
<!DOCTYPE HTML>
|
|
||||||
|
|
||||||
<%@ include file="/jsp/init.jsp" %>
|
<%@ include file="/jsp/init.jsp" %>
|
||||||
<c:url value="mymaps.htm" var="shareMap">
|
<c:url value="mymaps.htm" var="shareMap">
|
||||||
@ -11,10 +12,12 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<base href="../"/>
|
<base href="../"/>
|
||||||
|
<title><spring:message code="SITE.TITLE"/> - ${mindmap.title} </title>
|
||||||
|
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<title><spring:message code="SITE.TITLE"/> - ${mindmap.title} </title>
|
|
||||||
|
|
||||||
<link rel="stylesheet/less" type="text/css" href="css/editor.less"/>
|
<link rel="stylesheet/less" type="text/css" href="css/editor.less"/>
|
||||||
<script type='text/javascript' src='js/mootools-core.js'></script>
|
<script type='text/javascript' src='js/mootools-core.js'></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user