Update to HSQLDB driver
Remove DWR Remove native SVG tables Add new REST services for persistence.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user