Package util
Class URITools
java.lang.Object
util.URITools
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringappendName(URI uri, String name) static voidcopy(org.janelia.saalfeldlab.n5.KeyValueAccess kva, String relativeSrc, String relativeDst) static voidstatic StringdetectS3Region(URI uri) Attempts to detect the AWS region of an S3 bucket without any credentials.static Stringstatic StringgetFileName(URI uri) getKeyValueAccess(URI uri) A little hack to get a generic KeyValueAccess for a cloud storestatic URIgetParentURI(URI uri) static URIgetParentURINoEx(URI uri) static booleanstatic booleanstatic booleanisKnownScheme(URI uri) static booleanstatic SpimData2loadSpimData(URI xmlURI, XmlIoSpimData2 io) static voidstatic BufferedReaderstatic InputStreamstatic OutputStreamstatic PrintWriterstatic booleanprefetch(mpicbg.spim.data.generic.sequence.BasicImgLoader loader, int threads) static voidsaveSpimData(SpimData2 data, URI xmlURI, XmlIoSpimData2 io) static booleansetNumFetcherThreads(mpicbg.spim.data.generic.sequence.BasicImgLoader loader, int threads) static URIstatic URIxmlFilenameToFullPath(mpicbg.spim.data.generic.AbstractSpimData<?> data, String xmlFileName)
-
Field Details
-
cloudThreads
public static int cloudThreads -
s3Region
-
useS3CredentialsWrite
public static boolean useS3CredentialsWrite -
useS3CredentialsRead
public static boolean useS3CredentialsRead
-
-
Constructor Details
-
URITools
public URITools()
-
-
Method Details
-
getParentURINoEx
-
getParentURI
-
getKeyValueAccess
A little hack to get a generic KeyValueAccess for a cloud store- Parameters:
uri- - the full URI (even though only scheme and host/bucket will be used)- Returns:
- the KeyValueStore
-
saveSpimData
public static void saveSpimData(SpimData2 data, URI xmlURI, XmlIoSpimData2 io) throws mpicbg.spim.data.SpimDataException -
instantiateN5Writer
public static org.janelia.saalfeldlab.n5.N5Writer instantiateN5Writer(org.janelia.saalfeldlab.n5.universe.StorageFormat format, URI uri) -
instantiateN5Reader
public static org.janelia.saalfeldlab.n5.N5Reader instantiateN5Reader(org.janelia.saalfeldlab.n5.universe.StorageFormat format, URI uri) -
detectS3Region
Attempts to detect the AWS region of an S3 bucket without any credentials. Issues an unauthenticated HTTP HEAD request (path-style) against the global S3 endpoint and reads thex-amz-bucket-regionresponse header, which S3 returns even for 301/403 responses. Path-style againsts3.amazonaws.comis used so that bucket names containing dots are handled and TLS still validates.- Parameters:
uri- ans3://URI; the bucket is taken from the host component- Returns:
- the region string (e.g. "us-west-2"), or null if it could not be determined
-
loadSpimData
public static SpimData2 loadSpimData(URI xmlURI, XmlIoSpimData2 io) throws mpicbg.spim.data.SpimDataException -
setNumFetcherThreads
public static boolean setNumFetcherThreads(mpicbg.spim.data.generic.sequence.BasicImgLoader loader, int threads) -
prefetch
public static boolean prefetch(mpicbg.spim.data.generic.sequence.BasicImgLoader loader, int threads) -
openFileReadCloudReader
public static BufferedReader openFileReadCloudReader(org.janelia.saalfeldlab.n5.KeyValueAccess kva, URI uri) throws IOException - Throws:
IOException
-
openFileReadCloudStream
public static InputStream openFileReadCloudStream(org.janelia.saalfeldlab.n5.KeyValueAccess kva, URI uri) throws IOException - Throws:
IOException
-
openFileWriteCloudWriter
public static PrintWriter openFileWriteCloudWriter(org.janelia.saalfeldlab.n5.KeyValueAccess kva, URI uri) throws IOException - Throws:
IOException
-
openFileWriteCloudStream
public static OutputStream openFileWriteCloudStream(org.janelia.saalfeldlab.n5.KeyValueAccess kva, URI uri) throws IOException - Throws:
IOException
-
copy
public static void copy(org.janelia.saalfeldlab.n5.KeyValueAccess kva, String relativeSrc, String relativeDst) throws IOException - Throws:
IOException
-
isKnownScheme
-
isGC
-
isS3
-
isFile
-
toURI
- Parameters:
uriString- - if relative we assume it's a local path and file:/ scheme will be added- Returns:
- the URI of the String
-
fromURI
- Parameters:
uri- a URI- Returns:
- a String representation of a URI, if it starts with file:/ it will be removed
-
getFileName
-
appendName
-
xmlFilenameToFullPath
public static URI xmlFilenameToFullPath(mpicbg.spim.data.generic.AbstractSpimData<?> data, String xmlFileName) -
copyFile
- Throws:
IOException
-
main
public static void main(String[] args) throws mpicbg.spim.data.SpimDataException, IOException, URISyntaxException
-