protected Path convertToAbsolute( final Path path )
{
if( path != null )
{
final RelativePathService service = property().service( RelativePathService.class );
if( service == null )
{
if( enclosed() && path.segmentCount() > 0 && path.segment( 0 ).equals( ".." ) )
{
return null;
}
Path absolute = null;
for( Path root : getBasePaths() )
{
try
{
final File file = root.append( path ).toFile().getCanonicalFile();
absolute = new Path( file.getPath() );
if( file.exists() )
{
break;
}
}
catch( IOException e )
{
// Intentionally ignoring to continue to the next root. If none of the roots
// produce a viable absolute path, a null return from this method signifies
// being unable to convert the relative path. That is sufficient.
}
}
return absolute;
}
else
{
return service.convertToAbsolute( path );
}
}
return null;
}