Giter Club home page Giter Club logo

jsr203-http's Introduction

This project is in a pre-release stage and it is subject to change without warning.

Build Status Build status codecov Codacy Badge Language License (3-Clause BSD)

jsr203-http

HTTP/S FileSystem provider for Java NIO.2

License

Code licensed under the BSD License. See the LICENSE.txt.

jsr203-http's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

broadinstitute

jsr203-http's Issues

Library Status

Hi @magicDGS,

I hope things are going well! I'm looking at adding native support for URL's to GATK and I was going to use your library as a starting point. Do you have any interest/availability in continuing work on this? I'm going to fork the project and start doing some work on it. If you're interested I'm happy to work with you together on it, or I can just do the work on my own.

Evaluate reckon plugin to infer version

In #48, we change our plugin to git versioning to com.palantir.git-version; nevertheless, this does not handle the tagging system, nor help with the release proces (thus, it requires some scripting). There is a plugin that could handle this: https://github.com/ajoberstar/reckon

We should explore that option and add it before we move forward to version 0.1.0

Implement simple HttpPath

With the following fields:

  • HttpFileSystem originating the URL (to get the separator and the scheme from the provider)
  • Authority part of URL (to re-construct the URL)
  • Path within authority as byte array (to operate over the paths) with offsets array (int[])
  • Optional fields (may be null): quey/reference from URL (for re-create the complete URL)

The implementation of the path part (byte[]) should be similar to other implementations of java.nio.Path (e.g., UnixPath or HadoopPath).

The methods implemented for this simple HttpPath should be:

  • Constructors from URL/URI
  • getFileSystem()
  • toUri()
  • toString() / hashCode / equals / compareTo
  • isAbsolute() / toAbsolutePath() - should return always true/this in the first implementation and we shouldn't allow relative HTTP/S paths

The rest should still throw UnsupportedOperationException

Implement start/end with methods in HttpPath

We should implement start/end with methods for other HTTP/S paths. We should also decide, although it can be later and moved to a different issue, if we want the following behavior for the String version:

  • The contract suggest to throw InvalidPathExceptionif the String cannot be converted into a Path, but this does not allow to return true for HttpPath("http://example.com/file.txt").endsWITH("file.txt"). Nevertheless, if using the string "file://file.txt" it should throw because there is a mismatch with the providers. I don't know how much strict we should follow the contract here...
  • If we want to test HttpPath("http://example.com/file.txt").startWith("file.txt"), this method should fail with InvalidPathException because the scheme and authority aren't provided and thus it cannot be tested. Maybe we can relax this by returning false by anything that cannot be converted into an HttpPath with the instance FileSystem to mimic the behaviour of endsWith described before.

Consider a FS for each authority

Instead of a FS for each authority, as currently designed, it will be nice to have one por page to being able to retrieve "root" directories, etc.

It requires:

  • HttpPath without authority, but stored in the FS field
  • FileSystem for each authority (base URI with only authority and protocol)
  • FileSystemProvider keeping all the generated FileSystems.

This might be better before going further in the direction of a single FS per protocol.

Add dev wiki/docs for testing on Windows (EOL problems)

If Git for linux is configured to convert EOL to CRLR, then the tests in the current master branch fail (see #39), because some of the tests check at the byte level the content of the file and thus there is a mismatch between the hosted file in GitHub pages and the local one.

We should add recommendations to clone the repository in Windows to make tests not failing.

Should be useable with Java NIO FileSystems API

It would be good if the library could be used with the Java NIO FileSystems API. See:
https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystems.html

please try following code with your library:
(after creating the usual "java.nio.file.spi.FileSystemProvider" file in META-INF)

final URI uri = new URI("http://localhost:8000/");
final Path rootPath = FileSystems.getFileSystem(uri).getPath("/test/test.txt");

it will crash with a "java.nio.file.FileSystemNotFoundException".

Could you please fix following code in your "AbstractHttpFileSystemProvider":

    @Override
    public final HttpFileSystem getFileSystem(final URI uri) {
        final HttpFileSystem fs = fileSystems.get(checkUri(uri).getAuthority());
        if (fs == null) {
            throw new FileSystemNotFoundException("URI: " + uri);
        }
        return fs;
    }

it should be like following to work:

    @Override
    public final HttpFileSystem getFileSystem(final URI uri) {
        final HttpFileSystem fs = fileSystems.get(checkUri(uri).getAuthority());
        if (fs == null) {
            try {
                return newFileSystem(uri, new HashMap<>());
            } catch (final IOException e) {
                throw new RuntimeException(e);
            }
        }
        return fs;
    }

thanx!, greetings.

Implement simple functionality for relative HttpPath

We should implement a relative HttpPathto get parts of the Path (file name, directory name, etc), and also iterate over paths. This support should include:

  • Add offsets field (int[]) for easier splitting the directory (as in other path implementations)
  • isAbsolute() returning false for this paths
  • toAbsolutePath() should return an absolute path sited on the root
  • getFileName
  • getParent
  • getNameCount
  • getName(int)
  • subpath
  • iterator - using getName(int)

In addition, this relative Paths should fail for constructing an URI (no relative paths there), with a meaningful error.

HttpUtils.exists handling some exceptions

We should check if there is any exception when establishing a connection with an URL that throws when the file does not exists. Here is a tracker for that. By now, we only catch the UnknownHostException, but it can be other reasons to say that the file does not exists.

Implement close of FS

Closing the FS might be useful to get rid of all connections with an HTTP/S host, but that requires that we track all the open connections and also remove from the map of the FSP.

Implement HttpPath resolution

Implement the following methods to be able to resolve paths and get an absolute path from a relative ones:

  • resolve and resolveSibling
  • relativize

Tests failing in windows due to line endings

If using git for Windows, the EOL is converted and thus tests relying on reading all bytes from a file are not working. There are two possibilities to fix this problem:

  • Change tests to do not check bytes but lines, removing the system-specific EOL.
  • Add .gitattributes specific for the docs folder, where the line endings are kept as they are (also important for formatting docs, I guess)

In addition, we should test this on the CI (see #38)

Simple implementation of AbstractHttpFileSystemProvider

Requires a functional HttpFileSystem (#19 and #22). For this being functional, we need to implement two parts (might be two different PRs):

  • getFileSystem / newFileSystem: should create a FileSystem for each host in a Map and re-use
  • getPath: should get the FS associated with the host from the map and construct the path from it
  • newByteChannel returning a URLSeekableByteChannel (and failing for a writable channel), using Path.toUri().toUrl()
  • checkAccess for checking for existance of files (using a HEAD request and checking HttpURLConnection.HTTP_OK.

This is the minimal for working with http paths that it is required for a functional version from my point of view.

Simple implementation of HttpFileSystem

By now, all the FS will be always open and a no-op for closing. We should implement also the getPath method for having a functional FS (requires #15).

Other methods will be implemented later.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.