/** * Verifies that the given {@link RootResourceInformation} has searches exposed. * * @param resourceInformation */ private static SearchResourceMappings verifySearchesExposed(RootResourceInformation resourceInformation) { SearchResourceMappings resourceMappings = resourceInformation.getSearchMappings(); if (!resourceMappings.isExported()) { throw new ResourceNotFoundException(); } return resourceMappings; }
/** * Executes the search with the given name. * * @param resourceInformation * @param parameters * @param search * @param pageable * @param sort * @param assembler * @return * @throws ResourceNotFoundException */ @ResponseBody @RequestMapping(value = BASE_MAPPING + "/{search}", method = RequestMethod.GET) public ResponseEntity<?> executeSearch(RootResourceInformation resourceInformation, @RequestParam MultiValueMap<String, Object> parameters, @PathVariable String search, DefaultedPageable pageable, Sort sort, PersistentEntityResourceAssembler assembler, @RequestHeader HttpHeaders headers) { Method method = checkExecutability(resourceInformation, search); Optional<Object> result = executeQueryMethod(resourceInformation.getInvoker(), parameters, method, pageable, sort, assembler); SearchResourceMappings searchMappings = resourceInformation.getSearchMappings(); MethodResourceMapping methodMapping = searchMappings.getExportedMethodMappingForPath(search); Class<?> domainType = methodMapping.getReturnedDomainType(); return toResource(result, assembler, domainType, Optional.empty(), headers, resourceInformation); }
/** * Verifies that the given {@link RootResourceInformation} has searches exposed. * * @param resourceInformation */ private static SearchResourceMappings verifySearchesExposed(RootResourceInformation resourceInformation) { SearchResourceMappings resourceMappings = resourceInformation.getSearchMappings(); if (!resourceMappings.isExported()) { throw new ResourceNotFoundException(); } return resourceMappings; }
/** * Executes the search with the given name. * * @param resourceInformation * @param parameters * @param search * @param pageable * @param sort * @param assembler * @return * @throws ResourceNotFoundException */ @ResponseBody @RequestMapping(value = BASE_MAPPING + "/{search}", method = RequestMethod.GET) public ResponseEntity<?> executeSearch(RootResourceInformation resourceInformation, @RequestParam MultiValueMap<String, Object> parameters, @PathVariable String search, DefaultedPageable pageable, Sort sort, PersistentEntityResourceAssembler assembler, @RequestHeader HttpHeaders headers) { Method method = checkExecutability(resourceInformation, search); Optional<Object> result = executeQueryMethod(resourceInformation.getInvoker(), parameters, method, pageable, sort, assembler); SearchResourceMappings searchMappings = resourceInformation.getSearchMappings(); MethodResourceMapping methodMapping = searchMappings.getExportedMethodMappingForPath(search); Class<?> domainType = methodMapping.getReturnedDomainType(); return toResource(result, assembler, domainType, Optional.empty(), headers, resourceInformation); }