@Override public void delete(String id) { try { // If the users is PO of apps or apis, throw an exception long apiCount = apiService.findByUser(id, null) .stream() .filter(entity -> entity.getPrimaryOwner().getId().equals(id)) .count(); long applicationCount = applicationService.findByUser(id) .stream() .filter(entity -> entity.getPrimaryOwner().getId().equals(id)) .count(); if (apiCount > 0 || applicationCount > 0) { throw new StillPrimaryOwnerException(apiCount, applicationCount); } Optional<User> optionalUser = userRepository.findById(id); if (!optionalUser.isPresent()) { throw new UserNotFoundException(id); } membershipService.removeUser(id); userRepository.delete(id); final UserEntity userEntity = convert(optionalUser.get(), false); searchEngineService.delete(userEntity); } catch (TechnicalException ex) { LOGGER.error("An error occurs while trying to delete user", ex); throw new TechnicalManagementException("An error occurs while trying to delete user", ex); } }
@Override public void delete(String id) { try { // If the users is PO of apps or apis, throw an exception long apiCount = apiService.findByUser(id, null) .stream() .filter(entity -> entity.getPrimaryOwner().getId().equals(id)) .count(); long applicationCount = applicationService.findByUser(id) .stream() .filter(entity -> entity.getPrimaryOwner().getId().equals(id)) .count(); if (apiCount > 0 || applicationCount > 0) { throw new StillPrimaryOwnerException(apiCount, applicationCount); } Optional<User> optionalUser = userRepository.findById(id); if (!optionalUser.isPresent()) { throw new UserNotFoundException(id); } membershipService.removeUser(id); userRepository.delete(id); final UserEntity userEntity = convert(optionalUser.get(), false); searchEngineService.delete(userEntity); } catch (TechnicalException ex) { LOGGER.error("An error occurs while trying to delete user", ex); throw new TechnicalManagementException("An error occurs while trying to delete user", ex); } }
if (owner != null) { JsonObject jsonOwner = new JsonObject(); jsonOwner.put("id", owner.getId()); jsonOwner.put("username", owner.getDisplayName()); content.put("owner", jsonOwner);
if (owner != null) { JsonObject jsonOwner = new JsonObject(); jsonOwner.put("id", owner.getId()); jsonOwner.put("username", owner.getDisplayName()); content.put("owner", jsonOwner);
!Objects.equals(currentApi.getPrimaryOwner().getId(), getAuthenticatedUser()) && !isAdmin()) { apiToUpdate.getProxy().setContextPath(currentApi.getProxy().getContextPath());
!Objects.equals(currentApi.getPrimaryOwner().getId(), getAuthenticatedUser()) && !isAdmin()) { apiToUpdate.getProxy().setContextPath(currentApi.getProxy().getContextPath());
application.getType(), new Subscription.User( application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName()
application.getType(), new Subscription.User( application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName()
application.getType(), new Subscription.User( application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName()
application.getType(), new Subscription.User( application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName()
api.getVersion(), new Subscription.User( api.getPrimaryOwner().getId(), api.getPrimaryOwner().getDisplayName()
api.getVersion(), new Subscription.User( api.getPrimaryOwner().getId(), api.getPrimaryOwner().getDisplayName()
application.getType(), new Subscription.User( application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName()
application.getType(), new Subscription.User( application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName()