463144 - modules do not see pre-downloaded ALPN libs

+ Test all BaseHome configured locations for download file existence.
This commit is contained in:
Joakim Erdfelt 2015-04-13 16:19:29 -07:00
parent b7c7211cf5
commit cea577bd17
5 changed files with 35 additions and 20 deletions

View File

@ -256,7 +256,7 @@ public class BaseBuilder
// Process via initializers
for (FileInitializer finit : fileInitializers)
{
if (finit.init(uri,file))
if (finit.init(uri,file,arg.location))
{
// Completed successfully
return true;

View File

@ -33,11 +33,14 @@ public interface FileInitializer
* @param uri
* the remote URI of the resource acting as its source
* @param file
* the local file resource to initialize
* the local file resource to initialize. (often in ${jetty.base} directory)
* @param fileRef
* the simple string reference to the output file, suitable for searching
* for the file in other locations (like ${jetty.home} or ${jetty.dir})
* @return true if local file is initialized (resulted in a change on disk), false if this
* {@link FileInitializer} did nothing.
* @throws IOException
* if there was an attempt to initialize, but an error occurred.
*/
public boolean init(URI uri, Path file) throws IOException;
public boolean init(URI uri, Path file, String fileRef) throws IOException;
}

View File

@ -93,7 +93,7 @@ public class MavenLocalRepoFileInitializer extends UriFileInitializer implements
}
@Override
public boolean init(URI uri, Path file) throws IOException
public boolean init(URI uri, Path file, String fileRef) throws IOException
{
Coordinates coords = getCoordinates(uri);
if (coords == null)
@ -102,7 +102,7 @@ public class MavenLocalRepoFileInitializer extends UriFileInitializer implements
return false;
}
if (isFilePresent(file))
if (isFilePresent(file, baseHome.getPath(fileRef)))
{
// All done
return true;

View File

@ -34,7 +34,7 @@ import org.eclipse.jetty.start.StartLog;
public class TestFileInitializer implements FileInitializer
{
@Override
public boolean init(URI uri, Path file) throws IOException
public boolean init(URI uri, Path file, String fileRef) throws IOException
{
FS.ensureDirectoryExists(file.getParent());

View File

@ -41,9 +41,9 @@ public class UriFileInitializer implements FileInitializer
{
this.baseHome = baseHome;
}
@Override
public boolean init(URI uri, Path file) throws IOException
public boolean init(URI uri, Path file, String fileRef) throws IOException
{
if (!isSupportedScheme(uri))
{
@ -51,7 +51,7 @@ public class UriFileInitializer implements FileInitializer
return false;
}
if(isFilePresent(file))
if(isFilePresent(file, baseHome.getPath(fileRef)))
{
// All done
return true;
@ -98,23 +98,35 @@ public class UriFileInitializer implements FileInitializer
}
}
protected boolean isFilePresent(Path file) throws IOException
/**
* Test if any of the Paths exist (as files)
*
* @param paths
* the list of paths to check
* @return true if the path exist (as a file), false if it doesn't exist
* @throws IOException
* if the path points to a non-file, or is not readable.
*/
protected boolean isFilePresent(Path... paths) throws IOException
{
if (Files.exists(file))
for (Path file : paths)
{
if (Files.isDirectory(file))
if (Files.exists(file))
{
throw new IOException("Directory in the way: " + file.toAbsolutePath());
}
if (Files.isDirectory(file))
{
throw new IOException("Directory in the way: " + file.toAbsolutePath());
}
if (!Files.isReadable(file))
{
throw new IOException("File not readable: " + file.toAbsolutePath());
if (!Files.isReadable(file))
{
throw new IOException("File not readable: " + file.toAbsolutePath());
}
return true;
}
return true;
}
return false;
}