Repository: nifi-registry Updated Branches: refs/heads/master e74846402 -> 312a179b6
NIFIREG-205: Allow Git repo to delete a flow with snapshot version 0 This closes #146. Signed-off-by: Bryan Bende <bbe...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/nifi-registry/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi-registry/commit/312a179b Tree: http://git-wip-us.apache.org/repos/asf/nifi-registry/tree/312a179b Diff: http://git-wip-us.apache.org/repos/asf/nifi-registry/diff/312a179b Branch: refs/heads/master Commit: 312a179b6780847fd9986b7b6515622103c2e933 Parents: e748464 Author: Koji Kawamura <ijokaruma...@gmail.com> Authored: Tue Nov 6 14:24:08 2018 +0900 Committer: Bryan Bende <bbe...@apache.org> Committed: Tue Nov 6 14:47:17 2018 -0500 ---------------------------------------------------------------------- .../provider/flow/git/GitFlowPersistenceProvider.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/312a179b/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowPersistenceProvider.java ---------------------------------------------------------------------- diff --git a/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowPersistenceProvider.java b/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowPersistenceProvider.java index f642632..e34c86f 100644 --- a/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowPersistenceProvider.java +++ b/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowPersistenceProvider.java @@ -188,7 +188,14 @@ public class GitFlowPersistenceProvider implements FlowPersistenceProvider { @Override public void deleteAllFlowContent(String bucketId, String flowId) throws FlowPersistenceException { final Bucket bucket = getBucketOrFail(bucketId); - final Flow flow = getFlowOrFail(bucket, flowId); + final Optional<Flow> flowOpt = bucket.getFlow(flowId); + if (!flowOpt.isPresent()) { + logger.debug(format("Tried deleting all versions, but the Flow ID %s was not found in bucket %s:%s.", + flowId, bucket.getBucketDirName(), bucket.getBucketId())); + return; + } + + final Flow flow = flowOpt.get(); final Optional<Integer> latestVersionOpt = flow.getLatestVersion(); if (!latestVersionOpt.isPresent()) { throw new IllegalStateException("Flow version is not added yet, can not be deleted.");