Hi Christian

On 25/01/13 15:56, Christian Schneider wrote:
When doing the CXF version of the UserRequestService I found that our
current UserRequestController does not really follow the rest ideas.

The problem is that it does follow the idea of doing CRUD operations on
resources. Some methods work with userId others with requestId. So for
example the are create, update and delete operations but they
do not mean the UserRequest but the underlying user.

So I worked out a new interface that purely works on UserRequest and
only supports POST, READ and DELETE. So basically if you want to create
or delete or update a user you will POST a UserRequestTO in all cases.
I added constructors to the UserRequestTO to make the use cases simpler.

request to create a user:  userRequestService.create(new
UserRequestTO(userTO));
request to update a user: userRequestService.create(new
UserRequestTO(userMod));
request to delete a user:  userRequestService.create(new
UserRequestTO(userTO.getId()));

So what do you think about this?

IMHO it would be nicer to avoid overloading proxy "create" request to mean different things, definitely would not use "create" to mean "delete" - perhaps it is a typo, the interface below suggests it might be ? Would also use "update()" for updates

Just my 2c :-)

Sergey


The only thing I really struggled with is the old isCreateAllowed
method. I implemented this using @Options and return the boolean in a
custom header. I am not sure if this is really the best way to do this
but it
follows the rest principles quite closely. The alternative would be to
do a get on a magic path like in the current spring service.

Best regards

Christian

------------------------------
Current Interface:
@RequestMapping(method = RequestMethod.POST, value = "/create")
public UserRequestTO create(@RequestBody final UserTO userTO);

@RequestMapping(method = RequestMethod.POST, value = "/update")
public UserRequestTO update(@RequestBody final UserMod userMod);

@RequestMapping(method = RequestMethod.GET, value = "/delete/{userId}")
public UserRequestTO delete(@PathVariable("userId") final Long userId)

@RequestMapping(method = RequestMethod.GET, value = "/list")
public List<UserRequestTO>  list();

@RequestMapping(method = RequestMethod.GET, value = "/read/{requestId}")
public UserRequestTO read(@PathVariable("requestId") final Long requestId);

@RequestMapping(method = RequestMethod.GET, value =
"/deleteRequest/{requestId}")
public UserRequestTO deleteRequest(@PathVariable("requestId") final Long
requestId);

--------------------
New interface for CXF Service:
@Path("requests/user")
public interface UserRequestService {
     public static final String SYNCOPE_CREATE_ALLOWED =
"Syncope-Create-Allowed";

     @OPTIONS
     Response getOptions();

     @POST
     Response create(UserRequestTO userRequestTO);

     @GET
     List<UserRequestTO>  list();

     @GET
     @Path("{requestId}")
     UserRequestTO read(@PathParam("requestId") Long requestId);

     @DELETE
     @Path("{requestId}")
     void delete(@PathParam("requestId") Long requestId);
}



Reply via email to