public void setDirectory ( final String directory ) { this . directory = new File ( this . configuration . getDirectory ( ) , directory ) ; if ( ! this . directory . exists ( ) ) { throw new IllegalArgumentException ( String . format ( "Directory does not exist: %s.\n" + "Configuration contained value %s which is supposed to be relative to " + "configuration directory." , this . directory , directory ) ) ; } if ( ! this . directory . getAbsolutePath ( ) . startsWith ( this . configuration . getDirectory ( ) . getAbsolutePath ( ) ) ) { throw new IllegalArgumentException ( String . format ( "All files and directories must be contained in the configuration directory the " + "directory provided in the configuration breaks that contract: %s in config " + "file resolved to %s." , directory , this . directory ) ) ; } }
Set the directory and test that the directory exists and is contained within the Configuration directory .