diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy index a475ad4f..92db5024 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy @@ -33,7 +33,10 @@ class QuiltObserverFactory implements TraceObserverFactory { @Override Collection create(Session session) { //log.debug("`create` ${this}") - return (Collection) [new QuiltObserver()] + Collection quiltObservers = new ArrayList<>() + quiltObservers.add(new QuiltObserver()) + + return quiltObservers as Collection } } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy index b07f5182..6523e71c 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy @@ -51,7 +51,7 @@ class QuiltPathify { Files.copy(source, dest) } catch (Exception e) { - log.error("writeString: cannot write `$source` to `$dest` in `${destRoot}`") + log.error("writeString: cannot write `$source` to `$dest` in `${destRoot}`\n$e") } } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy index 4517a60d..d48ad1d6 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy @@ -110,7 +110,7 @@ ${nextflow} Files.write(path, text.bytes) } catch (Exception e) { - log.error("writeString: cannot write `$text` to `$path` for `${pkg}`") + log.error("writeString: cannot write `$text` to `$path` for `${pkg}`\n$e") } } @@ -121,7 +121,7 @@ ${nextflow} Files.copy(source, dest) } catch (Exception e) { - log.error("writeString: cannot write `$source` to `$dest` in `${destRoot}`") + log.error("writeString: cannot write `$source` to `$dest` in `${destRoot}`\n$e.message()") } } @@ -182,7 +182,7 @@ ${nextflow} Map cf_meta = quilt_cf.navigate(KEY_META) as Map ?: [:] quilt_cf.remove(KEY_META) // println("getMetadata.cf_meta: ${cf_meta}") - Map pkg_meta = pkg.meta + Map pkg_meta = pkg.getMetadata() updateFlags(pkg_meta, quilt_cf) Map params = session.getParams() diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy index 28d9691a..19c867fb 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy @@ -15,9 +15,6 @@ */ package nextflow.quilt.jep -/* groovylint-disable-next-line ImportFromSamePackage */ -import nextflow.quilt.jep.QuiltParser - import groovy.transform.CompileStatic import groovy.util.logging.Slf4j diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy index bf0f642a..7c60f7cc 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy @@ -49,8 +49,8 @@ class QuiltPackage { private static final String INSTALL_PREFIX = 'QuiltPackage' static final Path INSTALL_ROOT = Files.createTempDirectory(INSTALL_PREFIX) + public final String packageName private final String bucket - private final String packageName private final QuiltParser parsed private final String hash private final Path folder @@ -220,6 +220,10 @@ class QuiltPackage { return folder } + Map getMetadata() { + return this.meta + } + /* * Package methods */ diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy index 8c0d043d..69048cde 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy @@ -92,20 +92,21 @@ class QuiltParser { static Map parseQuery(String query) { if (!query) { return [:] } // skip for urls without query params def params = query.split('&') - def result = [:] + Map> result = [:] params.each { param -> def keyValue = param.split('=') if (keyValue.size() == 2) { String key = decode(keyValue[0]) String value = decode(keyValue[1]) if (result.containsKey(key)) { - if (result[key] instanceof List) { - result[key] += value + List listVal = result[key] + if (listVal instanceof List) { + listVal << value } else { - result[key] = [result[key], value] + result[key] = [listVal, value] as List } } else { - result[key] = value + result[key] = value as List } } } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileAttributesView.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileAttributesView.groovy index b51abd42..1b8b4349 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileAttributesView.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileAttributesView.groovy @@ -49,7 +49,7 @@ class QuiltFileAttributesView implements BasicFileAttributeView { /** * This API is implemented is not supported but instead of throwing an exception just do nothing - * to not break the method {@link java.nio.file.CopyMoveHelper#copyToForeignTarget(...)} + * to not break the method {@link java.nio.file.CopyMoveHelper copyToForeignTarget(...)} * * @param lastModifiedTime * @param lastAccessTime diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy index cf6ffc11..98587d88 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy @@ -58,11 +58,11 @@ final class QuiltFileSystem extends FileSystem implements Closeable { return quiltIDS } - void copy(QuiltPath source, QuiltPath target) { + static void copy(QuiltPath source, QuiltPath target) { throw new UnsupportedOperationException("NOT Implemented 'QuiltFileSystem.copy' `$source` -> `$target`") } - void delete(QuiltPath path) { + static void delete(QuiltPath path) { //log.debug("QuiltFileSystem.delete: $path") path.deinstall() //throw new UnsupportedOperationException("Operation 'delete' is not supported by QuiltFileSystem") @@ -93,7 +93,7 @@ final class QuiltFileSystem extends FileSystem implements Closeable { return QuiltParser.SEP } - QuiltFileAttributesView getFileAttributeView(QuiltPath path) { + static QuiltFileAttributesView getFileAttributeView(QuiltPath path) { //log.debug("QuiltFileAttributesView QuiltFileSystem.getFileAttributeView($path)") String pathString = path.toUriString() try { @@ -105,7 +105,7 @@ final class QuiltFileSystem extends FileSystem implements Closeable { } } - QuiltFileAttributes readAttributes(QuiltPath path) { + static QuiltFileAttributes readAttributes(QuiltPath path) { log.debug("QuiltFileAttributes QuiltFileSystem.readAttributes($path)") Path installedPath = path.localPath() try { @@ -113,12 +113,12 @@ final class QuiltFileSystem extends FileSystem implements Closeable { return new QuiltFileAttributes(path, path.toString(), attrs) } catch (NoSuchFileException e) { - log.debug("No attributes yet for: ${installedPath}") + log.debug("No attributes yet for: ${installedPath}\n$e") } return null } - boolean exists(QuiltPath path) { + static boolean exists(QuiltPath path) { return path.pkg().isInstalled() } @@ -145,15 +145,15 @@ final class QuiltFileSystem extends FileSystem implements Closeable { return new QuiltPath(this, p) } - String toUriString(Path path) { + static String toUriString(Path path) { return path in QuiltPath ? ((QuiltPath)path).toUriString() : null } - String getBashLib(Path path) { + static String getBashLib(Path path) { return path in QuiltPath ? QuiltBashLib.script() : null } - String getUploadCmd(String source, Path target) { + static String getUploadCmd(String source, Path target) { return target in QuiltPath ? QuiltFileCopyStrategy.uploadCmd(source, target) : null } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy index 5ed5ad7e..8c4d664c 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy @@ -34,7 +34,6 @@ import java.nio.file.NoSuchFileException import java.nio.file.OpenOption import java.nio.file.Path import java.nio.file.Paths -import java.nio.file.StandardOpenOption import java.nio.file.attribute.BasicFileAttributeView import java.nio.file.attribute.BasicFileAttributes import java.nio.file.attribute.FileAttribute @@ -94,12 +93,12 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr boolean canUpload(Path source, Path target) { log.debug "QuiltFileSystemProvider.canUpload: ${source} -> ${target}" - return FileSystems.getDefault().equals(source.getFileSystem()) && target instanceof QuiltPath + return FileSystems.getDefault() == source.getFileSystem() && target instanceof QuiltPath } boolean canDownload(Path source, Path target) { log.debug "QuiltFileSystemProvider.canDownload: ${source} -> ${target}" - return source instanceof QuiltPath && FileSystems.getDefault().equals(target.getFileSystem()) + return source instanceof QuiltPath && FileSystems.getDefault() == target.getFileSystem() } void download(Path remoteFile, Path localDestination, CopyOption... options) throws IOException { @@ -161,7 +160,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr return QuiltParser.SCHEME } - String getQuiltIDS(URI uri) { + static String getQuiltIDS(URI uri) { assert uri QuiltParser parsed = QuiltParser.forURI(uri) return parsed.quiltID().toString() @@ -213,6 +212,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr /* groovylint-disable-next-line UnusedMethodParameter */ QuiltFileSystem newFileSystem(String quiltIDS, Map env) throws IOException { + log.debug("newFileSystem $env") final fs = new QuiltFileSystem(quiltIDS, this) fileSystems[quiltIDS] = fs return fs @@ -301,7 +301,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr return new QuiltPath(fs, parsed) } - void checkRoot(Path path) { + static void checkRoot(Path path) { if (path == Paths.get('/')) { throw new UnsupportedOperationException("Operation 'checkRoot' not supported on root path") } @@ -316,7 +316,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr * @return * @throws IOException */ - void notifyFilePublish(QuiltPath destination) { //, Path source=null) { + static void notifyFilePublish(QuiltPath destination) { //, Path source=null) { final sess = Global.session /* groovylint-disable-next-line Instanceof */ if (sess instanceof Session) { @@ -345,12 +345,13 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr FileChannel channel = FileChannel.open(installedPath, options) return channel } - catch (java.nio.file.NoSuchFileException e) { - log.error("Failed `FileChannel.open`: ${installedPath} <- ${options}") + catch (NoSuchFileException e) { + log.error("Failed `FileChannel.open`: ${installedPath} <- ${options}\n$e") } + return null } - DirectoryStream emptyStream() throws IOException { + static DirectoryStream emptyStream() throws IOException { return new DirectoryStream() { @Override @@ -450,32 +451,32 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr } @Override - def V getFileAttributeView(Path path, Class type, LinkOption... options) { + V getFileAttributeView(Path path, Class type, LinkOption... options) { // log.debug("Calling `getFileAttributeView`: ${path}") checkRoot(path) if (type == BasicFileAttributeView || type == QuiltFileAttributesView) { QuiltPath qPath = asQuiltPath(path) - QuiltFileSystem fs = qPath.filesystem + QuiltFileSystem fs = qPath.getFileSystem() as QuiltFileSystem return (V)fs.getFileAttributeView(qPath) } throw new UnsupportedOperationException("Operation 'getFileAttributeView' is not supported for type $type") } @Override - def A readAttributes(Path path, Class type, LinkOption... options) + A readAttributes(Path path, Class type, LinkOption... options) throws IOException { log.debug 'BasicFileAttributes QuiltFileSystemProvider.readAttributes()' def attr = attributesCache.get(path) if (attr) { - return attr + return attr as A } if (type == BasicFileAttributes || type == QuiltFileAttributes) { QuiltPath qPath = asQuiltPath(path) - QuiltFileSystem fs = qPath.filesystem + QuiltFileSystem fs = qPath.getFileSystem() as QuiltFileSystem def result = (A)fs.readAttributes(qPath) if (result) { attributesCache[path] = result - return result + return result as A } log.debug("readAttributes: File ${qPath.localPath()} not found") if (!qPath.isNull()) { @@ -484,7 +485,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr log.warn("readAttributes: Ignore ${qPath} for null bucket") } throw new UnsupportedOperationException("Not a valid Quilt Storage file attribute type: $type") - } + } @Override Map readAttributes(Path path, String attributes, LinkOption... options) throws IOException { diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy index 256e554b..31b09e56 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy @@ -21,6 +21,7 @@ import nextflow.quilt.jep.QuiltParser import java.nio.file.Files import java.nio.file.FileSystem import java.nio.file.LinkOption +import java.nio.file.NoSuchFileException import java.nio.file.Path import java.nio.file.Paths import java.nio.file.ProviderMismatchException @@ -112,10 +113,11 @@ final class QuiltPath implements Path, Comparable { log.debug("QuiltPath.deinstall: $path") try { Files.delete(path) - } catch (java.nio.file.NoSuchFileException e) { + } catch (NoSuchFileException e) { // Handle the exception here log.error("Failed to delete path: $path", e) } + return false } @Override