use of org.apache.nifi.web.api.dto.PortDTO in project nifi by apache.
the class StandardNiFiServiceFacade method validateSnippetContents.
private void validateSnippetContents(final FlowSnippetDTO flow) {
// validate any processors
if (flow.getProcessors() != null) {
for (final ProcessorDTO processorDTO : flow.getProcessors()) {
final ProcessorNode processorNode = processorDAO.getProcessor(processorDTO.getId());
final Collection<ValidationResult> validationErrors = processorNode.getValidationErrors();
if (validationErrors != null && !validationErrors.isEmpty()) {
final List<String> errors = new ArrayList<>();
for (final ValidationResult validationResult : validationErrors) {
errors.add(validationResult.toString());
}
processorDTO.setValidationErrors(errors);
}
}
}
if (flow.getInputPorts() != null) {
for (final PortDTO portDTO : flow.getInputPorts()) {
final Port port = inputPortDAO.getPort(portDTO.getId());
final Collection<ValidationResult> validationErrors = port.getValidationErrors();
if (validationErrors != null && !validationErrors.isEmpty()) {
final List<String> errors = new ArrayList<>();
for (final ValidationResult validationResult : validationErrors) {
errors.add(validationResult.toString());
}
portDTO.setValidationErrors(errors);
}
}
}
if (flow.getOutputPorts() != null) {
for (final PortDTO portDTO : flow.getOutputPorts()) {
final Port port = outputPortDAO.getPort(portDTO.getId());
final Collection<ValidationResult> validationErrors = port.getValidationErrors();
if (validationErrors != null && !validationErrors.isEmpty()) {
final List<String> errors = new ArrayList<>();
for (final ValidationResult validationResult : validationErrors) {
errors.add(validationResult.toString());
}
portDTO.setValidationErrors(errors);
}
}
}
// get any remote process group issues
if (flow.getRemoteProcessGroups() != null) {
for (final RemoteProcessGroupDTO remoteProcessGroupDTO : flow.getRemoteProcessGroups()) {
final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupDTO.getId());
if (remoteProcessGroup.getAuthorizationIssue() != null) {
remoteProcessGroupDTO.setAuthorizationIssues(Arrays.asList(remoteProcessGroup.getAuthorizationIssue()));
}
}
}
}
use of org.apache.nifi.web.api.dto.PortDTO in project nifi by apache.
the class StandardNiFiServiceFacade method deleteInputPort.
@Override
public PortEntity deleteInputPort(final Revision revision, final String inputPortId) {
final Port port = inputPortDAO.getPort(inputPortId);
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(port);
final PortDTO snapshot = deleteComponent(revision, port.getResource(), () -> inputPortDAO.deletePort(inputPortId), true, dtoFactory.createPortDto(port));
return entityFactory.createPortEntity(snapshot, null, permissions, null, null);
}
use of org.apache.nifi.web.api.dto.PortDTO in project nifi by apache.
the class StandardNiFiServiceFacade method createOutputPort.
@Override
public PortEntity createOutputPort(final Revision revision, final String groupId, final PortDTO outputPortDTO) {
final RevisionUpdate<PortDTO> snapshot = createComponent(revision, outputPortDTO, () -> outputPortDAO.createPort(groupId, outputPortDTO), port -> dtoFactory.createPortDto(port));
final Port port = outputPortDAO.getPort(outputPortDTO.getId());
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(port);
final PortStatusDTO status = dtoFactory.createPortStatusDto(controllerFacade.getOutputPortStatus(port.getIdentifier()));
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(port.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
return entityFactory.createPortEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
}
use of org.apache.nifi.web.api.dto.PortDTO in project nifi by apache.
the class StandardNiFiServiceFacade method createInputPort.
@Override
public PortEntity createInputPort(final Revision revision, final String groupId, final PortDTO inputPortDTO) {
final RevisionUpdate<PortDTO> snapshot = createComponent(revision, inputPortDTO, () -> inputPortDAO.createPort(groupId, inputPortDTO), port -> dtoFactory.createPortDto(port));
final Port port = inputPortDAO.getPort(inputPortDTO.getId());
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(port);
final PortStatusDTO status = dtoFactory.createPortStatusDto(controllerFacade.getInputPortStatus(port.getIdentifier()));
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(port.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
return entityFactory.createPortEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
}
use of org.apache.nifi.web.api.dto.PortDTO in project nifi by apache.
the class StandardNiFiServiceFacade method deleteOutputPort.
@Override
public PortEntity deleteOutputPort(final Revision revision, final String outputPortId) {
final Port port = outputPortDAO.getPort(outputPortId);
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(port);
final PortDTO snapshot = deleteComponent(revision, port.getResource(), () -> outputPortDAO.deletePort(outputPortId), true, dtoFactory.createPortDto(port));
return entityFactory.createPortEntity(snapshot, null, permissions, null, null);
}
Aggregations