/** * Updates the affected controller services in the specified updateRequest with the serviceEntities. * * @param serviceEntities service entities * @param affectedServices affected services */ private void updateAffectedControllerServices(final Set<ControllerServiceEntity> serviceEntities, final Map<String, AffectedComponentEntity> affectedServices) { // update the affected components serviceEntities.stream() .filter(entity -> affectedServices.containsKey(entity.getId())) .forEach(entity -> { final AffectedComponentEntity affectedComponentEntity = affectedServices.get(entity.getId()); affectedComponentEntity.setRevision(entity.getRevision()); // only consider update this component if the user had permissions to it if (Boolean.TRUE.equals(affectedComponentEntity.getPermissions().getCanRead())) { final AffectedComponentDTO affectedComponent = affectedComponentEntity.getComponent(); affectedComponent.setState(entity.getComponent().getState()); if (Boolean.TRUE.equals(entity.getPermissions().getCanRead())) { affectedComponent.setValidationErrors(entity.getComponent().getValidationErrors()); } } }); }
public ControllerServiceEntity createControllerServiceEntity(final ControllerServiceDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final PermissionsDTO operatePermissions, final List<BulletinEntity> bulletins) { final ControllerServiceEntity entity = new ControllerServiceEntity(); entity.setRevision(revision); if (dto != null) { entity.setPermissions(permissions); entity.setOperatePermissions(operatePermissions); entity.setId(dto.getId()); entity.setParentGroupId(dto.getParentGroupId()); entity.setPosition(dto.getPosition()); final ControllerServiceStatusDTO status = new ControllerServiceStatusDTO(); status.setRunStatus(dto.getState()); status.setValidationStatus(dto.getValidationStatus()); entity.setStatus(status); if (permissions != null && permissions.getCanRead()) { entity.setComponent(dto); entity.setBulletins(bulletins); } } return entity; }
/** * Populate the uri's for the specified controller service. * * @param controllerServiceEntity controller service * @return dtos */ public ControllerServiceEntity populateRemainingControllerServiceEntityContent(final ControllerServiceEntity controllerServiceEntity) { // populate the controller service href controllerServiceEntity.setUri(generateResourceUri("controller-services", controllerServiceEntity.getId())); // populate the remaining content if (controllerServiceEntity.getComponent() != null) { populateRemainingControllerServiceContent(controllerServiceEntity.getComponent()); } return controllerServiceEntity; }
public AffectedComponentEntity createAffectedComponentEntity(final ControllerServiceEntity serviceEntity) { if (serviceEntity == null) { return null; } final AffectedComponentEntity component = new AffectedComponentEntity(); component.setBulletins(serviceEntity.getBulletins()); component.setId(serviceEntity.getId()); component.setPermissions(serviceEntity.getPermissions()); component.setPosition(serviceEntity.getPosition()); component.setRevision(serviceEntity.getRevision()); component.setUri(serviceEntity.getUri()); final ControllerServiceDTO serviceDto = serviceEntity.getComponent(); final AffectedComponentDTO componentDto = new AffectedComponentDTO(); componentDto.setId(serviceDto.getId()); componentDto.setName(serviceDto.getName()); componentDto.setProcessGroupId(serviceDto.getParentGroupId()); componentDto.setReferenceType(AffectedComponentDTO.COMPONENT_TYPE_CONTROLLER_SERVICE); componentDto.setState(serviceDto.getState()); componentDto.setValidationErrors(serviceDto.getValidationErrors()); component.setComponent(componentDto); return component; }
private void printServicesStillEnabling(final FlowClient flowClient, final String pgId) throws NiFiClientException, IOException { final ControllerServicesEntity servicesEntity = flowClient.getControllerServices(pgId); if (servicesEntity == null || servicesEntity.getControllerServices() == null) { return; } println(); println("One or more services appear to be stuck enabling: "); for (final ControllerServiceEntity serviceEntity : servicesEntity.getControllerServices()) { if (ControllerServiceStates.STATE_ENABLING.equals(serviceEntity.getComponent().getState())) { println(); println("Service: " + serviceEntity.getId() + " - " + serviceEntity.getComponent().getName()); if (serviceEntity.getBulletins() != null) { println(); println("Reasons: "); for (final BulletinEntity bulletinEntity : serviceEntity.getBulletins()) { println("- " + bulletinEntity.getBulletin().getMessage()); } } } } }
/** * Merges the ControllerServiceEntity responses. * * @param clientEntity the entity being returned to the client * @param entityMap all node responses */ @Override public void mergeComponents(final ControllerServiceEntity clientEntity, final Map<NodeIdentifier, ControllerServiceEntity> entityMap) { final ControllerServiceDTO clientDto = clientEntity.getComponent(); final Map<NodeIdentifier, ControllerServiceDTO> dtoMap = new HashMap<>(); for (final Map.Entry<NodeIdentifier, ControllerServiceEntity> entry : entityMap.entrySet()) { final ControllerServiceEntity nodeControllerServiceEntity = entry.getValue(); final ControllerServiceDTO nodeControllerServiceDto = nodeControllerServiceEntity.getComponent(); dtoMap.put(entry.getKey(), nodeControllerServiceDto); } mergeDtos(clientDto, dtoMap); }
private void printServicesNotEnabled(final FlowClient flowClient, final String pgId) throws NiFiClientException, IOException { final ControllerServicesEntity servicesEntity = flowClient.getControllerServices(pgId); if (servicesEntity == null || servicesEntity.getControllerServices() == null) { return; } println(); println("The following services could not be enabled: "); for (final ControllerServiceEntity serviceEntity : servicesEntity.getControllerServices()) { if (!ControllerServiceStates.STATE_ENABLED.equals(serviceEntity.getComponent().getState())) { println(); println("Service: " + serviceEntity.getId() + " - " + serviceEntity.getComponent().getName()); final ControllerServiceDTO serviceDTO = serviceEntity.getComponent(); if (serviceDTO.getValidationErrors() != null) { println(); println("Validation Errors: "); for (final String validationError : serviceDTO.getValidationErrors()) { println("- " + validationError); } } } } }
) final ControllerServiceEntity requestControllerServiceEntity) { if (requestControllerServiceEntity == null || requestControllerServiceEntity.getComponent() == null) { throw new IllegalArgumentException("Controller service details must be specified."); if (requestControllerServiceEntity.getRevision() == null || (requestControllerServiceEntity.getRevision().getVersion() == null || requestControllerServiceEntity.getRevision().getVersion() != 0)) { throw new IllegalArgumentException("A revision of 0 must be specified when creating a new Controller service."); final ControllerServiceDTO requestControllerService = requestControllerServiceEntity.getComponent(); if (requestControllerService.getId() != null) { throw new IllegalArgumentException("Controller service ID cannot be specified."); return replicate(HttpMethod.POST, requestControllerServiceEntity); } else if (isDisconnectedFromCluster()) { verifyDisconnectedNodeModification(requestControllerServiceEntity.isDisconnectedNodeAcknowledged()); () -> serviceFacade.verifyCreateControllerService(requestControllerService), (controllerServiceEntity) -> { final ControllerServiceDTO controllerService = controllerServiceEntity.getComponent(); return generateCreatedResponse(URI.create(entity.getUri()), entity).build();
final ControllerServiceEntity requestControllerServiceEntity = new ControllerServiceEntity(); requestControllerServiceEntity.setId(id); (controllerServiceEntity) -> { serviceFacade.clearControllerServiceState(controllerServiceEntity.getId());
final ControllerServiceEntity controllerServiceEntity = new ControllerServiceEntity(); controllerServiceEntity.setRevision(revisionDto); controllerServiceEntity.setComponent(controllerServiceDto); controllerServiceDto.setId(id); controllerServiceDto.setAnnotationData(annotationData); entity = nodeResponse.getClientResponse().readEntity(ControllerServiceEntity.class); controllerService = entity.getComponent(); } else { final ControllerServiceDTO controllerServiceDto = new ControllerServiceDTO(); controllerService = entity.getComponent();
) final ControllerServiceEntity requestControllerServiceEntity) { if (requestControllerServiceEntity == null || requestControllerServiceEntity.getComponent() == null) { throw new IllegalArgumentException("Controller service details must be specified."); if (requestControllerServiceEntity.getRevision() == null) { throw new IllegalArgumentException("Revision must be specified."); final ControllerServiceDTO requestControllerServiceDTO = requestControllerServiceEntity.getComponent(); if (!id.equals(requestControllerServiceDTO.getId())) { throw new IllegalArgumentException(String.format("The controller service id (%s) in the request body does not equal the " return replicate(HttpMethod.PUT, requestControllerServiceEntity); } else if (isDisconnectedFromCluster()) { verifyDisconnectedNodeModification(requestControllerServiceEntity.isDisconnectedNodeAcknowledged()); () -> serviceFacade.verifyUpdateControllerService(requestControllerServiceDTO), (revision, controllerServiceEntity) -> { final ControllerServiceDTO controllerService = controllerServiceEntity.getComponent();
final ControllerServiceEntity targetEntity = serviceEntityById.get(serviceEntity.getId()); if (targetEntity != null) { PermissionsDtoMerger.mergePermissions(targetEntity.getPermissions(), serviceEntity.getPermissions());
/** * Merges multiple ControllerServiceEntity responses. * * @param controllerServiceEntities entities being returned to the client * @param entityMap all node responses */ public static void mergeControllerServices(final Set<ControllerServiceEntity> controllerServiceEntities, final Map<String, Map<NodeIdentifier, ControllerServiceEntity>> entityMap) { for (final ControllerServiceEntity entity : controllerServiceEntities) { controllerServiceEntityMerger.merge(entity, entityMap.get(entity.getId())); } } }
private void printServicesStillDisabling(final FlowClient flowClient, final String pgId) throws NiFiClientException, IOException { final ControllerServicesEntity servicesEntity = flowClient.getControllerServices(pgId); if (servicesEntity == null || servicesEntity.getControllerServices() == null) { return; } println(); println("One or more services appear to be stuck disabling: "); for (final ControllerServiceEntity serviceEntity : servicesEntity.getControllerServices()) { if (ControllerServiceStates.STATE_DISABLING.equals(serviceEntity.getComponent().getState())) { println(); println("Service: " + serviceEntity.getId() + " - " + serviceEntity.getComponent().getName()); if (serviceEntity.getBulletins() != null) { println(); println("Reasons: "); for (final BulletinEntity bulletinEntity : serviceEntity.getBulletins()) { println("- " + bulletinEntity.getBulletin().getMessage()); } } } } }
.map(entity -> entity.getComponent()) .filter(service -> affectedServices.containsKey(service.getId())) .map(service -> service.getState())
final Set<ControllerServiceDiagnosticsDTO> filteredReferencedServices = referencedServices.stream() .filter(csDiagnostics -> { final String csId = csDiagnostics.getControllerService().getId(); return authorizableLookup.getControllerService(csId).getAuthorizable().isAuthorized(authorizer, RequestAction.READ, user); }) .map(csDiagnostics -> { final ControllerServiceDTO serviceDto = csDiagnostics.getControllerService().getComponent(); if (serviceDto != null) { serviceDto.setReferencingComponents(null);
) final ControllerServiceEntity requestControllerServiceEntity) { if (requestControllerServiceEntity == null || requestControllerServiceEntity.getComponent() == null) { throw new IllegalArgumentException("Controller service details must be specified."); if (requestControllerServiceEntity.getRevision() == null || (requestControllerServiceEntity.getRevision().getVersion() == null || requestControllerServiceEntity.getRevision().getVersion() != 0)) { throw new IllegalArgumentException("A revision of 0 must be specified when creating a new Controller service."); final ControllerServiceDTO requestControllerService = requestControllerServiceEntity.getComponent(); if (requestControllerService.getId() != null) { throw new IllegalArgumentException("Controller service ID cannot be specified."); return replicate(HttpMethod.POST, requestControllerServiceEntity); } else if (isDisconnectedFromCluster()) { verifyDisconnectedNodeModification(requestControllerServiceEntity.isDisconnectedNodeAcknowledged()); () -> serviceFacade.verifyCreateControllerService(requestControllerService), controllerServiceEntity -> { final ControllerServiceDTO controllerService = controllerServiceEntity.getComponent(); return generateCreatedResponse(URI.create(entity.getUri()), entity).build();
final ControllerServiceEntity requestControllerServiceEntity = new ControllerServiceEntity(); requestControllerServiceEntity.setId(id); (revision, controllerServiceEntity) -> { final ControllerServiceEntity entity = serviceFacade.deleteControllerService(revision, controllerServiceEntity.getId()); return generateOkResponse(entity).build();
if (innerMap == null) { innerMap = new HashMap<>(); entityMap.put(nodeControllerServiceEntity.getId(), innerMap);
/** * Updates the affected controller services in the specified updateRequest with the serviceEntities. * * @param serviceEntities service entities * @param affectedServices all Controller Services whose state should be equal to the given desired state */ private void updateAffectedControllerServices(final Set<ControllerServiceEntity> serviceEntities, final Map<String, AffectedComponentEntity> affectedServices) { // update the affected components serviceEntities.stream() .filter(entity -> affectedServices.containsKey(entity.getId())) .forEach(entity -> { final AffectedComponentEntity affectedComponentEntity = affectedServices.get(entity.getId()); affectedComponentEntity.setRevision(entity.getRevision()); // only consider update this component if the user had permissions to it if (Boolean.TRUE.equals(affectedComponentEntity.getPermissions().getCanRead())) { final AffectedComponentDTO affectedComponent = affectedComponentEntity.getComponent(); affectedComponent.setState(entity.getComponent().getState()); if (Boolean.TRUE.equals(entity.getPermissions().getCanRead())) { affectedComponent.setValidationErrors(entity.getComponent().getValidationErrors()); } } }); }