@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); } }