Java 类org.hibernate.validator.constraints.NotBlank 实例源码

项目:cmc-claim-store    文件:DocumentsController.java   
@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));
}
项目:REST-Web-Services    文件:MessagePersistenceServiceImpl.java   
/**
 * {@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();
}
项目:REST-Web-Services    文件:MessagePersistenceServiceImpl.java   
/**
 * {@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);
}
项目:REST-Web-Services    文件:MessagePersistenceServiceImpl.java   
/**
 * {@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);
}
项目:spring-boot-wechat    文件:UserController.java   
/**
 * 添加用户
 *
 * @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("添加用户失败");
}
项目:REST-Web-Services    文件:MessageSearchServiceImpl.java   
/**
 * {@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);
}
项目:REST-Web-Services    文件:MessageSearchServiceImpl.java   
/**
 * {@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;
}
项目:REST-Web-Services    文件:UserPersistenceServiceImpl.java   
/**
 * {@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());
}
项目:REST-Web-Services    文件:UserPersistenceServiceImpl.java   
/**
 * {@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()));
}
项目:cmc-claim-store    文件:DocumentsController.java   
@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));
}
项目:REST-Web-Services    文件:UserPersistenceServiceImpl.java   
/**
 * {@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);
}
项目:REST-Web-Services    文件:MoviePersistenceServiceImpl.java   
/**
 * {@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);
}
项目:REST-Web-Services    文件:MoviePersistenceServiceImpl.java   
/**
 * {@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());
}
项目:cmc-claim-store    文件:DocumentsController.java   
@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));
}
项目:REST-Web-Services    文件:UserSearchServiceImpl.java   
/**
 * {@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());
    }
}
项目:cmc-claim-store    文件:DocumentsController.java   
@ApiOperation("Returns a Defendant Response receipt for a given claim external id")
@GetMapping(
    value = "/defendantResponseReceipt/{externalId}",
    produces = MediaType.APPLICATION_PDF_VALUE
)
public ResponseEntity<ByteArrayResource> defendantResponseReceipt(
    @ApiParam("Claim external id")
    @PathVariable("externalId") @NotBlank String externalId
) {
    byte[] pdfDocument = documentsService.generateDefendantResponseReceipt(externalId);

    return ResponseEntity
        .ok()
        .contentLength(pdfDocument.length)
        .body(new ByteArrayResource(pdfDocument));
}
项目:cmc-claim-store    文件:DocumentsController.java   
@ApiOperation("Returns a sealed claim copy for a given claim external id")
@GetMapping(
    value = "/legalSealedClaim/{externalId}",
    produces = MediaType.APPLICATION_PDF_VALUE
)
public ResponseEntity<ByteArrayResource> legalSealedClaim(
    @ApiParam("Claim external id")
    @PathVariable("externalId") @NotBlank String externalId,
    @RequestHeader(HttpHeaders.AUTHORIZATION) String authorisation
) {
    byte[] pdfDocument = documentsService.getLegalSealedClaim(externalId, authorisation);

    return ResponseEntity
        .ok()
        .contentLength(pdfDocument.length)
        .body(new ByteArrayResource(pdfDocument));
}
项目:REST-Web-Services    文件:MailServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Async
@Override
public void sendMailWithNewPassword(
        @NotBlank @Email final String email,
        @NotBlank final String newPassword
) {
    log.info("Called with e-mail {}, newPassword {}", email, newPassword);

    try {
        final JavaMailSenderImpl sender = new JavaMailSenderImpl();

        final MimeMessage message = sender.createMimeMessage();

        final MimeMessageHelper helper = new MimeMessageHelper(message);

        helper.setTo(email);
        helper.setSubject("Recover password");
        helper.setText("Your new password: " + "<b>" + newPassword + "</b>", true);

        sendMail(message);
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}
项目:REST-Web-Services    文件:UserSearchResult.java   
/**
 * Constructor.
 *
 * @param id The user ID
 * @param username The user's name
 * @param email The user's e-mail
 */
@JsonCreator
public UserSearchResult(
        @NotBlank @JsonProperty("id") final String id,
        @NotBlank @JsonProperty("username") final String username,
        @NotBlank @JsonProperty("email") final String email
) {
    super(id);
    this.username = username;
    this.email = email;
}
项目:REST-Web-Services    文件:MovieSearchResult.java   
/**
 * Constructor.
 *
 * @param id The movie ID
 * @param title The title of the movie
 * @param type The type of the movie
 * @param rating The movie rating
 */
@JsonCreator
public MovieSearchResult(
        @NotNull @JsonProperty("id") final Long id,
        @NotBlank @JsonProperty("title") final String title,
        @NotNull @JsonProperty("type") final MovieType type,
        @NotNull @JsonProperty("rating") final Float rating
) {
    super(id.toString());
    this.title = title;
    this.type = type;
    this.rating = rating;
}
项目:playground-scenario-generator    文件:ScenarioRestController.java   
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/{scenario}/enable", method = {RequestMethod.POST, RequestMethod.PUT})
public boolean enableScenario(@NotBlank @PathVariable("scenario") String scenarioId) throws Exception {
    return scenarioService.enable(scenarioId);
}
项目:REST-Web-Services    文件:MessageSearchServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public boolean existsMessageSent(
        @NotBlank final String messageId,
        @NotBlank final String userId
) throws ResourceNotFoundException {
    log.info("Called with messageId {}, userId {}", messageId, userId);

    final UserEntity user = this.findUser(userId);

    return this.messageRepository.existsByUniqueIdAndSenderAndIsVisibleForSenderTrue(messageId, user);
}
项目:REST-Web-Services    文件:MessageSearchServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public boolean existsMessageReceived(
        @NotBlank final String messageId,
        @NotBlank final String userId
) throws ResourceNotFoundException {
    log.info("Called with messageId {}, userId {}", messageId, userId);

    final UserEntity user = this.findUser(userId);

    return this.messageRepository.existsByUniqueIdAndRecipientAndIsVisibleForRecipientTrue(messageId, user);
}
项目:REST-Web-Services    文件:MovieContributionPersistenceServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void updateReleaseDateContribution(
        @NotNull @Valid final ContributionUpdate<ReleaseDate> contribution,
        @Min(1) final Long contributionId,
        @NotBlank final String userId
) throws ResourceNotFoundException, ResourceConflictException {
    log.info("Called with contribution {}, contributionId {}, userId {}",
            contribution, contributionId, userId);

    final UserEntity user = this.findUser(userId);
    final ContributionEntity contributionEntity = this.findContribution(contributionId, DataStatus.WAITING, user, MovieField.RELEASE_DATE);

    this.validIds(contributionEntity, contribution);
    this.cleanUp(contributionEntity, contribution, contributionEntity.getMovie().getReleaseDates());

    contribution.getElementsToAdd().forEach((key, value) -> {
        this.moviePersistenceService.updateReleaseDate(value, key, contributionEntity.getMovie());
    });
    contribution.getElementsToUpdate().forEach((key, value) -> {
        this.moviePersistenceService.updateReleaseDate(value, key, contributionEntity.getMovie());
    });
    contribution.getNewElementsToAdd()
            .forEach(releaseDate -> {
                final Long id = this.moviePersistenceService.createReleaseDate(releaseDate, contributionEntity.getMovie());
                contributionEntity.getIdsToAdd().add(id);
            });

    contributionEntity.setSources(contribution.getSources());
    Optional.ofNullable(contribution.getComment()).ifPresent(contributionEntity::setUserComment);
}
项目:REST-Web-Services    文件:MovieContributionPersistenceServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void updateSiteContribution(
        @NotNull @Valid final ContributionUpdate<Site> contribution,
        @Min(1) final Long contributionId,
        @NotBlank final String userId
) throws ResourceNotFoundException, ResourceConflictException {
    log.info("Called with contribution {}, contributionId {}, userId {}",
            contribution, contributionId, userId);

    final UserEntity user = this.findUser(userId);
    final ContributionEntity contributionEntity = this.findContribution(contributionId, DataStatus.WAITING, user, MovieField.SITE);

    this.validIds(contributionEntity, contribution);
    this.cleanUp(contributionEntity, contribution, contributionEntity.getMovie().getSites());

    contribution.getElementsToAdd().forEach((key, value) -> {
        this.moviePersistenceService.updateSite(value, key, contributionEntity.getMovie());
    });
    contribution.getElementsToUpdate().forEach((key, value) -> {
        this.moviePersistenceService.updateSite(value, key, contributionEntity.getMovie());
    });
    contribution.getNewElementsToAdd()
            .forEach(site -> {
                final Long id = this.moviePersistenceService.createSite(site, contributionEntity.getMovie());
                contributionEntity.getIdsToAdd().add(id);
            });

    contributionEntity.setSources(contribution.getSources());
    Optional.ofNullable(contribution.getComment()).ifPresent(contributionEntity::setUserComment);
}
项目:REST-Web-Services    文件:MovieContributionPersistenceServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void updateCountryContribution(
        @NotNull @Valid final ContributionUpdate<Country> contribution,
        @Min(1) final Long contributionId,
        @NotBlank final String userId
) throws ResourceNotFoundException, ResourceConflictException {
    log.info("Called with contribution {}, contributionId {}, userId {}",
            contribution, contributionId, userId);

    final UserEntity user = this.findUser(userId);
    final ContributionEntity contributionEntity = this.findContribution(contributionId, DataStatus.WAITING, user, MovieField.COUNTRY);

    this.validIds(contributionEntity, contribution);
    this.cleanUp(contributionEntity, contribution, contributionEntity.getMovie().getCountries());

    contribution.getElementsToAdd().forEach((key, value) -> {
        this.moviePersistenceService.updateCountry(value, key, contributionEntity.getMovie());
    });
    contribution.getElementsToUpdate().forEach((key, value) -> {
        this.moviePersistenceService.updateCountry(value, key, contributionEntity.getMovie());
    });
    contribution.getNewElementsToAdd()
            .forEach(country -> {
                final Long id = this.moviePersistenceService.createCountry(country, contributionEntity.getMovie());
                contributionEntity.getIdsToAdd().add(id);
            });

    contributionEntity.setSources(contribution.getSources());
    Optional.ofNullable(contribution.getComment()).ifPresent(contributionEntity::setUserComment);
}
项目:REST-Web-Services    文件:MovieContributionPersistenceServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void updateLanguageContribution(
        @NotNull @Valid final ContributionUpdate<Language> contribution,
        @Min(1) final Long contributionId,
        @NotBlank final String userId
) throws ResourceNotFoundException, ResourceConflictException {
    log.info("Called with contribution {}, contributionId {}, userId {}",
            contribution, contributionId, userId);

    final UserEntity user = this.findUser(userId);
    final ContributionEntity contributionEntity = this.findContribution(contributionId, DataStatus.WAITING, user, MovieField.LANGUAGE);

    this.validIds(contributionEntity, contribution);
    this.cleanUp(contributionEntity, contribution, contributionEntity.getMovie().getLanguages());

    contribution.getElementsToAdd().forEach((key, value) -> {
        this.moviePersistenceService.updateLanguage(value, key, contributionEntity.getMovie());
    });
    contribution.getElementsToUpdate().forEach((key, value) -> {
        this.moviePersistenceService.updateLanguage(value, key, contributionEntity.getMovie());
    });
    contribution.getNewElementsToAdd()
            .forEach(language -> {
                final Long id = this.moviePersistenceService.createLanguage(language, contributionEntity.getMovie());
                contributionEntity.getIdsToAdd().add(id);
            });

    contributionEntity.setSources(contribution.getSources());
    Optional.ofNullable(contribution.getComment()).ifPresent(contributionEntity::setUserComment);
}
项目:REST-Web-Services    文件:MovieContributionPersistenceServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void updateGenreContribution(
        @NotNull @Valid final ContributionUpdate<Genre> contribution,
        @Min(1) final Long contributionId,
        @NotBlank final String userId
) throws ResourceNotFoundException, ResourceConflictException {
    log.info("Called with contribution {}, contributionId {}, userId {}",
            contribution, contributionId, userId);

    final UserEntity user = this.findUser(userId);
    final ContributionEntity contributionEntity = this.findContribution(contributionId, DataStatus.WAITING, user, MovieField.GENRE);

    this.validIds(contributionEntity, contribution);
    this.cleanUp(contributionEntity, contribution, contributionEntity.getMovie().getGenres());

    contribution.getElementsToAdd().forEach((key, value) -> {
        this.moviePersistenceService.updateGenre(value, key, contributionEntity.getMovie());
    });
    contribution.getElementsToUpdate().forEach((key, value) -> {
        this.moviePersistenceService.updateGenre(value, key, contributionEntity.getMovie());
    });
    contribution.getNewElementsToAdd()
            .forEach(genre -> {
                final Long id = this.moviePersistenceService.createGenre(genre, contributionEntity.getMovie());
                contributionEntity.getIdsToAdd().add(id);
            });

    contributionEntity.setSources(contribution.getSources());
    Optional.ofNullable(contribution.getComment()).ifPresent(contributionEntity::setUserComment);
}
项目:REST-Web-Services    文件:MovieContributionPersistenceServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void updateReviewContribution(
        @NotNull @Valid final ContributionUpdate<Review> contribution,
        @Min(1) final Long contributionId,
        @NotBlank final String userId
) throws ResourceNotFoundException, ResourceConflictException {
    log.info("Called with contribution {}, contributionId {}, userId {}",
            contribution, contributionId, userId);

    final UserEntity user = this.findUser(userId);
    final ContributionEntity contributionEntity = this.findContribution(contributionId, DataStatus.WAITING, user, MovieField.REVIEW);

    this.validIds(contributionEntity, contribution);
    this.cleanUp(contributionEntity, contribution, contributionEntity.getMovie().getReviews());

    contribution.getElementsToAdd().forEach((key, value) -> {
        this.moviePersistenceService.updateReview(value, key, contributionEntity.getMovie());
    });
    contribution.getElementsToUpdate().forEach((key, value) -> {
        this.moviePersistenceService.updateReview(value, key, contributionEntity.getMovie());
    });
    contribution.getNewElementsToAdd()
            .forEach(review -> {
                final Long id = this.moviePersistenceService.createReview(review, contributionEntity.getMovie());
                contributionEntity.getIdsToAdd().add(id);
            });

    contributionEntity.setSources(contribution.getSources());
    Optional.ofNullable(contribution.getComment()).ifPresent(contributionEntity::setUserComment);
}
项目:REST-Web-Services    文件:UserPersistenceServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void activationUser(
        @NotBlank final String token
) throws ResourceNotFoundException {
    log.info("Called with token {}", token);

    final UserEntity user
            = this.userRepository.findByActivationToken(token)
                     .orElseThrow(() -> new ResourceNotFoundException("No user found with token " + token));

    user.setActivationToken(null);
    user.setEnabled(true);
}
项目:REST-Web-Services    文件:UserPersistenceServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void updateEmail(
        @NotBlank final String token
) throws ResourceNotFoundException {
    log.info("Called with token {}", token);

    final UserEntity user
            = this.userRepository.findByEmailChangeToken(token)
                     .orElseThrow(() -> new ResourceNotFoundException("No user found with token " + token));

    user.setEmail(user.getNewEmail());
    user.setEmailChangeToken(null);
    user.setNewEmail(null);
}
项目:REST-Web-Services    文件:UserPersistenceServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void removeFriend(
        @NotBlank final String fromId,
        @NotBlank final String toId
) throws ResourceNotFoundException {
    log.info("Called with fromId {}, toId {}", fromId, toId);

    this.findUser(fromId).removeFriend(this.findUser(toId));
}
项目:REST-Web-Services    文件:UserPersistenceServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void removeInvitation(
        @NotBlank final String fromId,
        @NotBlank final String toId
) throws ResourceNotFoundException {
    log.info("Called with fromId {}, toId {}", fromId, toId);

    this.findUser(fromId).removeSentInvitation(this.findUser(toId));
}
项目:REST-Web-Services    文件:UserSearchServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public User getUserByUsername(
        @NotBlank @Pattern(regexp = "[a-zA-Z0-9_-]{6,36}") final String username
) throws ResourceNotFoundException {
    log.info("Called with username {}", username);

    return this.userRepository.findByUsernameIgnoreCaseAndEnabledTrue(username)
            .map(ServiceUtils::toUserDto)
            .orElseThrow(() -> new ResourceNotFoundException("No user found with username " + username));
}
项目:waggle-dance    文件:FederatedMetaStore.java   
@NotBlank
@Override
public String getDatabasePrefix() {
  String prefix = super.getDatabasePrefix();
  if (prefix == null) {
    prefix = getName() + "_";
  }
  return prefix;
}
项目:REST-Web-Services    文件:UserSearchServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public boolean existsUserByUsername(
        @NotBlank @Pattern(regexp = "[a-zA-Z0-9_-]{6,36}") final String username
) {
    log.info("Called with username {}", username);

    return this.userRepository.existsByUsernameIgnoreCase(username);
}
项目:REST-Web-Services    文件:UserSearchServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public String getUserPassword(
        @NotBlank @Pattern(regexp = "[a-zA-Z0-9_-]{6,36}") final String username
) throws ResourceNotFoundException {
    log.info("Called with username {}", username);

    return this.userRepository.findByUsernameIgnoreCaseAndEnabledTrue(username)
            .map(UserEntity::getPassword)
            .orElseThrow(() -> new ResourceNotFoundException("No user found with username " + username));
}
项目:REST-Web-Services    文件:MailServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Async
@Override
public void sendMailWithActivationToken(
        @NotBlank @Email final String email,
        @NotBlank final String token
) {
    log.info("Called with e-mail {}, token {}", email, token);

    try {
        final JavaMailSenderImpl sender = new JavaMailSenderImpl();

        final MimeMessage message = sender.createMimeMessage();

        final MimeMessageHelper helper = new MimeMessageHelper(message);

        helper.setTo(email);
        helper.setSubject("Complete registration");
        helper.setText("To activation your account, click the link below:<br />"
                + "<a href='" + "https://localhost:8443" + "/register/thanks?token=" + token + "'>" +
                "Click here to complete your registration" +
                "</a>", true);

        sendMail(message);
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}
项目:REST-Web-Services    文件:MailServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Async
@Override
public void sendMailWithEmailChangeToken(
        @NotBlank @Email final String email,
        @NotBlank final String token
) {
    log.info("Called with e-mail {}, token {}", email, token);

    try {
        final JavaMailSenderImpl sender = new JavaMailSenderImpl();

        final MimeMessage message = sender.createMimeMessage();

        final MimeMessageHelper helper = new MimeMessageHelper(message);

        helper.setTo(email);
        helper.setSubject("Change e-mail");
        helper.setText("Change e-mail address, click the link below:<br />"
                + "<a href='" + "https://localhost:8443" + "/settings/changeEmail/thanks?token=" + token + "'>" +
                "Click here to complete the change of your e-mail" +
                "</a>", true);

        sendMail(message);
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}
项目:REST-Web-Services    文件:GoogleStorageServiceImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public void delete(
        @NotBlank final String fileId
) throws ResourcePreconditionException, ResourceServerException {
    // Build a new authorized API client service.
    final Drive service = getDriveService();

    try {
        service.files().delete(fileId).execute();
        log.info("Deleted file");
    } catch (final IOException e) {
        throw new ResourceServerException("The initialization of the request fails", e);
    }
}