diff --git a/src/loci/formats/S3FileSystemStore.java b/src/loci/formats/S3FileSystemStore.java index 2d5a40f..5ba521b 100644 --- a/src/loci/formats/S3FileSystemStore.java +++ b/src/loci/formats/S3FileSystemStore.java @@ -33,7 +33,6 @@ import com.bc.zarr.ZarrUtils; import com.bc.zarr.storage.Store; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -88,8 +87,8 @@ public String getRoot() { } private void setupClient() { - String[] pathSplit = root.toString().split(File.separator); - String endpoint = ENDPOINT_PROTOCOL + pathSplit[1] + File.separator; + String[] pathSplit = root.toString().split("/"); + String endpoint = ENDPOINT_PROTOCOL + pathSplit[1] + "/"; try { client = AmazonS3ClientBuilder.standard() .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, "auto")) @@ -115,11 +114,11 @@ public S3FileSystemStore(Path rootPath) { @Override public InputStream getInputStream(String key) throws IOException { // Get the base bucket name from splitting the root path and removing the prefixed protocol and end-point - String[] pathSplit = root.toString().split(File.separator); + String[] pathSplit = root.toString().split("/"); String bucketName = pathSplit[2]; // Append the desired key onto the remaining prefix - String key2 = root.toString().substring(root.toString().indexOf(pathSplit[3]), root.toString().length()) + File.separator + key; + String key2 = root.toString().substring(root.toString().indexOf(pathSplit[3]), root.toString().length()) + "/" + key; try { S3Object o = client.getObject(bucketName, key2); @@ -201,7 +200,7 @@ private TreeSet getKeysFor(String suffix) throws IOException { TreeSet keys = new TreeSet(); // Get the base bucket name from splitting the root path and removing the prefixed protocol and end-point - String[] pathSplit = root.toString().split(File.separator); + String[] pathSplit = root.toString().split("/"); String bucketName = pathSplit[2]; // Append the desired key onto the remaining prefix diff --git a/src/loci/formats/in/ZarrReader.java b/src/loci/formats/in/ZarrReader.java index bf8822f..22dc3bc 100644 --- a/src/loci/formats/in/ZarrReader.java +++ b/src/loci/formats/in/ZarrReader.java @@ -111,6 +111,7 @@ public class ZarrReader extends FormatReader { private boolean planesPrePopulated = false; private boolean hasSPW = false; private transient int currentOpenZarr = -1; + private String zarrRootPath; public ZarrReader() { super("Zarr", "zarr"); @@ -181,8 +182,7 @@ protected void initFile(String id) throws FormatException, IOException { final MetadataStore store = makeFilterMetadata(); Location zarrFolder = new Location(id); String zarrPath = zarrFolder.getAbsolutePath(); - String zarrRootPath = zarrPath.substring(0, zarrPath.indexOf(".zarr") + 5); - String name = zarrRootPath.substring(zarrRootPath.lastIndexOf(File.separator)+1, zarrRootPath.length() - 5); + this.zarrRootPath = zarrPath.substring(0, zarrPath.indexOf(".zarr") + 5); Location omeMetaFile = new Location( zarrRootPath + File.separator + "OME", "METADATA.ome.xml" ); String canonicalPath = new Location(zarrRootPath).getCanonicalPath(); @@ -456,7 +456,6 @@ private static int[] getOriginalShape(int [] shape5D, int size) { @Override public void reopenFile() throws IOException { try { - String canonicalPath = new Location(currentId).getCanonicalPath(); initializeZarrService(); } catch (FormatException e) { @@ -465,7 +464,7 @@ public void reopenFile() throws IOException { } protected void initializeZarrService() throws IOException, FormatException { - zarrService = new JZarrServiceImpl(altStore()); + zarrService = new JZarrServiceImpl(zarrRootPath); openZarr(); } @@ -779,16 +778,6 @@ private void parsePlate(Map attr, String root, String key, Metad } } -// TODO: Likely remove as values unused -// for (int c = 0; c < columns.size(); c++) { -// Map column = (Map) columns.get(c); -// String colName = (String) column.get("name"); -// } -// for (int r = 0; r < rows.size(); r++) { -// Map row = (Map) rows.get(r); -// String rowName = (String) row.get("name"); -// } - //Create empty wells for each row and column wellCount = rows.size() * columns.size(); for (int r = 0; r < rows.size(); r++) { diff --git a/src/loci/formats/services/JZarrServiceImpl.java b/src/loci/formats/services/JZarrServiceImpl.java index 732b8c2..b8b3ea2 100644 --- a/src/loci/formats/services/JZarrServiceImpl.java +++ b/src/loci/formats/services/JZarrServiceImpl.java @@ -32,14 +32,9 @@ */ import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; import java.nio.ByteOrder; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Path; + import java.nio.file.Paths; -import java.text.MessageFormat; import java.util.Map; import java.util.Set; @@ -80,14 +75,8 @@ public class JZarrServiceImpl extends AbstractService */ public JZarrServiceImpl(String root) { checkClassDependency(com.bc.zarr.ZarrArray.class); - if (root != null && (root.toLowerCase().contains("s3:") || root.toLowerCase().contains("s3."))) { - String[] pathSplit = root.toString().split(File.separator); - if (S3FileSystemStore.ENDPOINT_PROTOCOL.contains(pathSplit[0].toLowerCase())) { + if (root != null && (root.matches("^https?:.*") || root.matches("^s3:.*"))) { s3fs = new S3FileSystemStore(Paths.get(root)); - } - else { - LOGGER.warn("Zarr Reader is not using S3FileSystemStore as this is currently for use with S3 configured with a https endpoint"); - } } } diff --git a/src/loci/formats/services/ZarrService.java b/src/loci/formats/services/ZarrService.java index 13b6c3a..ccc1ac2 100644 --- a/src/loci/formats/services/ZarrService.java +++ b/src/loci/formats/services/ZarrService.java @@ -36,7 +36,6 @@ import loci.common.services.Service; import loci.formats.FormatException; import loci.formats.meta.MetadataRetrieve; -import loci.formats.services.ZarrService.Compression; public interface ZarrService extends Service { diff --git a/test/loci/formats/utests/JZarrServiceImplTest.java b/test/loci/formats/utests/JZarrServiceImplTest.java index 220b223..0b617b3 100644 --- a/test/loci/formats/utests/JZarrServiceImplTest.java +++ b/test/loci/formats/utests/JZarrServiceImplTest.java @@ -1,4 +1,4 @@ -package test.loci.formats.utests; +package loci.formats.utests; /*- * #%L diff --git a/test/loci/formats/utests/ZarrReaderMock.java b/test/loci/formats/utests/ZarrReaderMock.java index bc0cd23..7bd38f8 100644 --- a/test/loci/formats/utests/ZarrReaderMock.java +++ b/test/loci/formats/utests/ZarrReaderMock.java @@ -1,4 +1,4 @@ -package test.loci.formats.utests; +package loci.formats.utests; /*- * #%L diff --git a/test/loci/formats/utests/ZarrReaderTest.java b/test/loci/formats/utests/ZarrReaderTest.java index 7c45fe1..7b3ac76 100644 --- a/test/loci/formats/utests/ZarrReaderTest.java +++ b/test/loci/formats/utests/ZarrReaderTest.java @@ -1,4 +1,4 @@ -package test.loci.formats.utests; +package loci.formats.utests; /*- * #%L