mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 07:44:56 +01:00
Add REST service /service/maps.
This commit is contained in:
parent
ae43a27dd2
commit
89f7fd8d3c
@ -5,6 +5,7 @@ import com.wisemapping.model.MindMap;
|
|||||||
import com.wisemapping.model.MindmapUser;
|
import com.wisemapping.model.MindmapUser;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
import com.wisemapping.rest.model.RestMindmap;
|
import com.wisemapping.rest.model.RestMindmap;
|
||||||
|
import com.wisemapping.rest.model.RestMindmapList;
|
||||||
import com.wisemapping.service.MindmapService;
|
import com.wisemapping.service.MindmapService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@ -30,13 +32,17 @@ public class MindmapController {
|
|||||||
return new ModelAndView("mapView", "map", map);
|
return new ModelAndView("mapView", "map", map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/maps")
|
@RequestMapping(method = RequestMethod.GET, value = "/maps", produces = {"text/xml", "application/json", "text/html"})
|
||||||
public ModelAndView getMindmaps() throws IOException {
|
public ModelAndView getMindmaps() throws IOException {
|
||||||
final User user = com.wisemapping.security.Utils.getUser();
|
final User user = com.wisemapping.security.Utils.getUser();
|
||||||
|
|
||||||
final List<MindmapUser> list = mindmapService.getMindmapUserByUser(user);
|
final List<MindmapUser> mapsByUser = mindmapService.getMindmapUserByUser(user);
|
||||||
// final RestMindMap map = new RestMindmap(mindMap);
|
final List<MindMap> mindmaps = new ArrayList<MindMap>();
|
||||||
// return new ModelAndView("mapView", "map", map);
|
for (MindmapUser mindmapUser : mapsByUser) {
|
||||||
return null;
|
mindmaps.add(mindmapUser.getMindMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
final RestMindmapList restMindmapList = new RestMindmapList(mindmaps);
|
||||||
|
return new ModelAndView("mapsView", "list", restMindmapList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.wisemapping.rest.model;
|
|||||||
|
|
||||||
import com.wisemapping.model.MindMap;
|
import com.wisemapping.model.MindMap;
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
|
import org.codehaus.jackson.annotate.JsonAutoDetect;
|
||||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -10,16 +11,16 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@XmlRootElement(name = "map")
|
@XmlRootElement(name = "map")
|
||||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||||
|
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||||
|
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||||
public class RestMindmap {
|
public class RestMindmap {
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private MindMap mindmap;
|
private MindMap mindmap;
|
||||||
|
|
||||||
public RestMindmap() {
|
public RestMindmap() {
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.wisemapping.rest.model;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wisemapping.model.MindMap;
|
||||||
|
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.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "maps")
|
||||||
|
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||||
|
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE,
|
||||||
|
getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, isGetterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
|
||||||
|
public class RestMindmapList {
|
||||||
|
|
||||||
|
private List<RestMindmap> mindmaps;
|
||||||
|
|
||||||
|
public RestMindmapList() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RestMindmapList(@NotNull List<MindMap> mindmaps) {
|
||||||
|
this.mindmaps = new ArrayList<RestMindmap>();
|
||||||
|
for (MindMap mindMap : mindmaps) {
|
||||||
|
this.mindmaps.add(new RestMindmap(mindMap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return this.mindmaps.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCount(int count) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "map")
|
||||||
|
public List<RestMindmap> getMindmaps() {
|
||||||
|
return mindmaps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMindmaps(List<RestMindmap> mindmaps) {
|
||||||
|
this.mindmaps = mindmaps;
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
log4j.rootLogger=WARN, stdout, R
|
log4j.rootLogger=WARN, stdout, R
|
||||||
log4j.logger.net.sf=FATAL,stdout, R
|
log4j.logger.net.sf=FATAL,stdout, R
|
||||||
log4j.logger.com.wisemapping=WARN,stdout,R
|
log4j.logger.com.wisemapping=WARN,stdout,R
|
||||||
log4j.logger.org.wisemapping.ws= WARN,stdout, R
|
log4j.logger.org.springframework=WARN,stdout,R
|
||||||
log4j.logger.org.acegisecurity.event.authentication= FATAL,stdout, R
|
|
||||||
|
|
||||||
# Stdout logger <20>
|
# Stdout logger <20>
|
||||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||||
|
@ -1,24 +1,48 @@
|
|||||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<title>Employees</title>
|
<title>Mindmap Detail</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<table border=1>
|
<h1>Details for map with id '${map.id}'</h1>
|
||||||
<thead><tr>
|
<table border="1" cellspacing="0">
|
||||||
<th>ID</th>
|
<tbody>
|
||||||
<th>Name</th>
|
<tr>
|
||||||
<th>Email</th>
|
<td>Id:</td>
|
||||||
</tr></thead>
|
<td>${map.id}</td>
|
||||||
<%--<c:forEach var="employee" items="${employees.employees}">--%>
|
</tr>
|
||||||
<%--<tr>--%>
|
<tr>
|
||||||
<%--<td>${employee.id}</td>--%>
|
<td>Title:</td>
|
||||||
<%--<td>${employee.name}</td>--%>
|
<td>${map.title}</td>
|
||||||
<%--<td>${employee.email}</td>--%>
|
</tr>
|
||||||
<%--</tr>--%>
|
<tr>
|
||||||
<%--</c:forEach>--%>
|
<td>Description:</td>
|
||||||
|
<td>${map.description}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Owner:</td>
|
||||||
|
<td>${map.owner}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Xml:</td>
|
||||||
|
<td><textarea rows="10" cols="100">${map.xml}</textarea></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Last Modified:</td>
|
||||||
|
<td>${map.lastModifierUser}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Creator:</td>
|
||||||
|
<td>${map.creator}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Public:</td>
|
||||||
|
<td>${map.public}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
51
wise-webapp/src/main/webapp/WEB-INF/jsp-rest/mapsView.jsp
Normal file
51
wise-webapp/src/main/webapp/WEB-INF/jsp-rest/mapsView.jsp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<%@ 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">
|
||||||
|
<title>Mindmaps List</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Mindmaps List</h1>
|
||||||
|
<c:forEach items="${list.mindmaps}" var="map">
|
||||||
|
<table border="1" cellspacing="0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Id:</td>
|
||||||
|
<td>${map.id}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Title:</td>
|
||||||
|
<td>${map.title}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Description:</td>
|
||||||
|
<td>${map.description}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Owner:</td>
|
||||||
|
<td>${map.owner}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Xml:</td>
|
||||||
|
<td><textarea rows="10" cols="100">${map.xml}</textarea></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Last Modified:</td>
|
||||||
|
<td>${map.lastModifierUser}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Creator:</td>
|
||||||
|
<td>${map.creator}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Public:</td>
|
||||||
|
<td>${map.public}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</c:forEach>
|
||||||
|
<br/>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -19,6 +19,7 @@
|
|||||||
<property name="classesToBeBound">
|
<property name="classesToBeBound">
|
||||||
<list>
|
<list>
|
||||||
<value>com.wisemapping.rest.model.RestMindmap</value>
|
<value>com.wisemapping.rest.model.RestMindmap</value>
|
||||||
|
<value>com.wisemapping.rest.model.RestMindmapList</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
@ -29,7 +30,7 @@
|
|||||||
<property name="mediaTypes">
|
<property name="mediaTypes">
|
||||||
<map>
|
<map>
|
||||||
<entry key="html" value="text/html"/>
|
<entry key="html" value="text/html"/>
|
||||||
<entry key="xml" value="text/xml"/>
|
<entry key="xml" value="application/xml"/>
|
||||||
<entry key="json" value="application/json"/>
|
<entry key="json" value="application/json"/>
|
||||||
<entry key="freemind" value="application/freemind"/>
|
<entry key="freemind" value="application/freemind"/>
|
||||||
<entry key="pdf" value="application/pdf"/>
|
<entry key="pdf" value="application/pdf"/>
|
||||||
|
@ -29,14 +29,11 @@
|
|||||||
<sec:http pattern="/dwr/engine.js" security="none"/>
|
<sec:http pattern="/dwr/engine.js" security="none"/>
|
||||||
<sec:http pattern="/dwr/interface/loggerservice.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="/dwr/call/plaincall/loggerservice.logerror.dwr" security="none"/>
|
||||||
|
|
||||||
<sec:http pattern="/service/transform.*" security="none"/>
|
<sec:http pattern="/service/transform.*" security="none"/>
|
||||||
<sec:http use-expressions="true" create-session="stateless" entry-point-ref="digestEntryPoint"
|
|
||||||
pattern="/service/**">
|
|
||||||
<sec:intercept-url pattern="/service/**" access="isAuthenticated()"/>
|
|
||||||
|
|
||||||
|
<sec:http use-expressions="true" create-session="never" pattern="/service/**">
|
||||||
|
<sec:intercept-url pattern="/service/**" access="isAuthenticated()"/>
|
||||||
<sec:http-basic/>
|
<sec:http-basic/>
|
||||||
<sec:custom-filter ref="digestFilter" after="BASIC_AUTH_FILTER"/>
|
|
||||||
</sec:http>
|
</sec:http>
|
||||||
|
|
||||||
<sec:http use-expressions="true">
|
<sec:http use-expressions="true">
|
||||||
@ -61,17 +58,4 @@
|
|||||||
<bean id="userDetailsService" class="com.wisemapping.security.UserDetailService">
|
<bean id="userDetailsService" class="com.wisemapping.security.UserDetailService">
|
||||||
<property name="userManager" ref="userManager"/>
|
<property name="userManager" ref="userManager"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="digestFilter" class="org.springframework.security.web.authentication.www.DigestAuthenticationFilter">
|
|
||||||
<property name="userDetailsService" ref="userDetailsService"/>
|
|
||||||
<property name="authenticationEntryPoint" ref="digestEntryPoint"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="digestEntryPoint"
|
|
||||||
class="org.springframework.security.web.authentication.www.DigestAuthenticationEntryPoint">
|
|
||||||
<property name="realmName" value="Wise Contacts Realm via Digest Authentication"/>
|
|
||||||
<property name="key" value="wisemapping-digest"/>
|
|
||||||
<property name="nonceValiditySeconds" value="10"/>
|
|
||||||
|
|
||||||
</bean>
|
|
||||||
</beans>
|
</beans>
|
Loading…
Reference in New Issue
Block a user