Uploaded image for project: 'Spring Data REST'
  1. Spring Data REST
  2. DATAREST-423

Spring Data REST registered ConversionService not used when overriding individual resources

    Details

    • Sprint:
      55 - Evans SR2

      Description

      I have a business object User and in my application I have to set property active to false when deleting User.

      I don't want to expose my business logic on REST model so I wanted to override DELETE /user/{id} behavior to patch user to set active to false.

      In order to achieve that I write my own controller with following piece of code:

      @RepositoryRestController
      @ResponseBody
      @RequestMapping("/users")
      public class UserController {
      
          @Inject
          private UserService userService;
      
          @ResponseStatus(value = HttpStatus.NO_CONTENT)
          @RequestMapping(method = RequestMethod.DELETE, value = "/{user}")
          public void delete(@PathVariable("user") User user) {
              user.setActive(false);
              userService.save(user);
          }
      }
      

      Method is correctly called but I get an org.springframework.beans.ConversionNotSupportedException...

      So I tried to add a custom converter (String -> User) like describe here: http://docs.spring.io/spring-data/rest/docs/1.1.0.M1/reference/htmlsingle/#d4e110

      But the converter is never called.

      When debugging I saw that https://github.com/spring-projects/spring-framework/blob/master/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java#L169 is NULL that why my converter is not called.

      I will try to find more and create PR if possible but atm I don't have more information.

        Attachments

          Activity

            People

            • Assignee:
              olivergierke Oliver Drotbohm
              Reporter:
              kakawait Thibaud Lepretre
              Last updater:
              Oliver Drotbohm
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: