private File initializeDirectory(final String[] locations, final boolean isTemp)
    {
        final String tempOrPermanent = (isTemp) ? "temporary" : "permanent";
        boolean first = true;
        for (final String location : locations) {
            if (location == null) {
                continue;
            }
            if (!first) {
                this.logger.warn("Falling back on [{}] as the {} directory.", location, tempOrPermanent);
            }
            first = false;
            final File dir = initializeDirectory(location, isTemp, tempOrPermanent);
            if (dir != null) {
                return dir;
            }
        }

        throw new RuntimeException(String.format(
            "Could not find a writable %s directory. Check the server logs for more information.", tempOrPermanent));
    }
private File initializeDirectory ( final String [ ] locations , final boolean isTemp ) { final String tempOrPermanent = ( isTemp ) ? "temporary" : "permanent" ; boolean first = true ; for ( final String location : locations ) { if ( location == null ) { continue ; } if ( ! first ) { this . logger . warn ( "Falling back on [{}] as the {} directory." , location , tempOrPermanent ) ; } first = false ; final File dir = initializeDirectory ( location , isTemp , tempOrPermanent ) ; if ( dir != null ) { return dir ; } } throw new RuntimeException ( String . format ( "Could not find a writable %s directory. Check the server logs for more information." , tempOrPermanent ) ) ; }
@param locations the names of the directories to try to initialize ordered from best to worst. If none of these
can be initialized, the system will be halted.
@param isTemp true if the directory is a temporary directory.
@return the initialized directory as a {@link File} or null if the directory doesn't exist, cannot be created or
the passed name was null