use of org.springframework.web.bind.annotation.RequestParam in project data-prep by Talend.
the class DataSetAPI method listSummary.
@RequestMapping(value = "/api/datasets/summary", method = GET, produces = APPLICATION_JSON_VALUE)
@ApiOperation(value = "List data sets summary.", produces = APPLICATION_JSON_VALUE, notes = "Returns a list of data sets summary the user can use.")
@Timed
public Callable<Stream<EnrichedDataSetMetadata>> listSummary(@ApiParam(value = "Sort key (by name or date), defaults to 'date'.") @RequestParam(defaultValue = "creationDate") Sort sort, @ApiParam(value = "Order for sort key (desc or asc), defaults to 'desc'.") @RequestParam(defaultValue = "desc") Order order, @ApiParam(value = "Filter on name containing the specified name") @RequestParam(defaultValue = "") String name, @ApiParam(value = "Filter on certified data sets") @RequestParam(defaultValue = "false") boolean certified, @ApiParam(value = "Filter on favorite data sets") @RequestParam(defaultValue = "false") boolean favorite, @ApiParam(value = "Filter on recent data sets") @RequestParam(defaultValue = "false") boolean limit) {
if (LOG.isDebugEnabled()) {
LOG.debug("Listing datasets summary (pool: {})...", getConnectionStats());
}
return () -> {
GenericCommand<InputStream> listDataSets = getCommand(DataSetList.class, sort, order, name, certified, favorite, limit);
return //
Flux.from(CommandHelper.toPublisher(UserDataSetMetadata.class, mapper, listDataSets)).map(m -> {
LOG.debug("found dataset {} in the summary list" + m.getName());
// Add the related preparations list to the given dataset metadata.
final PreparationSearchByDataSetId getPreparations = getCommand(PreparationSearchByDataSetId.class, m.getId());
return //
Flux.from(CommandHelper.toPublisher(Preparation.class, mapper, getPreparations)).collectList().map(preparations -> {
final List<Preparation> list = //
preparations.stream().filter(//
p -> p.getSteps() != null).collect(Collectors.toList());
return new EnrichedDataSetMetadata(m, list);
}).block();
}).toStream(1);
};
}
use of org.springframework.web.bind.annotation.RequestParam in project alien4cloud by alien4cloud.
the class LocationSecurityController method getAuthorizedEnvironmentsAndEnvTypesPerApplicationPaginated.
/**
* search applications,environments and environment types authorised to access the location.
*
* @return {@link RestResponse} that contains a {@link GetMultipleDataResult} of {@link GroupDTO}..
*/
@ApiOperation(value = "List all applications,environments and environment types authorized to access the location", notes = "Only user with ADMIN role can list authorized applications,environments and environment types to the location.")
@RequestMapping(value = "/applications/search", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public RestResponse<GetMultipleDataResult<ApplicationEnvironmentAuthorizationDTO>> getAuthorizedEnvironmentsAndEnvTypesPerApplicationPaginated(@PathVariable String orchestratorId, @PathVariable String locationId, @ApiParam(value = "Text Query to search.") @RequestParam(required = false) String query, @ApiParam(value = "Query from the given index.") @RequestParam(required = false, defaultValue = "0") int from, @ApiParam(value = "Maximum number of results to retrieve.") @RequestParam(required = false, defaultValue = "20") int size) {
Location location = locationService.getLocation(orchestratorId, locationId);
List<Application> applicationsRelatedToEnvironment = Lists.newArrayList();
List<Application> applicationsRelatedToEnvironmentType = Lists.newArrayList();
List<ApplicationEnvironment> environments = Lists.newArrayList();
List<String> environmentTypes = Lists.newArrayList();
List<Application> applications = Lists.newArrayList();
// we get all authorized applications and environment to not favor the one of them
if (MapUtils.isNotEmpty(location.getEnvironmentPermissions())) {
environments = alienDAO.findByIds(ApplicationEnvironment.class, location.getEnvironmentPermissions().keySet().toArray(new String[location.getEnvironmentPermissions().size()]));
Set<String> environmentApplicationIds = environments.stream().map(ae -> new String(ae.getApplicationId())).collect(Collectors.toSet());
applicationsRelatedToEnvironment = alienDAO.findByIds(Application.class, environmentApplicationIds.toArray(new String[environmentApplicationIds.size()]));
}
if (MapUtils.isNotEmpty(location.getEnvironmentTypePermissions())) {
environmentTypes.addAll(location.getEnvironmentTypePermissions().keySet());
Set<String> environmentTypeApplicationIds = Sets.newHashSet();
for (String envType : safe(location.getEnvironmentTypePermissions()).keySet()) {
environmentTypeApplicationIds.add(envType.split(":")[0]);
}
applicationsRelatedToEnvironmentType = alienDAO.findByIds(Application.class, environmentTypeApplicationIds.toArray(new String[environmentTypeApplicationIds.size()]));
}
if (MapUtils.isNotEmpty(location.getApplicationPermissions())) {
applications = alienDAO.findByIds(Application.class, location.getApplicationPermissions().keySet().toArray(new String[location.getApplicationPermissions().size()]));
}
List<ApplicationEnvironmentAuthorizationDTO> allDTOs = ApplicationEnvironmentAuthorizationDTO.buildDTOs(applicationsRelatedToEnvironment, applicationsRelatedToEnvironmentType, environments, applications, environmentTypes);
int to = (from + size < allDTOs.size()) ? from + size : allDTOs.size();
allDTOs = IntStream.range(from, to).mapToObj(allDTOs::get).collect(Collectors.toList());
List<String> ids = allDTOs.stream().map(appEnvDTO -> appEnvDTO.getApplication().getId()).collect(Collectors.toList());
IdsFilterBuilder idFilters = FilterBuilders.idsFilter().ids(ids.toArray(new String[ids.size()]));
GetMultipleDataResult<Application> tempResult = alienDAO.search(Application.class, query, null, idFilters, null, from, to, "id", false);
return RestResponseBuilder.<GetMultipleDataResult<ApplicationEnvironmentAuthorizationDTO>>builder().data(ApplicationEnvironmentAuthorizationDTO.convert(tempResult, allDTOs)).build();
}
use of org.springframework.web.bind.annotation.RequestParam in project cas by apereo.
the class OidcJwksEndpointController method handleRequestInternal.
/**
* Handle request for jwk set.
*
* @param request the request
* @param response the response
* @param state the state
* @return the jwk set
*/
@GetMapping(value = { '/' + OidcConstants.BASE_OIDC_URL + '/' + OidcConstants.JWKS_URL, "/**/" + OidcConstants.JWKS_URL }, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Produces the collection of keys from the keystore", parameters = { @Parameter(name = "state", description = "Filter keys by their state name", required = false) })
public ResponseEntity<String> handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response, @RequestParam(value = "state", required = false) final String state) {
val webContext = new JEEContext(request, response);
if (!getConfigurationContext().getOidcRequestSupport().isValidIssuerForEndpoint(webContext, OidcConstants.JWKS_URL)) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
try {
val resource = oidcJsonWebKeystoreGeneratorService.generate();
val jsonJwks = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8);
val jsonWebKeySet = new JsonWebKeySet(jsonJwks);
val servicesManager = getConfigurationContext().getServicesManager();
servicesManager.getAllServicesOfType(OidcRegisteredService.class).stream().filter(s -> {
val serviceJwks = SpringExpressionLanguageValueResolver.getInstance().resolve(s.getJwks());
return StringUtils.isNotBlank(serviceJwks);
}).forEach(service -> {
val set = OidcJsonWebKeyStoreUtils.getJsonWebKeySet(service, getConfigurationContext().getApplicationContext(), Optional.empty());
set.ifPresent(keys -> keys.getJsonWebKeys().forEach(jsonWebKeySet::addJsonWebKey));
});
if (StringUtils.isNotBlank(state)) {
jsonWebKeySet.getJsonWebKeys().removeIf(key -> {
val st = OidcJsonWebKeystoreRotationService.JsonWebKeyLifecycleStates.getJsonWebKeyState(key).name();
return !state.equalsIgnoreCase(st);
});
}
val body = jsonWebKeySet.toJson(JsonWebKey.OutputControlLevel.PUBLIC_ONLY);
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
return new ResponseEntity<>(body, HttpStatus.OK);
} catch (final Exception e) {
LoggingUtils.error(LOGGER, e);
return new ResponseEntity<>(StringEscapeUtils.escapeHtml4(e.getMessage()), HttpStatus.BAD_REQUEST);
}
}
use of org.springframework.web.bind.annotation.RequestParam in project cas by apereo.
the class SamlIdentityProviderDiscoveryFeedController method redirect.
/**
* Redirect.
*
* @param entityID the entity id
* @param httpServletRequest the http servlet request
* @param httpServletResponse the http servlet response
* @return the view
*/
@GetMapping(path = "redirect")
public View redirect(@RequestParam("entityID") final String entityID, final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) {
val idp = getDiscoveryFeed().stream().filter(entity -> entity.getEntityID().equals(entityID)).findFirst().orElseThrow();
val samlClient = clients.findAllClients().stream().filter(c -> c instanceof SAML2Client).map(SAML2Client.class::cast).peek(InitializableObject::init).filter(c -> c.getIdentityProviderResolvedEntityId().equalsIgnoreCase(idp.getEntityID())).findFirst().orElseThrow();
val webContext = new JEEContext(httpServletRequest, httpServletResponse);
val service = this.argumentExtractor.extractService(httpServletRequest);
if (delegatedAuthenticationAccessStrategyHelper.isDelegatedClientAuthorizedForService(samlClient, service, httpServletRequest)) {
val provider = DelegatedClientIdentityProviderConfigurationFactory.builder().service(service).client(samlClient).webContext(webContext).casProperties(casProperties).build().resolve();
if (provider.isPresent()) {
return new RedirectView('/' + provider.get().getRedirectUrl(), true, true, true);
}
}
throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, StringUtils.EMPTY);
}
use of org.springframework.web.bind.annotation.RequestParam in project leopard by tanhaichao.
the class PrimitiveMethodArgumentResolver method supportsParameter.
@Override
public boolean supportsParameter(MethodParameter parameter) {
RequestParam ann = parameter.getParameterAnnotation(RequestParam.class);
if (ann != null) {
return false;
}
// logger.info("supportsParameter name:" + parameter.getParameterName() + " clazz:" + parameter.getParameterType());
Class<?> clazz = parameter.getParameterType();
if (clazz.equals(long.class) || clazz.equals(Long.class)) {
return true;
} else if (clazz.equals(int.class) || clazz.equals(Integer.class)) {
return true;
} else if (clazz.equals(double.class) || clazz.equals(Double.class)) {
return true;
} else if (clazz.equals(float.class) || clazz.equals(Float.class)) {
return true;
} else if (clazz.equals(boolean.class) || clazz.equals(Boolean.class)) {
return true;
} else if (clazz.equals(Date.class)) {
return true;
} else if (clazz.equals(String.class)) {
return true;
}
return false;
}
Aggregations