ClientAPI now sets owner for clients

pull/105/merge
Michael Jett 13 years ago
parent f7a0b8de32
commit 51fe98b383

@ -28,6 +28,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.security.Principal;
import java.util.Collection;
import java.util.UUID;
@ -61,19 +62,23 @@ public class ClientAPI {
}
@RequestMapping(method = RequestMethod.POST, headers = "Accept=application/json")
public String apiAddClient(@RequestBody String json, Model m) {
public String apiAddClient(@RequestBody String json, Model m, Principal principal) {
ClientDetailsEntity client = new Gson().fromJson(json, ClientDetailsEntity.class);
// set owners as current logged in user
client.setOwner(principal.getName());
m.addAttribute("entity", clientService.saveClient(client));
return "jsonClientView";
}
@RequestMapping(value="/{id}", method = RequestMethod.PUT, headers = "Accept=application/json")
public String apiUpdateClient(@PathVariable("id") String id, @RequestBody String json, Model m) {
public String apiUpdateClient(@PathVariable("id") String id, @RequestBody String json, Model m, Principal principal) {
ClientDetailsEntity client = new Gson().fromJson(json, ClientDetailsEntity.class);
client.setClientId(id);
// set owners as current logged in user
client.setOwner(principal.getName());
m.addAttribute("entity", clientService.saveClient(client));

Loading…
Cancel
Save