From a228ea6ed5988c3b5eae782ad20a00605192dcf7 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 10 Nov 2012 17:19:28 -0300 Subject: [PATCH] Split rest authentication into two. For web apps integration url is /c/restful/ --- .../main/javascript/RestPersistenceManager.js | 14 ++++++ mindplot/src/main/javascript/Topic.js | 1 + .../src/main/resources/messages_en.properties | 3 +- .../src/main/resources/messages_es.properties | 3 +- wise-webapp/pom.xml | 2 +- .../exceptions/ClientException.java | 6 ++- .../MultipleSessionsOpenException.java | 5 ++ .../exceptions/SessionExpiredException.java | 13 +++-- .../wisemapping/rest/MindmapController.java | 47 +++++++++---------- .../wisemapping/rest/model/RestLockInfo.java | 7 +-- .../AuthenticationSuccessHandler.java | 43 +++++++++++++++++ .../com/wisemapping/service/LockInfo.java | 12 ++--- .../com/wisemapping/service/LockManager.java | 10 ++-- .../wisemapping/service/LockManagerImpl.java | 18 +++---- .../ExtensionsController.java | 5 +- .../LoginController.java | 4 +- .../MindmapController.java | 4 +- .../PublicPagesController.java | 2 +- .../UsersController.java | 2 +- .../src/main/resources/messages_en.properties | 4 +- .../src/main/resources/messages_es.properties | 3 +- .../src/main/resources/messages_fr.properties | 1 - .../src/main/resources/messages_it.properties | 1 - .../main/resources/messages_pt_BR.properties | 1 - .../main/resources/messages_zh_CN.properties | 1 - .../main/resources/messages_zh_TW.properties | 1 - wise-webapp/src/main/webapp/WEB-INF/web.xml | 5 ++ .../webapp/WEB-INF/wisemapping-security.xml | 19 +++++--- .../webapp/WEB-INF/wisemapping-servlet.xml | 2 +- wise-webapp/src/main/webapp/js/mindmapList.js | 12 ++--- .../src/main/webapp/jsp/accountSettings.jsp | 8 ++-- .../src/main/webapp/jsp/iframeWrapper.jsp | 2 +- .../src/main/webapp/jsp/mindmapEditor.jsp | 10 ++-- .../src/main/webapp/jsp/mindmapExport.jsp | 6 +-- .../src/main/webapp/jsp/mindmapHistory.jsp | 4 +- .../src/main/webapp/jsp/mindmapImport.jsp | 2 +- .../src/main/webapp/jsp/mindmapList.jsp | 2 +- .../src/main/webapp/jsp/mindmapPublish.jsp | 2 +- .../src/main/webapp/jsp/mindmapShare.jsp | 4 +- 39 files changed, 178 insertions(+), 113 deletions(-) create mode 100644 wise-webapp/src/main/java/com/wisemapping/security/AuthenticationSuccessHandler.java rename wise-webapp/src/main/java/com/wisemapping/{ncontroller => webmvc}/ExtensionsController.java (93%) rename wise-webapp/src/main/java/com/wisemapping/{ncontroller => webmvc}/LoginController.java (92%) rename wise-webapp/src/main/java/com/wisemapping/{ncontroller => webmvc}/MindmapController.java (98%) rename wise-webapp/src/main/java/com/wisemapping/{ncontroller => webmvc}/PublicPagesController.java (98%) rename wise-webapp/src/main/java/com/wisemapping/{ncontroller => webmvc}/UsersController.java (99%) diff --git a/mindplot/src/main/javascript/RestPersistenceManager.js b/mindplot/src/main/javascript/RestPersistenceManager.js index 82c0d2cd..9d42a9e0 100644 --- a/mindplot/src/main/javascript/RestPersistenceManager.js +++ b/mindplot/src/main/javascript/RestPersistenceManager.js @@ -50,14 +50,20 @@ mindplot.RESTPersistenceManager = new Class({ url:this.saveUrl.replace("{id}", mapId) + "?" + query, method:'put', async:!sync, + onSuccess:function (responseText, responseXML) { events.onSuccess(); persistence.timestamp = responseText; }, + onException:function (headerName, value) { + console.log("onException...."); + events.onError(persistence._buildError()); }, + onFailure:function (xhr) { + console.log("onFailure...."); var responseText = xhr.responseText; var error = null; @@ -70,8 +76,16 @@ mindplot.RESTPersistenceManager = new Class({ events.onError(persistence._buildError()); throw new Error("Unexpected error saving. Error response is not json object:" + responseText); } + } else { + var msg = {severity:"ERROR", message:$msg('SAVE_COULD_NOT_BE_COMPLETED')}; + if (this.status == 405) { + msg = {severity:"ERROR", message:$msg('SESSION_EXPIRED')}; + } + events.onError(msg); } + }, + headers:{"Content-Type":"application/json", "Accept":"application/json"}, emulation:false, urlEncoded:false diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index e608fc51..ec70d2cb 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -629,6 +629,7 @@ mindplot.Topic = new Class({ fade.addEvent('complete', function () { }); fade.start(); + mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeShrinkEvent, model); }, diff --git a/mindplot/src/main/resources/messages_en.properties b/mindplot/src/main/resources/messages_en.properties index b7ff2de4..c18c7719 100644 --- a/mindplot/src/main/resources/messages_en.properties +++ b/mindplot/src/main/resources/messages_en.properties @@ -36,7 +36,7 @@ ZOOM_ERROR=No more zoom can be applied. ONLY_ONE_TOPIC_MUST_BE_SELECTED=Could not create a topic. Only one topic must be selected. ONE_TOPIC_MUST_BE_SELECTED=Could not create a topic. One topic must be selected. ONLY_ONE_TOPIC_MUST_BE_SELECTED_COLLAPSE=Children can not be collapsed. One topic must be selected. -SAVE_COULD_NOT_BE_COMPLETED=Save could not be completed. Try latter. +SAVE_COULD_NOT_BE_COMPLETED=Save could not be completed, please try again latter. UNEXPECTED_ERROR_LOADING=We're sorry, an unexpected error has occurred.\nTry again reloading the editor.If the problem persists, contact us to support@wisemapping.com. MAIN_TOPIC=Main Topic SUB_TOPIC=Sub Topic @@ -56,4 +56,5 @@ ACCEPT=Accept CANCEL=Cancel LINK=Link OPEN_LINK=Open URL +SESSION_EXPIRED=Your session has expired, please log-in again. diff --git a/mindplot/src/main/resources/messages_es.properties b/mindplot/src/main/resources/messages_es.properties index 7e193d79..48e6f0cb 100644 --- a/mindplot/src/main/resources/messages_es.properties +++ b/mindplot/src/main/resources/messages_es.properties @@ -56,4 +56,5 @@ REMOVE=Borrar ACCEPT=Aceptar CANCEL=Cancelar LINK=Enlace -OPEN_LINK=Abrir Enlace \ No newline at end of file +OPEN_LINK=Abrir Enlace +SESSION_EXPIRED=Su session ha expirado. Por favor, ingrese nuevamente. \ No newline at end of file diff --git a/wise-webapp/pom.xml b/wise-webapp/pom.xml index aedf280a..2c422cd2 100644 --- a/wise-webapp/pom.xml +++ b/wise-webapp/pom.xml @@ -162,7 +162,7 @@ org.springframework.security spring-security-web ${org.springframework.version} - runtime + compile org.springframework.security diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java index 0d60d1f7..484c1557 100644 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/ClientException.java @@ -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(), null, locale); + return messageSource.getMessage(this.getMsgBundleKey(), this.getMsgBundleArgs(), locale); + } + + protected Object[] getMsgBundleArgs(){ + return null; } public Severity getSeverity() { diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java index ff3a13c7..fb4c97e3 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/MultipleSessionsOpenException.java @@ -35,4 +35,9 @@ public class MultipleSessionsOpenException protected String getMsgBundleKey() { return MSG_KEY; } + + @Override + protected Object[] getMsgBundleArgs() { + return new String[]{"you"}; + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/SessionExpiredException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/SessionExpiredException.java index c33bcd20..edff15a2 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exceptions/SessionExpiredException.java +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/SessionExpiredException.java @@ -18,17 +18,15 @@ package com.wisemapping.exceptions; -import com.wisemapping.model.Collaborator; +import com.wisemapping.model.User; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class SessionExpiredException extends ClientException { public static final String MSG_KEY = "MINDMAP_TIMESTAMP_OUTDATED"; - @Nullable - private Collaborator lastUpdater; + private User lastUpdater; - public SessionExpiredException(@Nullable Collaborator lastUpdater) { + public SessionExpiredException(@NotNull User lastUpdater) { super("Map has been updated by " + (lastUpdater != null ? lastUpdater.getEmail() : ""), Severity.FATAL); this.lastUpdater = lastUpdater; } @@ -38,4 +36,9 @@ public class SessionExpiredException protected String getMsgBundleKey() { return MSG_KEY; } + + @Override + protected Object[] getMsgBundleArgs() { + return new String[]{lastUpdater.getFullName() + "<" + lastUpdater.getEmail() + ">"}; + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index b5a0d2b5..b5b42130 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -174,31 +174,30 @@ public class MindmapController extends BaseController { } private void verifyLock(@NotNull Mindmap mindmap, @NotNull User user, long session, long timestamp) throws WiseMappingException { - throw new SessionExpiredException(user); -// // The lock was lost, reclaim as the ownership of it. -// final LockManager lockManager = mindmapService.getLockManager(); -// final boolean lockLost = lockManager.isLocked(mindmap); -// if (!lockLost) { -// lockManager.lock(mindmap, user, session); -// } -// -// final LockInfo lockInfo = lockManager.getLockInfo(mindmap); -// if (lockInfo.getCollaborator().equals(user)) { -// final boolean outdated = mindmap.getLastModificationTime().getTimeInMillis() > timestamp; -// if (lockInfo.getSession() == session) { -// // Timestamp might not be returned to the client. This try to cover this case, ignoring the client timestamp check. -// final User lastEditor = mindmap.getLastEditor(); -// if (outdated && (lockInfo.getPreviousTimestamp() != timestamp || lastEditor == null || !lastEditor.equals(user))) { -// throw new SessionExpiredException(lastEditor); -// } -// } else if (outdated) { -// throw new MultipleSessionsOpenException("The map has been updated and not by you. Session lost."); -// } -// } else { -// throw new SessionExpiredException(lockInfo.getCollaborator()); -// -// } + // The lock was lost, reclaim as the ownership of it. + final LockManager lockManager = mindmapService.getLockManager(); + final boolean lockLost = lockManager.isLocked(mindmap); + if (!lockLost) { + lockManager.lock(mindmap, user, session); + } + + final LockInfo lockInfo = lockManager.getLockInfo(mindmap); + if (lockInfo.getUser().equals(user)) { + final boolean outdated = mindmap.getLastModificationTime().getTimeInMillis() > timestamp; + if (lockInfo.getSession() == session) { + // Timestamp might not be returned to the client. This try to cover this case, ignoring the client timestamp check. + final User lastEditor = mindmap.getLastEditor(); + if (outdated && (lockInfo.getPreviousTimestamp() != timestamp || lastEditor == null || !lastEditor.equals(user))) { + throw new SessionExpiredException(lastEditor); + } + } else if (outdated) { + throw new MultipleSessionsOpenException("The map has been updated and not by you. Session lost."); + } + } else { + throw new SessionExpiredException(lockInfo.getUser()); + + } } /** diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java index 7c635f16..e0d00b2c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLockInfo.java @@ -20,10 +20,8 @@ package com.wisemapping.rest.model; import com.wisemapping.model.Collaborator; -import com.wisemapping.model.User; import com.wisemapping.service.LockInfo; 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; @@ -31,9 +29,6 @@ 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.util.Calendar; -import java.util.Date; -import java.util.Set; @XmlRootElement(name = "lock") @XmlAccessorType(XmlAccessType.PROPERTY) @@ -73,7 +68,7 @@ public class RestLockInfo { } public boolean isLockedByMe() { - return isLocked() && lockInfo != null && lockInfo.getCollaborator().equals(user); + return isLocked() && lockInfo != null && lockInfo.getUser().equals(user); } public void setLockedByMe(boolean lockedForMe) { diff --git a/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationSuccessHandler.java b/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationSuccessHandler.java new file mode 100644 index 00000000..a1515e41 --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/security/AuthenticationSuccessHandler.java @@ -0,0 +1,43 @@ +package com.wisemapping.security; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; +import org.springframework.security.web.savedrequest.HttpSessionRequestCache; +import org.springframework.security.web.savedrequest.RequestCache; +import org.springframework.security.web.savedrequest.SavedRequest; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + + +public class AuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler { + private RequestCache cache; + + public AuthenticationSuccessHandler() { + cache = new HttpSessionRequestCache(); + this.setRequestCache(cache); + } + + @Override + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { + + SavedRequest savedRequest = cache.getRequest(request, response); + if (savedRequest!=null && savedRequest.getRedirectUrl().contains("c/restful")) { + cache.removeRequest(request,response); + } + super.onAuthenticationSuccess(request, response, authentication); + } + + @Override + protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response) { + String url = super.determineTargetUrl(request, response); + // Prevent redirecting to rest services on login ... + if (url.contains("c/restful")) { + url = this.getDefaultTargetUrl(); + } + return url; + } + +} \ No newline at end of file diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java b/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java index e3cb76b8..02131b0d 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockInfo.java @@ -18,28 +18,28 @@ package com.wisemapping.service; -import com.wisemapping.model.Collaborator; import com.wisemapping.model.Mindmap; +import com.wisemapping.model.User; import org.jetbrains.annotations.NotNull; import java.util.Calendar; public class LockInfo { - final private Collaborator collaborator; + final private User user; private Calendar timeout; private long session; private static int EXPIRATION_MIN = 30; private long timestamp = -1; private long previousTimestamp; - public LockInfo(@NotNull Collaborator collaborator, @NotNull Mindmap mindmap, long session) { - this.collaborator = collaborator; + public LockInfo(@NotNull User user, @NotNull Mindmap mindmap, long session) { + this.user = user; this.updateTimeout(); this.updateTimestamp(mindmap); } - public Collaborator getCollaborator() { - return collaborator; + public User getUser() { + return user; } public boolean isExpired() { diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java index 78ad7ad6..c0ee588e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManager.java @@ -19,10 +19,8 @@ package com.wisemapping.service; import com.wisemapping.exceptions.AccessDeniedSecurityException; -import com.wisemapping.exceptions.ClientException; import com.wisemapping.exceptions.LockException; import com.wisemapping.exceptions.WiseMappingException; -import com.wisemapping.model.Collaborator; import com.wisemapping.model.Mindmap; import com.wisemapping.model.User; import org.jetbrains.annotations.NotNull; @@ -32,13 +30,13 @@ public interface LockManager { LockInfo getLockInfo(@NotNull Mindmap mindmap); - LockInfo updateExpirationTimeout(@NotNull Mindmap mindmap, @NotNull Collaborator user,long session); + LockInfo updateExpirationTimeout(@NotNull Mindmap mindmap, @NotNull User user,long session); - void unlock(@NotNull Mindmap mindmap, @NotNull Collaborator user) throws LockException, AccessDeniedSecurityException; + void unlock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException, AccessDeniedSecurityException; - boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull Collaborator collaborator); + boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User collaborator); - LockInfo lock(@NotNull Mindmap mindmap, @NotNull Collaborator user, long session) throws WiseMappingException; + LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws WiseMappingException; long generateSession(); } diff --git a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java index 1e7d7c5a..e60329e1 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/LockManagerImpl.java @@ -22,8 +22,8 @@ import com.wisemapping.exceptions.AccessDeniedSecurityException; import com.wisemapping.exceptions.LockException; import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.model.CollaborationRole; -import com.wisemapping.model.Collaborator; import com.wisemapping.model.Mindmap; +import com.wisemapping.model.User; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -63,25 +63,25 @@ class LockManagerImpl implements LockManager { } @Override - public LockInfo updateExpirationTimeout(@NotNull Mindmap mindmap, @NotNull Collaborator user, long session) { + public LockInfo updateExpirationTimeout(@NotNull Mindmap mindmap, @NotNull User user, long session) { if (!this.isLocked(mindmap)) { throw new IllegalStateException("Lock lost for map. No update possible."); } final LockInfo result = this.getLockInfo(mindmap); - if (!result.getCollaborator().equals(user)) { - throw new IllegalStateException("Could not update map lock timeout if you are not the locking user. User:" + result.getCollaborator() + ", " + user); + if (!result.getUser().equals(user)) { + throw new IllegalStateException("Could not update map lock timeout if you are not the locking user. User:" + result.getUser() + ", " + user); } result.updateTimeout(); result.setSession(session); result.updateTimestamp(mindmap); - logger.debug("Timeout updated for:" + mindmap.getId()); +// logger.debug("Timeout updated for:" + mindmap.getId()); return result; } @Override - public void unlock(@NotNull Mindmap mindmap, @NotNull Collaborator user) throws LockException, AccessDeniedSecurityException { + public void unlock(@NotNull Mindmap mindmap, @NotNull User user) throws LockException, AccessDeniedSecurityException { if (isLocked(mindmap) && !isLockedBy(mindmap, user)) { throw new LockException("Lock can be only revoked by the locker."); } @@ -99,10 +99,10 @@ class LockManagerImpl implements LockManager { } @Override - public boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull Collaborator collaborator) { + public boolean isLockedBy(@NotNull Mindmap mindmap, @NotNull User collaborator) { boolean result = false; final LockInfo lockInfo = this.getLockInfo(mindmap); - if (lockInfo != null && lockInfo.getCollaborator().equals(collaborator)) { + if (lockInfo != null && lockInfo.getUser().equals(collaborator)) { result = true; } return result; @@ -110,7 +110,7 @@ class LockManagerImpl implements LockManager { @Override @NotNull - public LockInfo lock(@NotNull Mindmap mindmap, @NotNull Collaborator user, long session) throws WiseMappingException { + public LockInfo lock(@NotNull Mindmap mindmap, @NotNull User user, long session) throws WiseMappingException { if (isLocked(mindmap) && !isLockedBy(mindmap, user)) { throw new LockException("Invalid lock, this should not happen"); } diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/ExtensionsController.java b/wise-webapp/src/main/java/com/wisemapping/webmvc/ExtensionsController.java similarity index 93% rename from wise-webapp/src/main/java/com/wisemapping/ncontroller/ExtensionsController.java rename to wise-webapp/src/main/java/com/wisemapping/webmvc/ExtensionsController.java index 81a0f550..17299f6e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/ExtensionsController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/ExtensionsController.java @@ -16,9 +16,8 @@ * limitations under the License. */ -package com.wisemapping.ncontroller; +package com.wisemapping.webmvc; -import com.wisemapping.model.Mindmap; import com.wisemapping.service.MindmapService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -26,8 +25,6 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; -import java.io.IOException; - @Controller public class ExtensionsController { @Qualifier("mindmapService") diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/LoginController.java b/wise-webapp/src/main/java/com/wisemapping/webmvc/LoginController.java similarity index 92% rename from wise-webapp/src/main/java/com/wisemapping/ncontroller/LoginController.java rename to wise-webapp/src/main/java/com/wisemapping/webmvc/LoginController.java index bfa4659e..ddc9c240 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/LoginController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/LoginController.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.wisemapping.ncontroller; +package com.wisemapping.webmvc; import com.wisemapping.model.User; import com.wisemapping.security.Utils; @@ -26,8 +26,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; -import javax.servlet.http.HttpServletRequest; - @Controller public class LoginController { diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java similarity index 98% rename from wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java rename to wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java index 6ede94ae..7617a533 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/MindmapController.java @@ -16,11 +16,9 @@ * limitations under the License. */ -package com.wisemapping.ncontroller; +package com.wisemapping.webmvc; -import com.wisemapping.exceptions.AccessDeniedSecurityException; -import com.wisemapping.exceptions.LockException; import com.wisemapping.exceptions.WiseMappingException; import com.wisemapping.model.CollaborationRole; import com.wisemapping.model.Mindmap; diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/PublicPagesController.java b/wise-webapp/src/main/java/com/wisemapping/webmvc/PublicPagesController.java similarity index 98% rename from wise-webapp/src/main/java/com/wisemapping/ncontroller/PublicPagesController.java rename to wise-webapp/src/main/java/com/wisemapping/webmvc/PublicPagesController.java index d267617f..80bb3b2c 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/PublicPagesController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/PublicPagesController.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.wisemapping.ncontroller; +package com.wisemapping.webmvc; import com.wisemapping.service.MindmapService; import org.springframework.beans.factory.annotation.Autowired; diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/UsersController.java b/wise-webapp/src/main/java/com/wisemapping/webmvc/UsersController.java similarity index 99% rename from wise-webapp/src/main/java/com/wisemapping/ncontroller/UsersController.java rename to wise-webapp/src/main/java/com/wisemapping/webmvc/UsersController.java index 872bd1e2..9d33b0b7 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/UsersController.java +++ b/wise-webapp/src/main/java/com/wisemapping/webmvc/UsersController.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package com.wisemapping.ncontroller; +package com.wisemapping.webmvc; import com.wisemapping.validator.Messages; diff --git a/wise-webapp/src/main/resources/messages_en.properties b/wise-webapp/src/main/resources/messages_en.properties index a51224ab..99046bba 100644 --- a/wise-webapp/src/main/resources/messages_en.properties +++ b/wise-webapp/src/main/resources/messages_en.properties @@ -249,8 +249,8 @@ DIRECT_LINK_EXPLANATION=Copy and paste the link below to share your map with col TEMPORAL_PASSWORD_SENT=Your temporal password has been sent TEMPORAL_PASSWORD_SENT_DETAILS=We've sent you an email that will allow you to reset your password. Please check your email now. TEMPORAL_PASSWORD_SENT_SUPPORT=If you have any problem receiving the email, contact us to support@wisemapping.com -MINDMAP_TIMESTAMP_OUTDATED=It's not possible to save your changes because your mindmap has been modified by '%s'. Refresh the page and try again. -MINDMAP_LOCKED="This map is being edited by %s <%s>. Map is opened in read only." +MINDMAP_TIMESTAMP_OUTDATED=It's not possible to save your changes because your mindmap has been modified by '{0}'. Refresh the page and try again. +MINDMAP_LOCKED=Map is being edited by {0} <{1}>. Map is opened in read only mode. diff --git a/wise-webapp/src/main/resources/messages_es.properties b/wise-webapp/src/main/resources/messages_es.properties index 57da7d25..8a1f5c49 100644 --- a/wise-webapp/src/main/resources/messages_es.properties +++ b/wise-webapp/src/main/resources/messages_es.properties @@ -248,7 +248,8 @@ DIRECT_LINK_EXPLANATION=Copie y pegue el este enlace para compartir su mapa ment TEMPORAL_PASSWORD_SENT_SUPPORT=Si tienes algun problema o no reciviste el mail, contactanos a support@wisemapping.com TEMPORAL_PASSWORD_SENT_DETAILS=Se te ha enviado un mail con los detalles para cambiar to password. Revisa tu correo ahora. TEMPORAL_PASSWORD_SENT=Tu contraseña temporal ha sido enviada -MINDMAP_LOCKED="This map is being edited by %s <%s>. Map is opened in read only." +MINDMAP_LOCKED=El mapa esta siendo editado por {0} <{1}>. Mapa sera abierto en modo lectura. +MINDMAP_TIMESTAMP_OUTDATED=No es posible grabar sus cambios por que el mapa ha sido modificado por {0}'. Refresque la pagina y intentelo nuevamente. diff --git a/wise-webapp/src/main/resources/messages_fr.properties b/wise-webapp/src/main/resources/messages_fr.properties index af79a722..da8758d7 100644 --- a/wise-webapp/src/main/resources/messages_fr.properties +++ b/wise-webapp/src/main/resources/messages_fr.properties @@ -250,7 +250,6 @@ ACCESS_HAS_BEEN_REVOKED= Upps. your access permissions to this map has been revo LICENSE=License WELCOME_TO_WISEMAPPING=Welcome to WiseMapping WELCOME_DETAILS=WiseMapping will enable you to create and read your mind maps everywhere. With WiseMapping you can: . -MINDMAP_LOCKED="This map is being edited by %s <%s>. Map is opened in read only." diff --git a/wise-webapp/src/main/resources/messages_it.properties b/wise-webapp/src/main/resources/messages_it.properties index 632a17cb..9720aec2 100644 --- a/wise-webapp/src/main/resources/messages_it.properties +++ b/wise-webapp/src/main/resources/messages_it.properties @@ -235,7 +235,6 @@ TUTORIAL.FONT_COLOR=Colore TUTORIAL.FONT_STYLE=Stili TUTORIAL.FONT_TYPE=Font TUTORIAL.SAMPLE_NOTE=Questa è una semplice nota !. -MINDMAP_LOCKED="This map is being edited by %s <%s>. Map is opened in read only." diff --git a/wise-webapp/src/main/resources/messages_pt_BR.properties b/wise-webapp/src/main/resources/messages_pt_BR.properties index b5395913..b21b4b0c 100644 --- a/wise-webapp/src/main/resources/messages_pt_BR.properties +++ b/wise-webapp/src/main/resources/messages_pt_BR.properties @@ -235,5 +235,4 @@ TUTORIAL.SAMPLE_NOTE=Esta é uma nota simples !. SUPPORT=Ajudar FEEDBACK=Feedback CONTACT_US=Contato -MINDMAP_LOCKED="This map is being edited by %s <%s>. Map is opened in read only." diff --git a/wise-webapp/src/main/resources/messages_zh_CN.properties b/wise-webapp/src/main/resources/messages_zh_CN.properties index 697acbcf..6fbe7de4 100644 --- a/wise-webapp/src/main/resources/messages_zh_CN.properties +++ b/wise-webapp/src/main/resources/messages_zh_CN.properties @@ -210,5 +210,4 @@ TERM_OF_USE=条款和条件 CONTACT_US=联系我们 FEEDBACK=反馈 SUPPORT=支援 -MINDMAP_LOCKED="This map is being edited by %s <%s>. Map is opened in read only." diff --git a/wise-webapp/src/main/resources/messages_zh_TW.properties b/wise-webapp/src/main/resources/messages_zh_TW.properties index 96901979..86496bc9 100644 --- a/wise-webapp/src/main/resources/messages_zh_TW.properties +++ b/wise-webapp/src/main/resources/messages_zh_TW.properties @@ -210,5 +210,4 @@ TERM_OF_USE=條款和條件 CONTACT_US=聯繫我們 FEEDBACK=反饋 SUPPORT=幫助 -MINDMAP_LOCKED="This map is being edited by %s <%s>. Map is opened in read only." diff --git a/wise-webapp/src/main/webapp/WEB-INF/web.xml b/wise-webapp/src/main/webapp/WEB-INF/web.xml index 2e2b8b06..63bfab89 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/web.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/web.xml @@ -113,6 +113,11 @@ /service/* + + mvc-rest + /c/restful/* + + index.jsp diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml index a84c5a99..f6656d48 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml @@ -2,14 +2,11 @@ + http://www.springframework.org/schema/security/spring-security-3.1.xsd"> @@ -39,17 +36,19 @@ - + + + @@ -67,7 +66,13 @@ + + + + + + \ No newline at end of file diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml index 76584ef5..f88ff7b3 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml @@ -11,7 +11,7 @@ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> - + diff --git a/wise-webapp/src/main/webapp/js/mindmapList.js b/wise-webapp/src/main/webapp/js/mindmapList.js index 425c876f..b01f7a49 100644 --- a/wise-webapp/src/main/webapp/js/mindmapList.js +++ b/wise-webapp/src/main/webapp/js/mindmapList.js @@ -212,7 +212,7 @@ function updateStarred(spanElem) { $(spanElem).addClass('starredOff'); } - jQuery.ajax("service/maps/" + mapId + "/starred", { + jQuery.ajax("c/restful/maps/" + mapId + "/starred", { async:false, dataType:'json', data:"" + starred, @@ -250,7 +250,7 @@ $(function () { function () { $("#new-dialog-modal").dialogForm({ redirect:"c/maps/{header.resourceId}/edit", - url:"service/maps" + url:"c/restful/maps" }); }); @@ -270,7 +270,7 @@ $(function () { // Initialize dialog ... $("#duplicate-dialog-modal").dialogForm({ redirect:"c/maps/{header.resourceId}/edit", - url:"service/maps/" + mapId + url:"c/restful/maps/" + mapId }); } }); @@ -304,7 +304,7 @@ $(function () { rowData.description = reqBodyData.description; dataTable.fnAddData(JSON.parse(JSON.stringify(rowData))); }, - url:"service/maps/" + mapId + url:"c/restful/maps/" + mapId }); } }); @@ -322,7 +322,7 @@ $(function () { // Remove old entry ... tableUI.dataTableExt.removeSelectedRows(); }, - url:"service/maps/batch?ids=" + jQuery.makeArray(mapIds).join(',') + url:"c/restful/maps/batch?ids=" + jQuery.makeArray(mapIds).join(',') }); } }); @@ -385,7 +385,7 @@ $(function () { $('#foldersContainer .active i').addClass('icon-white'); // Reload the table data ... - dataTable.fnReloadAjax("service/maps/?q=" + $(this).attr('data-filter'), callbackOnTableInit, true); + dataTable.fnReloadAjax("c/restful/maps/?q=" + $(this).attr('data-filter'), callbackOnTableInit, true); event.preventDefault(); }); }); diff --git a/wise-webapp/src/main/webapp/jsp/accountSettings.jsp b/wise-webapp/src/main/webapp/jsp/accountSettings.jsp index 0930c3a1..4c1c79c1 100755 --- a/wise-webapp/src/main/webapp/jsp/accountSettings.jsp +++ b/wise-webapp/src/main/webapp/jsp/accountSettings.jsp @@ -116,7 +116,7 @@ $('#changePasswordMsg').removeClass('alert-info').addClass('alert-error').show(); $('#changePasswordMsg').text(''); } else { - postChange("service/account/password", inputVal, 'changePasswordMsg', ''); + postChange("c/restful/account/password", inputVal, 'changePasswordMsg', ''); } event.preventDefault(); }); @@ -125,15 +125,15 @@ var fistname = $('#changeUserForm #firstname').val(); var lastname = $('#changeUserForm #lastname').val(); - postChange("service/account/firstname", fistname, 'changeInfoMsg', ''); - postChange("service/account/lastname", lastname, 'changeInfoMsg', ''); + postChange("c/restful/account/firstname", fistname, 'changeInfoMsg', ''); + postChange("c/restful/account/lastname", lastname, 'changeInfoMsg', ''); event.preventDefault(); }); $('#languageForm').submit(function (event) { var locale = $('#languageForm option:selected').val(); - postChange("service/account/locale", locale, 'languageMsg', ''); + postChange("c/restful/account/locale", locale, 'languageMsg', ''); event.preventDefault(); }); diff --git a/wise-webapp/src/main/webapp/jsp/iframeWrapper.jsp b/wise-webapp/src/main/webapp/jsp/iframeWrapper.jsp index e86b08c1..efca321f 100644 --- a/wise-webapp/src/main/webapp/jsp/iframeWrapper.jsp +++ b/wise-webapp/src/main/webapp/jsp/iframeWrapper.jsp @@ -40,7 +40,7 @@ } }); -
diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp index 6826ad78..86648206 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp @@ -9,6 +9,7 @@ <%--@elvariable id="editorTryMode" type="java.lang.Boolean"--%> <%--@elvariable id="editorTryMode" type="java.lang.String"--%> <%--@elvariable id="mapXml" type="com.wisemapping.model.User"--%> +<%--@elvariable id="lockInfo" type="com.wisemapping.service.LockInfo"--%> @@ -37,13 +38,14 @@ options.persistenceManager = new mindplot.RESTPersistenceManager( { - saveUrl:"service/maps/{id}/document", - revertUrl:"service/maps/{id}/history/latest", - lockUrl:"service/maps/{id}/lock", + saveUrl:"c/restful/maps/{id}/document", + revertUrl:"c/restful/maps/{id}/history/latest", + lockUrl:"c/restful/maps/{id}/lock", timestamp: ${lockTimestamp}, session: ${lockSession} } ); + var userOptions = ${mindmap.properties}; options.zoom = userOptions.zoom; @@ -68,7 +70,7 @@ } - $notify("", false); + $notify("", false); }); diff --git a/wise-webapp/src/main/webapp/jsp/mindmapExport.jsp b/wise-webapp/src/main/webapp/jsp/mindmapExport.jsp index e96d855d..556e4916 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapExport.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapExport.jsp @@ -6,7 +6,7 @@

- @@ -75,7 +75,7 @@ var form = $('#dialogMainForm'); // Restore default .. - form.attr('action', 'service/maps/${mindmap.id}.' + formatType); + form.attr('action', 'c/restful/maps/${mindmap.id}.' + formatType); if (formatType == 'image' || formatType == 'svg' || formatType == 'pdf') { @@ -85,7 +85,7 @@ } // Change to transform url ... form.attr('method', "POST"); - form.attr('action', 'service/transform.' + formatType); + form.attr('action', 'c/restful/transform.' + formatType); // Load page SVG ... var svgXml = window.parent.document.getElementById('workspaceContainer').innerHTML; diff --git a/wise-webapp/src/main/webapp/jsp/mindmapHistory.jsp b/wise-webapp/src/main/webapp/jsp/mindmapHistory.jsp index 4fd2b36a..365c7f4d 100755 --- a/wise-webapp/src/main/webapp/jsp/mindmapHistory.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapHistory.jsp @@ -26,7 +26,7 @@