Search in sources :

Example 41 with RequestParam

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);
    };
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) StringUtils(org.apache.commons.lang.StringUtils) RequestParam(org.springframework.web.bind.annotation.RequestParam) DataSetGet(org.talend.dataprep.command.dataset.DataSetGet) UpdateDataSet(org.talend.dataprep.api.service.command.dataset.UpdateDataSet) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) ApiParam(io.swagger.annotations.ApiParam) DataSetGetEncodings(org.talend.dataprep.api.service.command.dataset.DataSetGetEncodings) SetFavorite(org.talend.dataprep.api.service.command.dataset.SetFavorite) CommandHelper.toStream(org.talend.dataprep.command.CommandHelper.toStream) TEXT_PLAIN_VALUE(org.springframework.http.MediaType.TEXT_PLAIN_VALUE) CommandHelper.toStreaming(org.talend.dataprep.command.CommandHelper.toStreaming) DataSetGetImports(org.talend.dataprep.api.service.command.dataset.DataSetGetImports) SemanticDomain(org.talend.dataprep.api.dataset.statistics.SemanticDomain) ApiOperation(io.swagger.annotations.ApiOperation) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) UserDataSetMetadata(org.talend.dataprep.dataset.service.UserDataSetMetadata) Order(org.talend.dataprep.util.SortAndOrderHelper.Order) MediaType(org.springframework.http.MediaType) UpdateColumn(org.talend.dataprep.api.service.command.dataset.UpdateColumn) PublicAPI(org.talend.dataprep.security.PublicAPI) StreamingResponseBody(org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) DataSetPreview(org.talend.dataprep.api.service.command.dataset.DataSetPreview) List(java.util.List) HystrixCommand(com.netflix.hystrix.HystrixCommand) Stream(java.util.stream.Stream) GetDataSetColumnTypes(org.talend.dataprep.api.service.command.dataset.GetDataSetColumnTypes) CommandHelper.toPublisher(org.talend.dataprep.command.CommandHelper.toPublisher) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) PreparationList(org.talend.dataprep.api.service.command.preparation.PreparationList) CopyDataSet(org.talend.dataprep.api.service.command.dataset.CopyDataSet) GenericCommand(org.talend.dataprep.command.GenericCommand) EnrichedDataSetMetadata(org.talend.dataprep.api.service.api.EnrichedDataSetMetadata) SuggestLookupActions(org.talend.dataprep.api.service.command.transformation.SuggestLookupActions) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Callable(java.util.concurrent.Callable) CreateOrUpdateDataSet(org.talend.dataprep.api.service.command.dataset.CreateOrUpdateDataSet) SortAndOrderHelper(org.talend.dataprep.util.SortAndOrderHelper) GET(org.springframework.web.bind.annotation.RequestMethod.GET) PreparationSearchByDataSetId(org.talend.dataprep.api.service.command.preparation.PreparationSearchByDataSetId) DataSetList(org.talend.dataprep.api.service.command.dataset.DataSetList) Import(org.talend.dataprep.api.dataset.Import) CONTENT_TYPE(org.springframework.http.HttpHeaders.CONTENT_TYPE) CompatibleDataSetList(org.talend.dataprep.api.service.command.dataset.CompatibleDataSetList) POST(org.springframework.web.bind.annotation.RequestMethod.POST) Preparation(org.talend.dataprep.api.preparation.Preparation) DataSetGetImportParameters(org.talend.dataprep.api.service.command.dataset.DataSetGetImportParameters) DELETE(org.springframework.web.bind.annotation.RequestMethod.DELETE) HttpResponseContext(org.talend.dataprep.http.HttpResponseContext) CreateDataSet(org.talend.dataprep.api.service.command.dataset.CreateDataSet) Sort(org.talend.dataprep.util.SortAndOrderHelper.Sort) Mono(reactor.core.publisher.Mono) APPLICATION_JSON_VALUE(org.springframework.http.MediaType.APPLICATION_JSON_VALUE) Flux(reactor.core.publisher.Flux) DataSetDelete(org.talend.dataprep.api.service.command.dataset.DataSetDelete) DataSetGetMetadata(org.talend.dataprep.command.dataset.DataSetGetMetadata) ResponseEntity(org.springframework.http.ResponseEntity) CommandHelper(org.talend.dataprep.command.CommandHelper) SuggestDataSetActions(org.talend.dataprep.api.service.command.transformation.SuggestDataSetActions) Timed(org.talend.dataprep.metrics.Timed) InputStream(java.io.InputStream) EnrichedDataSetMetadata(org.talend.dataprep.api.service.api.EnrichedDataSetMetadata) GenericCommand(org.talend.dataprep.command.GenericCommand) PreparationSearchByDataSetId(org.talend.dataprep.api.service.command.preparation.PreparationSearchByDataSetId) List(java.util.List) PreparationList(org.talend.dataprep.api.service.command.preparation.PreparationList) DataSetList(org.talend.dataprep.api.service.command.dataset.DataSetList) CompatibleDataSetList(org.talend.dataprep.api.service.command.dataset.CompatibleDataSetList) DataSetList(org.talend.dataprep.api.service.command.dataset.DataSetList) CompatibleDataSetList(org.talend.dataprep.api.service.command.dataset.CompatibleDataSetList) Timed(org.talend.dataprep.metrics.Timed) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 42 with RequestParam

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();
}
Also used : IntStream(java.util.stream.IntStream) PathVariable(org.springframework.web.bind.annotation.PathVariable) Lists(org.elasticsearch.common.collect.Lists) RequestParam(org.springframework.web.bind.annotation.RequestParam) Arrays(java.util.Arrays) ApplicationEnvironmentService(alien4cloud.application.ApplicationEnvironmentService) Subject(alien4cloud.security.Subject) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) LocationService(alien4cloud.orchestrators.locations.services.LocationService) ResourcePermissionService(alien4cloud.authorization.ResourcePermissionService) ApplicationEnvironmentAuthorizationDTO(alien4cloud.rest.orchestrator.model.ApplicationEnvironmentAuthorizationDTO) ApiParam(io.swagger.annotations.ApiParam) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) IdsFilterBuilder(org.elasticsearch.index.query.IdsFilterBuilder) User(alien4cloud.security.model.User) AlienUtils.safe(alien4cloud.utils.AlienUtils.safe) Location(alien4cloud.model.orchestrators.locations.Location) RequestBody(org.springframework.web.bind.annotation.RequestBody) ApiOperation(io.swagger.annotations.ApiOperation) Audit(alien4cloud.audit.annotation.Audit) RestResponseBuilder(alien4cloud.rest.model.RestResponseBuilder) RestResponse(alien4cloud.rest.model.RestResponse) Application(alien4cloud.model.application.Application) Api(io.swagger.annotations.Api) MapUtils(org.apache.commons.collections4.MapUtils) GetMultipleDataResult(alien4cloud.dao.model.GetMultipleDataResult) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) FilterBuilders(org.elasticsearch.index.query.FilterBuilders) MediaType(org.springframework.http.MediaType) Resource(javax.annotation.Resource) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Set(java.util.Set) IGenericSearchDAO(alien4cloud.dao.IGenericSearchDAO) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) IAlienGroupDao(alien4cloud.security.groups.IAlienGroupDao) IAlienUserDao(alien4cloud.security.users.IAlienUserDao) List(java.util.List) GroupDTO(alien4cloud.rest.orchestrator.model.GroupDTO) Group(alien4cloud.security.model.Group) UserDTO(alien4cloud.rest.orchestrator.model.UserDTO) ApplicationEnvironmentAuthorizationUpdateRequest(alien4cloud.rest.orchestrator.model.ApplicationEnvironmentAuthorizationUpdateRequest) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) IdsFilterBuilder(org.elasticsearch.index.query.IdsFilterBuilder) ApplicationEnvironmentAuthorizationDTO(alien4cloud.rest.orchestrator.model.ApplicationEnvironmentAuthorizationDTO) GetMultipleDataResult(alien4cloud.dao.model.GetMultipleDataResult) Application(alien4cloud.model.application.Application) Location(alien4cloud.model.orchestrators.locations.Location) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 43 with RequestParam

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);
    }
}
Also used : lombok.val(lombok.val) RequestParam(org.springframework.web.bind.annotation.RequestParam) StringUtils(org.apache.commons.lang3.StringUtils) OidcJsonWebKeystoreRotationService(org.apereo.cas.oidc.jwks.rotation.OidcJsonWebKeystoreRotationService) LoggingUtils(org.apereo.cas.util.LoggingUtils) Operation(io.swagger.v3.oas.annotations.Operation) HttpServletRequest(javax.servlet.http.HttpServletRequest) BaseOidcController(org.apereo.cas.oidc.web.controllers.BaseOidcController) GetMapping(org.springframework.web.bind.annotation.GetMapping) JEEContext(org.pac4j.core.context.JEEContext) OidcConstants(org.apereo.cas.oidc.OidcConstants) JsonWebKey(org.jose4j.jwk.JsonWebKey) MediaType(org.springframework.http.MediaType) lombok.val(lombok.val) HttpServletResponse(javax.servlet.http.HttpServletResponse) StringEscapeUtils(org.apache.commons.text.StringEscapeUtils) JsonWebKeySet(org.jose4j.jwk.JsonWebKeySet) StandardCharsets(java.nio.charset.StandardCharsets) OidcJsonWebKeystoreGeneratorService(org.apereo.cas.oidc.jwks.generator.OidcJsonWebKeystoreGeneratorService) OidcConfigurationContext(org.apereo.cas.oidc.OidcConfigurationContext) Parameter(io.swagger.v3.oas.annotations.Parameter) IOUtils(org.apache.commons.io.IOUtils) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) OidcRegisteredService(org.apereo.cas.services.OidcRegisteredService) SpringExpressionLanguageValueResolver(org.apereo.cas.util.spring.SpringExpressionLanguageValueResolver) OidcJsonWebKeyStoreUtils(org.apereo.cas.oidc.jwks.OidcJsonWebKeyStoreUtils) Optional(java.util.Optional) ResponseEntity(org.springframework.http.ResponseEntity) ResponseEntity(org.springframework.http.ResponseEntity) OidcRegisteredService(org.apereo.cas.services.OidcRegisteredService) JEEContext(org.pac4j.core.context.JEEContext) JsonWebKeySet(org.jose4j.jwk.JsonWebKeySet) GetMapping(org.springframework.web.bind.annotation.GetMapping) Operation(io.swagger.v3.oas.annotations.Operation)

Example 44 with RequestParam

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);
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) RequestParam(org.springframework.web.bind.annotation.RequestParam) ArgumentExtractor(org.apereo.cas.web.support.ArgumentExtractor) RequiredArgsConstructor(lombok.RequiredArgsConstructor) SAML2Client(org.pac4j.saml.client.SAML2Client) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) HttpServletRequest(javax.servlet.http.HttpServletRequest) Clients(org.pac4j.core.client.Clients) RedirectView(org.springframework.web.servlet.view.RedirectView) GetMapping(org.springframework.web.bind.annotation.GetMapping) InitializableObject(org.pac4j.core.util.InitializableObject) JEEContext(org.pac4j.core.context.JEEContext) UnauthorizedServiceException(org.apereo.cas.services.UnauthorizedServiceException) MediaType(org.springframework.http.MediaType) Collection(java.util.Collection) lombok.val(lombok.val) HttpServletResponse(javax.servlet.http.HttpServletResponse) Set(java.util.Set) SamlIdentityProviderEntity(org.apereo.cas.entity.SamlIdentityProviderEntity) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) ModelAndView(org.springframework.web.servlet.ModelAndView) Slf4j(lombok.extern.slf4j.Slf4j) View(org.springframework.web.servlet.View) List(java.util.List) DelegatedAuthenticationAccessStrategyHelper(org.apereo.cas.validation.DelegatedAuthenticationAccessStrategyHelper) SamlIdentityProviderEntityParser(org.apereo.cas.entity.SamlIdentityProviderEntityParser) JEEContext(org.pac4j.core.context.JEEContext) RedirectView(org.springframework.web.servlet.view.RedirectView) SAML2Client(org.pac4j.saml.client.SAML2Client) UnauthorizedServiceException(org.apereo.cas.services.UnauthorizedServiceException) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 45 with RequestParam

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;
}
Also used : RequestParam(org.springframework.web.bind.annotation.RequestParam) Date(java.util.Date)

Aggregations

RequestParam (org.springframework.web.bind.annotation.RequestParam)72 List (java.util.List)56 PathVariable (org.springframework.web.bind.annotation.PathVariable)52 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)49 Collectors (java.util.stream.Collectors)47 IOException (java.io.IOException)37 HttpServletRequest (javax.servlet.http.HttpServletRequest)35 HttpServletResponse (javax.servlet.http.HttpServletResponse)35 Autowired (org.springframework.beans.factory.annotation.Autowired)34 HttpStatus (org.springframework.http.HttpStatus)31 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)31 Map (java.util.Map)30 GetMapping (org.springframework.web.bind.annotation.GetMapping)30 MediaType (org.springframework.http.MediaType)28 Controller (org.springframework.stereotype.Controller)28 RestController (org.springframework.web.bind.annotation.RestController)28 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)27 Set (java.util.Set)21 RequestBody (org.springframework.web.bind.annotation.RequestBody)21 ArrayList (java.util.ArrayList)20