if (owner != null) { JsonObject jsonOwner = new JsonObject(); jsonOwner.put("id", owner.getId()); jsonOwner.put("username", owner.getDisplayName()); content.put("owner", jsonOwner);
doc.add(new TextField(FIELD_NAME_SPLIT, api.getName(), Field.Store.NO)); doc.add(new TextField(FIELD_DESCRIPTION, api.getDescription(), Field.Store.NO)); doc.add(new TextField(FIELD_OWNER, api.getPrimaryOwner().getDisplayName(), Field.Store.NO)); if (api.getPrimaryOwner().getEmail() != null) { doc.add(new TextField(FIELD_OWNER_MAIL, api.getPrimaryOwner().getEmail(), Field.Store.NO));
if (primaryOwnerMembership.isPresent()) { final UserEntity user = userService.findById(primaryOwnerMembership.get().getUserId()); apiEntity.setPrimaryOwner(new PrimaryOwnerEntity(user));
@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); } }
private String getOwnerEmail(final AlertEntity alert) { switch (alert.getReferenceType()) { case API: return apiService.findById(alert.getReferenceId()).getPrimaryOwner().getEmail(); case APPLICATION: return applicationService.findById(alert.getReferenceId()).getPrimaryOwner().getEmail(); default: return null; } } }
private ApplicationEntity convert(Application application, UserEntity primaryOwner) { ApplicationEntity applicationEntity = new ApplicationEntity(); applicationEntity.setId(application.getId()); applicationEntity.setName(application.getName()); applicationEntity.setDescription(application.getDescription()); applicationEntity.setType(application.getType()); applicationEntity.setStatus(application.getStatus().toString()); applicationEntity.setGroups(application.getGroups()); applicationEntity.setCreatedAt(application.getCreatedAt()); applicationEntity.setUpdatedAt(application.getUpdatedAt()); applicationEntity.setClientId(application.getClientId()); if (primaryOwner != null) { applicationEntity.setPrimaryOwner(new PrimaryOwnerEntity(primaryOwner)); } return applicationEntity; }
@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); } }
private String getOwnerEmail(final AlertEntity alert) { switch (alert.getReferenceType()) { case API: return apiService.findById(alert.getReferenceId()).getPrimaryOwner().getEmail(); case APPLICATION: return applicationService.findById(alert.getReferenceId()).getPrimaryOwner().getEmail(); default: return null; } } }
if (owner != null) { JsonObject jsonOwner = new JsonObject(); jsonOwner.put("id", owner.getId()); jsonOwner.put("username", owner.getDisplayName()); content.put("owner", jsonOwner);
private ApplicationEntity convert(Application application, UserEntity primaryOwner) { ApplicationEntity applicationEntity = new ApplicationEntity(); applicationEntity.setId(application.getId()); applicationEntity.setName(application.getName()); applicationEntity.setDescription(application.getDescription()); applicationEntity.setType(application.getType()); applicationEntity.setStatus(application.getStatus().toString()); applicationEntity.setGroups(application.getGroups()); applicationEntity.setCreatedAt(application.getCreatedAt()); applicationEntity.setUpdatedAt(application.getUpdatedAt()); applicationEntity.setClientId(application.getClientId()); if (primaryOwner != null) { applicationEntity.setPrimaryOwner(new PrimaryOwnerEntity(primaryOwner)); } return applicationEntity; }
doc.add(new TextField(FIELD_NAME_SPLIT, api.getName(), Field.Store.NO)); doc.add(new TextField(FIELD_DESCRIPTION, api.getDescription(), Field.Store.NO)); doc.add(new TextField(FIELD_OWNER, api.getPrimaryOwner().getDisplayName(), Field.Store.NO)); if (api.getPrimaryOwner().getEmail() != null) { doc.add(new TextField(FIELD_OWNER_MAIL, api.getPrimaryOwner().getEmail(), Field.Store.NO));
!Objects.equals(currentApi.getPrimaryOwner().getId(), getAuthenticatedUser()) && !isAdmin()) { apiToUpdate.getProxy().setContextPath(currentApi.getProxy().getContextPath());
application.getType(), new Subscription.User( application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName()
apiEntity.setPrimaryOwner(new PrimaryOwnerEntity(primaryOwner));
!Objects.equals(currentApi.getPrimaryOwner().getId(), getAuthenticatedUser()) && !isAdmin()) { apiToUpdate.getProxy().setContextPath(currentApi.getProxy().getContextPath());
application.getType(), new Subscription.User( application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName()
apiEntity.setPrimaryOwner(new PrimaryOwnerEntity(primaryOwner));
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()