From 7b6cae0fd29ba049b8fbbaffc4bb9fa7745b27ce Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 21 Feb 2012 15:37:15 -0300 Subject: [PATCH] - Add missing changes. --- mindplot/pom.xml | 2 +- .../main/javascript/RestPersistenceManager.js | 140 +++-- mindplot/src/main/javascript/widget/IMenu.js | 2 +- wise-editor/src/main/webapp/js/editor.js | 477 +++++++++--------- .../main/java/com/wisemapping/model/User.java | 2 - .../security/AuthenticationProvider.java | 4 +- .../com/wisemapping/test/model/JsonTest.java | 9 +- .../src/test/sql/hsql/create-schemas.sql | 2 +- 8 files changed, 310 insertions(+), 328 deletions(-) diff --git a/mindplot/pom.xml b/mindplot/pom.xml index 92ee3278..f04c21fb 100644 --- a/mindplot/pom.xml +++ b/mindplot/pom.xml @@ -94,7 +94,7 @@ - + diff --git a/mindplot/src/main/javascript/RestPersistenceManager.js b/mindplot/src/main/javascript/RestPersistenceManager.js index 739901f1..7569c1eb 100644 --- a/mindplot/src/main/javascript/RestPersistenceManager.js +++ b/mindplot/src/main/javascript/RestPersistenceManager.js @@ -1,83 +1,57 @@ -/* - * 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. - */ - -mindplot.DwrPersitenceManager = new Class({ - Extends:mindplot.PersistenceManager, - initialize: function() { - this.parent(); - }, - - saveMapXml : function(mapId, mapXml, pref, saveHistory, events) { - window.MapEditorService.saveMap(mapId, mapXml, pref, saveHistory, { - callback:function(response) { - if (response.msgCode != "OK") { - events.onError(response); - } else { - events.onSuccess(response); - } - }, - - errorHandler:function(message) { - events.onError(message); - }, - verb:"POST", - async: true - } - ) - }, - - loadMapDom : function(mapId) { - $assert(mapId, "mapId can not be null"); - throw "This must be implemented"; - -// var result = {r:null}; -// window.MapEditorService.loadMap(mapId, { -// callback:function(response) { -// -// if (response.msgCode == "OK") { -// // Explorer Hack with local files ... -// var xmlContent = response.content; -// var domDocument = core.Utils.createDocumentFromText(xmlContent); -// var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument); -// var mindmap = serializer.loadFromDom(domDocument); -// mindmap.setId(mapId); -// -// result.r = mindmap; -// } else { -// // Handle error message ... -// var msg = response.msgDetails; -// var monitor = core.ToolbarNotifier.getInstance(); -// monitor.logFatal("We're sorry, an error has occurred and we can't load your map. Please try again in a few minutes."); -//// wLogger.error(msg); -// } -// }, -// verb:"GET", -// async: false, -// errorHandler:function(msg) { -// var monitor = core.ToolbarNotifier.getInstance(); -// monitor.logFatal("We're sorry, an error has occurred and we can't load your map. Please try again in a few minutes."); -//// wLogger.error(msg); -// } -// }); -// -// return result.r; - } - } -); - - +/* + * 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. + */ + +mindplot.RESTPersistenceManager = new Class({ + Extends:mindplot.PersistenceManager, + initialize: function(saveUrl) { + this.parent(); + $assert(saveUrl, "saveUrl can not be null"); + this.saveUrl = saveUrl; + }, + + saveMapXml : function(mapId, mapXml, pref, saveHistory, events) { + + var data = { + id:mapId, + xml: mapXml, + properties: pref + }; + + var request = new Request({ + url:this.saveUrl + mapId, + method: 'put', + onSuccess:function(responseText, responseXML) { + events.onSuccess(); + + }, + onException:function(headerName, value) { + events.onError(); + }, + onFailure:function(xhr) { + events.onError(); + }, + headers: {"Content-Type":"application/json","Accept":"application/json"}, + emulation:false, + urlEncoded:false + }); + request.put(JSON.encode(data)); + } + } +); + + diff --git a/mindplot/src/main/javascript/widget/IMenu.js b/mindplot/src/main/javascript/widget/IMenu.js index aaec386b..3a480550 100644 --- a/mindplot/src/main/javascript/widget/IMenu.js +++ b/mindplot/src/main/javascript/widget/IMenu.js @@ -59,7 +59,7 @@ mindplot.widget.IMenu = new Class({ onError: function() { if (saveHistory) { saveElem.setStyle('cursor', 'pointer'); - $notify("Save could not be completed. Try latter"); + $notify("Save could not be completed. Try latter."); } } }); diff --git a/wise-editor/src/main/webapp/js/editor.js b/wise-editor/src/main/webapp/js/editor.js index 06e0e677..2f6e8ccb 100644 --- a/wise-editor/src/main/webapp/js/editor.js +++ b/wise-editor/src/main/webapp/js/editor.js @@ -1,236 +1,241 @@ -/* - * 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. - */ - -var designer = null; - -function buildDesigner(options) { - - var container = $(options.container); - $assert(container, 'container could not be null'); - - // Register load events ... - designer = new mindplot.Designer(options, container); - designer.addEvent('loadSuccess', function() { - window.waitDialog.close(); - window.waitDialog.destroy(); - }); - - designer.addEvent('loadError', function(e) { - window.waitDialog.close(); - window.waitDialog.destroy(); - console.log(e); - }); - - - // Configure default persistence manager ... - var persistence; - if (options.persistenceManager) { - persistence = eval("new " + options.persistenceManager + "()"); - - } else { - persistence = new mindplot.LocalStorageManager(); - } - mindplot.PersistenceManager.init(persistence); - - // Register toolbar event ... - if ($('toolbar')) { - var menu = new mindplot.widget.Menu(designer, 'toolbar',""); - - // If a node has focus, focus can be move to another node using the keys. - designer._cleanScreen = function() { - menu.clear() - }; - } - - return designer; -} - - -function loadDesignerOptions(jsonConf) { - // Load map options ... - if (jsonConf) { - var request = new Request.JSON({ - url: jsonConf, - async:false, - onSuccess: - function(options) { - this.options = options; - - }.bind(this) - } - ); - request.get(); - result = this.options; - } - else { - // Set workspace screen size as default. In this way, resize issues are solved. - var containerSize = { - height: parseInt(screen.height), - width: parseInt(screen.width) - }; - - var viewPort = { - height: parseInt(window.innerHeight - 70), // Footer and Header - width: parseInt(window.innerWidth) - }; - result = {readOnly:false,zoom:0.85,saveOnLoad:true,size:containerSize,viewPort:viewPort,container:'mindplot'}; - } - console.log("result:" + JSON.encode(result)); - return result; -} - -editor = {}; -editor.WaitDialog = new Class({ - Extends:MooDialog, - initialize : function() { - var panel = this._buildPanel(); - this.parent({ - closeButton:false, - destroyOnClose:true, - autoOpen:true, - useEscKey:false, - title:'Loading ...', - onInitialize: function(wrapper) { - wrapper.setStyle('opacity', 0); - this.fx = new Fx.Morph(wrapper, { - duration: 100, - transition: Fx.Transitions.Bounce.easeOut - }); - this.overlay = new Overlay(this.options.inject, { - duration: this.options.duration - }); - if (this.options.closeOnOverlayClick) this.overlay.addEvent('click', this.close.bind(this)); - } - , - - onBeforeOpen: function() { - this.overlay.open(); - this.fx.start({ - 'margin-top': [-200, -100], - opacity: [0, 1] - }).chain(function() { - this.fireEvent('show'); - }.bind(this)); - } - , - - onBeforeClose: function() { - this.fx.start({ - 'margin-top': [-100, 0], - opacity: 0, - duration: 200 - }).chain(function() { - this.fireEvent('hide'); - }.bind(this)); - this.overlay.close(); - }} - ) - ; - this.setContent(panel); - }, - - _buildPanel : function () { - var result = new Element('div'); - result.setStyles({ - 'text-align':'center', - width: '400px' - }); - var img = new Element('img', {'src': 'images/ajax-loader.gif'}); - img.inject(result); - return result; - }, - - show : function() { - this.open(); - } - -}); - -editor.Help = { - buildHelp:function(panel) { - var container = new Element('div'); - container.setStyles({width:'100%', textAlign:'center'}); - var content1 = Help.buildContentIcon('images/black-keyboard.png', 'Keyboard Shortcuts', function() { - MOOdalBox.open('keyboard.htm', 'KeyBoard Shortcuts', '500px 400px', false); - panel.hidePanel(); - }); - var content2 = Help.buildContentIcon('images/firstSteps.png', 'Editor First Steps', function() { - var wOpen; - var sOptions; - - sOptions = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes'; - sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString(); - sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString(); - sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0'; - - wOpen = window.open("firststeps.htm", "WiseMapping", "width=100px, height=100px"); - wOpen.focus(); - wOpen.moveTo(0, 0); - wOpen.resizeTo(screen.availWidth, screen.availHeight); - panel.hidePanel(); - }); - - container.addEvent('show', function() { - content1.effect('opacity', {duration:800}).start(0, 100); - var eff = function() { - content2.effect('opacity', {duration:800}).start(0, 100); - }; - eff.delay(150); - }); - container.addEvent('hide', function() { - content1.effect('opacity').set(0); - content2.effect('opacity').set(0) - }); - content1.inject(container); - content2.inject(container); - return container; - }, - buildContentIcon:function(image, text, onClickFn) { - var container = new Element('div').setStyles({margin:'15px 0px 0px 0px', opacity:0, padding:'5px 0px', border: '1px solid transparent', cursor:'pointer'}); - - var icon = new Element('div'); - icon.addEvent('click', onClickFn); - var img = new Element('img'); - img.setProperty('src', image); - img.inject(icon); - icon.inject(container); - - var textContainer = new Element('div').setStyles({width:'100%', color:'white'}); - textContainer.innerHTML = text; - textContainer.inject(container); - - container.addEvent('mouseover', function() { - $(this).setStyle('border-top', '1px solid #BBB4D6'); - $(this).setStyle('border-bottom', '1px solid #BBB4D6'); - }.bindWithEvent(container)); - container.addEvent('mouseout', function() { - $(this).setStyle('border-top', '1px solid transparent'); - $(this).setStyle('border-bottom', '1px solid transparent'); - - }.bindWithEvent(container)); - return container; - } -}; - - -// Show loading dialog ... -waitDialog = new editor.WaitDialog(); -waitDialog.show(); - -// Loading libraries ... -Asset.javascript("js/mindplot-min.js"); +/* + * 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. + */ + +var designer = null; + +function buildDesigner(options) { + + var container = $(options.container); + $assert(container, 'container could not be null'); + + // Register load events ... + designer = new mindplot.Designer(options, container); + designer.addEvent('loadSuccess', function() { + window.waitDialog.close(); + window.waitDialog.destroy(); + }); + + designer.addEvent('loadError', function(e) { + window.waitDialog.close(); + window.waitDialog.destroy(); + console.log(e); + }); + + + // Configure default persistence manager ... + var persistence; + if (options.persistenceManager) { + if(options.persistenceManager instanceof String) { + persistence = eval("new " + options.persistenceManager + "()"); + } + else { + persistence = options.persistenceManager; + } + + } else { + persistence = new mindplot.LocalStorageManager(); + } + mindplot.PersistenceManager.init(persistence); + + // Register toolbar event ... + if ($('toolbar')) { + var menu = new mindplot.widget.Menu(designer, 'toolbar',""); + + // If a node has focus, focus can be move to another node using the keys. + designer._cleanScreen = function() { + menu.clear() + }; + } + + return designer; +} + + +function loadDesignerOptions(jsonConf) { + // Load map options ... + if (jsonConf) { + var request = new Request.JSON({ + url: jsonConf, + async:false, + onSuccess: + function(options) { + this.options = options; + + }.bind(this) + } + ); + request.get(); + result = this.options; + } + else { + // Set workspace screen size as default. In this way, resize issues are solved. + var containerSize = { + height: parseInt(screen.height), + width: parseInt(screen.width) + }; + + var viewPort = { + height: parseInt(window.innerHeight - 70), // Footer and Header + width: parseInt(window.innerWidth) + }; + result = {readOnly:false,zoom:0.85,saveOnLoad:true,size:containerSize,viewPort:viewPort,container:'mindplot'}; + } + console.log("result:" + JSON.encode(result)); + return result; +} + +editor = {}; +editor.WaitDialog = new Class({ + Extends:MooDialog, + initialize : function() { + var panel = this._buildPanel(); + this.parent({ + closeButton:false, + destroyOnClose:true, + autoOpen:true, + useEscKey:false, + title:'Loading ...', + onInitialize: function(wrapper) { + wrapper.setStyle('opacity', 0); + this.fx = new Fx.Morph(wrapper, { + duration: 100, + transition: Fx.Transitions.Bounce.easeOut + }); + this.overlay = new Overlay(this.options.inject, { + duration: this.options.duration + }); + if (this.options.closeOnOverlayClick) this.overlay.addEvent('click', this.close.bind(this)); + } + , + + onBeforeOpen: function() { + this.overlay.open(); + this.fx.start({ + 'margin-top': [-200, -100], + opacity: [0, 1] + }).chain(function() { + this.fireEvent('show'); + }.bind(this)); + } + , + + onBeforeClose: function() { + this.fx.start({ + 'margin-top': [-100, 0], + opacity: 0, + duration: 200 + }).chain(function() { + this.fireEvent('hide'); + }.bind(this)); + this.overlay.close(); + }} + ) + ; + this.setContent(panel); + }, + + _buildPanel : function () { + var result = new Element('div'); + result.setStyles({ + 'text-align':'center', + width: '400px' + }); + var img = new Element('img', {'src': 'images/ajax-loader.gif'}); + img.inject(result); + return result; + }, + + show : function() { + this.open(); + } + +}); + +editor.Help = { + buildHelp:function(panel) { + var container = new Element('div'); + container.setStyles({width:'100%', textAlign:'center'}); + var content1 = Help.buildContentIcon('images/black-keyboard.png', 'Keyboard Shortcuts', function() { + MOOdalBox.open('keyboard.htm', 'KeyBoard Shortcuts', '500px 400px', false); + panel.hidePanel(); + }); + var content2 = Help.buildContentIcon('images/firstSteps.png', 'Editor First Steps', function() { + var wOpen; + var sOptions; + + sOptions = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes'; + sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString(); + sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString(); + sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0'; + + wOpen = window.open("firststeps.htm", "WiseMapping", "width=100px, height=100px"); + wOpen.focus(); + wOpen.moveTo(0, 0); + wOpen.resizeTo(screen.availWidth, screen.availHeight); + panel.hidePanel(); + }); + + container.addEvent('show', function() { + content1.effect('opacity', {duration:800}).start(0, 100); + var eff = function() { + content2.effect('opacity', {duration:800}).start(0, 100); + }; + eff.delay(150); + }); + container.addEvent('hide', function() { + content1.effect('opacity').set(0); + content2.effect('opacity').set(0) + }); + content1.inject(container); + content2.inject(container); + return container; + }, + buildContentIcon:function(image, text, onClickFn) { + var container = new Element('div').setStyles({margin:'15px 0px 0px 0px', opacity:0, padding:'5px 0px', border: '1px solid transparent', cursor:'pointer'}); + + var icon = new Element('div'); + icon.addEvent('click', onClickFn); + var img = new Element('img'); + img.setProperty('src', image); + img.inject(icon); + icon.inject(container); + + var textContainer = new Element('div').setStyles({width:'100%', color:'white'}); + textContainer.innerHTML = text; + textContainer.inject(container); + + container.addEvent('mouseover', function() { + $(this).setStyle('border-top', '1px solid #BBB4D6'); + $(this).setStyle('border-bottom', '1px solid #BBB4D6'); + }.bindWithEvent(container)); + container.addEvent('mouseout', function() { + $(this).setStyle('border-top', '1px solid transparent'); + $(this).setStyle('border-bottom', '1px solid transparent'); + + }.bindWithEvent(container)); + return container; + } +}; + + +// Show loading dialog ... +waitDialog = new editor.WaitDialog(); +waitDialog.show(); + +// Loading libraries ... +Asset.javascript("js/mindplot-min.js"); diff --git a/wise-webapp/src/main/java/com/wisemapping/model/User.java b/wise-webapp/src/main/java/com/wisemapping/model/User.java index 7c7a9165..4e5ba43d 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/User.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/User.java @@ -18,11 +18,9 @@ package com.wisemapping.model; -import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.*; -@XmlRootElement(name = "user") public class User extends Collaborator implements Serializable { diff --git a/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationProvider.java b/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationProvider.java index db861554..0f1a3030 100644 --- a/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationProvider.java +++ b/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationProvider.java @@ -17,12 +17,12 @@ public class AuthenticationProvider implements org.springframework.security.auth private PasswordEncoder encoder; - @Override + @Override() public Authentication authenticate(@NotNull final Authentication auth) throws AuthenticationException { // All your user authentication needs - final String email = auth.getName(); + final User user = userManager.getUserBy(email); final String credentials = (String) auth.getCredentials(); if (user == null || credentials == null || !encoder.isPasswordValid(user.getPassword(), credentials, null)) { diff --git a/wise-webapp/src/test/java/com/wisemapping/test/model/JsonTest.java b/wise-webapp/src/test/java/com/wisemapping/test/model/JsonTest.java index 8e9535f7..a70755f5 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/model/JsonTest.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/model/JsonTest.java @@ -2,6 +2,7 @@ package com.wisemapping.test.model; import com.wisemapping.rest.model.RestMindmap; +import com.wisemapping.rest.model.RestUser; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; import org.testng.annotations.Test; @@ -13,10 +14,14 @@ public class JsonTest { @Test void deserialize() throws IOException { - String json = "{\"id\":\"1\",\"xml\":\"\",\"properties\":\"{\\\"zoom\\\":0.85}\"}"; + String mapJson = "{\"id\":\"1\",\"xml\":\"\",\"properties\":\"{\\\"zoom\\\":0.85}\"}"; ObjectMapper mapper = new ObjectMapper(); - final RestMindmap restMindmap = mapper.readValue(json, RestMindmap.class); + final RestMindmap restMindmap = mapper.readValue(mapJson, RestMindmap.class); + + String userJson = "{\"username\":\"admin\",\"email\":\"admin@wisemapping.org\",\"tags\":[],\"creationDate\":1329706800000,\"firstname\":\"Wise\",\"lastname\":\"test\",\"password\":\"test\"}"; + final RestUser restUser = mapper.readValue(userJson, RestUser.class); } + } diff --git a/wise-webapp/src/test/sql/hsql/create-schemas.sql b/wise-webapp/src/test/sql/hsql/create-schemas.sql index 993ebfad..f589b5ba 100644 --- a/wise-webapp/src/test/sql/hsql/create-schemas.sql +++ b/wise-webapp/src/test/sql/hsql/create-schemas.sql @@ -14,7 +14,7 @@ activationCode BIGINT NOT NULL, activation_date DATE, allowSendEmail CHAR(1) NOT NULL, FOREIGN KEY(colaborator_id) REFERENCES colaborator(id) -) ; +); CREATE TABLE MINDMAP ( id INTEGER NOT NULL IDENTITY,