@Test void createFromFormPost() throws Exception { mockMvc .perform( post(HREF_ENTITY) .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param("id", "p1") .param("name", "Piet")) .andExpect(status().isCreated()) .andExpect(MockMvcResultMatchers.header().string("Location", HREF_ENTITY_ID)); verify(dataService).add(ArgumentMatchers.eq(ENTITY_NAME), any(Entity.class)); }
@Transactional @PostMapping( value = "/{entityTypeId}", headers = "Content-Type=application/x-www-form-urlencoded") public void createFromFormPost( @PathVariable("entityTypeId") String entityTypeId, HttpServletRequest request, HttpServletResponse response) { Map<String, Object> paramMap = new HashMap<>(); for (String param : request.getParameterMap().keySet()) { String[] values = request.getParameterValues(param); String value = values != null ? StringUtils.join(values, ',') : null; if (StringUtils.isNotBlank(value)) { paramMap.put(param, value); } } createInternal(entityTypeId, paramMap, response); }
RestController { @Transactional @PostMapping( value = "/{entityTypeId}", headers = "Content-Type=application/x-www-form-urlencoded") public void createFromFormPost( @PathVariable("entityTypeId") String entityTypeId, HttpServletRequest request, HttpServletResponse response) { Map<String, Object> paramMap = new HashMap<>(); for (String param : request.getParameterMap().keySet()) { String[] values = request.getParameterValues(param); String value = values != null ? StringUtils.join(values, ',') : null; if (StringUtils.isNotBlank(value)) { paramMap.put(param, value); } } createInternal(entityTypeId, paramMap, response); } }
RestController { @Transactional @PostMapping( value = "/{entityTypeId}", headers = "Content-Type=application/x-www-form-urlencoded") public void createFromFormPost( @PathVariable("entityTypeId") String entityTypeId, HttpServletRequest request, HttpServletResponse response) { Map<String, Object> paramMap = new HashMap<>(); for (String param : request.getParameterMap().keySet()) { String[] values = request.getParameterValues(param); String value = values != null ? StringUtils.join(values, ',') : null; if (StringUtils.isNotBlank(value)) { paramMap.put(param, value); } } createInternal(entityTypeId, paramMap, response); } RestController(
      AuthenticationSettings authenticationSettings,
      DataService dataService,
      TokenService tokenService,
      AuthenticationManager authenticationManager,
      UserPermissionEvaluator permissionService,
      UserAccountService userAccountService,
      MolgenisRSQL molgenisRSQL,
      RestService restService); }
RestController { @Transactional @PostMapping( value = "/{entityTypeId}", headers = "Content-Type=application/x-www-form-urlencoded") public void createFromFormPost( @PathVariable("entityTypeId") String entityTypeId, HttpServletRequest request, HttpServletResponse response) { Map<String, Object> paramMap = new HashMap<>(); for (String param : request.getParameterMap().keySet()) { String[] values = request.getParameterValues(param); String value = values != null ? StringUtils.join(values, ',') : null; if (StringUtils.isNotBlank(value)) { paramMap.put(param, value); } } createInternal(entityTypeId, paramMap, response); } RestController(
      AuthenticationSettings authenticationSettings,
      DataService dataService,
      TokenService tokenService,
      AuthenticationManager authenticationManager,
      UserPermissionEvaluator permissionService,
      UserAccountService userAccountService,
      MolgenisRSQL molgenisRSQL,
      RestService restService); @GetMapping(value = "/{entityTypeId}/exist", produces = APPLICATION_JSON_VALUE) boolean entityExists(@PathVariable("entityTypeId") String entityTypeId); @GetMapping(value = "/{entityTypeId}/meta", produces = APPLICATION_JSON_VALUE) EntityTypeResponse retrieveEntityType(
      @PathVariable("entityTypeId") String entityTypeId,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands); @PostMapping( value = "/{entityTypeId}/meta", params = "_method=GET", produces = APPLICATION_JSON_VALUE) EntityTypeResponse retrieveEntityTypePost(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid @RequestBody EntityTypeRequest request); @GetMapping(value = "/{entityTypeId}/meta/{attributeName}", produces = APPLICATION_JSON_VALUE) AttributeResponse retrieveEntityAttributeMeta(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeName") String attributeName,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands); @PostMapping( value = "/{entityTypeId}/meta/{attributeName}", params = "_method=GET", produces = APPLICATION_JSON_VALUE) AttributeResponse retrieveEntityAttributeMetaPost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeName") String attributeName,
      @Valid @RequestBody EntityTypeRequest request); @GetMapping(value = "/{entityTypeId}/{id}", produces = APPLICATION_JSON_VALUE) Map<String, Object> retrieveEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands); @PostMapping( value = "/{entityTypeId}/{id}", params = "_method=GET", produces = APPLICATION_JSON_VALUE) @ResponseBody @SuppressWarnings("javasecurity:S5131") // untypedId is validated in dataService.findOneById() Map<String, Object> retrieveEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @Valid @RequestBody EntityTypeRequest request); @GetMapping(value = "/{entityTypeId}/{id}/{refAttributeName}", produces = APPLICATION_JSON_VALUE) Object retrieveEntityAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @PathVariable("refAttributeName") String refAttributeName,
      @Valid EntityCollectionRequest request,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands); @PostMapping( value = "/{entityTypeId}/{id}/{refAttributeName}", params = "_method=GET", produces = APPLICATION_JSON_VALUE) Object retrieveEntityAttributePost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @PathVariable("refAttributeName") String refAttributeName,
      @Valid @RequestBody EntityCollectionRequest request); @GetMapping(value = "/{entityTypeId}", produces = APPLICATION_JSON_VALUE) EntityCollectionResponse retrieveEntityCollection(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid EntityCollectionRequest request,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands); @PostMapping(value = "/{entityTypeId}", params = "_method=GET", produces = APPLICATION_JSON_VALUE) EntityCollectionResponse retrieveEntityCollectionPost(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid @RequestBody EntityCollectionRequest request); @GetMapping(value = "/csv/{entityTypeId}", produces = "text/csv") @ResponseBody EntityCollection retrieveEntityCollection(
      @PathVariable("entityTypeId") String entityTypeId,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      HttpServletRequest req,
      HttpServletResponse resp); @Transactional @PostMapping( value = "/{entityTypeId}", headers = "Content-Type=application/x-www-form-urlencoded") void createFromFormPost(
      @PathVariable("entityTypeId") String entityTypeId,
      HttpServletRequest request,
      HttpServletResponse response); @Transactional @PostMapping(value = "/{entityTypeId}", headers = "Content-Type=multipart/form-data") void createFromFormPostMultiPart(
      @PathVariable("entityTypeId") String entityTypeId,
      MultipartHttpServletRequest request,
      HttpServletResponse response); @Transactional @PostMapping("/{entityTypeId}") void create(
      @PathVariable("entityTypeId") String entityTypeId,
      @RequestBody Map<String, Object> entityMap,
      HttpServletResponse response); @Transactional @PutMapping("/{entityTypeId}/{id}") @ResponseStatus(OK) void update(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @RequestBody Map<String, Object> entityMap); @Transactional @PostMapping(value = "/{entityTypeId}/{id}", params = "_method=PUT") @ResponseStatus(OK) void updatePost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @RequestBody Map<String, Object> entityMap); @PutMapping(value = "/{entityTypeId}/{id}/{attributeName}") @ResponseStatus(OK) void updateAttributePut(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeName") String attributeName,
      @PathVariable("id") String untypedId,
      @RequestBody(required = false) Object paramValue); @PostMapping(value = "/{entityTypeId}/{id}/{attributeName}", params = "_method=PUT") @ResponseStatus(OK) synchronized void updateAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeName") String attributeName,
      @PathVariable("id") String untypedId,
      @RequestBody(required = false) Object paramValue); @Transactional @PostMapping( value = "/{entityTypeId}/{id}", params = "_method=PUT", headers = "Content-Type=multipart/form-data") @ResponseStatus(NO_CONTENT) void updateFromFormPostMultiPart(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      MultipartHttpServletRequest request); @Transactional @PostMapping( value = "/{entityTypeId}/{id}", params = "_method=PUT", headers = "Content-Type=application/x-www-form-urlencoded") @ResponseStatus(NO_CONTENT) void updateFromFormPost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      HttpServletRequest request); @Transactional @DeleteMapping("/{entityTypeId}/{id}") @ResponseStatus(NO_CONTENT) void deleteDelete(
      @PathVariable("entityTypeId") String entityTypeId, @PathVariable("id") String untypedId); @PostMapping(value = "/{entityTypeId}/{id}", params = "_method=DELETE") @ResponseStatus(NO_CONTENT) void deletePost(
      @PathVariable("entityTypeId") String entityTypeId, @PathVariable("id") String untypedId); @DeleteMapping("/{entityTypeId}") @ResponseStatus(NO_CONTENT) void deleteAll(@PathVariable("entityTypeId") String entityTypeId); @PostMapping(value = "/{entityTypeId}", params = "_method=DELETE") @ResponseStatus(NO_CONTENT) void deleteAllPost(@PathVariable("entityTypeId") String entityTypeId); @DeleteMapping(value = "/{entityTypeId}/meta") @ResponseStatus(NO_CONTENT) void deleteMeta(@PathVariable("entityTypeId") String entityTypeId); @PostMapping(value = "/{entityTypeId}/meta", params = "_method=DELETE") @ResponseStatus(NO_CONTENT) void deleteMetaPost(@PathVariable("entityTypeId") String entityTypeId); @PostMapping(value = "/login", produces = APPLICATION_JSON_VALUE) @ResponseBody LoginResponse login(@Valid @RequestBody LoginRequest login, HttpServletRequest request); @PostMapping("/logout") @ResponseStatus(OK) void logout(@TokenParam(required = true) String token, HttpServletRequest request); @ExceptionHandler(HttpMessageNotReadableException.class) @ResponseStatus(BAD_REQUEST) ErrorMessageResponse handleHttpMessageNotReadableException(
      HttpMessageNotReadableException e); @ExceptionHandler(UnknownTokenException.class) @ResponseStatus(NOT_FOUND) ErrorMessageResponse handleUnknownTokenException(UnknownTokenException e); @ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(BAD_REQUEST) ErrorMessageResponse handleMethodArgumentNotValidException(
      MethodArgumentNotValidException e); @ExceptionHandler(MolgenisValidationException.class) @ResponseStatus(BAD_REQUEST) ErrorMessageResponse handleMolgenisValidationException(MolgenisValidationException e); @ExceptionHandler(ConversionException.class) @ResponseStatus(BAD_REQUEST) ErrorMessageResponse handleConversionException(ConversionException e); @ExceptionHandler(MolgenisDataException.class) @ResponseStatus(BAD_REQUEST) ErrorMessageResponse handleMolgenisDataException(MolgenisDataException e); @ExceptionHandler(AuthenticationException.class) @ResponseStatus(UNAUTHORIZED) ErrorMessageResponse handleAuthenticationException(AuthenticationException e); @ExceptionHandler(MolgenisDataAccessException.class) @ResponseStatus(UNAUTHORIZED) ErrorMessageResponse handleMolgenisDataAccessException(MolgenisDataAccessException e); }
RestController { @Transactional @PostMapping( value = "/{entityTypeId}", headers = "Content-Type=application/x-www-form-urlencoded") public void createFromFormPost( @PathVariable("entityTypeId") String entityTypeId, HttpServletRequest request, HttpServletResponse response) { Map<String, Object> paramMap = new HashMap<>(); for (String param : request.getParameterMap().keySet()) { String[] values = request.getParameterValues(param); String value = values != null ? StringUtils.join(values, ',') : null; if (StringUtils.isNotBlank(value)) { paramMap.put(param, value); } } createInternal(entityTypeId, paramMap, response); } RestController(
      AuthenticationSettings authenticationSettings,
      DataService dataService,
      TokenService tokenService,
      AuthenticationManager authenticationManager,
      UserPermissionEvaluator permissionService,
      UserAccountService userAccountService,
      MolgenisRSQL molgenisRSQL,
      RestService restService); @GetMapping(value = "/{entityTypeId}/exist", produces = APPLICATION_JSON_VALUE) boolean entityExists(@PathVariable("entityTypeId") String entityTypeId); @GetMapping(value = "/{entityTypeId}/meta", produces = APPLICATION_JSON_VALUE) EntityTypeResponse retrieveEntityType(
      @PathVariable("entityTypeId") String entityTypeId,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands); @PostMapping( value = "/{entityTypeId}/meta", params = "_method=GET", produces = APPLICATION_JSON_VALUE) EntityTypeResponse retrieveEntityTypePost(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid @RequestBody EntityTypeRequest request); @GetMapping(value = "/{entityTypeId}/meta/{attributeName}", produces = APPLICATION_JSON_VALUE) AttributeResponse retrieveEntityAttributeMeta(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeName") String attributeName,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands); @PostMapping( value = "/{entityTypeId}/meta/{attributeName}", params = "_method=GET", produces = APPLICATION_JSON_VALUE) AttributeResponse retrieveEntityAttributeMetaPost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeName") String attributeName,
      @Valid @RequestBody EntityTypeRequest request); @GetMapping(value = "/{entityTypeId}/{id}", produces = APPLICATION_JSON_VALUE) Map<String, Object> retrieveEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands); @PostMapping( value = "/{entityTypeId}/{id}", params = "_method=GET", produces = APPLICATION_JSON_VALUE) @ResponseBody @SuppressWarnings("javasecurity:S5131") // untypedId is validated in dataService.findOneById() Map<String, Object> retrieveEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @Valid @RequestBody EntityTypeRequest request); @GetMapping(value = "/{entityTypeId}/{id}/{refAttributeName}", produces = APPLICATION_JSON_VALUE) Object retrieveEntityAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @PathVariable("refAttributeName") String refAttributeName,
      @Valid EntityCollectionRequest request,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands); @PostMapping( value = "/{entityTypeId}/{id}/{refAttributeName}", params = "_method=GET", produces = APPLICATION_JSON_VALUE) Object retrieveEntityAttributePost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @PathVariable("refAttributeName") String refAttributeName,
      @Valid @RequestBody EntityCollectionRequest request); @GetMapping(value = "/{entityTypeId}", produces = APPLICATION_JSON_VALUE) EntityCollectionResponse retrieveEntityCollection(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid EntityCollectionRequest request,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands); @PostMapping(value = "/{entityTypeId}", params = "_method=GET", produces = APPLICATION_JSON_VALUE) EntityCollectionResponse retrieveEntityCollectionPost(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid @RequestBody EntityCollectionRequest request); @GetMapping(value = "/csv/{entityTypeId}", produces = "text/csv") @ResponseBody EntityCollection retrieveEntityCollection(
      @PathVariable("entityTypeId") String entityTypeId,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      HttpServletRequest req,
      HttpServletResponse resp); @Transactional @PostMapping( value = "/{entityTypeId}", headers = "Content-Type=application/x-www-form-urlencoded") void createFromFormPost(
      @PathVariable("entityTypeId") String entityTypeId,
      HttpServletRequest request,
      HttpServletResponse response); @Transactional @PostMapping(value = "/{entityTypeId}", headers = "Content-Type=multipart/form-data") void createFromFormPostMultiPart(
      @PathVariable("entityTypeId") String entityTypeId,
      MultipartHttpServletRequest request,
      HttpServletResponse response); @Transactional @PostMapping("/{entityTypeId}") void create(
      @PathVariable("entityTypeId") String entityTypeId,
      @RequestBody Map<String, Object> entityMap,
      HttpServletResponse response); @Transactional @PutMapping("/{entityTypeId}/{id}") @ResponseStatus(OK) void update(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @RequestBody Map<String, Object> entityMap); @Transactional @PostMapping(value = "/{entityTypeId}/{id}", params = "_method=PUT") @ResponseStatus(OK) void updatePost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @RequestBody Map<String, Object> entityMap); @PutMapping(value = "/{entityTypeId}/{id}/{attributeName}") @ResponseStatus(OK) void updateAttributePut(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeName") String attributeName,
      @PathVariable("id") String untypedId,
      @RequestBody(required = false) Object paramValue); @PostMapping(value = "/{entityTypeId}/{id}/{attributeName}", params = "_method=PUT") @ResponseStatus(OK) synchronized void updateAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeName") String attributeName,
      @PathVariable("id") String untypedId,
      @RequestBody(required = false) Object paramValue); @Transactional @PostMapping( value = "/{entityTypeId}/{id}", params = "_method=PUT", headers = "Content-Type=multipart/form-data") @ResponseStatus(NO_CONTENT) void updateFromFormPostMultiPart(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      MultipartHttpServletRequest request); @Transactional @PostMapping( value = "/{entityTypeId}/{id}", params = "_method=PUT", headers = "Content-Type=application/x-www-form-urlencoded") @ResponseStatus(NO_CONTENT) void updateFromFormPost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      HttpServletRequest request); @Transactional @DeleteMapping("/{entityTypeId}/{id}") @ResponseStatus(NO_CONTENT) void deleteDelete(
      @PathVariable("entityTypeId") String entityTypeId, @PathVariable("id") String untypedId); @PostMapping(value = "/{entityTypeId}/{id}", params = "_method=DELETE") @ResponseStatus(NO_CONTENT) void deletePost(
      @PathVariable("entityTypeId") String entityTypeId, @PathVariable("id") String untypedId); @DeleteMapping("/{entityTypeId}") @ResponseStatus(NO_CONTENT) void deleteAll(@PathVariable("entityTypeId") String entityTypeId); @PostMapping(value = "/{entityTypeId}", params = "_method=DELETE") @ResponseStatus(NO_CONTENT) void deleteAllPost(@PathVariable("entityTypeId") String entityTypeId); @DeleteMapping(value = "/{entityTypeId}/meta") @ResponseStatus(NO_CONTENT) void deleteMeta(@PathVariable("entityTypeId") String entityTypeId); @PostMapping(value = "/{entityTypeId}/meta", params = "_method=DELETE") @ResponseStatus(NO_CONTENT) void deleteMetaPost(@PathVariable("entityTypeId") String entityTypeId); @PostMapping(value = "/login", produces = APPLICATION_JSON_VALUE) @ResponseBody LoginResponse login(@Valid @RequestBody LoginRequest login, HttpServletRequest request); @PostMapping("/logout") @ResponseStatus(OK) void logout(@TokenParam(required = true) String token, HttpServletRequest request); @ExceptionHandler(HttpMessageNotReadableException.class) @ResponseStatus(BAD_REQUEST) ErrorMessageResponse handleHttpMessageNotReadableException(
      HttpMessageNotReadableException e); @ExceptionHandler(UnknownTokenException.class) @ResponseStatus(NOT_FOUND) ErrorMessageResponse handleUnknownTokenException(UnknownTokenException e); @ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(BAD_REQUEST) ErrorMessageResponse handleMethodArgumentNotValidException(
      MethodArgumentNotValidException e); @ExceptionHandler(MolgenisValidationException.class) @ResponseStatus(BAD_REQUEST) ErrorMessageResponse handleMolgenisValidationException(MolgenisValidationException e); @ExceptionHandler(ConversionException.class) @ResponseStatus(BAD_REQUEST) ErrorMessageResponse handleConversionException(ConversionException e); @ExceptionHandler(MolgenisDataException.class) @ResponseStatus(BAD_REQUEST) ErrorMessageResponse handleMolgenisDataException(MolgenisDataException e); @ExceptionHandler(AuthenticationException.class) @ResponseStatus(UNAUTHORIZED) ErrorMessageResponse handleAuthenticationException(AuthenticationException e); @ExceptionHandler(MolgenisDataAccessException.class) @ResponseStatus(UNAUTHORIZED) ErrorMessageResponse handleMolgenisDataAccessException(MolgenisDataAccessException e);  }