package at.fwd.swagger.spring.demo.user.controller;

import java.math.BigDecimal;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import javax.annotation.PostConstruct;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import at.fwd.swagger.spring.demo.user.exception.ObjectNotFoundException;
import at.fwd.swagger.spring.demo.user.model.Category;
import at.fwd.swagger.spring.demo.user.model.Location;
import at.fwd.swagger.spring.demo.user.model.State;
import at.fwd.swagger.spring.demo.user.model.User;

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;

/**
 * User Controller with full POST request
 * supports GET + POST
 * 
 * @author johannes.fiala@fwd.at
 *
 */
@RestController
@Api(value="user-crud-complete-post", position=2, description ="User services with complete post")
public class UserControllerWithCompletePost {
	/**
	 * Logger for this class
	 */
	private static final Logger log = Logger.getLogger(UserControllerWithCompletePost.class);

	private static final String PATH = "/user_complete_post";
	
	private static final String MESSAGE_NOT_FOUND = "User not found";
	
	private static final String MESSAGE_POST_SUCCESS = "User has been updated";
	
	@Autowired
	UserController userController;
	 
    @RequestMapping(method=RequestMethod.POST, value=PATH + "_complete")
    @ApiOperation(value="create or update a user name by id", position = 1)
    @ApiResponses(value = {
    	    @ApiResponse(code = 200, message = MESSAGE_POST_SUCCESS, response = User.class) })
    public User saveUserComplete(@RequestParam(required=true) Long id, 
    		@RequestParam(required=true) User user) {
    	
    	if (user!=null) {
    		userController.getUserMap().put(id,  user);

    	} else {
    		throw new ObjectNotFoundException(MESSAGE_NOT_FOUND);
    	}
    	
    	return user;
    }
    
}

@@ -50,168 +50,8 @@
 r;%0A%0A
-import java.math.BigDecimal;%0Aimport java.util.concurrent.ConcurrentHashMap;%0Aimport java.util.concurrent.ConcurrentMap;%0A%0Aimport javax.annotation.PostConstruct;%0A%0A
 impo
@@ -141,16 +141,76 @@
 owired;%0A
+import org.springframework.web.bind.annotation.RequestBody;%0A
 import o
@@ -379,379 +379,95 @@
 n.Re
-questParam;%0Aimport org.springframework.web.bind.annotation.ResponseBody;%0Aimport org.springframework.web.bind.annotation.RestController;%0A%0Aimport at.fwd.swagger.spring.demo.user.exception.ObjectNotFoundException;%0Aimport at.fwd.swagger.spring.demo.user.model.Category;%0Aimport at.fwd.swagger.spring.demo.user.model.Location;%0Aimport at.fwd.swagger.spring.demo.user.model.State
+stController;%0A%0Aimport at.fwd.swagger.spring.demo.user.exception.ObjectNotFoundException
 ;%0Aim
@@ -1691,73 +1691,12 @@
 uest
-Param(required=true) Long id, %0A    %09%09@RequestParam(required=true)
+Body
  Use
@@ -1772,18 +1772,28 @@
 p().put(
-id
+user.getId()
 ,  user)

Fix @RequestBody instead of @RequestParam for complete object