Skip to content

Commit

Permalink
Fix an issue related to parameter names in V2 Application API
Browse files Browse the repository at this point in the history
- Reverted to using {applicationName:.+} to match url parameters containing a dot
  • Loading branch information
jeyrschabu committed Sep 16, 2016
1 parent 8f786b9 commit e9fde37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public class Front50WebConfig extends WebMvcConfigurerAdapter {
)
}

@Override
void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(false)
}

@Bean
FilterRegistrationBean authenticatedRequestFilter() {
def frb = new FilterRegistrationBean(new AuthenticatedRequestFilter(true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ public class ApplicationsController {

@PreAuthorize("hasPermission(#applicationName, 'APPLICATION', 'WRITE')")
@ApiOperation(value = "", notes = "Delete an application")
@RequestMapping(method = RequestMethod.DELETE, value = "/{applicationName}")
@RequestMapping(method = RequestMethod.DELETE, value = "/{applicationName:.+}")
void delete(@PathVariable String applicationName, HttpServletResponse response) {
getApplication().initialize(new Application().withName(applicationName)).delete()
response.setStatus(HttpStatus.NO_CONTENT.value())
}

@PreAuthorize("hasPermission(#app.name, 'APPLICATION', 'WRITE')")
@ApiOperation(value = "", notes = "Update an existing application")
@RequestMapping(method = RequestMethod.PATCH, value = "/{applicationName}")
@RequestMapping(method = RequestMethod.PATCH, value = "/{applicationName:.+}")
Application update(@PathVariable String applicationName, @RequestBody final Application app) {
if (!applicationName.trim().equalsIgnoreCase(app.getName())) {
throw new InvalidApplicationRequestException("Application name '${app.getName()}' does not match path parameter '${applicationName}'")
Expand All @@ -108,13 +108,13 @@ public class ApplicationsController {
// vs. 403s if the app exists, but the user doesn't have access to it.
@PostAuthorize("hasPermission(#applicationName, 'APPLICATION', 'READ')")
@ApiOperation(value = "", notes = "Fetch a single application by name")
@RequestMapping(method = RequestMethod.GET, value = "/{applicationName}")
@RequestMapping(method = RequestMethod.GET, value = "/{applicationName:.+}")
Application get(@PathVariable final String applicationName) {
return applicationDAO.findByName(applicationName.toUpperCase())
}

@PreAuthorize("hasPermission(#applicationName, 'APPLICATION', 'READ')")
@RequestMapping(value = '{applicationName}/history', method = RequestMethod.GET)
@RequestMapping(value = '{applicationName:.+}/history', method = RequestMethod.GET)
Collection<Application> getHistory(@PathVariable String applicationName,
@RequestParam(value = "limit", defaultValue = "20") int limit) {
return applicationDAO.getApplicationHistory(applicationName, limit)
Expand Down

0 comments on commit e9fde37

Please sign in to comment.