public FileDataStore()

in src/main/java/org/apache/sling/installer/core/impl/FileDataStore.java [84:128]


    public FileDataStore( final BundleContext bundleContext ) {
        String location = bundleContext.getProperty(CONFIG_DIR);

        // no configured location, use the config dir in the bundle persistent
        // area
        if ( location == null ) {
            final File locationFile = bundleContext.getDataFile( DEFAULT_DIR );
            if ( locationFile != null ) {
                location = locationFile.getAbsolutePath();
            }
        }

        // fall back to the current working directory if the platform does
        // not support filesystem based data area
        if ( location == null ) {
            location = System.getProperty( "user.dir" ) + File.separatorChar + DEFAULT_DIR;
        }

        // ensure the file is absolute
        File locationFile = new File( location );
        if ( !locationFile.isAbsolute() ) {
            final File bundleLocationFile = bundleContext.getDataFile( locationFile.getPath() );
            if ( bundleLocationFile != null ) {
                locationFile = bundleLocationFile;
            }

            // ensure the file object is an absolute file object
            locationFile = locationFile.getAbsoluteFile();
        }

        // check the location
        if ( !locationFile.isDirectory() ) {
            if ( locationFile.exists() ) {
                throw new IllegalArgumentException( location + " is not a directory" );
            }

            if ( !locationFile.mkdirs() ) {
                throw new IllegalArgumentException( "Cannot create directory " + location );
            }
        }

        this.directory = locationFile;
        SHARED = this;
        log.debug("FileDataStore setup with directory={}", safePath(directory));
    }