From 55e5e2959792c50fa8a259486f3493144264c778 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Tue, 10 Sep 2024 11:39:48 -0500 Subject: [PATCH] Fix handling of target list to account for possible omission --- .../dcache/pool/migration/MigrationModule.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/dcache/src/main/java/org/dcache/pool/migration/MigrationModule.java b/modules/dcache/src/main/java/org/dcache/pool/migration/MigrationModule.java index 327f7ba5118..18b52d46f4f 100644 --- a/modules/dcache/src/main/java/org/dcache/pool/migration/MigrationModule.java +++ b/modules/dcache/src/main/java/org/dcache/pool/migration/MigrationModule.java @@ -537,8 +537,12 @@ public class MigrationCopyCommand implements Callable { usage = "Enables the transfer of files from a disabled pool.") boolean forceSourceMode; - @Argument(metaVar = "target") - String[] targets; + @Argument(metaVar = "target", + required = false, + usage = "Required unless -target=pgroup is supplied, in which case we" + + "default to the unique pool group of which the source pool is a member," + + "if such exists.") + String[] targets = {}; @CommandLine String commandLine; @@ -804,8 +808,13 @@ public String call() throws IllegalArgumentException { Expression includeExpression = createPoolPredicate(includeWhen, TRUE_EXPRESSION); + List targets_list = asList(targets); + if (targets_list.isEmpty() && ! target.equals("pgroup")) { + throw new IllegalArgumentException("target(s) required when target type is " + target); + } + RefreshablePoolList poolList = - new PoolListFilter(createPoolList(target, asList(targets)), + new PoolListFilter(createPoolList(target, targets_list), excluded, excludeExpression, included, includeExpression, sourceList);