Update to HSQLDB driver
Remove DWR Remove native SVG tables Add new REST services for persistence.
This commit is contained in:
@@ -48,7 +48,7 @@ public class EmbeddedViewController extends BaseMultiActionController {
|
||||
if (userAgent.isBrowserSupported()) {
|
||||
view = new ModelAndView("embeddedView");
|
||||
view.addObject("mindmap", mindmap);
|
||||
final String xmlMap = mindmap.getNativeXmlAsJsLiteral();
|
||||
final String xmlMap = mindmap.getXmlAsJsLiteral();
|
||||
view.addObject("mapXml", xmlMap);
|
||||
|
||||
final String zoomStr = httpServletRequest.getParameter("zoom");
|
||||
|
@@ -50,8 +50,8 @@ public class MindmapCooker extends BaseMultiActionController {
|
||||
final int mapId = Integer.parseInt(mindmapId);
|
||||
final MindMap mindmap = getMindmapService().getMindmapById(mapId);
|
||||
|
||||
String nativeXml = httpServletRequest.getParameter("nativeXml");
|
||||
mindmap.setNativeXml(nativeXml);
|
||||
String xml = httpServletRequest.getParameter("xml");
|
||||
mindmap.setXmlStr(xml);
|
||||
|
||||
getMindmapService().updateMindmap(mindmap, false);
|
||||
|
||||
|
@@ -58,7 +58,7 @@ public class MindmapEditorController extends BaseMultiActionController {
|
||||
view.addObject("editorTryMode", false);
|
||||
final boolean showHelp = isWelcomeMap(mindmap);
|
||||
view.addObject("showHelp", showHelp);
|
||||
final String xmlMap = mindmap.getNativeXmlAsJsLiteral();
|
||||
final String xmlMap = mindmap.getXmlAsJsLiteral();
|
||||
view.addObject(MAP_XML_PARAM, xmlMap);
|
||||
view.addObject("user", Utils.getUser());
|
||||
}
|
||||
|
@@ -51,8 +51,8 @@ public class NewMindmapController
|
||||
mindmap.setTitle(title);
|
||||
mindmap.setOwner(user);
|
||||
|
||||
final String defaultNativeMap = getDefaultMindmapXml(title);
|
||||
mindmap.setNativeXml(defaultNativeMap);
|
||||
final String xml = getDefaultMindmapXml(title);
|
||||
mindmap.setXmlStr(xml);
|
||||
|
||||
final User dbUSer = getUserService().getUserBy(user.getId());
|
||||
|
||||
|
@@ -65,7 +65,7 @@ public class PublicPagesController extends BaseMultiActionController {
|
||||
final MindMap mindmap = getMindmapService().getMindmapById(TRY_EXAMPLE_MINDMAP_ID);
|
||||
|
||||
ModelAndView view = new ModelAndView("mindmapEditor", "mindmap", mindmap);
|
||||
final String xmlMap = mindmap.getNativeXmlAsJsLiteral();
|
||||
final String xmlMap = mindmap.getXmlAsJsLiteral();
|
||||
view.addObject(MindmapEditorController.MAP_XML_PARAM, xmlMap);
|
||||
view.addObject("editorTryMode", true);
|
||||
view.addObject("showHelp", true);
|
||||
|
@@ -24,11 +24,11 @@ import java.util.List;
|
||||
|
||||
public interface MindmapManager {
|
||||
|
||||
Colaborator getColaboratorBy(String email);
|
||||
Collaborator getCollaboratorBy(String email);
|
||||
|
||||
Colaborator getColaboratorBy(long id);
|
||||
Collaborator getCollaboratorBy(long id);
|
||||
|
||||
List<MindmapUser> getMindmapUserByColaborator(final long colaboratorId);
|
||||
List<MindmapUser> getMindmapUserByCollaborator(final long collaboratorId);
|
||||
|
||||
List<MindmapUser> getMindmapUserByRole(final UserRole userRole);
|
||||
|
||||
@@ -40,7 +40,7 @@ public interface MindmapManager {
|
||||
|
||||
MindMap getMindmapByTitle(final String name, final User user);
|
||||
|
||||
void addColaborator (Colaborator colaborator);
|
||||
void addCollaborator(Collaborator collaborator);
|
||||
|
||||
void addMindmap(User user, MindMap mindMap);
|
||||
|
||||
@@ -50,7 +50,7 @@ public interface MindmapManager {
|
||||
|
||||
void updateMindmap(MindMap mindMap, boolean saveHistory);
|
||||
|
||||
void removeColaborator(Colaborator colaborator);
|
||||
void removeCollaborator(Collaborator collaborator);
|
||||
|
||||
void removeMindmap(MindMap mindap);
|
||||
|
||||
|
@@ -33,16 +33,16 @@ public class MindmapManagerImpl
|
||||
extends HibernateDaoSupport
|
||||
implements MindmapManager {
|
||||
|
||||
public Colaborator getColaboratorBy(final String email) {
|
||||
final Colaborator colaborator;
|
||||
final List colaborators = getHibernateTemplate().find("from com.wisemapping.model.Colaborator colaborator where email=?", email);
|
||||
public Collaborator getCollaboratorBy(final String email) {
|
||||
final Collaborator collaborator;
|
||||
final List colaborators = getHibernateTemplate().find("from com.wisemapping.model.Collaborator collaborator where email=?", email);
|
||||
if (colaborators != null && !colaborators.isEmpty()) {
|
||||
assert colaborators.size() == 1 : "More than one user with the same username!";
|
||||
colaborator = (Colaborator) colaborators.get(0);
|
||||
collaborator = (Collaborator) colaborators.get(0);
|
||||
} else {
|
||||
colaborator = null;
|
||||
collaborator = null;
|
||||
}
|
||||
return colaborator;
|
||||
return collaborator;
|
||||
}
|
||||
|
||||
public List<MindMap> search(MindMapCriteria criteria) {
|
||||
@@ -104,11 +104,11 @@ public class MindmapManagerImpl
|
||||
return hibernateCriteria.list();
|
||||
}
|
||||
|
||||
public Colaborator getColaboratorBy(long id) {
|
||||
return (Colaborator) getHibernateTemplate().get(Colaborator.class, id);
|
||||
public Collaborator getCollaboratorBy(long id) {
|
||||
return (Collaborator) getHibernateTemplate().get(Collaborator.class, id);
|
||||
}
|
||||
|
||||
public List<MindmapUser> getMindmapUserByColaborator(final long colaboratorId) {
|
||||
public List<MindmapUser> getMindmapUserByCollaborator(final long colaboratorId) {
|
||||
return getHibernateTemplate().find("from com.wisemapping.model.MindmapUser mindmapUser where colaborator_id=?", colaboratorId);
|
||||
}
|
||||
|
||||
@@ -129,17 +129,17 @@ public class MindmapManagerImpl
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addColaborator(Colaborator colaborator) {
|
||||
assert colaborator != null : "ADD MINDMAP COLABORATOR: Colaborator is required!";
|
||||
getHibernateTemplate().save(colaborator);
|
||||
public void addCollaborator(Collaborator collaborator) {
|
||||
assert collaborator != null : "ADD MINDMAP COLABORATOR: Collaborator is required!";
|
||||
getHibernateTemplate().save(collaborator);
|
||||
}
|
||||
|
||||
public void removeMindmapUser(MindmapUser mindmapUser) {
|
||||
getHibernateTemplate().delete(mindmapUser);
|
||||
}
|
||||
|
||||
public void removeColaborator(Colaborator colaborator) {
|
||||
getHibernateTemplate().delete(colaborator);
|
||||
public void removeCollaborator(Collaborator collaborator) {
|
||||
getHibernateTemplate().delete(collaborator);
|
||||
}
|
||||
|
||||
public List<MindMap> getAllMindmaps() {
|
||||
@@ -172,13 +172,11 @@ public class MindmapManagerImpl
|
||||
|
||||
public void saveMindmap(MindMap mindMap) {
|
||||
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
||||
getSession().saveOrUpdate(mindMap.getNativeBrowser());
|
||||
getSession().save(mindMap);
|
||||
}
|
||||
|
||||
public void updateMindmap(MindMap mindMap, boolean saveHistory) {
|
||||
assert mindMap != null : "Save Mindmap: Mindmap is required!";
|
||||
getHibernateTemplate().saveOrUpdate(mindMap.getNativeBrowser());
|
||||
getHibernateTemplate().saveOrUpdate(mindMap);
|
||||
if (saveHistory)
|
||||
{
|
||||
|
@@ -18,9 +18,9 @@
|
||||
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.UserLogin;
|
||||
import com.wisemapping.model.Colaborator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface UserManager {
|
||||
|
||||
User getUserByActivationCode(long code);
|
||||
|
||||
public Colaborator getColaboratorBy(String email);
|
||||
public Collaborator getCollaboratorBy(String email);
|
||||
|
||||
public User createUser(User user, Colaborator col);
|
||||
public User createUser(User user, Collaborator col);
|
||||
}
|
||||
|
@@ -18,10 +18,11 @@
|
||||
|
||||
package com.wisemapping.dao;
|
||||
|
||||
import com.wisemapping.model.Colaborator;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.MindmapUser;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.UserLogin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
//import org.acegisecurity.providers.encoding.PasswordEncoder;
|
||||
|
||||
@@ -55,12 +56,12 @@ public class UserManagerImpl
|
||||
return user;
|
||||
}
|
||||
|
||||
public Colaborator getColaboratorBy(final String email) {
|
||||
final Colaborator cola;
|
||||
final List cols = getHibernateTemplate().find("from com.wisemapping.model.Colaborator colaborator where email=?", email);
|
||||
public Collaborator getCollaboratorBy(final String email) {
|
||||
final Collaborator cola;
|
||||
final List cols = getHibernateTemplate().find("from com.wisemapping.model.Collaborator colaborator where email=?", email);
|
||||
if (cols != null && !cols.isEmpty()) {
|
||||
assert cols.size() == 1 : "More than one colaborator with the same email!";
|
||||
cola = (Colaborator) cols.get(0);
|
||||
cola = (Collaborator) cols.get(0);
|
||||
} else {
|
||||
cola = null;
|
||||
}
|
||||
@@ -97,7 +98,7 @@ public class UserManagerImpl
|
||||
getHibernateTemplate().saveOrUpdate(user);
|
||||
}
|
||||
|
||||
public User createUser(User user, Colaborator col)
|
||||
public User createUser(@NotNull User user, @NotNull Collaborator col)
|
||||
{
|
||||
// user.setPassword(passwordEncoder.encodePassword(user.getPassword(),null));
|
||||
assert user != null : "Trying to store a null user";
|
||||
@@ -107,7 +108,7 @@ public class UserManagerImpl
|
||||
MindmapUser newMapUser = new MindmapUser();
|
||||
newMapUser.setRoleId(mindmapUser.getRole().ordinal());
|
||||
newMapUser.setMindMap(mindmapUser.getMindMap());
|
||||
newMapUser.setColaborator(user);
|
||||
newMapUser.setCollaborator(user);
|
||||
user.addMindmapUser(newMapUser);
|
||||
}
|
||||
|
||||
|
@@ -1,58 +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 com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.UserService;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.security.Utils;
|
||||
import org.directwebremoting.WebContextFactory;
|
||||
import org.directwebremoting.WebContext;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
abstract public class BaseDwrService {
|
||||
private MindmapService mindmapService;
|
||||
private UserService userService;
|
||||
|
||||
public MindmapService getMindmapService() {
|
||||
return mindmapService;
|
||||
}
|
||||
|
||||
public void setMindmapService(MindmapService mindmapService) {
|
||||
this.mindmapService = mindmapService;
|
||||
}
|
||||
|
||||
public UserService getUserService() {
|
||||
return userService;
|
||||
}
|
||||
|
||||
public void setUserService(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
|
||||
WebContext ctx = WebContextFactory.get();
|
||||
final HttpServletRequest request = ctx.getHttpServletRequest();
|
||||
|
||||
return Utils.getUser(request);
|
||||
}
|
||||
|
||||
}
|
@@ -16,30 +16,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ...........................................................................................................
|
||||
// (C) Copyright 1996/2007 Fuego Inc. All Rights Reserved
|
||||
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Fuego Inc.
|
||||
// The copyright notice above does not evidence any actual or intended
|
||||
// publication of such source code.
|
||||
//
|
||||
// Last changed on 2007-08-01 19:08:20 (-0300), by: imanzano. $Revision$
|
||||
// ...........................................................................................................
|
||||
|
||||
package com.wisemapping.dwr;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.directwebremoting.WebContext;
|
||||
import org.directwebremoting.WebContextFactory;
|
||||
import com.wisemapping.model.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class JavaScriptErrorLoggerService
|
||||
extends BaseDwrService {
|
||||
|
||||
{
|
||||
final Log logger = LogFactory.getLog(JavaScriptErrorLoggerService.class);
|
||||
private static final int ERROR_MESSAGE = 3;
|
||||
private static final int FATAL_MESSAGE = 4;
|
||||
@@ -53,27 +38,24 @@ public class JavaScriptErrorLoggerService
|
||||
public void logError(final int severity, final String logMsg)
|
||||
throws IOException {
|
||||
|
||||
final User user = getUser();
|
||||
|
||||
final WebContext ctx = WebContextFactory.get();
|
||||
final HttpServletRequest request = ctx.getHttpServletRequest();
|
||||
// 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);
|
||||
}
|
||||
// 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) {
|
||||
|
@@ -1,77 +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.
|
||||
*/
|
||||
|
||||
// ...........................................................................................................
|
||||
// (C) Copyright 1996/2007 Fuego Inc. All Rights Reserved
|
||||
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Fuego Inc.
|
||||
// The copyright notice above does not evidence any actual or intended
|
||||
// publication of such source code.
|
||||
//
|
||||
// Last changed on 2007-08-01 19:08:21 (-0300), by: imanzano. $Revision$
|
||||
// ...........................................................................................................
|
||||
|
||||
package com.wisemapping.dwr;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
|
||||
public class MapEditorService
|
||||
extends BaseDwrService {
|
||||
|
||||
//~ Methods ..............................................................................................
|
||||
|
||||
public ResponseMessage draftMap(final int mapId, final String nativeXml) {
|
||||
final ResponseMessage response = new ResponseMessage();
|
||||
response.setMsgCode(ResponseMessage.Code.OK.name());
|
||||
response.setMsgDetails("Map Saved Successfully");
|
||||
return response;
|
||||
}
|
||||
|
||||
public ResponseMessage saveMap(final int mapId, final String nativeXml,
|
||||
final String editorProperties,boolean saveHistory)
|
||||
throws IOException, WiseMappingException {
|
||||
final MindmapService serservice = getMindmapService();
|
||||
final MindMap mindMap = serservice.getMindmapById(mapId);
|
||||
final User user = this.getUser();
|
||||
|
||||
mindMap.setProperties(editorProperties);
|
||||
|
||||
final Calendar now = Calendar.getInstance();
|
||||
mindMap.setLastModificationTime(now);
|
||||
mindMap.setLastModifierUser(user.getUsername());
|
||||
|
||||
final Calendar lastModification = Calendar.getInstance();
|
||||
lastModification.setTime(new Date());
|
||||
mindMap.setLastModificationTime(lastModification);
|
||||
|
||||
mindMap.setNativeXml(nativeXml);
|
||||
serservice.updateMindmap(mindMap,saveHistory);
|
||||
|
||||
final ResponseMessage response = new ResponseMessage();
|
||||
response.setMsgCode(ResponseMessage.Code.OK.name());
|
||||
response.setMsgDetails("Map Saved Successfully");
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
@@ -1,66 +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;
|
||||
|
||||
public class ResponseMessage {
|
||||
private ResponseMessage.Code msgCode;
|
||||
private String msgDetails;
|
||||
private String content;
|
||||
private String contentType;
|
||||
|
||||
public ResponseMessage() {
|
||||
this.contentType = "text/xml;charset=UTF-8";
|
||||
}
|
||||
|
||||
public String getMsgCode() {
|
||||
return msgCode.name();
|
||||
}
|
||||
|
||||
public void setMsgCode(String msgCode) {
|
||||
this.msgCode = Code.valueOf(msgCode);
|
||||
}
|
||||
|
||||
public String getMsgDetails() {
|
||||
return msgDetails;
|
||||
}
|
||||
|
||||
public void setMsgDetails(String msgDetails) {
|
||||
this.msgDetails = msgDetails;
|
||||
}
|
||||
|
||||
public enum Code {
|
||||
OK, ERROR
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
}
|
@@ -55,7 +55,7 @@ public class ExporterFactory {
|
||||
|
||||
}
|
||||
|
||||
public static void export(@NotNull ExportProperties properties, @NotNull String xml, @NotNull OutputStream output, @NotNull String mapSvg) throws TranscoderException, IOException, ParserConfigurationException, SAXException, XMLStreamException, TransformerException, JAXBException, ExportException {
|
||||
public static void export(@NotNull ExportProperties properties, @Nullable String xml, @NotNull OutputStream output, @Nullable String mapSvg) throws TranscoderException, IOException, ParserConfigurationException, SAXException, XMLStreamException, TransformerException, JAXBException, ExportException {
|
||||
final ExportFormat format = properties.getFormat();
|
||||
|
||||
final String imgPath = properties.getBaseImgPath();
|
||||
|
@@ -30,7 +30,6 @@ import com.wisemapping.xml.mindmap.Icon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.math.BigInteger;
|
||||
@@ -50,11 +49,7 @@ public class FreemindExporter
|
||||
private Map<String, Node> nodesMap = null;
|
||||
|
||||
public void export(MindMap map, OutputStream outputStream) throws ExportException {
|
||||
try {
|
||||
export(map.getUnzippedXml().getBytes("UTF-8"), outputStream);
|
||||
} catch (IOException e) {
|
||||
throw new ExportException(e);
|
||||
}
|
||||
export(map.getXml(), outputStream);
|
||||
}
|
||||
|
||||
public void export(byte[] xml, OutputStream outputStream) throws ExportException {
|
||||
|
@@ -142,7 +142,7 @@ public class FreemindImporter
|
||||
wiseXml = new String(baos.toByteArray(), UTF_8_CHARSET);
|
||||
|
||||
|
||||
result.setNativeXml(wiseXml);
|
||||
result.setXmlStr(wiseXml);
|
||||
result.setTitle(mapName);
|
||||
result.setDescription(description);
|
||||
|
||||
|
@@ -23,15 +23,15 @@ import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
public class Colaborator {
|
||||
public class Collaborator {
|
||||
private long id;
|
||||
private String email;
|
||||
private Calendar creationDate;
|
||||
private Set<MindmapUser> mindmapUsers = new HashSet<MindmapUser>();
|
||||
|
||||
public Colaborator() {}
|
||||
public Collaborator() {}
|
||||
|
||||
public Colaborator(Set<MindmapUser> mindmapUsers) {
|
||||
public Collaborator(Set<MindmapUser> mindmapUsers) {
|
||||
this.mindmapUsers = mindmapUsers;
|
||||
}
|
||||
|
@@ -32,16 +32,17 @@ import org.apache.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class MindMap {
|
||||
private static final String UTF_8 = "UTF-8";
|
||||
|
||||
//~ Instance fields ......................................................................................
|
||||
|
||||
final Logger logger = Logger.getLogger(MindMap.class.getName());
|
||||
private Calendar creationTime;
|
||||
private String creator;
|
||||
private String description;
|
||||
@@ -52,24 +53,12 @@ public class MindMap {
|
||||
private String lastModifierUser;
|
||||
|
||||
private Set<MindmapUser> mindmapUsers = new HashSet<MindmapUser>();
|
||||
private MindMapNative nativeBrowser = new MindMapNative();
|
||||
private User owner;
|
||||
private String properties;
|
||||
private String tags;
|
||||
private String title;
|
||||
private byte[] xml;
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
String xml = "pepe\n hole";
|
||||
xml = xml.replace("'", "\\'");
|
||||
xml = xml.replace("\n", "");
|
||||
xml = xml.trim();
|
||||
|
||||
System.out.println("xml:" + xml);
|
||||
|
||||
}
|
||||
|
||||
//~ Constructors .........................................................................................
|
||||
|
||||
public MindMap() {
|
||||
@@ -85,13 +74,27 @@ public class MindMap {
|
||||
this.xml = xml;
|
||||
}
|
||||
|
||||
public void setXmlStr(@NotNull String xml)
|
||||
throws IOException {
|
||||
this.xml = xml.getBytes(UTF_8);
|
||||
}
|
||||
|
||||
public byte[] getXml() {
|
||||
return xml;
|
||||
}
|
||||
|
||||
public String getUnzippedXml()
|
||||
public String getXmlStr() throws UnsupportedEncodingException {
|
||||
return new String(this.xml, UTF_8);
|
||||
}
|
||||
|
||||
public byte[] getZippedXml()
|
||||
throws IOException {
|
||||
return ZipUtils.zipToString(xml);
|
||||
return ZipUtils.stringToZip(new String(this.xml, UTF_8));
|
||||
}
|
||||
|
||||
public void setZippedXml(byte[] xml)
|
||||
throws IOException {
|
||||
this.xml = ZipUtils.zipToString(xml).getBytes(UTF_8);
|
||||
}
|
||||
|
||||
public void setProperties(String properties) {
|
||||
@@ -117,8 +120,8 @@ public class MindMap {
|
||||
this.mindmapUsers = mindmapUsers;
|
||||
}
|
||||
|
||||
public void addMindmapUser(MindmapUser mindmaUser) {
|
||||
mindmapUsers.add(mindmaUser);
|
||||
public void addMindmapUser(MindmapUser mindmapUser) {
|
||||
mindmapUsers.add(mindmapUser);
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
@@ -173,15 +176,9 @@ public class MindMap {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getNativeXml()
|
||||
public String getXmlAsJsLiteral()
|
||||
throws IOException {
|
||||
return getUnzippedXml();
|
||||
}
|
||||
|
||||
|
||||
public String getNativeXmlAsJsLiteral()
|
||||
throws IOException {
|
||||
String xml = getNativeXml();
|
||||
String xml = this.getXmlStr();
|
||||
if (xml != null) {
|
||||
xml = xml.replace("'", "\\'");
|
||||
xml = xml.replaceAll("\\r|\\n", "");
|
||||
@@ -190,10 +187,6 @@ public class MindMap {
|
||||
return xml;
|
||||
}
|
||||
|
||||
public void setNativeXml(@NotNull String nativeXml)
|
||||
throws IOException {
|
||||
this.xml = ZipUtils.stringToZip(nativeXml);
|
||||
}
|
||||
|
||||
public void setTags(String tags) {
|
||||
this.tags = tags;
|
||||
@@ -226,12 +219,4 @@ public class MindMap {
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public MindMapNative getNativeBrowser() {
|
||||
return nativeBrowser;
|
||||
}
|
||||
|
||||
public void setNativeBrowser(MindMapNative nativeBrowser) {
|
||||
this.nativeBrowser = nativeBrowser;
|
||||
}
|
||||
}
|
||||
|
@@ -75,10 +75,4 @@ public class MindMapHistory {
|
||||
public void setXml(byte[] xml) {
|
||||
this.xml = xml;
|
||||
}
|
||||
|
||||
public String getNativeXml()
|
||||
throws IOException
|
||||
{
|
||||
return ZipUtils.zipToString(xml);
|
||||
}
|
||||
}
|
||||
|
@@ -1,79 +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.model;
|
||||
|
||||
import com.wisemapping.util.ZipUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This class contains the SVG and VML representation of the MindMap
|
||||
*/
|
||||
public class MindMapNative {
|
||||
private int id;
|
||||
|
||||
private byte[] svgXml;
|
||||
private byte[] vmlXml;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public byte[] getSvgXml() {
|
||||
return svgXml;
|
||||
}
|
||||
|
||||
public void setSvgXml(byte[] svgXml) {
|
||||
this.svgXml = svgXml;
|
||||
}
|
||||
|
||||
public byte[] getVmlXml() {
|
||||
return vmlXml;
|
||||
}
|
||||
|
||||
public void setVmlXml(byte[] vmlXml) {
|
||||
this.vmlXml = vmlXml;
|
||||
}
|
||||
|
||||
public String getUnzippedVmlXml()
|
||||
throws IOException
|
||||
{
|
||||
return ZipUtils.zipToString(vmlXml);
|
||||
}
|
||||
|
||||
public String getUnzippedSvgXml()
|
||||
throws IOException
|
||||
{
|
||||
return ZipUtils.zipToString(svgXml);
|
||||
}
|
||||
|
||||
public void setVmlXml(String xml) throws IOException {
|
||||
// compress and set
|
||||
vmlXml = ZipUtils.stringToZip(xml);
|
||||
}
|
||||
|
||||
public void setSvgXml(String xml) throws IOException {
|
||||
// compress and set
|
||||
svgXml = ZipUtils.stringToZip(xml);
|
||||
}
|
||||
}
|
@@ -23,19 +23,19 @@ public class MindmapUser {
|
||||
private int id;
|
||||
private int roleId;
|
||||
private MindMap mindMap;
|
||||
private Colaborator colaborator;
|
||||
private Collaborator collaborator;
|
||||
|
||||
public MindmapUser(){ }
|
||||
|
||||
public MindmapUser(int role, Colaborator colaborator , MindMap mindmap)
|
||||
public MindmapUser(int role, Collaborator collaborator, MindMap mindmap)
|
||||
{
|
||||
this.roleId = role;
|
||||
this.mindMap =mindmap;
|
||||
this.colaborator = colaborator;
|
||||
this.collaborator = collaborator;
|
||||
|
||||
// Guarantee referential integrity
|
||||
mindmap.addMindmapUser(this);
|
||||
colaborator.addMindmapUser(this);
|
||||
collaborator.addMindmapUser(this);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@@ -78,11 +78,11 @@ public class MindmapUser {
|
||||
this.mindMap = mindMap;
|
||||
}
|
||||
|
||||
public Colaborator getColaborator() {
|
||||
return colaborator;
|
||||
public Collaborator getCollaborator() {
|
||||
return collaborator;
|
||||
}
|
||||
|
||||
public void setColaborator(Colaborator colaborator) {
|
||||
this.colaborator = colaborator;
|
||||
public void setCollaborator(Collaborator collaborator) {
|
||||
this.collaborator = collaborator;
|
||||
}
|
||||
}
|
||||
|
@@ -22,12 +22,12 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
@XmlRootElement(name="user")
|
||||
@XmlRootElement(name = "user")
|
||||
public class User
|
||||
extends Colaborator
|
||||
implements Serializable
|
||||
{
|
||||
extends Collaborator
|
||||
implements Serializable {
|
||||
|
||||
private static final String ADMIN_EMAIL = "test@wisemapping.org";
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String password;
|
||||
@@ -40,13 +40,11 @@ public class User
|
||||
public User() {
|
||||
}
|
||||
|
||||
public void setTags(Set<String> tags)
|
||||
{
|
||||
public void setTags(Set<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public Set<String> getTags()
|
||||
{
|
||||
public Set<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
@@ -94,20 +92,17 @@ public class User
|
||||
return activationDate;
|
||||
}
|
||||
|
||||
public boolean isAllowSendEmail()
|
||||
{
|
||||
public boolean isAllowSendEmail() {
|
||||
return allowSendEmail;
|
||||
}
|
||||
|
||||
public void setAllowSendEmail(boolean allowSendEmail)
|
||||
{
|
||||
public void setAllowSendEmail(boolean allowSendEmail) {
|
||||
this.allowSendEmail = allowSendEmail;
|
||||
}
|
||||
|
||||
public boolean getAllowSendEmail()
|
||||
{
|
||||
public boolean getAllowSendEmail() {
|
||||
return allowSendEmail;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -139,4 +134,8 @@ public class User
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return ADMIN_EMAIL.equals(this.getEmail());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
package com.wisemapping.rest;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestUser;
|
||||
import com.wisemapping.service.UserService;
|
||||
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 java.io.IOException;
|
||||
|
||||
@Controller
|
||||
public class AdminController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "admin/users/{id}", produces = {"application/xml", "application/json"})
|
||||
@ResponseBody
|
||||
public ModelAndView getUserById(@PathVariable int 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/xml", "application/json"})
|
||||
@ResponseBody
|
||||
public ModelAndView getUserByEmail(@PathVariable String email) throws IOException {
|
||||
final User userBy = userService.getUserBy(email);
|
||||
if (userBy == null) {
|
||||
throw new IllegalArgumentException("User could not be found");
|
||||
}
|
||||
return new ModelAndView("userView", "user", new RestUser(userBy));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "admin/users", consumes = {"application/xml", "application/json"})
|
||||
public void getUserByEmail(@RequestBody RestUser user) throws IOException, WiseMappingException {
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User could not be found");
|
||||
}
|
||||
userService.createUser(user.getDelegated(), false);
|
||||
}
|
||||
|
||||
}
|
@@ -1,22 +1,24 @@
|
||||
package com.wisemapping.rest;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.MindmapUser;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestMindmap;
|
||||
import com.wisemapping.rest.model.RestMindmapList;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
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.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@@ -24,7 +26,7 @@ public class MindmapController {
|
||||
@Autowired
|
||||
private MindmapService mindmapService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/map/{id}", produces = {"text/xml", "application/json", "text/html"})
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/xml", "application/json", "text/html"})
|
||||
@ResponseBody
|
||||
public ModelAndView getMindmap(@PathVariable int id) throws IOException {
|
||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||
@@ -32,7 +34,7 @@ public class MindmapController {
|
||||
return new ModelAndView("mapView", "map", map);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps", produces = {"text/xml", "application/json", "text/html"})
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps", produces = {"application/xml", "application/json", "text/html"})
|
||||
public ModelAndView getMindmaps() throws IOException {
|
||||
final User user = com.wisemapping.security.Utils.getUser();
|
||||
|
||||
@@ -45,4 +47,29 @@ public class MindmapController {
|
||||
final RestMindmapList restMindmapList = new RestMindmapList(mindmaps);
|
||||
return new ModelAndView("mapsView", "list", restMindmapList);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}", consumes = {"application/xml", "application/json"})
|
||||
public ModelAndView updateMap(@RequestBody RestMindmap restMindmap, @PathVariable int id) throws IOException, WiseMappingException {
|
||||
|
||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||
final User user = Utils.getUser();
|
||||
|
||||
final String properties = restMindmap.getProperties();
|
||||
mindMap.setProperties(properties);
|
||||
|
||||
final Calendar now = Calendar.getInstance();
|
||||
mindMap.setLastModificationTime(now);
|
||||
mindMap.setLastModifierUser(user.getUsername());
|
||||
|
||||
final Calendar lastModification = Calendar.getInstance();
|
||||
lastModification.setTime(new Date());
|
||||
mindMap.setLastModificationTime(lastModification);
|
||||
|
||||
final String xml = restMindmap.getXml();
|
||||
mindMap.setXmlStr(xml);
|
||||
mindmapService.updateMindmap(mindMap, true);
|
||||
|
||||
return new ModelAndView("responseView", "message", "Map has been updated successfully");
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -70,7 +70,7 @@ public class TransformerController {
|
||||
return new ModelAndView("transformViewJpeg", values);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"application/freemind"}, consumes = {"text/xml"})
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/transform", produces = {"application/freemind"}, consumes = {"application/xml"})
|
||||
@ResponseBody
|
||||
public ModelAndView transformFreemind(@RequestBody @Nullable final String content) throws IOException {
|
||||
final Map<String, Object> values = new HashMap<String, Object>();
|
||||
|
@@ -3,9 +3,7 @@ package com.wisemapping.rest.model;
|
||||
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.User;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
import org.codehaus.jackson.annotate.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
@@ -17,14 +15,19 @@ import java.util.Date;
|
||||
|
||||
@XmlRootElement(name = "map")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
@JsonAutoDetect(
|
||||
fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY,
|
||||
isGetterVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY
|
||||
)
|
||||
public class RestMindmap {
|
||||
|
||||
@JsonIgnore
|
||||
private MindMap mindmap;
|
||||
|
||||
public RestMindmap() {
|
||||
this(null);
|
||||
this(new MindMap());
|
||||
|
||||
}
|
||||
|
||||
@@ -73,12 +76,12 @@ public class RestMindmap {
|
||||
}
|
||||
|
||||
public String getXml() throws IOException {
|
||||
return mindmap.getNativeXml();
|
||||
return mindmap.getXmlStr();
|
||||
}
|
||||
|
||||
public void setXml(String xml) throws IOException {
|
||||
public void setXml(@NotNull String xml) throws IOException {
|
||||
|
||||
mindmap.setNativeXml(xml);
|
||||
mindmap.setXmlStr(xml);
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
@@ -105,6 +108,7 @@ public class RestMindmap {
|
||||
mindmap.setCreator(creatorUser);
|
||||
}
|
||||
|
||||
|
||||
public void setProperties(String properties) {
|
||||
mindmap.setProperties(properties);
|
||||
}
|
||||
@@ -117,6 +121,10 @@ public class RestMindmap {
|
||||
mindmap.setLastModifierUser(lastModifierUser);
|
||||
}
|
||||
|
||||
public String getProperties() {
|
||||
return mindmap.getProperties();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public MindMap getDelegated() {
|
||||
return this.mindmap;
|
||||
|
@@ -0,0 +1,102 @@
|
||||
package com.wisemapping.rest.model;
|
||||
|
||||
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.User;
|
||||
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
@XmlRootElement(name = "user")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||
public class RestUser {
|
||||
|
||||
private User user;
|
||||
|
||||
public RestUser() {
|
||||
this(new User());
|
||||
}
|
||||
|
||||
public RestUser(@NotNull User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Calendar getCreationDate() {
|
||||
return user.getCreationDate();
|
||||
}
|
||||
|
||||
public void setTags(Set<String> tags) {
|
||||
user.setTags(tags);
|
||||
}
|
||||
|
||||
public Set<String> getTags() {
|
||||
return user.getTags();
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return user.getFirstname();
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
user.setFirstname(firstname);
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return user.getLastname();
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
user.setLastname(lastname);
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return user.isActive();
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
user.setUsername(username);
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return user.getId();
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
user.setId(id);
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return user.getEmail();
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
user.setEmail(email);
|
||||
}
|
||||
|
||||
public void setCreationDate(Calendar creationDate) {
|
||||
// user.setCreationDate(creationDate);
|
||||
}
|
||||
|
||||
public void setPassword(@NotNull final String password){
|
||||
this.user.setPassword(password);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public User getDelegated(){
|
||||
return this.user;
|
||||
}
|
||||
}
|
@@ -34,8 +34,12 @@ public class UserDetails implements org.springframework.security.core.userdetail
|
||||
}
|
||||
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
final SimpleGrantedAuthority role_user = new SimpleGrantedAuthority("ROLE_USER");
|
||||
final Collection<GrantedAuthority> result = new ArrayList<GrantedAuthority>();
|
||||
if(this.getUser().isAdmin()) {
|
||||
final SimpleGrantedAuthority role_admin = new SimpleGrantedAuthority("ROLE_ADMIN");
|
||||
result.add(role_admin);
|
||||
}
|
||||
final SimpleGrantedAuthority role_user = new SimpleGrantedAuthority("ROLE_USER");
|
||||
result.add(role_user);
|
||||
return result;
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ public class MindmapServiceImpl
|
||||
final Set<MindmapUser> users = map.getMindmapUsers();
|
||||
UserRole rol = null;
|
||||
for (MindmapUser mindmapUser : users) {
|
||||
if (mindmapUser.getColaborator().getId() == user.getId()) {
|
||||
if (mindmapUser.getCollaborator().getId() == user.getId()) {
|
||||
rol = mindmapUser.getRole();
|
||||
break;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class MindmapServiceImpl
|
||||
}
|
||||
|
||||
public List<MindmapUser> getMindmapUserByUser(User user) {
|
||||
return mindmapManager.getMindmapUserByColaborator(user.getId());
|
||||
return mindmapManager.getMindmapUserByCollaborator(user.getId());
|
||||
}
|
||||
|
||||
public void updateMindmap(MindMap mindMap, boolean saveHistory) throws WiseMappingException {
|
||||
@@ -115,10 +115,10 @@ public class MindmapServiceImpl
|
||||
Set<MindmapUser> mindmapusers = mindmap.getMindmapUsers();
|
||||
MindmapUser mindmapuserToDelete = null;
|
||||
for (MindmapUser mindmapuser : mindmapusers) {
|
||||
if (mindmapuser.getColaborator().getId() == colaboratorId) {
|
||||
if (mindmapuser.getCollaborator().getId() == colaboratorId) {
|
||||
mindmapuserToDelete = mindmapuser;
|
||||
//@TODO evaluar si el colaborador no tiene mas asociaciones si hay que eliminarlo, por ahora NO
|
||||
// final List<MindmapUser> otherAsociations = mindmapManager.getMindmapUserByColaborator(colaboratorId);
|
||||
// final List<MindmapUser> otherAsociations = mindmapManager.getMindmapUserByCollaborator(colaboratorId);
|
||||
// if (otherAsociations != null)
|
||||
// {
|
||||
//
|
||||
@@ -126,8 +126,8 @@ public class MindmapServiceImpl
|
||||
// // Is not a User
|
||||
// if (user == null)
|
||||
// {
|
||||
// final Colaborator col = mindmapManager.getColaboratorBy(colaboratorId);
|
||||
// mindmapManager.removeColaborator(col);
|
||||
// final Collaborator col = mindmapManager.getCollaboratorBy(colaboratorId);
|
||||
// mindmapManager.removeCollaborator(col);
|
||||
// }
|
||||
// }
|
||||
break;
|
||||
@@ -178,7 +178,7 @@ public class MindmapServiceImpl
|
||||
public void addColaborators(MindMap mindmap, String[] colaboratorEmails, UserRole role, ColaborationEmail email)
|
||||
throws InvalidColaboratorException {
|
||||
if (colaboratorEmails != null && colaboratorEmails.length > 0) {
|
||||
final Colaborator owner = mindmap.getOwner();
|
||||
final Collaborator owner = mindmap.getOwner();
|
||||
final Set<MindmapUser> mindmapUsers = mindmap.getMindmapUsers();
|
||||
|
||||
for (String colaboratorEmail : colaboratorEmails) {
|
||||
@@ -244,7 +244,7 @@ public class MindmapServiceImpl
|
||||
public void revertMapToHistory(MindMap map, int historyId)
|
||||
throws IOException, WiseMappingException {
|
||||
final MindMapHistory history = mindmapManager.getHistory(historyId);
|
||||
map.setNativeXml(history.getNativeXml());
|
||||
map.setXml(history.getXml());
|
||||
updateMindmap(map, false);
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ public class MindmapServiceImpl
|
||||
MindmapUser mindmapUser = null;
|
||||
|
||||
for (MindmapUser user : mindmapUsers) {
|
||||
if (user.getColaborator().getEmail().equals(email)) {
|
||||
if (user.getCollaborator().getEmail().equals(email)) {
|
||||
mindmapUser = user;
|
||||
break;
|
||||
}
|
||||
@@ -262,15 +262,15 @@ public class MindmapServiceImpl
|
||||
|
||||
private void addColaborator(String colaboratorEmail, UserRole role, MindMap mindmap, ColaborationEmail email) {
|
||||
|
||||
Colaborator colaborator = mindmapManager.getColaboratorBy(colaboratorEmail);
|
||||
if (colaborator == null) {
|
||||
colaborator = new Colaborator();
|
||||
colaborator.setEmail(colaboratorEmail);
|
||||
colaborator.setCreationDate(Calendar.getInstance());
|
||||
mindmapManager.addColaborator(colaborator);
|
||||
Collaborator collaborator = mindmapManager.getCollaboratorBy(colaboratorEmail);
|
||||
if (collaborator == null) {
|
||||
collaborator = new Collaborator();
|
||||
collaborator.setEmail(colaboratorEmail);
|
||||
collaborator.setCreationDate(Calendar.getInstance());
|
||||
mindmapManager.addCollaborator(collaborator);
|
||||
}
|
||||
|
||||
final MindmapUser newMindmapUser = new MindmapUser(role.ordinal(), colaborator, mindmap);
|
||||
final MindmapUser newMindmapUser = new MindmapUser(role.ordinal(), collaborator, mindmap);
|
||||
mindmap.getMindmapUsers().add(newMindmapUser);
|
||||
|
||||
mindmapManager.saveMindmap(mindmap);
|
||||
|
@@ -21,8 +21,8 @@ package com.wisemapping.service;
|
||||
import com.wisemapping.dao.UserManager;
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.mail.Mailer;
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.model.Colaborator;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.Calendar;
|
||||
@@ -102,7 +102,7 @@ public class UserServiceImpl
|
||||
user.setActivationDate(Calendar.getInstance());
|
||||
}
|
||||
|
||||
Colaborator col = userManager.getColaboratorBy(user.getEmail());
|
||||
Collaborator col = userManager.getCollaboratorBy(user.getEmail());
|
||||
if (col != null) {
|
||||
userManager.createUser(user, col);
|
||||
} else {
|
||||
|
@@ -18,26 +18,26 @@
|
||||
|
||||
package com.wisemapping.view;
|
||||
|
||||
import com.wisemapping.model.Collaborator;
|
||||
import com.wisemapping.model.UserRole;
|
||||
import com.wisemapping.model.Colaborator;
|
||||
import com.wisemapping.model.User;
|
||||
|
||||
public class ColaboratorBean
|
||||
{
|
||||
private UserRole userRole;
|
||||
private boolean isUser;
|
||||
private Colaborator colaborator;
|
||||
private Collaborator collaborator;
|
||||
|
||||
public ColaboratorBean(Colaborator colaborator, UserRole role)
|
||||
public ColaboratorBean(Collaborator collaborator, UserRole role)
|
||||
{
|
||||
this.colaborator = colaborator;
|
||||
this.collaborator = collaborator;
|
||||
this.userRole = role;
|
||||
this.isUser = false;
|
||||
}
|
||||
|
||||
public ColaboratorBean(User user, UserRole role)
|
||||
{
|
||||
this.colaborator = user;
|
||||
this.collaborator = user;
|
||||
this.userRole = role;
|
||||
this.isUser = true;
|
||||
}
|
||||
@@ -54,16 +54,16 @@ public class ColaboratorBean
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return isUser ? ((User)colaborator).getUsername() : colaborator.getEmail();
|
||||
return isUser ? ((User) collaborator).getUsername() : collaborator.getEmail();
|
||||
}
|
||||
|
||||
public String getEmail()
|
||||
{
|
||||
return colaborator.getEmail();
|
||||
return collaborator.getEmail();
|
||||
}
|
||||
|
||||
public long getId()
|
||||
{
|
||||
return colaborator.getId();
|
||||
return collaborator.getId();
|
||||
}
|
||||
}
|
||||
|
@@ -104,7 +104,7 @@ public class MindMapBean {
|
||||
if (source != null) {
|
||||
for (MindmapUser mu : source) {
|
||||
if (mu.getRole() == role) {
|
||||
col.add(new ColaboratorBean(mu.getColaborator(), mu.getRole()));
|
||||
col.add(new ColaboratorBean(mu.getCollaborator(), mu.getRole()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user