Ejemplo n.º 1
0
  @Override
  public void deletePublisher(String userId, String publisherId) {
    Assert.notNull(userId, "userId must not be null");
    Assert.notNull(publisherId, "publisherId must not be null");

    User user = userRepository.findOne(userId);
    User publisher = userRepository.findOne(publisherId);

    if (user == null) {
      String msg = String.format("user not find by id %s", userId);
      logger.debug(msg);
      throw errorService.createException(AccountException.class, ErrorEnum.ERROR_USER_NOT_FOUND);
    } else if (!user.getStatus().equals(AccountStatusEnum.ACTIVE)) {
      String msg = String.format("user status must be: %s", AccountStatusEnum.ACTIVE);
      logger.debug(msg);
      throw errorService.createException(AccountException.class, ErrorEnum.ERROR_USER_NOT_ACTIVE);
    } else if (publisher == null) {
      String msg = String.format("publisher not find by id %s", publisherId);
      logger.debug(msg);
      throw errorService.createException(AccountException.class, ErrorEnum.ERROR_USER_NOT_FOUND);
    } else if (!publisher.getStatus().equals(AccountStatusEnum.ACTIVE)) {
      String msg = String.format("publisher status must be: %s", AccountStatusEnum.ACTIVE);
      logger.debug(msg);
      throw errorService.createException(AccountException.class, ErrorEnum.ERROR_USER_NOT_ACTIVE);
    } else {
      if (publisher.getAccountType().toString().equals(AccountEnum.USER.toString())) {
        relationRepository.remove(userId, publisherId, RelationTypeEnum.PUBLISHER);
      } else {
        relationRepository.remove(publisherId, userId, RelationTypeEnum.SUBSCRIBER);
      }
      accountStoreService.update(userId);
    }
  }
Ejemplo n.º 2
0
  @RequestMapping(value = "registration/confirm", method = RequestMethod.GET)
  public String confirmRegistration(@RequestParam String uid, @RequestParam String value) {

    Assert.notNull(uid, "registration confirm uid must not be null");
    Assert.notNull(value, "registration confirm uid must not be null");

    accountService.confirmRegistration(uid, value);

    AccountModel account = profileModelService.getAccountInformation(uid);

    if (account.getTypeAccount().equals(AccountEnum.USER.name())) {
      return "redirect:" + scopeService.getCurrentContextPath() + "/pf/login";
    } else {
      return "redirect:" + scopeService.getCurrentContextPath() + "/pf/community?guid=" + uid;
    }
  }