diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java index 406729cb4ef2..973dae7164ab 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java @@ -2438,31 +2438,34 @@ ControllerServiceReferencingComponentsEntity updateControllerServiceReferencingC * Gets the flows for the current user for the specified registry and bucket. * * @param registryClientId registry client id + * @param branch the branch * @param bucketId bucket id * @return the flows */ - Set getFlowsForUser(String registryClientId, String bucketId); + Set getFlowsForUser(String registryClientId, String branch, String bucketId); /** * Returns the details of a versioned flow from a given bucket of a given registry. * * @param registryClientId registry client id + * @param branch the branch * @param bucketId bucket id * @param flowId flow id * @return the flow details */ - VersionedFlowEntity getFlowForUser(String registryClientId, String bucketId, String flowId); + VersionedFlowEntity getFlowForUser(String registryClientId, String branch, String bucketId, String flowId); /** * Gets the versions of the specified registry, bucket, and flow for the current user. * * @param registryClientId registry client id + * @param branch the branch * @param bucketId bucket id * @param flowId flow id * @return the versions of the flow */ - Set getFlowVersionsForUser(String registryClientId, String bucketId, String flowId); + Set getFlowVersionsForUser(String registryClientId, String branch, String bucketId, String flowId); /** * Updates the specified registry using the specified revision. diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java index c51b2de66057..66461519cbef 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java @@ -3272,27 +3272,24 @@ public Set getBucketsForUser(final String registryClie } @Override - public Set getFlowsForUser(final String registryClientId, final String bucketId) { + public Set getFlowsForUser(final String registryClientId, final String branch, final String bucketId) { final FlowRegistryClientUserContext clientUserContext = FlowRegistryClientContextFactory.getContextForUser(NiFiUserUtils.getNiFiUser()); - final FlowRegistryBranch defaultBranch = flowRegistryDAO.getDefaultBranchForUser(clientUserContext, registryClientId); - return flowRegistryDAO.getFlowsForUser(clientUserContext, registryClientId, defaultBranch.getName(), bucketId).stream() + return flowRegistryDAO.getFlowsForUser(clientUserContext, registryClientId, branch, bucketId).stream() .map(rf -> createVersionedFlowEntity(registryClientId, rf)) .collect(Collectors.toSet()); } @Override - public VersionedFlowEntity getFlowForUser(final String registryClientId, final String bucketId, final String flowId) { + public VersionedFlowEntity getFlowForUser(final String registryClientId, final String branch, final String bucketId, final String flowId) { final FlowRegistryClientUserContext clientUserContext = FlowRegistryClientContextFactory.getContextForUser(NiFiUserUtils.getNiFiUser()); - final FlowRegistryBranch defaultBranch = flowRegistryDAO.getDefaultBranchForUser(clientUserContext, registryClientId); - final RegisteredFlow flow = flowRegistryDAO.getFlowForUser(clientUserContext, registryClientId, defaultBranch.getName(), bucketId, flowId); + final RegisteredFlow flow = flowRegistryDAO.getFlowForUser(clientUserContext, registryClientId, branch, bucketId, flowId); return createVersionedFlowEntity(registryClientId, flow); } @Override - public Set getFlowVersionsForUser(final String registryClientId, final String bucketId, final String flowId) { + public Set getFlowVersionsForUser(final String registryClientId, final String branch, final String bucketId, final String flowId) { final FlowRegistryClientUserContext clientUserContext = FlowRegistryClientContextFactory.getContextForUser(NiFiUserUtils.getNiFiUser()); - final FlowRegistryBranch defaultBranch = flowRegistryDAO.getDefaultBranchForUser(clientUserContext, registryClientId); - return flowRegistryDAO.getFlowVersionsForUser(clientUserContext, registryClientId, defaultBranch.getName(), bucketId, flowId).stream() + return flowRegistryDAO.getFlowVersionsForUser(clientUserContext, registryClientId, branch, bucketId, flowId).stream() .map(md -> createVersionedFlowSnapshotMetadataEntity(registryClientId, md)) .collect(Collectors.toCollection(LinkedHashSet::new)); } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java index 2808e06eb2d5..4e77dc865324 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java @@ -1940,7 +1940,7 @@ public Response getBuckets( @Parameter( description = "The name of a branch to get the buckets from. If not specified the default branch of the registry client will be used." ) - @QueryParam("branch") String branch) throws NiFiRegistryException { + @QueryParam("branch") String branch) { authorizeFlow(); @@ -1995,11 +1995,16 @@ public Response getFlows( description = "The bucket id.", required = true ) - @PathParam("bucket-id") String bucketId) { + @PathParam("bucket-id") String bucketId, + @Parameter( + description = "The name of a branch to get the flows from. If not specified the default branch of the registry client will be used." + ) + @QueryParam("branch") String branch) { authorizeFlow(); - final Set registeredFlows = serviceFacade.getFlowsForUser(registryId, bucketId); + final String selectedBranch = branch == null ? serviceFacade.getDefaultBranch(registryId).getBranch().getName() : branch; + final Set registeredFlows = serviceFacade.getFlowsForUser(registryId, selectedBranch, bucketId); final SortedSet sortedFlows = sortFlows(registeredFlows); final VersionedFlowsEntity versionedFlowsEntity = new VersionedFlowsEntity(); @@ -2054,11 +2059,16 @@ public Response getDetails( description = "The flow id.", required = true ) - @PathParam("flow-id") String flowId) { + @PathParam("flow-id") String flowId, + @Parameter( + description = "The name of a branch to get the flow from. If not specified the default branch of the registry client will be used." + ) + @QueryParam("branch") String branch) { authorizeFlow(); - final VersionedFlowEntity flowDetails = serviceFacade.getFlowForUser(registryId, bucketId, flowId); + final String selectedBranch = branch == null ? serviceFacade.getDefaultBranch(registryId).getBranch().getName() : branch; + final VersionedFlowEntity flowDetails = serviceFacade.getFlowForUser(registryId, selectedBranch, bucketId, flowId); return generateOkResponse(flowDetails).build(); } @@ -2191,11 +2201,16 @@ public Response getVersions( description = "The flow id.", required = true ) - @PathParam("flow-id") String flowId) { + @PathParam("flow-id") String flowId, + @Parameter( + description = "The name of a branch to get the flow versions from. If not specified the default branch of the registry client will be used." + ) + @QueryParam("branch") String branch) { authorizeFlow(); - final Set registeredFlowSnapshotMetadataSet = serviceFacade.getFlowVersionsForUser(registryId, bucketId, flowId); + final String selectedBranch = branch == null ? serviceFacade.getDefaultBranch(registryId).getBranch().getName() : branch; + final Set registeredFlowSnapshotMetadataSet = serviceFacade.getFlowVersionsForUser(registryId, selectedBranch, bucketId, flowId); final VersionedFlowSnapshotMetadataSetEntity versionedFlowSnapshotMetadataSetEntity = new VersionedFlowSnapshotMetadataSetEntity(); versionedFlowSnapshotMetadataSetEntity.setVersionedFlowSnapshotMetadataSet(registeredFlowSnapshotMetadataSet);