Search in sources :

Example 1 with LocalFileSystem

use of org.apache.jackrabbit.core.fs.local.LocalFileSystem in project jackrabbit by apache.

the class DatabasePersistenceManager method init.

// ---------------------------------------------------< PersistenceManager >
/**
 * {@inheritDoc}
 */
public void init(PMContext context) throws Exception {
    if (initialized) {
        throw new IllegalStateException("already initialized");
    }
    // setup jdbc connection
    initConnection();
    DatabaseMetaData meta = con.getMetaData();
    try {
        log.info("Database: " + meta.getDatabaseProductName() + " / " + meta.getDatabaseProductVersion());
        log.info("Driver: " + meta.getDriverName() + " / " + meta.getDriverVersion());
    } catch (SQLException e) {
        log.warn("Can not retrieve database and driver name / version", e);
    }
    // make sure schemaObjectPrefix consists of legal name characters only
    prepareSchemaObjectPrefix();
    // check if schema objects exist and create them if necessary
    if (isSchemaCheckEnabled()) {
        checkSchema();
    }
    // build sql statements
    buildSQLStatements();
    // prepare statements
    initPreparedStatements();
    if (externalBLOBs) {
        /**
         * store BLOBs in local file system in a sub directory
         * of the workspace home directory
         */
        LocalFileSystem blobFS = new LocalFileSystem();
        blobFS.setRoot(new File(context.getHomeDir(), "blobs"));
        blobFS.init();
        this.blobFS = blobFS;
        blobStore = new FileSystemBLOBStore(blobFS);
    } else {
        /**
         * store BLOBs in db
         */
        blobStore = new DbBLOBStore();
    }
    initialized = true;
}
Also used : SQLException(java.sql.SQLException) LocalFileSystem(org.apache.jackrabbit.core.fs.local.LocalFileSystem) DatabaseMetaData(java.sql.DatabaseMetaData) File(java.io.File) FileSystemBLOBStore(org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore)

Example 2 with LocalFileSystem

use of org.apache.jackrabbit.core.fs.local.LocalFileSystem in project jackrabbit by apache.

the class InMemBundlePersistenceManager method init.

// ---------------------------------------------------< PersistenceManager >
/**
 * {@inheritDoc}
 */
public void init(PMContext context) throws Exception {
    if (initialized) {
        throw new IllegalStateException("already initialized");
    }
    super.init(context);
    // initialize mem stores
    bundleStore = new LinkedHashMap<NodeId, byte[]>(initialCapacity, loadFactor);
    refsStore = new HashMap<NodeId, byte[]>(initialCapacity, loadFactor);
    // Choose a FileSystem for the BlobStore based on whether data is persistent or not
    if (useFileBlobStore) {
        blobFS = new LocalFileSystem();
        ((LocalFileSystem) blobFS).setRoot(new File(context.getHomeDir(), "blobs"));
        blobFS.init();
        blobStore = new FileSystemBLOBStore(blobFS);
    } else {
        blobStore = new InMemBLOBStore();
    }
    wspFS = context.getFileSystem();
    // load namespaces
    binding = new BundleBinding(errorHandling, blobStore, getNsIndex(), getNameIndex(), context.getDataStore());
    binding.setMinBlobSize(minBlobSize);
    if (persistent) {
        // deserialize contents of the stores
        loadContents();
    }
    initialized = true;
}
Also used : LocalFileSystem(org.apache.jackrabbit.core.fs.local.LocalFileSystem) NodeId(org.apache.jackrabbit.core.id.NodeId) BundleBinding(org.apache.jackrabbit.core.persistence.util.BundleBinding) File(java.io.File) FileSystemBLOBStore(org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore)

Example 3 with LocalFileSystem

use of org.apache.jackrabbit.core.fs.local.LocalFileSystem in project jackrabbit by apache.

the class ObjectPersistenceManager method init.

// ---------------------------------------------------< PersistenceManager >
/**
 * {@inheritDoc}
 */
public void init(PMContext context) throws Exception {
    if (initialized) {
        throw new IllegalStateException("already initialized");
    }
    FileSystem wspFS = context.getFileSystem();
    itemStateFS = new BasedFileSystem(wspFS, "/data");
    /**
     * store BLOB data in local file system in a sub directory
     * of the workspace home directory
     */
    LocalFileSystem blobFS = new LocalFileSystem();
    blobFS.setRoot(new File(context.getHomeDir(), "blobs"));
    blobFS.init();
    this.blobFS = blobFS;
    blobStore = new FileSystemBLOBStore(blobFS);
    initialized = true;
}
Also used : BasedFileSystem(org.apache.jackrabbit.core.fs.BasedFileSystem) LocalFileSystem(org.apache.jackrabbit.core.fs.local.LocalFileSystem) LocalFileSystem(org.apache.jackrabbit.core.fs.local.LocalFileSystem) BasedFileSystem(org.apache.jackrabbit.core.fs.BasedFileSystem) FileSystem(org.apache.jackrabbit.core.fs.FileSystem) File(java.io.File) FileSystemBLOBStore(org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore)

Example 4 with LocalFileSystem

use of org.apache.jackrabbit.core.fs.local.LocalFileSystem in project jackrabbit by apache.

the class BundleFsPersistenceManager method init.

/**
 * {@inheritDoc}
 */
public void init(PMContext context) throws Exception {
    if (initialized) {
        throw new IllegalStateException("already initialized");
    }
    super.init(context);
    this.name = context.getHomeDir().getName();
    // create item fs
    itemFs = new BasedFileSystem(context.getFileSystem(), "items");
    // create correct blob store
    if (useLocalFsBlobStore()) {
        LocalFileSystem blobFS = new LocalFileSystem();
        blobFS.setRoot(new File(context.getHomeDir(), "blobs"));
        blobFS.init();
        blobStore = new BundleFsPersistenceManager.FSBlobStore(blobFS);
    } else {
        blobStore = new BundleFsPersistenceManager.FSBlobStore(itemFs);
    }
    // load namespaces
    binding = new BundleBinding(errorHandling, blobStore, getNsIndex(), getNameIndex(), context.getDataStore());
    binding.setMinBlobSize(minBlobSize);
    initialized = true;
}
Also used : BasedFileSystem(org.apache.jackrabbit.core.fs.BasedFileSystem) LocalFileSystem(org.apache.jackrabbit.core.fs.local.LocalFileSystem) BundleBinding(org.apache.jackrabbit.core.persistence.util.BundleBinding) File(java.io.File)

Example 5 with LocalFileSystem

use of org.apache.jackrabbit.core.fs.local.LocalFileSystem in project jackrabbit by apache.

the class BundleDbPersistenceManager method createLocalFSBlobStore.

/**
 * Creates a blob store that is based on a local fs. This is called by
 * init if {@link #useLocalFsBlobStore()} returns <code>true</code>.
 *
 * @param context the persistence manager context
 * @return a blob store
 * @throws Exception if an error occurs.
 */
protected CloseableBLOBStore createLocalFSBlobStore(PMContext context) throws Exception {
    /**
     * store blob's in local file system in a sub directory
     * of the workspace home directory
     */
    LocalFileSystem blobFS = new LocalFileSystem();
    blobFS.setRoot(new File(context.getHomeDir(), "blobs"));
    blobFS.init();
    return new FSBlobStore(blobFS);
}
Also used : LocalFileSystem(org.apache.jackrabbit.core.fs.local.LocalFileSystem) File(java.io.File)

Aggregations

File (java.io.File)9 LocalFileSystem (org.apache.jackrabbit.core.fs.local.LocalFileSystem)9 FileSystemBLOBStore (org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore)5 BasedFileSystem (org.apache.jackrabbit.core.fs.BasedFileSystem)3 FileSystemException (org.apache.jackrabbit.core.fs.FileSystemException)2 FileSystemResource (org.apache.jackrabbit.core.fs.FileSystemResource)2 NodeId (org.apache.jackrabbit.core.id.NodeId)2 BundleBinding (org.apache.jackrabbit.core.persistence.util.BundleBinding)2 DatabaseMetaData (java.sql.DatabaseMetaData)1 SQLException (java.sql.SQLException)1 RepositoryException (javax.jcr.RepositoryException)1 FileSystem (org.apache.jackrabbit.core.fs.FileSystem)1 MemoryFileSystem (org.apache.jackrabbit.core.fs.mem.MemoryFileSystem)1 ItemId (org.apache.jackrabbit.core.id.ItemId)1