mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
- JSON/XML/HTML configuration for map rendering
This commit is contained in:
parent
826606dc53
commit
a786c0de09
@ -261,8 +261,14 @@
|
|||||||
<artifactId>jackson-mapper-asl</artifactId>
|
<artifactId>jackson-mapper-asl</artifactId>
|
||||||
<version>1.9.4</version>
|
<version>1.9.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
|
<artifactId>xstream</artifactId>
|
||||||
|
<version>1.3.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -2,43 +2,32 @@ package com.wisemapping.rest;
|
|||||||
|
|
||||||
|
|
||||||
import com.wisemapping.model.MindMap;
|
import com.wisemapping.model.MindMap;
|
||||||
|
import com.wisemapping.rest.model.RestMindMap;
|
||||||
import com.wisemapping.service.MindmapService;
|
import com.wisemapping.service.MindmapService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@RequestMapping("/map")
|
||||||
public class MindmapController {
|
public class MindmapController {
|
||||||
|
@Autowired
|
||||||
private MindmapService mindmapService;
|
private MindmapService mindmapService;
|
||||||
|
|
||||||
public void setMindmapService(MindmapService mindmapService) {
|
|
||||||
this.mindmapService = mindmapService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/map/{id}")
|
@RequestMapping(method = RequestMethod.GET, value = "/{id}")
|
||||||
public
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
Map<String, Object> getMindmap(@PathVariable int id) throws IOException {
|
public ModelAndView getMindmap(@PathVariable int id) throws IOException {
|
||||||
final Map<String, Object> result = new HashMap<String, Object>();
|
|
||||||
final MindMap mindMap = mindmapService.getMindmapById(id);
|
final MindMap mindMap = mindmapService.getMindmapById(id);
|
||||||
result.put("xml", mindMap.getNativeXml());
|
final RestMindMap map = new RestMindMap(mindMap);
|
||||||
result.put("creationTime", mindMap.getCreationTime());
|
return new ModelAndView("mapView", "map", map);
|
||||||
result.put("description", mindMap.getDescription());
|
|
||||||
result.put("lastModification", mindMap.getLastModificationDate());
|
|
||||||
result.put("owner", mindMap.getOwner().getUsername());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/map/{id}")
|
|
||||||
public void updateMindmap(@PathVariable int id) throws IOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,67 +2,61 @@
|
|||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||||
xsi:schemaLocation="
|
xsi:schemaLocation="
|
||||||
http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||||
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context
|
||||||
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
http://www.springframework.org/schema/context/spring-context-3.1.xsd
|
||||||
|
http://www.springframework.org/schema/mvc
|
||||||
|
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
|
||||||
|
|
||||||
|
<context:component-scan base-package="com.wisemapping.rest"/>
|
||||||
|
<context:annotation-config/>
|
||||||
|
<mvc:annotation-driven/>
|
||||||
|
|
||||||
<context:component-scan base-package="dw.spring3.rest.controller"/>
|
|
||||||
|
|
||||||
<!-- To enable @RequestMapping process on type level and method level -->
|
<!-- To enable @RequestMapping process on type level and method level -->
|
||||||
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
|
<!--<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>-->
|
||||||
|
<!--<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>-->
|
||||||
|
|
||||||
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
|
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
|
||||||
|
<property name="classesToBeBound">
|
||||||
|
<list>
|
||||||
|
<value>com.wisemapping.rest.model.RestMindMap</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
|
||||||
|
<property name="defaultContentType" value="application/json"/>
|
||||||
|
<property name="favorPathExtension" value="true"/>
|
||||||
<property name="mediaTypes">
|
<property name="mediaTypes">
|
||||||
<map>
|
<map>
|
||||||
<entry key="xml" value="application/xml"/>
|
<entry key="xml" value="application/xml"/>
|
||||||
<entry key="html" value="text/html"/>
|
<entry key="html" value="text/html"/>
|
||||||
<entry key="json" value="application/json"/>
|
<entry key="json" value="application/json"/>
|
||||||
|
<entry key="pdf" value="application/pdf"/>
|
||||||
|
<entry key="png" value="application/pdf"/>
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
<property name="viewResolvers">
|
<property name="viewResolvers">
|
||||||
<list>
|
<list>
|
||||||
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
|
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||||
|
|
||||||
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
|
|
||||||
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
|
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
|
||||||
<property name="prefix" value="/WEB-INF/jsp-rest/"/>
|
<property name="prefix" value="/WEB-INF/jsp-rest/"/>
|
||||||
<property name="suffix" value=".jsp"/>
|
<property name="suffix" value=".jsp"/>
|
||||||
</bean>
|
</bean>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
<property name="defaultViews">
|
||||||
|
|
||||||
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
|
|
||||||
<property name="messageConverters">
|
|
||||||
<list>
|
<list>
|
||||||
<ref bean="jsonConverter"/>
|
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"/>
|
||||||
<ref bean="marshallingConverter"/>
|
<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
|
||||||
|
<constructor-arg ref="jaxbMarshaller"/>
|
||||||
|
</bean>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
|
|
||||||
<property name="supportedMediaTypes" value="application/json"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="marshallingConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
|
|
||||||
<constructor-arg ref="jaxbMarshaller"/>
|
|
||||||
<property name="supportedMediaTypes" value="application/xml"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
|
|
||||||
<property name="classesToBeBound">
|
|
||||||
<list>
|
|
||||||
<value>java.util.HashMap</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="mindmapRestController" class="com.wisemapping.rest.MindmapController">
|
|
||||||
<property name="mindmapService" ref="mindmapService"/>
|
|
||||||
</bean>
|
|
||||||
</beans>
|
</beans>
|
Loading…
Reference in New Issue
Block a user