Update to HSQLDB driver

Remove DWR
Remove native SVG tables
Add new REST services for persistence.
This commit is contained in:
Paulo Gustavo Veiga 2012-02-21 14:22:43 -03:00
parent 89f7fd8d3c
commit fb3f9946ae
58 changed files with 419 additions and 624 deletions

View File

@ -171,12 +171,6 @@
<version>1.7</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.directwebremoting</groupId>
<artifactId>dwr</artifactId>
<version>2.0.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-svg-dom</artifactId>
@ -245,9 +239,9 @@
</dependency>
<!-- Only for test purposes -->
<dependency>
<groupId>hsqldb</groupId>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
<version>2.2.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
@ -274,10 +268,10 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.2</version>
<version>1.5</version>
<configuration>
<driver>org.hsqldb.jdbcDriver</driver>
<driver>org.hsqldb.jdbc.JDBCDriver</driver>
<url>jdbc:hsqldb:file:${basedir}/target/db/wisemapping</url>
<username>sa</username>
<!--all executions are ignored if -Dmaven.test.skipDB=true
@ -293,9 +287,9 @@
<version>5.1.5</version>
</dependency>
<dependency>
<groupId>hsqldb</groupId>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.1</version>
<version>2.2.8</version>
</dependency>
</dependencies>

View File

@ -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");

View File

@ -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);

View File

@ -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());
}

View File

@ -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());

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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 {

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -75,10 +75,4 @@ public class MindMapHistory {
public void setXml(byte[] xml) {
this.xml = xml;
}
public String getNativeXml()
throws IOException
{
return ZipUtils.zipToString(xml);
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -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");
}
}

View File

@ -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>();

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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 {

View File

@ -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();
}
}

View File

@ -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()));
}
}
}

View File

@ -5,7 +5,7 @@
<hibernate-mapping>
<class name="com.wisemapping.model.Colaborator" table="COLABORATOR">
<class name="com.wisemapping.model.Collaborator" table="COLABORATOR">
<id name="id">
<generator class="increment"/>
</id>

View File

@ -12,7 +12,7 @@
<property name="title"/>
<property name="public"/>
<property name="description"/>
<property name="xml" column="XML"/>
<property name="zippedXml" column="XML"/>
<property name="lastModifierUser" column="last_editor"/>
<property name="lastModificationTime" column="edition_date"/>
<property name="creationTime" column="creation_date"/>
@ -21,7 +21,6 @@
<property name="properties" column="editor_properties"/>
<many-to-one name="owner" column="owner_id" unique="true" not-null="true"/>
<many-to-one name="nativeBrowser" column="mindMapNative_id" unique="true" not-null="true"/>
<set name="mindmapUsers"
cascade="all, delete-orphan"

View File

@ -1,21 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.wisemapping.model.MindMapNative" table="MINDMAP_NATIVE">
<id name="id">
<generator class="increment"/>
</id>
<property name="svgXml" type="binary">
<column name="SVG_XML" sql-type="blob"/>
</property>
<property name="vmlXml" type="binary">
<column name="VML_XML" sql-type="blob"/>
</property>
</class>
</hibernate-mapping>

View File

@ -11,19 +11,19 @@
</id>
<property name="roleId" column="ROLE_ID" unique="true" not-null="true"/>
<!-- Read-only association property -->
<!-- Read-only association property -->
<many-to-one name="mindMap"
column="MINDMAP_ID"
not-null="true"
class="com.wisemapping.model.MindMap"
column="MINDMAP_ID"
not-null="true"
class="com.wisemapping.model.MindMap"
/>
<many-to-one name="colaborator"
column="COLABORATOR_ID"
not-null="true"
class="com.wisemapping.model.Colaborator"
/>
<many-to-one name="collaborator"
column="COLABORATOR_ID"
not-null="true"
class="com.wisemapping.model.Collaborator"
/>
</class>
</hibernate-mapping>

View File

@ -11,7 +11,7 @@
# HSQL Configuration properties
database.url=jdbc:hsqldb:file:target/db/wisemapping
database.driver=org.hsqldb.jdbcDriver
database.driver=org.hsqldb.jdbc.JDBCDriver
database.hibernate.dialect=org.hibernate.dialect.HSQLDialect
database.username=sa
database.password=

View File

@ -1,8 +1,7 @@
log4j.rootLogger=WARN, stdout, R
log4j.logger.net.sf=FATAL,stdout, R
log4j.logger.com.wisemapping=WARN,stdout,R
log4j.logger.org.springframework=WARN,stdout,R
log4j.logger.org.codehaus.jackson=WARN,stdout,R
# Stdout logger <20>
log4j.appender.stdout=org.apache.log4j.ConsoleAppender

View File

@ -1,17 +0,0 @@
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr//dwr20.dtd">
<dwr>
<allow>
<create creator="spring" javascript="MapEditorService">
<param name="beanName" value="mapEditorService"/>
<include method="saveMap"/>
<include method="loadMap"/>
</create>
<create creator="spring" javascript="LoggerService">
<param name="beanName" value="loggerService"/>
<include method="logError"/>
</create>
<convert converter="bean" match="com.wisemapping.dwr.ResponseMessage"/>
</allow>
</dwr>

View File

@ -0,0 +1,11 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Message: ${message}</h1>
<br/>
</body>
</html>

View File

@ -110,15 +110,6 @@
</servlet>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>mvc-servlet</servlet-name>
<url-pattern>*.htm</url-pattern>
@ -129,11 +120,6 @@
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>
index.jsp

View File

@ -24,11 +24,10 @@
<property name="dataSource" ref="wiseDataSource"/>
<property name="mappingResources">
<list>
<value>com/wisemapping/model/Colaborator.hbm.xml</value>
<value>com/wisemapping/model/Collaborator.hbm.xml</value>
<value>com/wisemapping/model/MindMap.hbm.xml</value>
<value>com/wisemapping/model/MindmapUser.hbm.xml</value>
<value>com/wisemapping/model/UserLogin.hbm.xml</value>
<value>com/wisemapping/model/MindmapNative.hbm.xml</value>
<value>com/wisemapping/model/MindMapHistory.hbm.xml</value>
</list>
</property>

View File

@ -20,6 +20,7 @@
<list>
<value>com.wisemapping.rest.model.RestMindmap</value>
<value>com.wisemapping.rest.model.RestMindmapList</value>
<value>com.wisemapping.rest.model.RestUser</value>
</list>
</property>
</bean>

View File

@ -14,6 +14,7 @@
<sec:http pattern="/css/**" security="none"/>
<sec:http pattern="/js/**" security="none"/>
<sec:http pattern="/images/**" security="none"/>
<sec:http pattern="/icons/**" security="none"/>
<sec:http pattern="/favicon.ico" security="none"/>
<sec:http pattern="/c/login.htm" security="none"/>
<sec:http pattern="/c/userregistration.htm" security="none"/>
@ -26,12 +27,10 @@
<sec:http pattern="/c/embeddedview.htm" security="none"/>
<sec:http pattern="/c/export.htm" security="none"/>
<sec:http pattern="/c/publicview.htm" security="none"/>
<sec:http pattern="/dwr/engine.js" security="none"/>
<sec:http pattern="/dwr/interface/loggerservice.js" security="none"/>
<sec:http pattern="/dwr/call/plaincall/loggerservice.logerror.dwr" security="none"/>
<sec:http pattern="/service/transform.*" security="none"/>
<sec:http use-expressions="true" create-session="never" pattern="/service/**">
<sec:http use-expressions="true" create-session="never" pattern="/service/**">
<sec:intercept-url pattern="/service/admin/users/**" access="isAuthenticated() and hasRole('ROLE_ADMIN')"/>
<sec:intercept-url pattern="/service/**" access="isAuthenticated()"/>
<sec:http-basic/>
</sec:http>

View File

@ -40,24 +40,6 @@
<property name="target" ref="mindMapServiceTarget"/>
</bean>
<bean id="mapEditorService" class="com.wisemapping.dwr.MapEditorService">
<property name="mindmapService">
<ref local="mindmapService"/>
</property>
<property name="userService">
<ref local="userService"/>
</property>
</bean>
<bean id="loggerService" class="com.wisemapping.dwr.JavaScriptErrorLoggerService">
<property name="mindmapService">
<ref local="mindmapService"/>
</property>
<property name="userService">
<ref local="userService"/>
</property>
</bean>
<bean id="smtpAuthenticator" class="com.wisemapping.mail.SmtpAuthenticator">
<constructor-arg value="${mail.user}"/>
<constructor-arg value="${mail.password}"/>

View File

@ -13,7 +13,7 @@
Native XML:
</td>
<td>
<textarea name="nativeXml" id="xml" rows="20" cols="70">${mindmap.nativeXml}</textarea>
<textarea name="xml" id="xml" rows="20" cols="70">${mindmap.xml}</textarea>
</td>
</tr>
<tr>

View File

@ -33,7 +33,7 @@
// Configure designer options ...
var options = loadDesignerOptions();
options.persistenceManager = "mindplot.DwrPersitenceManager";
options.persistenceManager = new mindplot.RESTPersistenceManager("service/maps/");
var userOptions = ${mindmap.properties};
options.zoom = userOptions.zoom;

View File

@ -73,7 +73,6 @@ public class ExportTest {
final MindMap result = new MindMap();
result.setXml(content.toString().getBytes("UTF-8"));
result.setNativeXml(content.toString());
return result;
}

View File

@ -42,11 +42,11 @@ public class ImportExportTest {
final String recContent = readFile(wiseFile);
// Export mile content ...
Assert.assertEquals(mindMap.getUnzippedXml(), recContent);
Assert.assertEquals(mindMap.getXmlStr(), recContent);
} else {
final FileOutputStream fos = new FileOutputStream(wiseFile);
fos.write(mindMap.getUnzippedXml().getBytes("UTF-8"));
fos.write(mindMap.getXmlStr().getBytes("UTF-8"));
fos.close();
}

View File

@ -0,0 +1,22 @@
package com.wisemapping.test.model;
import com.wisemapping.rest.model.RestMindmap;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.testng.annotations.Test;
import java.io.IOException;
@Test
public class JsonTest {
@Test
void deserialize() throws IOException {
String json = "{\"id\":\"1\",\"xml\":\"<map name=\\\"1\\\" version=\\\"tango\\\"><topic central=\\\"true\\\" text=\\\"ss\\\" id=\\\"1\\\"/></map>\",\"properties\":\"{\\\"zoom\\\":0.85}\"}";
ObjectMapper mapper = new ObjectMapper();
final RestMindmap restMindmap = mapper.readValue(json, RestMindmap.class);
}
}

View File

@ -1,11 +1,10 @@
CREATE TABLE COLABORATOR (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
id INTEGER NOT NULL IDENTITY,
email varchar(255) NOT NULL,
creation_date date
);
creation_date date);
CREATE TABLE USER (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
id INTEGER NOT NULL IDENTITY,
colaborator_id INTEGER NOT NULL,
username varchar(255) NOT NULL,
firstname varchar(255) NOT NULL,
@ -18,12 +17,11 @@ FOREIGN KEY(colaborator_id) REFERENCES colaborator(id)
) ;
CREATE TABLE MINDMAP (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
id INTEGER NOT NULL IDENTITY,
title VARCHAR(255) NOT NULL,
description VARCHAR(255) NOT NULL,
xml LONGVARBINARY NOT NULL,
public BOOLEAN not null,
mindMapNative_id INTEGER NOT NULL,
creation_date date,
edition_date date,
owner_id INTEGER not null,
@ -32,44 +30,34 @@ last_editor varchar(255) ,
creator_user varchar(255) ,
editor_properties varchar(512)
--FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id)
) ;
CREATE TABLE MINDMAP_NATIVE
(
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
svg_xml LONGVARBINARY,
vml_xml LONGVARBINARY
) ;
);
CREATE TABLE MINDMAP_HISTORY
(
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
(id INTEGER NOT NULL IDENTITY,
xml LONGVARBINARY NOT NULL,
mindmap_id INTEGER NOT NULL,
creation_date datetime,
creator_user varchar(255)
) ;
creator_user varchar(255));
CREATE TABLE MINDMAP_COLABORATOR (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
CREATE TABLE MINDMAP_COLABORATOR
(id INTEGER NOT NULL IDENTITY,
colaborator_id INTEGER NOT NULL,
mindmap_id INTEGER NOT NULL,
role_id INTEGER NOT NULL,
FOREIGN KEY(colaborator_id) REFERENCES colaborator(id),
FOREIGN KEY(mindmap_id) REFERENCES mindmap(id)
) ;
);
CREATE TABLE TAG(
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
CREATE TABLE TAG
(id INTEGER NOT NULL IDENTITY,
name varchar(255) NOT NULL,
user_id INTEGER NOT NULL
user_id INTEGER NOT NULL,
--FOREIGN KEY(user_id) REFERENCES user(colaborator_id)
);
CREATE TABLE USER_LOGIN (
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
email varchar(255) ,
login_date date
) ;
CREATE TABLE USER_LOGIN
(id INTEGER NOT NULL IDENTITY,
email varchar(255),
login_date date);
COMMIT;
SHUTDOWN;

View File

@ -1,5 +1,4 @@
DROP TABLE TAG;
DROP TABLE MINDMAP_NATIVE;
DROP TABLE MINDMAP_COLABORATOR;
DROP TABLE MINDMAP_HISTORY;
DROP TABLE MINDMAP;

View File

@ -1,5 +1,5 @@
INSERT INTO COLABORATOR(id,email,creation_date) values (1,'test@wisemapping.org',CURDATE());
INSERT INTO USER (colaborator_id,username,firstname, lastname, password, activationCode,activation_date,allowSendEmail)
values(1,'Wise Mapping Test User','Wise','test', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',1237,CURDATE(),1);
values(1,'WiseMapping Test User','Wise','test', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',1237,CURDATE(),1);
COMMIT;
SHUTDOWN;

View File

@ -23,7 +23,6 @@ title varchar(255) CHARACTER SET utf8 NOT NULL,
description varchar(255) CHARACTER SET utf8 NOT NULL,
xml blob NOT NULL,
public BOOL not null default 0,
mindMapNative_id INTEGER NOT NULL default 0,
creation_date date,
edition_date date,
owner_id INTEGER not null,
@ -34,13 +33,6 @@ editor_properties varchar(512) CHARACTER SET utf8 ,
FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id)
) CHARACTER SET utf8 ;
CREATE TABLE MINDMAP_NATIVE
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
svg_xml blob,
vml_xml blob
) CHARACTER SET utf8 ;
CREATE TABLE MINDMAP_HISTORY
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,

View File

@ -1,5 +1,4 @@
DROP TABLE TAG;
DROP TABLE MINDMAP_NATIVE;
DROP TABLE MINDMAP_COLABORATOR;
DROP TABLE MINDMAP_HISTORY;
DROP TABLE MINDMAP;

View File

@ -1,4 +1,4 @@
INSERT INTO COLABORATOR(id,email,creation_date) values (1,'test@wisemapping.org',CURRENT_DATE());
INSERT INTO USER (colaborator_id,username,firstname, lastname, password, activationCode,activation_date,allowSendEmail)
values(1,'Wise Mapping Test User','Wise','Test', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',1237,CURRENT_DATE(),1);
values(1,'WiseMapping Test User','Wise','Test', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',1237,CURRENT_DATE(),1);
COMMIT;