本文整理匯總了Java中org.hibernate.validator.constraints.NotBlank類的典型用法代碼示例。如果您正苦於以下問題:Java NotBlank類的具體用法?Java NotBlank怎麽用?Java NotBlank使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NotBlank類屬於org.hibernate.validator.constraints包,在下文中一共展示了NotBlank類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: defendantResponseCopy
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
@ApiOperation("Returns a Defendant Response copy for a given claim external id")
@GetMapping(
value = "/defendantResponseCopy/{externalId}",
produces = MediaType.APPLICATION_PDF_VALUE
)
public ResponseEntity<ByteArrayResource> defendantResponseCopy(
@ApiParam("Claim external id")
@PathVariable("externalId") @NotBlank String externalId
) {
byte[] pdfDocument = documentsService.generateDefendantResponseCopy(externalId);
return ResponseEntity
.ok()
.contentLength(pdfDocument.length)
.body(new ByteArrayResource(pdfDocument));
}
示例2: claimIssueReceipt
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
@ApiOperation("Returns a Claim Issue receipt for a given claim external id")
@GetMapping(
value = "/claimIssueReceipt/{externalId}",
produces = MediaType.APPLICATION_PDF_VALUE
)
public ResponseEntity<ByteArrayResource> claimIssueReceipt(
@ApiParam("Claim external id")
@PathVariable("externalId") @NotBlank String externalId
) {
byte[] pdfDocument = documentsService.generateClaimIssueReceipt(externalId);
return ResponseEntity
.ok()
.contentLength(pdfDocument.length)
.body(new ByteArrayResource(pdfDocument));
}
示例3: createMessage
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public String createMessage(
@NotBlank final String senderId,
@NotNull @Valid SendMessageDTO sendMessageDTO
) throws ResourceNotFoundException, ResourceConflictException {
log.info("Called with senderId {}, sendMessageDTO {}", senderId, sendMessageDTO);
final UserEntity user = this.findUser(senderId);
final MessageEntity message = this.sendMessageDtoToMessageEntity(sendMessageDTO);
message.setSender(user);
if(message.getRecipient().getUniqueId().equals(senderId)) {
throw new ResourceConflictException("The recipient's ID can't be the same as the sender's ID");
}
user.getSentMessages().add(message);
this.userRepository.save(user);
return Iterables.getLast(user.getSentMessages()).getUniqueId();
}
示例4: deleteMessageSent
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void deleteMessageSent(
@NotBlank final String messageId,
@NotBlank final String userId
) throws ResourceNotFoundException {
log.info("Called with messageId {}, userId {}", messageId, userId);
final UserEntity user = this.findUser(userId);
final MessageEntity message
= this.messageRepository.findByUniqueIdAndSenderAndIsVisibleForSenderTrue(messageId, user)
.orElseThrow(() -> new ResourceNotFoundException("No message sent found with id " + messageId));
message.setVisibleForSender(false);
this.messageRepository.save(message);
}
示例5: deleteMessageReceived
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void deleteMessageReceived(
@NotBlank final String messageId,
@NotBlank final String userId
) throws ResourceNotFoundException {
log.info("Called with messageId {}, userId {}", messageId, userId);
final UserEntity user = this.findUser(userId);
final MessageEntity message
= this.messageRepository.findByUniqueIdAndRecipientAndIsVisibleForRecipientTrue(messageId, user)
.orElseThrow(() -> new ResourceNotFoundException("No message received found with id " + messageId));
message.setVisibleForRecipient(false);
this.messageRepository.save(message);
}
示例6: addUser
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* 添加用戶
*
* @param userName
* @param userPassword
* @return
*/
@PostMapping(PathRoute.USER_ADD)
public Object addUser(@RequestParam("userName") @NotBlank(message = "用戶名不能為空") String userName,
@RequestParam("userPassword") @NotBlank(message = "用戶密碼不能為空") String userPassword) {
try {
User user = new User();
user.setUserName(userName);
user.setUserPassword(userPassword);
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
user.setIsdelete(0);
userService.insertAllColumn(user);
return ResultResponse.success("添加用戶成功", user.getId());
} catch (Exception e) {
logger.error("添加用戶失敗", e);
}
return ResultResponse.error("添加用戶失敗");
}
示例7: getMessageReceived
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
@Transactional(readOnly = false)
public MessageReceived getMessageReceived(
@NotBlank final String messageId,
@NotBlank final String userId
) throws ResourceNotFoundException {
log.info("Called with messageId {}, userId {}", messageId, userId);
final UserEntity user = this.findUser(userId);
final MessageEntity message
= this.messageRepository.findByUniqueIdAndRecipientAndIsVisibleForRecipientTrue(messageId, user)
.orElseThrow(() -> new ResourceNotFoundException("No message found with id " + messageId));
if(message.getDateOfRead() == null) {
message.setDateOfRead(new Date());
}
return ServiceUtils.toMessageReceivedDto(message);
}
示例8: getMessagesReceived
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public List<MessageReceived> getMessagesReceived(
@NotBlank final String userId,
@Nullable final String content
) throws ResourceNotFoundException {
log.info("Called with userId {}, content {}", userId, content);
@SuppressWarnings("unchecked") final List<MessageEntity> messageEntities = this.messageRepository.findAll(
MessageSpecs.findReceivedMessagesForUser(
this.findUser(userId),
content,
content)
);
final List<MessageReceived> collect = messageEntities
.stream()
.map(ServiceUtils::toMessageReceivedDto)
.sorted(Comparator.comparing(Message::getDate))
.collect(Collectors.toList());
Collections.reverse(collect);
return collect;
}
示例9: updateNewEmail
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void updateNewEmail(
@NotBlank final String id,
@NotNull @Valid final ChangeEmailDTO changeEmailDTO
) throws ResourceNotFoundException, ResourceConflictException {
log.info("Called with id {}, changeEmailDTO {}", id, changeEmailDTO);
final UserEntity user = this.findUser(id);
if(this.userRepository.existsByEmailIgnoreCase(changeEmailDTO.getEmail())) {
throw new ResourceConflictException("The e-mail " + changeEmailDTO.getEmail() + " exists");
}
user.setEmailChangeToken(RandomUtils.randomToken());
user.setNewEmail(changeEmailDTO.getEmail());
this.mailService.sendMailWithEmailChangeToken(user.getEmail(), user.getEmailChangeToken());
}
示例10: updatePassword
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void updatePassword(
@NotBlank final String id,
@NotNull @Valid final ChangePasswordDTO changePasswordDTO
) throws ResourceNotFoundException, ResourceBadRequestException {
log.info("Called with id {}, changePasswordDTO {}", id, changePasswordDTO);
final UserEntity user = this.findUser(id);
if(!EncryptUtils.matches(changePasswordDTO.getOldPassword(), user.getPassword())) {
throw new ResourceBadRequestException("The entered password doesn't match the old password");
}
user.setPassword(EncryptUtils.encrypt(changePasswordDTO.getNewPassword()));
}
示例11: addInvitation
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void addInvitation(
@NotBlank final String fromId,
@NotBlank final String toId
) throws ResourceNotFoundException, ResourceConflictException {
log.info("Called with fromId {}, toId {}", fromId, toId);
final UserEntity fromUser = this.findUser(fromId);
final UserEntity toUser = this.findUser(toId);
if(toUser.getSentInvitations().contains(fromUser)) {
throw new ResourceConflictException("There is an invitation from the user with ID " + toUser.getUniqueId());
}
fromUser.addSentInvitation(toUser);
}
示例12: createMovie
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void createMovie(
@NotNull @Valid final MovieDTO movieDTO,
@NotBlank final String userId
) throws ResourceNotFoundException {
log.info("Called with {}, userId {}", movieDTO, userId);
final UserEntity user = this.findUser(userId);
final MovieEntity movie = new MovieEntity();
movie.setTitle(movieDTO.getTitle());
movie.setType(movieDTO.getType());
this.movieRepository.save(movie);
}
示例13: updateMovieStatus
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void updateMovieStatus(
@Min(1) final Long movieId,
@NotBlank final String userId,
@NotNull final VerificationStatus status
) throws ResourceForbiddenException, ResourceNotFoundException {
log.info("Called with movieId {}, userId {}, status {}", movieId, userId, status);
final UserEntity user = this.findUser(userId);
final MovieEntity movie = this.findMovie(movieId, DataStatus.WAITING);
if(!user.getPermissions().contains(UserMoviePermission.ALL)
&& !user.getPermissions().contains(UserMoviePermission.NEW_MOVIE)) {
throw new ResourceForbiddenException("No permissions");
}
movie.setStatus(status.getDataStatus());
}
示例14: countyCourtJudgement
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
@ApiOperation("Returns a County Court Judgement for a given claim external id")
@GetMapping(
value = "/ccj/{externalId}",
produces = MediaType.APPLICATION_PDF_VALUE
)
public ResponseEntity<ByteArrayResource> countyCourtJudgement(
@ApiParam("Claim external id")
@PathVariable("externalId") @NotBlank String externalId
) {
byte[] pdfDocument = documentsService.generateCountyCourtJudgement(externalId);
return ResponseEntity
.ok()
.contentLength(pdfDocument.length)
.body(new ByteArrayResource(pdfDocument));
}
示例15: getInvitations
import org.hibernate.validator.constraints.NotBlank; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public List<User> getInvitations(
@NotBlank final String id,
@NotNull final Boolean outgoing
) throws ResourceNotFoundException {
log.info("Called with id {}, outgoing {}", id, outgoing);
if(outgoing) {
return this.findUser(id).getSentInvitations()
.stream()
.map(ServiceUtils::toUserDto)
.collect(Collectors.toList());
} else {
return this.findUser(id).getReceivedInvitations()
.stream()
.map(ServiceUtils::toUserDto)
.collect(Collectors.toList());
}
}