- First REST operation working

This commit is contained in:
Paulo Gustavo Veiga
2012-02-12 21:57:11 -03:00
parent 5fd6ba30f5
commit 826606dc53
11 changed files with 133 additions and 77 deletions

View File

@@ -0,0 +1,44 @@
package com.wisemapping.rest;
import com.wisemapping.model.MindMap;
import com.wisemapping.service.MindmapService;
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 java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@Controller
public class MindmapController {
private MindmapService mindmapService;
public void setMindmapService(MindmapService mindmapService) {
this.mindmapService = mindmapService;
}
@RequestMapping(method = RequestMethod.GET, value = "/map/{id}")
public
@ResponseBody
Map<String, Object> getMindmap(@PathVariable int id) throws IOException {
final Map<String, Object> result = new HashMap<String, Object>();
final MindMap mindMap = mindmapService.getMindmapById(id);
result.put("xml", mindMap.getNativeXml());
result.put("creationTime", mindMap.getCreationTime());
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 {
}
}

View File

@@ -1,30 +0,0 @@
package com.wisemapping.rest;
import com.wisemapping.model.User;
import org.jetbrains.annotations.NotNull;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
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.servlet.ModelAndView;
@Controller
public class UserController {
private Jaxb2Marshaller jaxb2Mashaller;
public void setJaxb2Mashaller(@NotNull final Jaxb2Marshaller jaxb2Mashaller) {
this.jaxb2Mashaller = jaxb2Mashaller;
}
private static final String XML_VIEW_NAME = "users";
@RequestMapping(method = RequestMethod.GET, value = "/employee/{id}")
public ModelAndView getEmployee(@PathVariable String id) {
User user = new User();
return new ModelAndView(XML_VIEW_NAME, "object", user);
}
}