org.hibernate.validator.constraints.Range Java Examples

The following examples show how to use org.hibernate.validator.constraints.Range. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BrokerTokensController.java    From pulsar-manager with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Get the list of existing broker tokens, support paging, the default is 10 per page")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/tokens", method =  RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getEnvironmentsList(
        @ApiParam(value = "page_num", defaultValue = "1", example = "1")
        @RequestParam(name = "page_num", defaultValue = "1")
        @Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
                Integer pageNum,
        @ApiParam(value = "page_size", defaultValue = "10", example = "10")
        @RequestParam(name="page_size", defaultValue = "10")
        @Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
                Integer pageSize) {
    Page<BrokerTokenEntity> brokerTokenEntityPage = brokerTokensRepository.getBrokerTokensList(pageNum, pageSize);
    Map<String, Object> result = Maps.newHashMap();
    result.put("total", brokerTokenEntityPage.getTotal());
    result.put("data", brokerTokenEntityPage);
    return ResponseEntity.ok(result);
}
 
Example #2
Source File: BookiesController.java    From pulsar-manager with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Get the list of existing bookies, support paging, the default is 10 per page")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/bookies/{cluster}", method =  RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getClusters(
        @ApiParam(value = "page_num", defaultValue = "1", example = "1")
        @RequestParam(name = "page_num", defaultValue = "1")
        @Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
        Integer pageNum,
        @ApiParam(value = "page_size", defaultValue = "10", example = "10")
        @RequestParam(name="page_size", defaultValue = "10")
        @Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
        Integer pageSize,
        @PathVariable String cluster) {
    Map<String, Object> result = bookiesService.getBookiesList(pageNum, pageSize, cluster);
    return ResponseEntity.ok(result);
}
 
Example #3
Source File: BrokersController.java    From pulsar-manager with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Get the list of existing brokers, support paging, the default is 10 per page")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/brokers/{cluster}", method =  RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getBrokers(
        @ApiParam(value = "page_num", defaultValue = "1", example = "1")
        @RequestParam(name = "page_num", defaultValue = "1")
        @Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
        Integer pageNum,
        @ApiParam(value = "page_size", defaultValue = "10", example = "10")
        @RequestParam(name="page_size", defaultValue = "10")
        @Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
        Integer pageSize,
        @PathVariable String cluster) {
    String requestServiceUrl = environmentCacheService.getServiceUrl(request, cluster);
    Map<String, Object> result = brokersService.getBrokersList(pageNum, pageSize, cluster, requestServiceUrl);
    return ResponseEntity.ok(result);
}
 
Example #4
Source File: NamespacesController.java    From pulsar-manager with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Query list by the name of tenant or namespace, support paging, the default is 10 per page")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/namespaces/{tenantOrNamespace}", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getNamespacesByTenant(
        @ApiParam(value = "The name of tenant or namespace.")
        @Size(min = 1, max = 255)
        @PathVariable String tenantOrNamespace,
        @ApiParam(value = "page_num", defaultValue = "1", example = "1")
        @RequestParam(name = "page_num", defaultValue = "1")
        @Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
                Integer pageNum,
        @ApiParam(value = "page_size", defaultValue = "10", example = "10")
        @RequestParam(name="page_size", defaultValue = "10")
        @Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
        Integer pageSize) {
    String requestHost = environmentCacheService.getServiceUrl(request);
    Map<String, Object> result = namespacesService.getNamespaceList(pageNum, pageSize, tenantOrNamespace, requestHost);
    return ResponseEntity.ok(result);
}
 
Example #5
Source File: UsersController.java    From pulsar-manager with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Get users list")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 404, message = "Not found"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/users", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getUsers(
        @ApiParam(value = "page_num", defaultValue = "1", example = "1")
        @RequestParam(name = "page_num", defaultValue = "1")
        @Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
        Integer pageNum,
        @ApiParam(value = "page_size", defaultValue = "10", example = "10")
        @RequestParam(name = "page_size", defaultValue = "10")
        @Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
        Integer pageSize) {
    Page<UserInfoEntity> userInfoEntities = usersRepository.findUsersList(pageNum, pageSize);
    Map<String, Object> result = Maps.newHashMap();
    result.put("total", userInfoEntities.getTotal());
    result.put("data", userInfoEntities.getResult());
    return ResponseEntity.ok(result);
}
 
Example #6
Source File: TopicsController.java    From pulsar-manager with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Query topic info by tenant and namespace")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/topics/{tenant}/{namespace}", method = RequestMethod.GET)
public Map<String, Object> getTopicsByTenantNamespace(
        @ApiParam(value = "page_num", defaultValue = "1", example = "1")
        @RequestParam(name = "page_num", defaultValue = "1")
        @Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
                Integer pageNum,
        @ApiParam(value = "page_size", defaultValue = "10", example = "10")
        @RequestParam(name="page_size", defaultValue = "10")
        @Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
                Integer pageSize,
        @ApiParam(value = "The name of tenant")
        @Size(min = 1, max = 255)
        @PathVariable String tenant,
        @ApiParam(value = "The name of namespace")
        @Size(min = 1, max = 255)
        @PathVariable String namespace) {
    String requestHost = environmentCacheService.getServiceUrl(request);
    return topicsService.getTopicsList(pageNum, pageSize, tenant, namespace, requestHost);
}
 
Example #7
Source File: BodySettingsChangeImageController.java    From retro-game with GNU Affero General Public License v3.0 5 votes vote down vote up
@PostMapping("/body-settings/change-image")
@PreAuthorize("hasPermission(#bodyId, 'ACCESS')")
@Activity(bodies = "#bodyId")
public String doChangeImage(@RequestParam(name = "body") long bodyId,
                            @RequestParam @Range(min = 1, max = 10) int image) {
  bodyService.setImage(bodyId, image);
  return "redirect:/overview?body=" + bodyId;
}
 
Example #8
Source File: ClustersController.java    From pulsar-manager with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Get the list of existing clusters, support paging, the default is 10 per page")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/clusters", method =  RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getClusters(
        @ApiParam(value = "page_num", defaultValue = "1", example = "1")
        @RequestParam(name = "page_num", defaultValue = "1")
        @Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
                Integer pageNum,
        @ApiParam(value = "page_size", defaultValue = "10", example = "10")
        @RequestParam(name="page_size", defaultValue = "10")
        @Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
                Integer pageSize) {
    String requestHost = environmentCacheService.getServiceUrl(request);
    String token = request.getHeader("token");
    Map<String, Object> result = Maps.newHashMap();
    if (!rolesService.isSuperUser(token)) {
        result.put("isPage", false);
        result.put("total", 0);
        result.put("data", new ArrayList());
        result.put("pageNum", 0);
        result.put("pageSize", 0);
        return ResponseEntity.ok(result);
    }
    result = clusterService.getClustersList(
        pageNum, pageSize, requestHost, cluster -> {
            String environment = request.getHeader("environment");
            if (null == environment) {
                return requestHost;
            } else {
                return environmentCacheService.getServiceUrl(environment, cluster);
            }
        });

    return ResponseEntity.ok(result);
}
 
Example #9
Source File: TopicsController.java    From pulsar-manager with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Query topic stats info by tenant and namespace")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/topics/{tenant}/{namespace}/stats", method = RequestMethod.GET)
public Map<String, Object> getTopicsStats(
        @ApiParam(value = "page_num", defaultValue = "1", example = "1")
        @RequestParam(name = "page_num", defaultValue = "1")
        @Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
                Integer pageNum,
        @ApiParam(value = "page_size", defaultValue = "10", example = "10")
        @RequestParam(name="page_size", defaultValue = "10")
        @Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
                Integer pageSize,
        @ApiParam(value = "The name of tenant")
        @Size(min = 1, max = 255)
        @PathVariable String tenant,
        @ApiParam(value = "The name of namespace")
        @Size(min = 1, max = 255)
        @PathVariable String namespace) {
    String env = request.getHeader("environment");
    String serviceUrl = environmentCacheService.getServiceUrl(request);
    return topicsService.getTopicStats(
        pageNum, pageSize,
        tenant, namespace,
        env, serviceUrl);
}
 
Example #10
Source File: RoleBindingController.java    From pulsar-manager with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Get the list of role binding")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 404, message = "Not found"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/role-binding", method =  RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getRoleBingList(
        @ApiParam(value = "page_num", defaultValue = "1", example = "1")
        @RequestParam(name = "page_num", defaultValue = "1")
        @Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
                Integer pageNum,
        @ApiParam(value = "page_size", defaultValue = "10", example = "10")
        @RequestParam(name="page_size", defaultValue = "10")
        @Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
                Integer pageSize) {
    Map<String, Object> result = Maps.newHashMap();
    HttpServletRequest request = ((ServletRequestAttributes)
            RequestContextHolder.getRequestAttributes()).getRequest();
    String token = request.getHeader("token");
    String tenant = request.getHeader("tenant");
    if (rolesService.isSuperUser(token)) {
        List<Map<String, Object>> roleBindingList = roleBindingService.getAllRoleBindingList();
        result.put("total", roleBindingList.size());
        result.put("data", roleBindingList);
        return ResponseEntity.ok(result);
    }
    Map<String, String> validateResult = rolesService.validateCurrentTenant(token, tenant);
    if (validateResult.get("error") != null) {
        result.put("error", validateResult.get("error"));
        return ResponseEntity.ok(result);
    }
    List<Map<String, Object>> userRoleInfo = roleBindingService.getRoleBindingList(token, tenant);
    result.put("total", userRoleInfo.size());
    result.put("data", userRoleInfo);
    return ResponseEntity.ok(result);
}
 
Example #11
Source File: RolesController.java    From pulsar-manager with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Get the list of existing roles, support paging, the default is 10 per page")
@ApiResponses({
        @ApiResponse(code = 200, message = "ok"),
        @ApiResponse(code = 404, message = "Not found"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@RequestMapping(value = "/roles", method = RequestMethod.GET)
public ResponseEntity<Map<String, Object>> getRoles(
        @ApiParam(value = "page_num", defaultValue = "1", example = "1")
        @RequestParam(name = "page_num", defaultValue = "1")
        @Min(value = 1, message = "page_num is incorrect, should be greater than 0.")
                Integer pageNum,
        @ApiParam(value = "page_size", defaultValue = "10", example = "10")
        @RequestParam(name = "page_size", defaultValue = "10")
        @Range(min = 1, max = 1000, message = "page_size is incorrect, should be greater than 0 and less than 1000.")
                Integer pageSize) {
    String token = request.getHeader("token");
    Map<String, Object> result = Maps.newHashMap();
    String tenant = request.getHeader("tenant");
    if (rolesService.isSuperUser(token)) {
        List<RoleInfoEntity> roleInfoEntities = rolesRepository.findAllRolesList();
        result.put("total", roleInfoEntities.size());
        result.put("data", roleInfoEntities);
        return ResponseEntity.ok(result);
    }
    Map<String, String> validateResult = rolesService.validateCurrentTenant(token, tenant);
    if (validateResult.get("error") != null) {
        result.put("error", validateResult.get("error"));
        return ResponseEntity.ok(result);
    }
    List<RoleInfoEntity> roleInfoLists = rolesRepository.findRolesListByRoleSource(tenant);

    result.put("total", roleInfoLists.size());
    result.put("data", roleInfoLists);
    return ResponseEntity.ok(result);
}
 
Example #12
Source File: CreateHomeworldController.java    From retro-game with GNU Affero General Public License v3.0 5 votes vote down vote up
@GetMapping("/create-homeworld")
public String createHomeworld(@RequestParam @Range(min = 1, max = 5) int galaxy,
                              @RequestParam @Range(min = 1, max = 500) int system,
                              Model model) {
  model.addAttribute("galaxy", galaxy);
  model.addAttribute("system", system);
  model.addAttribute("slots", galaxyService.getSlots(galaxy, system));
  return "create-homeworld";
}
 
Example #13
Source File: MqttSinkProperties.java    From mqtt with Apache License 2.0 4 votes vote down vote up
@Range(min = 0, max = 2)
public int getQos() {
	return this.qos;
}
 
Example #14
Source File: RangeStrategy.java    From hsweb-framework with Apache License 2.0 4 votes vote down vote up
@Override
protected Class<Range> getAnnotationType() {
    return Range.class;
}
 
Example #15
Source File: RabbitCommonProperties.java    From spring-cloud-stream-binder-rabbit with Apache License 2.0 4 votes vote down vote up
@Range(min = 0, max = 255)
public Integer getMaxPriority() {
	return this.maxPriority;
}
 
Example #16
Source File: SftpSessionFactoryProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@Range(min = 0, max = 65535)
public int getPort() {
	return this.port;
}
 
Example #17
Source File: FtpSessionFactoryProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@Range(min = 0, max = 65535)
public int getPort() {
	return this.port;
}
 
Example #18
Source File: CassandraProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@Range(min = 0, max = 65535)
public int getPort() {
	return this.port;
}
 
Example #19
Source File: ParcelDescriptor.java    From cm_ext with Apache License 2.0 4 votes vote down vote up
@NotNull
@Range(min = 1, max = 1)
Integer getSchema_version();
 
Example #20
Source File: MemoryParameter.java    From cm_ext with Apache License 2.0 2 votes vote down vote up
/**
 * During autoconfiguration for RM, the share dictates the percentage of the
 * role's overall memory allotment that should be set aside for this memory
 * quantity.
 * <p>
 * If null, parameter is not autoconfigured for RM.
 */
@Range(min = 0, max = 100)
Integer getAutoConfigShare();