Search in sources :

Example 1 with URIxMatcher

use of maspack.fileutil.uri.URIxMatcher in project artisynth_core by artisynth.

the class FileCacher method resolveRemote.

private FileObject resolveRemote(URIx uri) throws FileSystemException {
    FileObject remoteFile = null;
    // base determines the first protocol
    URIx base = uri.getBaseURI();
    // clear authenticators
    setAuthenticator(fsOpts, null);
    setIdentityFactory(fsOpts, null);
    // first try to find matching identity
    for (URIxMatcher matcher : identMap.keySet()) {
        if (matcher.matches(base)) {
            // set identity, try to resolve file
            myIdFactory.setIdentityRepository(identMap.get(matcher));
            setIdentityFactory(fsOpts, myIdFactory);
            remoteFile = tryGettingRemote(uri);
            if (remoteFile != null) {
                return remoteFile;
            }
        }
    }
    // then try authenticator
    setIdentityFactory(fsOpts, null);
    for (URIxMatcher matcher : authMap.keySet()) {
        if (matcher.matches(base)) {
            // we have found an authenticator
            setAuthenticator(fsOpts, authMap.get(matcher));
            remoteFile = tryGettingRemote(uri);
            if (remoteFile != null) {
                return remoteFile;
            }
        }
    }
    // try without authentication last (otherwise it seems to resolve, which is bad)
    remoteFile = tryGettingRemote(uri);
    if (remoteFile != null) {
        return remoteFile;
    }
    return null;
}
Also used : FileObject(org.apache.commons.vfs2.FileObject) URIx(maspack.fileutil.uri.URIx) URIxMatcher(maspack.fileutil.uri.URIxMatcher)

Aggregations

URIx (maspack.fileutil.uri.URIx)1 URIxMatcher (maspack.fileutil.uri.URIxMatcher)1 FileObject (org.apache.commons.vfs2.FileObject)1