use of org.springframework.web.bind.annotation.RequestParam in project dhis2-core by dhis2.
the class TrackerImportController method getJobReport.
@GetMapping(value = "/jobs/{uid}/report", produces = APPLICATION_JSON_VALUE)
public TrackerImportReport getJobReport(@PathVariable String uid, @RequestParam(defaultValue = "errors", required = false) String reportMode, HttpServletResponse response) throws HttpStatusCodeException, NotFoundException {
TrackerBundleReportMode trackerBundleReportMode = TrackerBundleReportMode.getTrackerBundleReportMode(reportMode);
setNoStore(response);
return Optional.ofNullable(notifier.getJobSummaryByJobId(JobType.TRACKER_IMPORT_JOB, uid)).map(report -> trackerImportService.buildImportReport((TrackerImportReport) report, trackerBundleReportMode)).orElseThrow(() -> NotFoundException.notFoundUid(uid));
}
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;
}
use of org.springframework.web.bind.annotation.RequestParam in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method getResultFiles.
@ApiOperation("Get result files of the submission.")
@GetMapping("/api/v1/analysis-management/submissions/{submissionId}/results")
public List<ResultFileDTO> getResultFiles(Principal principal, @PathVariable("submissionId") Long submissionId, @RequestParam(value = "path", required = false, defaultValue = "") String path, @RequestParam(value = "real-name", required = false) String realName) throws PermissionDeniedException, IOException {
IUser user = userService.getByUsername(principal.getName());
ResultFileSearch resultFileSearch = new ResultFileSearch();
resultFileSearch.setPath(path);
resultFileSearch.setRealName(realName);
List<? extends ArachneFileMeta> resultFileList = submissionService.getResultFiles(user, submissionId, resultFileSearch);
String resultFilesPath = contentStorageHelper.getResultFilesDir(Submission.class, submissionId, null);
return resultFileList.stream().map(rf -> {
ResultFileDTO rfDto = conversionService.convert(rf, ResultFileDTO.class);
rfDto.setSubmissionId(submissionId);
rfDto.setRelativePath(contentStorageHelper.getRelativePath(resultFilesPath, rfDto.getPath()));
return rfDto;
}).collect(Collectors.toList());
}
Aggregations