From 2fe362de9d7ede0c132b05b0c8e1b28535db186c Mon Sep 17 00:00:00 2001 From: Wilson Liu <wliu5@unimelb.edu.au> Date: Tue, 12 Jan 2021 00:11:12 +1100 Subject: [PATCH] removed --mf.auth and --mf.token arguments. --- docs/unimelb-mf-check.md | 10 ++- docs/unimelb-mf-download.md | 19 ++++-- docs/unimelb-mf-upload.md | 65 +++++++++++++++--- pom.xml | 2 +- .../unimelb/mf/client/sync/cli/MFCheck.java | 66 +++++++++++-------- .../mf/client/sync/cli/MFDownload.java | 61 +++++++++-------- .../unimelb/mf/client/sync/cli/MFUpload.java | 37 +++++++---- 7 files changed, 173 insertions(+), 87 deletions(-) diff --git a/docs/unimelb-mf-check.md b/docs/unimelb-mf-check.md index 548dff2..38a3c7c 100644 --- a/docs/unimelb-mf-check.md +++ b/docs/unimelb-mf-check.md @@ -1,6 +1,6 @@ ``` USAGE: - unimelb-mf-check [OPTIONS] --direction <up|down|both> --output <output.csv> <dir1> <namespace1> [<dir2> <namespace2>...] + unimelb-mf-check [OPTIONS] --direction <up|down> --output <output.csv> <dir1> <namespace1> [<dir2> <namespace2>...] DESCRIPTION: Compare files in local directory with assets in remote Mediaflux asset namespace and generates a list of the differences. @@ -10,15 +10,13 @@ OPTIONS: --mf.host <host> Mediaflux server host. --mf.port <port> Mediaflux server port. --mf.transport <https|http|tcp/ip> Mediaflux server transport, can be http, https or tcp/ip. - --mf.auth <domain,user,password> Mediaflux user credentials. - --mf.token <token> Mediaflux secure identity token. --direction <up|down> Direction: up/down. -o, --output <output.csv> Output CSV file. --detailed-output Include all files checked. Otherwise, only the missing or invalid files are included in the output. - --compress-output Compress the output CSV file to GZIP format(.csv.gz). + --compress-output Compress output CSV file to GZIP format(.csv.gz). --no-csum-check Files are equated if the name, size and CRC32 checksum are the same. With this argument, you can exclude the CRC32 checksum comparison. - --nb-queriers <n> Number of query threads. Defaults to 1. Maximum is 4. - --nb-workers <n> Number of concurrent worker threads to read local file (to generate checksum) if needed. Defaults to 1. Maximum is 8. + --nb-queriers <n> Number of query threads. Defaults to 1. Maximum is 4 + --nb-workers <n> Number of concurrent worker threads to read local file (to generate checksum) if needed. Defaults to 1. Maximum is 8 --nb-retries <n> Retry times when error occurs. Defaults to 0 --batch-size <size> Size of the query result. Defaults to 1000 --follow-symlinks Follow symbolic links. diff --git a/docs/unimelb-mf-download.md b/docs/unimelb-mf-download.md index 2fba5bf..8042945 100644 --- a/docs/unimelb-mf-download.md +++ b/docs/unimelb-mf-download.md @@ -1,30 +1,35 @@ ``` USAGE: - unimelb-mf-download [OPTIONS] --out <dst-dir> <namespace1> [<namespace2>...] + unimelb-mf-download [OPTIONS] --out <dst-dir> <src-asset-or-namespace-path> [<src-asset-or-namespace-path>...] + unimelb-mf-download --config <mf-download-config.xml> DESCRIPTION: Download assets (files) from Mediaflux to the local file system. Pre-existing files in the local file system can be skipped or overwritten. In Daemon mode, the process will only download new assets (files) since the process last executed. OPTIONS: + --config <config.xml> A single configuration file including all required settings (Mediaflux server details, user credentials, application settings). If conflicts with all the other options. + --mf.config <mflux.cfg> Path to the config file that contains Mediaflux server details and user credentials. --mf.host <host> Mediaflux server host. --mf.port <port> Mediaflux server port. --mf.transport <https|http|tcp/ip> Mediaflux server transport, can be http, https or tcp/ip. - --mf.auth <domain,user,password> Mediaflux user credentials. - --mf.token <token> Mediaflux secure identity token. + --no-cluster-io Disable cluster I/O if applicable. -o, --out <dst-dir> The output/destination directory. --overwrite Overwrite if the dst file exists. --unarchive Extract Arcitecta .aar files. --csum-check Files are equated if the name and size are the same. In addition, with this argument, you can optionally compute the CRC32 checksumk to decide if two files are the same. --no-symlinks Do not restore symbolic links. If not specified, it will try to create (restore) symbolic links. Note: creating symbolic links works only the platforms that support symbolic links, such as Linux or MacOS. - --nb-queriers <n> Number of query threads. Defaults to 1. Maximum is 4. - --nb-workers <n> Number of concurrent worker threads to download data. Defaults to 1. Maximum is 8. + --nb-queriers <n> Number of query threads. Defaults to 1. Maximum is 4 + --nb-workers <n> Number of concurrent worker threads to download data. Defaults to 1. Maximum is 8 --nb-retries <n> Retry times when error occurs. Defaults to 0 --batch-size <size> Size of the query result. Defaults to 1000 --daemon Run as a daemon. --daemon-port <port> Daemon listener port if running as a daemon. Defaults to 9761 --daemon-scan-interval <seconds> Time interval (in seconds) between scans of source asset namespaces. Defaults to 60 seconds. + --exclude-parent Exclude parent directory at the destination (Download the contents of the directory) if the source path ends with trailing slash. --log-dir <dir> Path to the directory for log files. No logging if not specified. + --log-file-size-mb <n> Log file size limit in MB. Defaults to 100MB + --log-file-count <n> Log file count. Defaults to 2 --notify <email-addresses> When completes, send email notification to the recipients(comma-separated email addresses if multiple). Not applicable for daemon mode. --sync-delete-files Delete local files that do not have corresponding assets exist on the server side. --quiet Do not print progress messages. @@ -32,8 +37,10 @@ OPTIONS: --version Prints version. POSITIONAL ARGUMENTS: - <namespace> The asset namespace to download. + <src-asset-or-namespace-path> The source asset path or asset namespace path. EXAMPLES: unimelb-mf-download --mf.config ~/.Arcitecta/mflux.cfg --nb-workers 2 --out ~/Downloads /projects/proj-1128.1.59/foo /projects/proj-1128.1.59/bar + unimelb-mf-download --mf.config ~/.Arcitecta/mflux.cfg --nb-workers 2 --out ~/Downloads /projects/proj-1128.1.15/sample.zip + unimelb-mf-download --config ~/.Arcitecta/mf-download-config.xml ``` diff --git a/docs/unimelb-mf-upload.md b/docs/unimelb-mf-upload.md index 31d2384..375cf96 100644 --- a/docs/unimelb-mf-upload.md +++ b/docs/unimelb-mf-upload.md @@ -1,5 +1,4 @@ ``` - USAGE: unimelb-mf-upload [OPTIONS] --namespace <dst-namespace> [src-dir1 [src-dir2...]] [src-file1 [src-file2...]] unimelb-mf-upload --config <mf-upload-config.xml> @@ -8,39 +7,89 @@ DESCRIPTION: Upload local files to Mediaflux. If the file pre-exists in Mediaflux and is the same as that being uploaded, the Mediaflux asset is not modified. However, if the files differ, a new version of the asset will be created. In Daemon mode, the process will only upload new files since the process last executed. OPTIONS: - --config <config.xml> A single configuration file including all required settings (Mediaflux server details, user credentials, application settings). If conflicts with all the other options. + --config <config.xml> A single configuration file including all required settings (Mediaflux server details, user credentials, application settings). If supplied, all other configuration options are ignored. --mf.config <mflux.cfg> Path to the config file that contains Mediaflux server details and user credentials. --mf.host <host> Mediaflux server host. --mf.port <port> Mediaflux server port. --mf.transport <https|http|tcp/ip> Mediaflux server transport, can be http, https or tcp/ip. - --mf.auth <domain,user,password> Mediaflux user credentials. - --mf.token <token> Mediaflux secure identity token. + --no-cluster-io Disable cluster I/O if applicable. --namespace <dst-namespace> The destination asset namespace in Mediaflux. --csum-check If enabled, computes the checksum from the uploaded file and compares with that computed by the server for the Mediaflux asset. - --follow-symlinks Follow symbolic links. If not specified, it will not follow symbolic links, instead, it will create special symbolic link assets in Mediaflux. When exported as NFS share these symoblic assets will be represented as symbolic links. If downloaded using the unimelb-mf-download tool on Linux/MacOS platforms, they can be restored as symbolic links. - --nb-queriers <n> Number of query threads. Defaults to 1. Maximum is 4. - --nb-workers <n> Number of concurrent worker threads to upload data. Defaults to 1. Maximum is 8. + --nb-queriers <n> Number of query threads. Defaults to 1. Maximum is 4 + --nb-workers <n> Number of concurrent worker threads to upload data. Defaults to 1. Maximum is 8 --nb-retries <n> Retry times when error occurs. Defaults to 0 --batch-size <size> Size of the query result. Defaults to 1000 --daemon Run as a daemon. --daemon-port <port> Daemon listener port if running as a daemon. Defaults to 9761 --daemon-scan-interval <seconds> Time interval (in seconds) between scans of source directories. Defaults to 60 seconds. + --exclude-parent Exclude parent directory at the destination (Upload the contents of the directory) if the source path ends with trailing slash. --log-dir <dir> Path to the directory for log files. No logging if not specified. + --log-file-size-mb <n> Log file size limit in MB. Defaults to 100MB + --log-file-count <n> Log file count. Defaults to 2 --notify <email-addresses> When completes, send email notification to the recipients(comma-separated email addresses if multiple). Not applicable for daemon mode. --sync-delete-assets Delete assets that do not have corresponding local files exist. --hard-delete-assets Force the asset deletion (see --sync-delete-assets) process to hard delete assets. Otherwise, the behaviour is controlled by server properties (whether a deletion is a soft or hard action). + --follow-symlinks Follow symbolic links. If not specified, it will not follow symbolic links, instead, it will create special symbolic link assets in Mediaflux. When exported as NFS share these symoblic assets will be represented as symbolic links. If downloaded using the unimelb-mf-download tool on Linux/MacOS platforms, they can be restored as symbolic links. --quiet Do not print progress messages. --help Prints usage. --version Prints version. POSITIONAL ARGUMENTS: - <src-dir> Source directory to upload. + src-dir Source directory to upload. + src-file Source file to upload. EXAMPLES: unimelb-mf-upload --mf.config ~/.Arcitecta/mflux.cfg --nb-workers 4 --namespace /projects/proj-1128.1.59 ~/Documents/foo ~/Documents/bar unimelb-mf-upload --config ~/.Arcitecta/mf-upload-config.xml +wliu5@9870L-150298-M unix % clear +wliu5@9870L-150298-M unix % ./unimelb-mf-upload + +Invalid arguments: Missing arguments. + + +USAGE: + unimelb-mf-upload [OPTIONS] --namespace <dst-namespace> [src-dir1 [src-dir2...]] [src-file1 [src-file2...]] + unimelb-mf-upload --config <mf-upload-config.xml> + +DESCRIPTION: + Upload local files to Mediaflux. If the file pre-exists in Mediaflux and is the same as that being uploaded, the Mediaflux asset is not modified. However, if the files differ, a new version of the asset will be created. In Daemon mode, the process will only upload new files since the process last executed. +OPTIONS: + --config <config.xml> A single configuration file including all required settings (Mediaflux server details, user credentials, application settings). If supplied, all other configuration options are ignored. + --mf.config <mflux.cfg> Path to the config file that contains Mediaflux server details and user credentials. + --mf.host <host> Mediaflux server host. + --mf.port <port> Mediaflux server port. + --mf.transport <https|http|tcp/ip> Mediaflux server transport, can be http, https or tcp/ip. + --no-cluster-io Disable cluster I/O if applicable. + --namespace <dst-namespace> The destination asset namespace in Mediaflux. + --csum-check If enabled, computes the checksum from the uploaded file and compares with that computed by the server for the Mediaflux asset. + --nb-queriers <n> Number of query threads. Defaults to 1. Maximum is 4 + --nb-workers <n> Number of concurrent worker threads to upload data. Defaults to 1. Maximum is 8 + --nb-retries <n> Retry times when error occurs. Defaults to 0 + --batch-size <size> Size of the query result. Defaults to 1000 + --daemon Run as a daemon. + --daemon-port <port> Daemon listener port if running as a daemon. Defaults to 9761 + --daemon-scan-interval <seconds> Time interval (in seconds) between scans of source directories. Defaults to 60 seconds. + --exclude-parent Exclude parent directory at the destination (Upload the contents of the directory) if the source path ends with trailing slash. + --log-dir <dir> Path to the directory for log files. No logging if not specified. + --log-file-size-mb <n> Log file size limit in MB. Defaults to 100MB + --log-file-count <n> Log file count. Defaults to 2 + --notify <email-addresses> When completes, send email notification to the recipients(comma-separated email addresses if multiple). Not applicable for daemon mode. + --sync-delete-assets Delete assets that do not have corresponding local files exist. + --hard-delete-assets Force the asset deletion (see --sync-delete-assets) process to hard delete assets. Otherwise, the behaviour is controlled by server properties (whether a deletion is a soft or hard action). + --follow-symlinks Follow symbolic links. If not specified, it will not follow symbolic links, instead, it will create special symbolic link assets in Mediaflux. When exported as NFS share these symoblic assets will be represented as symbolic links. If downloaded using the unimelb-mf-download tool on Linux/MacOS platforms, they can be restored as symbolic links. + --quiet Do not print progress messages. + --help Prints usage. + --version Prints version. + +POSITIONAL ARGUMENTS: + src-dir Source directory to upload. + src-file Source file to upload. + +EXAMPLES: + unimelb-mf-upload --mf.config ~/.Arcitecta/mflux.cfg --nb-workers 4 --namespace /projects/proj-1128.1.59 ~/Documents/foo ~/Documents/bar + unimelb-mf-upload --config ~/.Arcitecta/mf-upload-config.xml ``` diff --git a/pom.xml b/pom.xml index 6552e06..749f41e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ <groupId>au.edu.unimelb.mf</groupId> <artifactId>unimelb-mf-clients</artifactId> - <version>0.5.6</version> + <version>0.5.7</version> <packaging>jar</packaging> <name>unimelb-mf-clients</name> <url>https://gitlab.unimelb.edu.au/resplat-mediaflux/unimelb-mf-clients</url> diff --git a/src/main/java/unimelb/mf/client/sync/cli/MFCheck.java b/src/main/java/unimelb/mf/client/sync/cli/MFCheck.java index cbc1ad0..8b3ebaf 100644 --- a/src/main/java/unimelb/mf/client/sync/cli/MFCheck.java +++ b/src/main/java/unimelb/mf/client/sync/cli/MFCheck.java @@ -11,6 +11,7 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import unimelb.mf.client.session.MFConfig; import unimelb.mf.client.session.MFConfigBuilder; import unimelb.mf.client.session.MFSession; import unimelb.mf.client.sync.MFSyncApp; @@ -27,7 +28,7 @@ public class MFCheck extends MFSyncApp { public static final String PROG = "unimelb-mf-check"; private MFConfigBuilder _mfconfig; - private Map<Path, String> _dirNamespaces; + private final Map<Path, String> _dirNamespaces; private Action.Direction _direction; private Path _outputFile; private boolean _detailedOutput = false; @@ -39,7 +40,7 @@ public class MFCheck extends MFSyncApp { settings().setCsumCheck(true); settings().setVerbose(true); - _dirNamespaces = new LinkedHashMap<Path, String>(); + _dirNamespaces = new LinkedHashMap<>(); } @@ -56,9 +57,9 @@ public class MFCheck extends MFSyncApp { // @formatter:off System.out.println(); System.out.println("USAGE:"); - System.out.println(String.format( - " %s [OPTIONS] --direction <up|down> --output <output.csv> <dir1> <namespace1> [<dir2> <namespace2>...]", - PROG)); + System.out.printf( + " %s [OPTIONS] --direction <up|down> --output <output.csv> <dir1> <namespace1> [<dir2> <namespace2>...]%n", + PROG); System.out.println(); System.out.println("DESCRIPTION:"); System.out.println( @@ -71,8 +72,10 @@ public class MFCheck extends MFSyncApp { System.out.println(" --mf.port <port> Mediaflux server port."); System.out.println( " --mf.transport <https|http|tcp/ip> Mediaflux server transport, can be http, https or tcp/ip."); - System.out.println(" --mf.auth <domain,user,password> Mediaflux user credentials."); - System.out.println(" --mf.token <token> Mediaflux secure identity token."); + +// System.out.println(" --mf.auth <domain,user,password> Mediaflux user credentials."); +// System.out.println(" --mf.token <token> Mediaflux secure identity token."); + System.out.println(" --direction <up|down> Direction: up/down."); System.out.println(" -o, --output <output.csv> Output CSV file."); System.out.println( @@ -102,9 +105,9 @@ public class MFCheck extends MFSyncApp { System.out.println(" <namespace> Remote Mediaflux namespace path."); System.out.println(); System.out.println("EXAMPLES:"); - System.out.println(String.format( - " %s --mf.config ~/.Arcitecta/mflux.cfg --direction down --output ~/Documents/foo-download-check.csv ~/Documents/foo /projects/proj-1.2.3/foo", - PROG)); + System.out.printf( + " %s --mf.config ~/.Arcitecta/mflux.cfg --direction down --output ~/Documents/foo-download-check.csv ~/Documents/foo /projects/proj-1.2.3/foo%n", + PROG); System.out.println(); // @formatter:on } @@ -212,7 +215,7 @@ public class MFCheck extends MFSyncApp { settings().setCheckHandler(_checkHandler); } - protected int parseMFOptions(String[] args, int i) throws Throwable { + protected int parseMFOptions(String[] args, int i) { if ("--mf.config".equalsIgnoreCase(args[i])) { try { _mfconfig.loadFromConfigFile(args[i + 1]); @@ -230,16 +233,26 @@ public class MFCheck extends MFSyncApp { _mfconfig.setTransport(args[i + 1]); return 2; } else if ("--mf.auth".equalsIgnoreCase(args[i])) { - String auth = args[i + 1]; - String[] parts = auth.split(","); - if (parts == null || parts.length != 3) { - throw new IllegalArgumentException("Invalid mf.auth: " + auth); - } - _mfconfig.setUserCredentials(parts[0], parts[1], parts[2]); - return 2; + throw new IllegalArgumentException("--mf.auth argument is no longer supported. Please specify user credentials in file: " + + MFConfig.DEFAULT_MFLUX_CFG_FILE + + " or the config file specified with --mf.config argument."); + // @formatter:off +// String auth = args[i + 1]; +// String[] parts = auth.split(","); +// if (parts.length != 3) { +// throw new IllegalArgumentException("Invalid mf.auth: " + auth); +// } +// _mfconfig.setUserCredentials(parts[0], parts[1], parts[2]); +// return 2; + // @formatter:on } else if ("--mf.token".equalsIgnoreCase(args[i])) { - _mfconfig.setToken(args[i + 1]); - return 2; + throw new IllegalArgumentException("--mf.token argument is no longer supported. Please specify the token in file: " + + MFConfig.DEFAULT_MFLUX_CFG_FILE + + " or the config file specified with --mf.config argument."); + // @formatter:off +// _mfconfig.setToken(args[i + 1]); +// return 2; + // @formatter:on } else { return 0; } @@ -360,15 +373,14 @@ public class MFCheck extends MFSyncApp { } private static Path renameOutputCsvFile(Path file) throws Throwable { - Path f = file; - Path dirPath = f.toAbsolutePath().getParent(); + Path dirPath = file.toAbsolutePath().getParent(); if (dirPath == null) { - throw new Exception("Null parent directory for file: " + f); + throw new Exception("Null parent directory for file: " + file); } String dir = dirPath.toString(); - Path fileName = f.getFileName(); + Path fileName = file.getFileName(); if (fileName == null) { - throw new Exception("Null file name for file: " + f); + throw new Exception("Null file name for file: " + file); } String name = fileName.toString(); if (!name.toLowerCase().endsWith(".csv")) { @@ -376,8 +388,8 @@ public class MFCheck extends MFSyncApp { } String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); StringBuilder sb = new StringBuilder(); - if (Files.exists(f)) { - sb.append(name.substring(0, name.length() - 4)); + if (Files.exists(file)) { + sb.append(name, 0, name.length() - 4); sb.append("-").append(timestamp); sb.append(".csv"); return Paths.get(dir, sb.toString()); diff --git a/src/main/java/unimelb/mf/client/sync/cli/MFDownload.java b/src/main/java/unimelb/mf/client/sync/cli/MFDownload.java index bc5bc76..e8cff11 100644 --- a/src/main/java/unimelb/mf/client/sync/cli/MFDownload.java +++ b/src/main/java/unimelb/mf/client/sync/cli/MFDownload.java @@ -7,6 +7,7 @@ import java.nio.file.Paths; import java.util.LinkedHashSet; import java.util.Set; +import unimelb.mf.client.session.MFConfig; import unimelb.mf.client.session.MFConfigBuilder; import unimelb.mf.client.session.MFSession; import unimelb.mf.client.sync.MFSyncApp; @@ -40,8 +41,8 @@ public class MFDownload extends MFSyncApp { // @formatter:off System.out.println(); System.out.println("USAGE:"); - System.out.println(String.format(" %s [OPTIONS] --out <dst-dir> <src-asset-or-namespace-path> [<src-asset-or-namespace-path>...]", PROG)); - System.out.println(String.format(" %s --config <mf-download-config.xml>", PROG)); + System.out.printf(" %s [OPTIONS] --out <dst-dir> <src-asset-or-namespace-path> [<src-asset-or-namespace-path>...]%n", PROG); + System.out.printf(" %s --config <mf-download-config.xml>%n", PROG); System.out.println(); System.out.println("DESCRIPTION:"); System.out.println(" Download assets (files) from Mediaflux to the local file system. Pre-existing files in the local file system can be skipped or overwritten. In Daemon mode, the process will only download new assets (files) since the process last executed."); @@ -53,8 +54,10 @@ public class MFDownload extends MFSyncApp { System.out.println(" --mf.host <host> Mediaflux server host."); System.out.println(" --mf.port <port> Mediaflux server port."); System.out.println(" --mf.transport <https|http|tcp/ip> Mediaflux server transport, can be http, https or tcp/ip."); - System.out.println(" --mf.auth <domain,user,password> Mediaflux user credentials."); - System.out.println(" --mf.token <token> Mediaflux secure identity token."); + +// System.out.println(" --mf.auth <domain,user,password> Mediaflux user credentials."); +// System.out.println(" --mf.token <token> Mediaflux secure identity token."); + System.out.println(" --no-cluster-io Disable cluster I/O if applicable."); System.out.println(" -o, --out <dst-dir> The output/destination directory."); @@ -83,9 +86,9 @@ public class MFDownload extends MFSyncApp { System.out.println(" <src-asset-or-namespace-path> The source asset path or asset namespace path."); System.out.println(); System.out.println("EXAMPLES:"); - System.out.println(String.format(" %s --mf.config ~/.Arcitecta/mflux.cfg --nb-workers 2 --out ~/Downloads /projects/proj-1128.1.59/foo /projects/proj-1128.1.59/bar", PROG)); - System.out.println(String.format(" %s --mf.config ~/.Arcitecta/mflux.cfg --nb-workers 2 --out ~/Downloads /projects/proj-1128.1.15/sample.zip", PROG)); - System.out.println(String.format(" %s --config ~/.Arcitecta/mf-download-config.xml", PROG)); + System.out.printf(" %s --mf.config ~/.Arcitecta/mflux.cfg --nb-workers 2 --out ~/Downloads /projects/proj-1128.1.59/foo /projects/proj-1128.1.59/bar%n", PROG); + System.out.printf(" %s --mf.config ~/.Arcitecta/mflux.cfg --nb-workers 2 --out ~/Downloads /projects/proj-1128.1.15/sample.zip%n", PROG); + System.out.printf(" %s --config ~/.Arcitecta/mf-download-config.xml%n", PROG); System.out.println(); // @formatter:on } @@ -141,7 +144,7 @@ public class MFDownload extends MFSyncApp { mfconfig.setApp(applicationName()); } - Set<String> srcPaths = new LinkedHashSet<String>(); + Set<String> srcPaths = new LinkedHashSet<>(); Path rootDir = null; try { for (int i = 0; i < args.length; ) { @@ -208,7 +211,7 @@ public class MFDownload extends MFSyncApp { /* * add jobs */ - Set<String> assets = new LinkedHashSet<String>(); + Set<String> assets = new LinkedHashSet<>(); for (String srcPath : srcPaths) { boolean trailingSlash = srcPath.length() > 1 && srcPath.endsWith("/"); if (trailingSlash) { @@ -233,7 +236,7 @@ public class MFDownload extends MFSyncApp { } } - protected int parseMFOptions(String[] args, int i, MFConfigBuilder mfconfig) throws Throwable { + protected int parseMFOptions(String[] args, int i, MFConfigBuilder mfconfig) { if ("--mf.config".equalsIgnoreCase(args[i])) { try { mfconfig.loadFromConfigFile(args[i + 1]); @@ -251,16 +254,26 @@ public class MFDownload extends MFSyncApp { mfconfig.setTransport(args[i + 1]); return 2; } else if ("--mf.auth".equalsIgnoreCase(args[i])) { - String auth = args[i + 1]; - String[] parts = auth.split(","); - if (parts == null || parts.length != 3) { - throw new IllegalArgumentException("Invalid mf.auth: " + auth); - } - mfconfig.setUserCredentials(parts[0], parts[1], parts[2]); - return 2; + throw new IllegalArgumentException("--mf.auth argument is no longer supported. Please specify user credentials in file: " + + MFConfig.DEFAULT_MFLUX_CFG_FILE + + " or the config file specified with --mf.config argument."); + // @formatter:off +// String auth = args[i + 1]; +// String[] parts = auth.split(","); +// if (parts.length != 3) { +// throw new IllegalArgumentException("Invalid mf.auth: " + auth); +// } +// mfconfig.setUserCredentials(parts[0], parts[1], parts[2]); +// return 2; + // @formatter:on } else if ("--mf.token".equalsIgnoreCase(args[i])) { - mfconfig.setToken(args[i + 1]); - return 2; + throw new IllegalArgumentException("--mf.token argument is no longer supported. Please specify the token in file: " + + MFConfig.DEFAULT_MFLUX_CFG_FILE + + " or the config file specified with --mf.config argument."); + // @formatter:off +// mfconfig.setToken(args[i + 1]); +// return 2; + // @formatter:on } else if ("--no-cluster-io".equalsIgnoreCase(args[i])) { mfconfig.setUseClusterIO(false); return 1; @@ -269,7 +282,7 @@ public class MFDownload extends MFSyncApp { } } - protected int parseDownloadOptions(String[] args, int i) throws Throwable { + protected int parseDownloadOptions(String[] args, int i) { if ("--overwrite".equalsIgnoreCase(args[i])) { settings().setOverwrite(true); return 1; @@ -423,13 +436,7 @@ public class MFDownload extends MFSyncApp { System.exit(1); } if (app.settings().daemon()) { - Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { - - @Override - public void run() { - app.interrupt(); - } - })); + Runtime.getRuntime().addShutdownHook(new Thread(app::interrupt)); new Thread(app).start(); } else { app.execute(); diff --git a/src/main/java/unimelb/mf/client/sync/cli/MFUpload.java b/src/main/java/unimelb/mf/client/sync/cli/MFUpload.java index d833a0a..f24673c 100644 --- a/src/main/java/unimelb/mf/client/sync/cli/MFUpload.java +++ b/src/main/java/unimelb/mf/client/sync/cli/MFUpload.java @@ -9,6 +9,7 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import unimelb.mf.client.session.MFConfig; import unimelb.mf.client.session.MFConfigBuilder; import unimelb.mf.client.session.MFSession; import unimelb.mf.client.sync.MFSyncApp; @@ -51,8 +52,10 @@ public class MFUpload extends MFSyncApp { System.out.println(" --mf.host <host> Mediaflux server host."); System.out.println(" --mf.port <port> Mediaflux server port."); System.out.println(" --mf.transport <https|http|tcp/ip> Mediaflux server transport, can be http, https or tcp/ip."); - System.out.println(" --mf.auth <domain,user,password> Mediaflux user credentials."); - System.out.println(" --mf.token <token> Mediaflux secure identity token."); + +// System.out.println(" --mf.auth <domain,user,password> Mediaflux user credentials."); +// System.out.println(" --mf.token <token> Mediaflux secure identity token."); + System.out.println(" --no-cluster-io Disable cluster I/O if applicable."); System.out.println(" --namespace <dst-namespace> The destination asset namespace in Mediaflux."); @@ -63,7 +66,7 @@ public class MFUpload extends MFSyncApp { System.out.println(" --batch-size <size> Size of the query result. Defaults to " + unimelb.mf.client.sync.settings.Settings.DEFAULT_BATCH_SIZE); System.out.println(" --daemon Run as a daemon."); System.out.println(" --daemon-port <port> Daemon listener port if running as a daemon. Defaults to " + unimelb.mf.client.sync.settings.Settings.DEFAULT_DAEMON_LISTENER_PORT); - System.out.println(" --daemon-scan-interval <seconds> Time interval (in seconds) between scans of source directories. Defaults to " + (unimelb.mf.client.sync.settings.Settings.DEFAULT_DAEMON_SCAN_INTERVAL/1000) + " seconds."); + System.out.println(" --daemon-scan-interval <seconds> Time interval (in seconds) between scans of source directories. Defaults to " + (unimelb.mf.client.sync.settings.Settings.DEFAULT_DAEMON_SCAN_INTERVAL / 1000) + " seconds."); System.out.println(" --exclude-parent Exclude parent directory at the destination (Upload the contents of the directory) if the source path ends with trailing slash."); System.out.println(" --log-dir <dir> Path to the directory for log files. No logging if not specified."); System.out.println(" --log-file-size-mb <n> Log file size limit in MB. Defaults to " + unimelb.mf.client.sync.settings.Settings.DEFAULT_LOG_FILE_SIZE_MB + "MB"); @@ -256,16 +259,26 @@ public class MFUpload extends MFSyncApp { mfconfig.setTransport(args[i + 1]); return 2; } else if ("--mf.auth".equalsIgnoreCase(args[i])) { - String auth = args[i + 1]; - String[] parts = auth.split(","); - if (parts.length != 3) { - throw new IllegalArgumentException("Invalid mf.auth: " + auth); - } - mfconfig.setUserCredentials(parts[0], parts[1], parts[2]); - return 2; + throw new IllegalArgumentException("--mf.auth argument is no longer supported. Please specify user credentials in file: " + + MFConfig.DEFAULT_MFLUX_CFG_FILE + + " or the config file specified with --mf.config argument."); + // @formatter:off +// String auth = args[i + 1]; +// String[] parts = auth.split(","); +// if (parts.length != 3) { +// throw new IllegalArgumentException("Invalid mf.auth: " + auth); +// } +// mfconfig.setUserCredentials(parts[0], parts[1], parts[2]); +// return 2; + // @formatter:on } else if ("--mf.token".equalsIgnoreCase(args[i])) { - mfconfig.setToken(args[i + 1]); - return 2; + throw new IllegalArgumentException("--mf.token argument is no longer supported. Please specify the token in file: " + + MFConfig.DEFAULT_MFLUX_CFG_FILE + + " or the config file specified with --mf.config argument."); + // @formatter:off +// mfconfig.setToken(args[i + 1]); +// return 2; + // @formatter:on } else if ("--no-cluster-io".equalsIgnoreCase(args[i])) { mfconfig.setUseClusterIO(false); return 1; -- GitLab