NIFI-10874 Fixed issue with multiple levels of versioned flows

This closes #6719

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Bence Simon 2022-11-24 21:41:50 +01:00 committed by exceptionfactory
parent 198a27abbe
commit df21478297
No known key found for this signature in database
GPG Key ID: 29B6A52D2AAE8DBA
2 changed files with 11 additions and 2 deletions

View File

@ -51,6 +51,7 @@ import org.apache.nifi.connectable.ConnectableType;
import org.apache.nifi.controller.ScheduledState;
import org.apache.nifi.controller.serialization.FlowEncodingVersion;
import org.apache.nifi.controller.service.ControllerServiceState;
import org.apache.nifi.flow.VersionedFlowCoordinates;
import org.apache.nifi.flow.VersionedParameterContext;
import org.apache.nifi.flow.VersionedProcessGroup;
import org.apache.nifi.parameter.ParameterContext;
@ -2013,7 +2014,13 @@ public class ProcessGroupResource extends FlowUpdateResource<ProcessGroupImportE
// Step 2: Retrieve flow from Flow Registry
final RegisteredFlowSnapshot flowSnapshot = getFlowFromRegistry(versionControlInfo);
// Step 3: Resolve Bundle info
// Step 3: Enrich version control info came from UI
if (flowSnapshot.getFlowContents() != null && flowSnapshot.getFlowContents().getVersionedFlowCoordinates() != null) {
final VersionedFlowCoordinates versionedFlowCoordinates = flowSnapshot.getFlowContents().getVersionedFlowCoordinates();
flowSnapshot.getFlowContents().getVersionedFlowCoordinates().setStorageLocation(versionedFlowCoordinates.getStorageLocation());
}
// Step 4: Resolve Bundle info
serviceFacade.discoverCompatibleBundles(flowSnapshot.getFlowContents());
// If there are any Controller Services referenced that are inherited from the parent group, resolve those to point to the appropriate Controller Service, if we are able to.
@ -2022,7 +2029,7 @@ public class ProcessGroupResource extends FlowUpdateResource<ProcessGroupImportE
// If there are any Parameter Providers referenced by Parameter Contexts, resolve these to point to the appropriate Parameter Provider, if we are able to.
serviceFacade.resolveParameterProviders(flowSnapshot, NiFiUserUtils.getNiFiUser());
// Step 4: Update contents of the ProcessGroupDTO passed in to include the components that need to be added.
// Step 5: Update contents of the ProcessGroupDTO passed in to include the components that need to be added.
requestProcessGroupEntity.setVersionedFlowSnapshot(flowSnapshot);
}

View File

@ -2810,6 +2810,7 @@ public final class DtoFactory {
dto.setFlowName(versionControlInfo.getFlowName());
dto.setFlowDescription(versionControlInfo.getFlowDescription());
dto.setVersion(versionControlInfo.getVersion());
dto.setStorageLocation(versionControlInfo.getStorageLocation());
final VersionedFlowStatus status = versionControlInfo.getStatus();
final VersionedFlowState state = status.getState();
@ -4594,6 +4595,7 @@ public final class DtoFactory {
copy.setVersion(original.getVersion());
copy.setState(original.getState());
copy.setStateExplanation(original.getStateExplanation());
copy.setStorageLocation(original.getStorageLocation());
return copy;
}