org.hibernate.validator.constraints.NotBlank Java Examples

The following examples show how to use org.hibernate.validator.constraints.NotBlank. 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: ViolationExceptionMapper.java    From pay-publicapi with MIT License 6 votes vote down vote up
@Override
public Response toResponse(JerseyViolationException exception) {
    LOGGER.info(exception.getMessage());
    ConstraintViolation<?> firstException = exception.getConstraintViolations().iterator().next();
    String fieldName = getApiFieldName(firstException.getPropertyPath());
    
    PaymentError paymentError;
    if (firstException.getConstraintDescriptor() != null &&
            firstException.getConstraintDescriptor().getAnnotation() != null &&
            firstException.getConstraintDescriptor().getAnnotation().annotationType() == NotBlank.class ||
            firstException.getConstraintDescriptor().getAnnotation().annotationType() == NotEmpty.class ||
            firstException.getConstraintDescriptor().getAnnotation().annotationType() == NotNull.class) {
        paymentError = PaymentError.aPaymentError(fieldName, CREATE_PAYMENT_MISSING_FIELD_ERROR);
    } else {
        paymentError = PaymentError.aPaymentError(fieldName, CREATE_PAYMENT_VALIDATION_ERROR, firstException.getMessage());
    }
    
    return Response.status(422)
            .entity(paymentError)
            .build();
}
 
Example #2
Source File: BootTimeSeriesMiniCubeController.java    From minicubes with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value="/groupsum", method={RequestMethod.POST, RequestMethod.GET})
public @ResponseBody Map<Integer, BigDecimal> groupsum(@NotBlank @RequestParam String indName, 
        @RequestParam(required=false) String filterDims,
        @RequestParam String groupbyDim,
        @NotBlank @RequestParam String... timeSeries) throws Throwable {
    
    LOGGER.info("Try to sum {} on {} with filter {}.", indName, ObjectUtils.getDisplayString(timeSeries), filterDims);
    long timing = System.currentTimeMillis();
    Map<String, List<Integer>> filter = (filterDims == null || "".equals(filterDims)) ? null
            : objectMapper.readValue(filterDims, new TypeReference<Map<String, List<Integer>>>() {});
    Map<Integer, BigDecimal> sum = manager.aggs(timeSeries).sum(indName, groupbyDim, filter);
    LOGGER.info("Sucess to sum {} on {} result size is {} using {}ms.", indName, timeSeries, sum.size(), System.currentTimeMillis() - timing);
    LOGGER.debug("Sucess to sum {} on {} result is {}.", indName, timeSeries, sum);
    
    return sum;
}
 
Example #3
Source File: FeatureResourceImpl.java    From osiris with Apache License 2.0 6 votes vote down vote up
@Override
@Path("/{idFeature}")
@GET
@ValidationRequired(processor = RestViolationProcessor.class)
@ApiOperation(value = "Get a feature by id", httpMethod="GET", response=FeatureDTO.class)
@ApiResponses(value = {
		@ApiResponse(code = 200, message = "Feature was found", response=FeatureDTO.class),
		@ApiResponse(code = 400, message = "Invalid input parameter (header)"),
		@ApiResponse(code = 404, message = "Feature was not found")})
public Response getFeatureByID(@Auth BasicAuth principal,
		@ApiParam(value = "Application identifier", required = true) @NotBlank @NotNull @HeaderParam("api_key") String appIdentifier, 
		@ApiParam(required=true, value="Feature identifier") @NotBlank @NotNull @PathParam("idFeature") String idFeature) throws AssemblyException, FeatureNotExistException {
	// TODO Auto-generated method stub
	validations.checkIsNotNullAndNotBlank(appIdentifier,idFeature);
	Feature feature = featureManager.getFeatureByID(appIdentifier,idFeature);
	FeatureDTO featureDTO=featureAssembler.createDataTransferObject(feature);
	return Response.ok(featureDTO).build();
}
 
Example #4
Source File: BootTimeSeriesMiniCubeController.java    From minicubes with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value="/groupcount", method={RequestMethod.POST, RequestMethod.GET})
public @ResponseBody Map<Integer, Long> groupcount(@NotBlank @RequestParam String indName, 
        @RequestParam(required=false) String filterDims,
        @RequestParam String groupbyDim,
        @NotBlank @RequestParam String... timeSeries) throws Throwable {
    
    LOGGER.info("Try to count {} on {} with filter {}.", indName, ObjectUtils.getDisplayString(timeSeries), filterDims);
    long timing = System.currentTimeMillis();
    Map<String, List<Integer>> filter = (filterDims == null || "".equals(filterDims)) ? null
            : objectMapper.readValue(filterDims, new TypeReference<Map<String, List<Integer>>>() {});
    Map<Integer, Long> count = manager.aggs(timeSeries).count(indName, groupbyDim, filter);
    LOGGER.info("Sucess to count {} on {} result size is {} using {}ms.", indName, timeSeries, count.size(), System.currentTimeMillis() - timing);
    LOGGER.debug("Sucess to count {} on {} result is {}.", indName, timeSeries, count);
    
    return count;
}
 
Example #5
Source File: FeatureResourceImpl.java    From osiris with Apache License 2.0 6 votes vote down vote up
@Override
@Path("/{idFeature}")
@DELETE
@ValidationRequired(processor = RestViolationProcessor.class)
@ApiOperation(value = "Delete a feature", httpMethod="DELETE")
@ApiResponses(value = {
		@ApiResponse(code = 204, message = "Feature was deleted"),
		@ApiResponse(code = 400, message = "Invalid input parameter (header)"),
		@ApiResponse(code = 404, message = "Feature was not found")})
public Response deleteFeature(@Auth BasicAuth principal,
		@ApiParam(value = "Application identifier", required = true) @NotBlank @NotNull @HeaderParam("api_key") String appIdentifier, 
		@ApiParam(required=true, value="Feature identifier") @NotBlank @NotNull @PathParam("idFeature") String idFeature) throws FeatureNotExistException {
	// TODO Auto-generated method stub
	validations.checkIsNotNullAndNotBlank(appIdentifier,idFeature);
	featureManager.deleteFeature(appIdentifier, idFeature);
	return Response.noContent().build();
}
 
Example #6
Source File: FeatureResourceImpl.java    From osiris with Apache License 2.0 6 votes vote down vote up
@Override
@POST		
@ValidationRequired(processor = RestViolationProcessor.class)
@ApiOperation(value = "Store a feature", httpMethod="POST", response=FeatureDTO.class)
@ApiResponses(value = {
		@ApiResponse(code = 200, message = "Feature was stored", response=FeatureDTO.class),
		@ApiResponse(code = 400, message = "Latitude range out of index"),
		@ApiResponse(code = 400, message = "Longitude range out of index"),
		@ApiResponse(code = 400, message = "Geometry is invalid"),
		@ApiResponse(code = 400, message = "Mongo GeoJSON format is not correct"),
		@ApiResponse(code = 400, message = "Invalid input parameter (header)")})
public Response storeFeature(@Auth BasicAuth principal,
		@ApiParam(value = "Application identifier", required = true) @NotBlank @NotNull @HeaderParam("api_key") String appIdentifier,
		@ApiParam(required=true, value="Feature") @Valid @NotNull FeatureDTO featureDTO) throws AssemblyException, MongoGeospatialException {
	validations.checkIsNotNullAndNotBlank(appIdentifier);
	validations.checkIsNotNull(featureDTO);
	Feature feature = featureManager.storeFeature(appIdentifier, featureAssembler.createDomainObject(featureDTO));		
	FeatureDTO featureResponseDTO=featureAssembler.createDataTransferObject(feature);		
	return Response.ok(featureResponseDTO).build();
}
 
Example #7
Source File: BootTimeSeriesMiniCubeController.java    From minicubes with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value="/distinctcount", method={RequestMethod.POST, RequestMethod.GET})
public @ResponseBody Map<Integer, Integer> distinctCount(@NotBlank @RequestParam String indName,
        @NotBlank @RequestParam(required=false) Boolean isDim,
        @RequestParam(required=false) String filterDims,
        @RequestParam String groupbyDim,
        @NotBlank @RequestParam String... timeSeries) throws Throwable {
    
    LOGGER.info("Try to distinct-count {} on {} with filter {}.", indName, ObjectUtils.getDisplayString(timeSeries), filterDims);
    long timing = System.currentTimeMillis();
    Map<String, List<Integer>> filter = (filterDims == null || "".equals(filterDims)) ? null
            : objectMapper.readValue(filterDims, new TypeReference<Map<String, List<Integer>>>() {});
    Map<Integer, Integer> distinct = manager.aggs(timeSeries).discnt(indName, isDim == null ? true : isDim, groupbyDim, filter);
    LOGGER.info("Sucess to distinct-count {} on {} result size is {} using {}ms.", indName, timeSeries, distinct.size(), System.currentTimeMillis() - timing);
    LOGGER.debug("Sucess to distinct-count {} on {} result is {}.", indName, timeSeries, distinct);
    
    return distinct;
}
 
Example #8
Source File: SearchResourceImpl.java    From osiris with Apache License 2.0 5 votes vote down vote up
@Override			
@Path("/room")
@GET
@ValidationRequired(processor = RestViolationProcessor.class)
@ApiOperation(value = "Get room according to indoor location", httpMethod="GET",response=RoomDTO.class)
@ApiResponses(value = {
		@ApiResponse(code = 200, message = "Room belongs to location", response=RoomDTO.class),
		@ApiResponse(code = 400, message = "Invalid input parameter"),
		@ApiResponse(code = 404, message = "Room not found"),
		@ApiResponse(code = 500, message = "Problem in the system")})
public Response getRoomByLocation(@Auth BasicAuth principal,
		@ApiParam(value = "Application identifier", required = true) @NotBlank @NotNull @HeaderParam("api_key") String appIdentifier, 			
		@ApiParam(value="Longitude of location", required=true) @Min(-180) @Max(180) @NotNull @QueryParam("longitude") Double longitude,
		@ApiParam(value="Latitude of location", required=true) @Min(-90) @Max(90) @NotNull @QueryParam("latitude") Double latitude,
		@ApiParam(value = "Floor of location", required = true) @NotNull  @QueryParam("floor") Integer floor) throws AssemblyException, RoomNotFoundException{
	validations.checkIsNotNullAndNotBlank(appIdentifier);
	validations.checkMin(-180.0, longitude);
	validations.checkMax(180.0, longitude);
	validations.checkMin(-90.0, latitude);
	validations.checkMax(90.0, latitude);
	validations.checkIsNotNull(floor);
	
	Feature room=searchManager.getRoomByLocation(appIdentifier, longitude, latitude, floor);			
	RoomDTO roomDTO=roomAssembler.createDataTransferObject(room);				
	return Response.ok(roomDTO).build();		
}
 
Example #9
Source File: SearchResourceImpl.java    From osiris with Apache License 2.0 5 votes vote down vote up
@Override		
@POST	
@ValidationRequired(processor = RestViolationProcessor.class)
@ApiOperation(value = "Get features according to query", httpMethod="POST", response=FeatureDTO.class, responseContainer = "List")
@ApiResponses(value = {
		@ApiResponse(code = 200, message = "Features were found", response=FeatureDTO.class),
		@ApiResponse(code = 400, message = "Invalid input parameter (header)"),
		@ApiResponse(code = 400, message = "Query is not correct")})
public Response getFeaturesByQuery(@Auth BasicAuth principal,
		@ApiParam(value = "Application identifier", required = true) @NotBlank @NotNull @HeaderParam("api_key") String appIdentifier, 
		@ApiParam(value = "Query", required = true) @NotBlank @NotNull String query, 
		@ApiParam(required=false,value="Layer",allowableValues="ALL,MAP,FEATURES",defaultValue="ALL") @QueryParam("layer") @DefaultValue("ALL") LayerDTO layer,
		@ApiParam(required=false,value="Index of page",defaultValue="0") @QueryParam("pageIndex") @DefaultValue("0") Integer pageIndex, 
		@ApiParam(required=false,value="Size of page",defaultValue="20") @QueryParam("pageSize") @DefaultValue("20") Integer pageSize,
		@ApiParam(required=false,value="Order field") @QueryParam("orderField") String orderField, 
		@ApiParam(required=false,value="Order",allowableValues="ASC,DESC") @DefaultValue("ASC") @QueryParam("order") String order) throws AssemblyException, QueryException {
					
	validations.checkIsNotNullAndNotBlank(appIdentifier,query);
	validations.checkIsNotNull(layer);
	validations.checkMin(0, pageIndex);
	validations.checkMin(1, pageSize);
	
	Collection<Feature>  features = null;
	
	if(StringUtils.isEmpty(orderField)){
		features =  searchManager.getFeaturesByQuery(appIdentifier, query, layer, pageIndex, pageSize);				
	}else{
		features =  searchManager.getFeaturesByQuery(appIdentifier, query, layer, pageIndex, pageSize, orderField, order);
	}
	
	Collection<FeatureDTO> collectionFeatureDTO=featureAssembler.createDataTransferObjects(features);
	return Response.ok(collectionFeatureDTO).build();
}
 
Example #10
Source File: MapFileResourceImpl.java    From osiris with Apache License 2.0 5 votes vote down vote up
@Override
@GET
@ValidationRequired(processor = RestViolationProcessor.class)
@ApiOperation(value = "Get .map file", httpMethod="GET", response=InputStream.class)
@ApiResponses(value = {
  @ApiResponse(code = 200, message = ".map file was found", response=InputStream.class),
  @ApiResponse(code = 400, message = "Invalid input parameter (header)"),
  @ApiResponse(code = 404, message = ".map file was not found")})
public Response getMapFile(@Auth BasicAuth principal,
  @ApiParam(value = "Application identifier", required = true) @NotBlank @NotNull @HeaderParam("api_key") String appIdentifier) throws MapFileNotExistsException{
 validations.checkIsNotNullAndNotBlank(appIdentifier);
 InputStream mapFile=mapFileManager.getMapFile(appIdentifier);
 return Response.ok(mapFile).build();
}
 
Example #11
Source File: MongodbSourceProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@NotBlank(message = "Collection name is required")
public String getCollection() {
    return collection;
}
 
Example #12
Source File: AbstractRemoteFileSinkProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@NotBlank
public String getTemporaryRemoteDir() {
	return this.temporaryRemoteDir;
}
 
Example #13
Source File: TagInput.java    From restdocs-wiremock with Apache License 2.0 4 votes vote down vote up
@JsonCreator
public TagInput(@NotBlank @JsonProperty("name") String name) {
	this.name = name;
}
 
Example #14
Source File: ParcelDescriptor.java    From cm_ext with Apache License 2.0 4 votes vote down vote up
@NotBlank
@Pattern(regexp="^((?!-).)*$", message="{custom.validation.constraints.ParcelName.message}")
String getName();
 
Example #15
Source File: User.java    From spring-boot-quickstart with Apache License 2.0 4 votes vote down vote up
@NotBlank
public String getLoginName() {
	return loginName;
}
 
Example #16
Source File: ParcelInfoDescriptor.java    From cm_ext with Apache License 2.0 4 votes vote down vote up
@NotBlank
String getParcelName();
 
Example #17
Source File: CreateHdfsDirDescriptor.java    From cm_ext with Apache License 2.0 4 votes vote down vote up
/** Name of the command. */
@NotBlank
String getName();
 
Example #18
Source File: Email.java    From osiam with MIT License 4 votes vote down vote up
@Override
@NotBlank(message = "Multi-Valued attributes may not have empty values")
@org.hibernate.validator.constraints.Email(message = "${validatedValue} is not a valid e-mail address")
public String getValue() {
    return super.getValue();
}
 
Example #19
Source File: ParcelDescriptor.java    From cm_ext with Apache License 2.0 4 votes vote down vote up
@NotBlank
String getVersion();
 
Example #20
Source File: CreateHdfsDirDescriptor.java    From cm_ext with Apache License 2.0 4 votes vote down vote up
/** Display name of the command. */
@NotBlank
String getLabel();
 
Example #21
Source File: GemfireSinkProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@NotBlank(message = "A valid key expression is required")
public String getKeyExpression() {
	return keyExpression;
}
 
Example #22
Source File: GemfireCqSourceProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@NotBlank(message = "A valid query string is required")
public String getQuery() {
	return query;
}
 
Example #23
Source File: GemfireRegionProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@NotBlank(message = "Region name is required")
public String getRegionName() {
	return regionName;
}
 
Example #24
Source File: RollingRestartNonWorkerStepDescriptor.java    From cm_ext with Apache License 2.0 4 votes vote down vote up
/** Role for which the steps are applied during rolling restart. */
@NotBlank
@Referencing(type=ReferenceType.ROLE)
String getRoleName();
 
Example #25
Source File: User.java    From Mario with Apache License 2.0 4 votes vote down vote up
@NotBlank
public String getName() {
    return name;
}
 
Example #26
Source File: ServiceCommandDescriptor.java    From cm_ext with Apache License 2.0 4 votes vote down vote up
@NotBlank
String getLabel();
 
Example #27
Source File: KerberosPrincipalDescriptor.java    From cm_ext with Apache License 2.0 4 votes vote down vote up
/**
 * First part of the principal.
 */
@NotBlank
@AvailableSubstitutions(type={PARAMETERS, PRINCIPAL})
String getPrimary();
 
Example #28
Source File: AbstractRemoteFileProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@NotBlank
public String getRemoteDir() {
	return remoteDir;
}
 
Example #29
Source File: ComponentDescriptor.java    From cm_ext with Apache License 2.0 4 votes vote down vote up
@NotBlank
String getName();
 
Example #30
Source File: Post.java    From frpMgr with MIT License 4 votes vote down vote up
@NotBlank(message="岗位名称不能为空")
@Length(min=0, max=100, message="岗位名称长度不能超过 100 个字符")
public String getPostName() {
	return postName;
}