本文整理汇总了Java中org.hibernate.validator.constraints.NotEmpty类的典型用法代码示例。如果您正苦于以下问题:Java NotEmpty类的具体用法?Java NotEmpty怎么用?Java NotEmpty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NotEmpty类属于org.hibernate.validator.constraints包,在下文中一共展示了NotEmpty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authorize
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@GET @Path("{username}")
@Produces(MediaType.APPLICATION_JSON)
public Response authorize(
@Username @PathParam("username") String username,
@NotEmpty @QueryParam("password") String password) {
Bson filter = and(eq(User.USERNAME, username), eq(User.PASSWORD, Hashes.sha1(password)));
Document newAuth = Authorizations.newInstance(username);
Document user = MongoDBs.users().findOneAndUpdate(filter, set(User.AUTHORIZATION, newAuth));
if (user == null) {
return Response.status(FORBIDDEN)
.entity(new Failure("The username or password is incorrect"))
.build();
} else {
return Response.ok(newAuth).build();
}
}
示例2: runNow
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@ResponseBody
@RequestMapping(value = "job/{id}/{opType}", method = RequestMethod.PUT)
public ResponseDTO runNow(@PathVariable @NotEmpty String id, @PathVariable @NotEmpty String opType) {
try {
logger.info("请求参数:{}, {}", id, opType);
//立即执行
if (Objects.equals(opType, "1")) {
jobDetailService.runNow(Integer.parseInt(id));
} else if (Objects.equals(opType, "2")) {//暂停
jobDetailService.stopNow(Integer.parseInt(id));
} else if (Objects.equals(opType, "3")) {//恢复
jobDetailService.resumeNow(Integer.parseInt(id));
} else {
return new ResponseDTO(0, "failed", null);
}
}catch (Exception e){
e.printStackTrace();
}
return new ResponseDTO(1, "", null);
}
示例3: primitiveTypesShouldNotBeAnnotatedWithNotNullOrEmpty
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@Test
public void primitiveTypesShouldNotBeAnnotatedWithNotNullOrEmpty() {
final Stream<Field> failedFields = filterFieldsOfManagedJpaTypes(field -> {
final boolean notNull = field.isAnnotationPresent(NotNull.class);
final boolean notEmpty = field.isAnnotationPresent(NotEmpty.class);
final boolean notBlank = field.isAnnotationPresent(NotBlank.class);
final boolean notNullOrEmpty = notNull || notEmpty || notBlank;
final boolean isPrimitive = field.getType().isPrimitive();
return isPrimitive && notNullOrEmpty;
});
assertNoFields(failedFields,
"Primitive entity fields should not be annotated with @NotNull, @NotEmpty or @NotBlank:\n" +
" These fields fail: ");
}
示例4: updateSnippet
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@PUT
@Path("/configurations/{id}/snippets/{snippet_id}")
@RequiresAuthentication
@RequiresPermissions(CollectorRestPermissions.COLLECTORS_UPDATE)
@ApiOperation(value = "Update a configuration snippet",
notes = "This is a stateless method which updates a collector snippet")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The supplied request is not valid.")
})
@AuditEvent(type = CollectorAuditEventTypes.SNIPPET_UPDATE)
public Response updateSnippet(@ApiParam(name = "id", required = true)
@PathParam("id") @NotEmpty String id,
@ApiParam(name = "snippet_id", required = true)
@PathParam("snippet_id") @NotEmpty String snippetId,
@ApiParam(name = "JSON body", required = true)
@Valid @NotNull CollectorConfigurationSnippet request) {
etagService.invalidateAll();
final CollectorConfiguration collectorConfiguration = collectorConfigurationService.updateSnippetFromRequest(id, snippetId, request);
collectorConfigurationService.save(collectorConfiguration);
return Response.accepted().build();
}
示例5: createInput
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@POST
@Path("/configurations/{id}/inputs")
@RequiresAuthentication
@RequiresPermissions(CollectorRestPermissions.COLLECTORS_CREATE)
@ApiOperation(value = "Create a configuration input",
notes = "This is a stateless method which inserts a collector input")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The supplied request is not valid.")
})
@AuditEvent(type = CollectorAuditEventTypes.INPUT_CREATE)
public Response createInput(@ApiParam(name = "id", required = true)
@PathParam("id") @NotEmpty String id,
@ApiParam(name = "JSON body", required = true)
@Valid @NotNull CollectorInput request) {
etagService.invalidateAll();
final CollectorConfiguration collectorConfiguration = collectorConfigurationService.withInputFromRequest(id, request);
collectorConfigurationService.save(collectorConfiguration);
return Response.accepted().build();
}
示例6: get
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@GET
@Timed
@Path("/{collectorId}")
@ApiOperation(value = "Returns at most one collector summary for the specified collector id")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "No collector with the specified id exists")
})
@RequiresAuthentication
@RequiresPermissions(CollectorRestPermissions.COLLECTORS_READ)
public CollectorSummary get(@ApiParam(name = "collectorId", required = true)
@PathParam("collectorId") @NotEmpty String collectorId) {
final Collector collector = collectorService.findById(collectorId);
if (collector != null) {
return collector.toSummary(lostCollectorFunction);
} else {
throw new NotFoundException("Collector <" + collectorId + "> not found!");
}
}
示例7: createSnippet
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@POST
@Path("/configurations/{id}/snippets")
@RequiresAuthentication
@RequiresPermissions(CollectorRestPermissions.COLLECTORS_CREATE)
@ApiOperation(value = "Create a configuration snippet",
notes = "This is a stateless method which inserts a collector configuration snippet")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The supplied request is not valid.")
})
@AuditEvent(type = CollectorAuditEventTypes.SNIPPET_CREATE)
public Response createSnippet(@ApiParam(name = "id", required = true)
@PathParam("id") @NotEmpty String id,
@ApiParam(name = "JSON body", required = true)
@Valid @NotNull CollectorConfigurationSnippet request) {
etagService.invalidateAll();
final CollectorConfiguration collectorConfiguration = collectorConfigurationService.withSnippetFromRequest(id, request);
collectorConfigurationService.save(collectorConfiguration);
return Response.accepted().build();
}
示例8: createOutput
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@POST
@Path("/configurations/{id}/outputs")
@RequiresAuthentication
@RequiresPermissions(CollectorRestPermissions.COLLECTORS_CREATE)
@ApiOperation(value = "Create a configuration output",
notes = "This is a stateless method which inserts a collector output")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The supplied request is not valid.")
})
@AuditEvent(type = CollectorAuditEventTypes.OUTPUT_CREATE)
public Response createOutput(@ApiParam(name = "id", required = true)
@PathParam("id") @NotEmpty String id,
@ApiParam(name = "JSON body", required = true)
@Valid @NotNull CollectorOutput request) {
etagService.invalidateAll();
final CollectorConfiguration collectorConfiguration = collectorConfigurationService.withOutputFromRequest(id, request);
collectorConfigurationService.save(collectorConfiguration);
return Response.accepted().build();
}
示例9: active
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@POST @Path("{_id}")
@Produces(MediaType.APPLICATION_JSON)
public Response active(@PathParam("_id") String id, @NotEmpty @QueryParam("device_id") String deviceId) {
if (!ObjectId.isValid(id)) {
return Responses.notFound("激活码无效");
}
Document license = MongoDBs.licenses().find(eq(License._ID, objectId(id))).first();
RebaseAsserts.notNull(license, "license");
if (!Objects.equals(deviceId, license.getString(License.DEVICE_ID))) {
final Bson target = eq(License._ID, objectId(id));
MongoDBs.licenses().updateOne(target, set(License.DEVICE_ID, deviceId));
license.put(License.DEVICE_ID, deviceId);
}
return Response.ok(license).build();
}
示例10: del
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@ResponseBody
@RequestMapping(value = "job/{id}", method = RequestMethod.DELETE)
public ResponseDTO del(@PathVariable @NotEmpty String id) {
logger.info("请求参数:{}", id);
//立即执行
jobDetailService.delJob(Integer.parseInt(id));
return new ResponseDTO(1, "", null);
}
示例11: getPassword
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@Editable(order=100, description="Input password of this user")
@CurrentPassword
@Password
@NotEmpty
public String getPassword() {
return password;
}
示例12: getOldPassword
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@Editable(order=100)
@CurrentPassword
@Password
@NotEmpty
public String getOldPassword() {
return oldPassword;
}
示例13: getLdapUrl
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@Editable(order=100, name="LDAP URL", description=
"Specifies LDAP URL of the Active Directory server, for example: <i>ldap://ad-server</i>, or <i>ldaps://ad-server</i>")
@NotEmpty
@Override
public String getLdapUrl() {
return super.getLdapUrl();
}
示例14: getManagerDN
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@Editable(order=300, description=""
+ "To authenticate user against Active Directory and retrieve associated attributes and groups, GitPlex "
+ "would have to first authenticate itself against the Active Directory server and GitPlex does that by "
+ "sending 'manager' DN and password. The manager DN should be specified in form of "
+ "<i><account name>@<domain></i>, for instance: <i>[email protected]</i>")
@NotEmpty
@Override
public String getManagerDN() {
return super.getManagerDN();
}
示例15: getUserSearchBase
import org.hibernate.validator.constraints.NotEmpty; //导入依赖的package包/类
@Editable(order=500, description=
"Specifies the base node for user search. For example: <i>cn=Users, dc=example, dc=com</i>")
@NotEmpty
@Override
public String getUserSearchBase() {
return super.getUserSearchBase();
}