use of org.apache.nifi.web.api.entity.ControllerServiceEntity in project nifi by apache.
the class EntityFactory method createControllerServiceEntity.
public ControllerServiceEntity createControllerServiceEntity(final ControllerServiceDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final List<BulletinEntity> bulletins) {
final ControllerServiceEntity entity = new ControllerServiceEntity();
entity.setRevision(revision);
if (dto != null) {
entity.setPermissions(permissions);
entity.setId(dto.getId());
entity.setPosition(dto.getPosition());
if (permissions != null && permissions.getCanRead()) {
entity.setComponent(dto);
entity.setBulletins(bulletins);
}
}
return entity;
}
use of org.apache.nifi.web.api.entity.ControllerServiceEntity in project nifi by apache.
the class LocalComponentLifecycle method updateAffectedControllerServices.
/**
* 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());
}
}
});
}
use of org.apache.nifi.web.api.entity.ControllerServiceEntity in project nifi by apache.
the class ControllerServicesEndpointMerger method merge.
@Override
public final NodeResponse merge(final URI uri, final String method, final Set<NodeResponse> successfulResponses, final Set<NodeResponse> problematicResponses, final NodeResponse clientResponse) {
if (!canHandle(uri, method)) {
throw new IllegalArgumentException("Cannot use Endpoint Mapper of type " + getClass().getSimpleName() + " to map responses for URI " + uri + ", HTTP Method " + method);
}
final ControllerServicesEntity responseEntity = clientResponse.getClientResponse().readEntity(ControllerServicesEntity.class);
final Set<ControllerServiceEntity> controllerServiceEntities = responseEntity.getControllerServices();
final Map<String, Map<NodeIdentifier, ControllerServiceEntity>> entityMap = new HashMap<>();
for (final NodeResponse nodeResponse : successfulResponses) {
final ControllerServicesEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().readEntity(ControllerServicesEntity.class);
final Set<ControllerServiceEntity> nodeControllerServiceEntities = nodeResponseEntity.getControllerServices();
for (final ControllerServiceEntity nodeControllerServiceEntity : nodeControllerServiceEntities) {
final NodeIdentifier nodeId = nodeResponse.getNodeId();
Map<NodeIdentifier, ControllerServiceEntity> innerMap = entityMap.get(nodeId);
if (innerMap == null) {
innerMap = new HashMap<>();
entityMap.put(nodeControllerServiceEntity.getId(), innerMap);
}
innerMap.put(nodeResponse.getNodeId(), nodeControllerServiceEntity);
}
}
ControllerServicesEntityMerger.mergeControllerServices(controllerServiceEntities, entityMap);
// create a new client response
return new NodeResponse(clientResponse, responseEntity);
}
use of org.apache.nifi.web.api.entity.ControllerServiceEntity in project kylo by Teradata.
the class NiFiProcessGroupsRestClientV1 method createControllerService.
@Nonnull
@Override
public ControllerServiceDTO createControllerService(@Nonnull final String processGroupId, @Nonnull final ControllerServiceDTO controllerService) {
final ControllerServiceEntity entity = new ControllerServiceEntity();
entity.setComponent(controllerService);
final RevisionDTO revision = new RevisionDTO();
revision.setVersion(0L);
entity.setRevision(revision);
try {
return client.post(BASE_PATH + processGroupId + "/controller-services", entity, ControllerServiceEntity.class).getComponent();
} catch (final NotFoundException e) {
throw new NifiComponentNotFoundException(processGroupId, NifiConstants.NIFI_COMPONENT_TYPE.PROCESS_GROUP, e);
}
}
use of org.apache.nifi.web.api.entity.ControllerServiceEntity in project kylo by Teradata.
the class NiFiReportingTaskRestClientV1 method createReportingTaskControllerService.
@Override
public ControllerServiceDTO createReportingTaskControllerService(@Nonnull ControllerServiceDTO controllerService) {
ControllerServiceEntity entity = new ControllerServiceEntity();
entity.setComponent(controllerService);
final RevisionDTO revision = new RevisionDTO();
revision.setVersion(0L);
entity.setRevision(revision);
ControllerServiceEntity updatedService = client.post(CREATE_CONTROLLER_SERVICE_PATH, entity, ControllerServiceEntity.class);
if (updatedService != null) {
return updatedService.getComponent();
} else {
return null;
}
}
Aggregations