markap14 commented on code in PR #10770:
URL: https://github.com/apache/nifi/pull/10770#discussion_r2694558693
##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java:
##########
@@ -3720,6 +3720,36 @@ public ProcessGroupStatusEntity
getConnectorProcessGroupStatus(final String id,
return entityFactory.createProcessGroupStatusEntity(dto, permissions);
}
+ @Override
+ public Set<ControllerServiceEntity> getConnectorControllerServices(final
String connectorId, final String processGroupId,
+ final boolean includeAncestorGroups, final boolean
includeDescendantGroups, final boolean includeReferencingComponents) {
+ final ConnectorNode connectorNode =
connectorDAO.getConnector(connectorId);
+ final ProcessGroup managedProcessGroup =
connectorNode.getActiveFlowContext().getManagedProcessGroup();
+ final ProcessGroup targetProcessGroup =
managedProcessGroup.findProcessGroup(processGroupId);
+ if (targetProcessGroup == null) {
+ throw new ResourceNotFoundException("Process Group with ID " +
processGroupId + " was not found within Connector " + connectorId);
+ }
+
+ final Set<ControllerServiceNode> serviceNodes = new HashSet<>();
+ serviceNodes.addAll(targetProcessGroup.getControllerServices(false));
+
+ if (includeDescendantGroups) {
+
serviceNodes.addAll(targetProcessGroup.findAllControllerServices());
+ }
+
+ if (includeAncestorGroups) {
+ ProcessGroup parent = targetProcessGroup.getParent();
+ while (parent != null &&
!parent.getIdentifier().equals(managedProcessGroup.getParent().getIdentifier()))
{
+ serviceNodes.addAll(parent.getControllerServices(false));
+ parent = parent.getParent();
+ }
+ }
Review Comment:
This works but it's a bit complicated. I think we can simplify it with
something like:
```
final Set<ControllerServiceNode> serviceNodes = new HashSet<>();
serviceNodes.addAll(targetProcessGroup.getControllerServices(includeAncestorGroups));
if (includeDescendantGroups) {
serviceNodes.addAll(targetProcessGroup.findAllControllerServices());
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]