Search in sources :

Example 1 with FileSystemBLOBStore

use of org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore 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 FileSystemBLOBStore

use of org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore 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 FileSystemBLOBStore

use of org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore 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 FileSystemBLOBStore

use of org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore in project jackrabbit by apache.

the class XMLPersistenceManager method init.

// ---------------------------------------------------< PersistenceManager >
/**
 * {@inheritDoc}
 */
public void init(PMContext context) throws Exception {
    if (initialized) {
        throw new IllegalStateException("already initialized");
    }
    itemStateFS = new BasedFileSystem(context.getFileSystem(), "/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) File(java.io.File) FileSystemBLOBStore(org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore)

Example 5 with FileSystemBLOBStore

use of org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore in project jackrabbit by apache.

the class InMemPersistenceManager method init.

// ---------------------------------------------------< PersistenceManager >
/**
 * {@inheritDoc}
 */
public void init(PMContext context) throws Exception {
    if (initialized) {
        throw new IllegalStateException("already initialized");
    }
    stateStore = new HashMap<ItemId, byte[]>(initialCapacity, loadFactor);
    refsStore = new HashMap<NodeId, byte[]>(initialCapacity, loadFactor);
    wspFS = context.getFileSystem();
    // Choose a FileSystem for the BlobStore based on whether data is persistent or not
    if (persistent) {
        blobFS = new LocalFileSystem();
        ((LocalFileSystem) blobFS).setRoot(new File(context.getHomeDir(), "blobs"));
    } else {
        blobFS = new MemoryFileSystem();
    }
    blobFS.init();
    blobStore = new FileSystemBLOBStore(blobFS);
    if (persistent) {
        // deserialize contents of state and refs stores
        loadContents();
    }
    initialized = true;
}
Also used : MemoryFileSystem(org.apache.jackrabbit.core.fs.mem.MemoryFileSystem) LocalFileSystem(org.apache.jackrabbit.core.fs.local.LocalFileSystem) NodeId(org.apache.jackrabbit.core.id.NodeId) ItemId(org.apache.jackrabbit.core.id.ItemId) File(java.io.File) FileSystemBLOBStore(org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore)

Aggregations

File (java.io.File)5 LocalFileSystem (org.apache.jackrabbit.core.fs.local.LocalFileSystem)5 FileSystemBLOBStore (org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore)5 BasedFileSystem (org.apache.jackrabbit.core.fs.BasedFileSystem)2 NodeId (org.apache.jackrabbit.core.id.NodeId)2 DatabaseMetaData (java.sql.DatabaseMetaData)1 SQLException (java.sql.SQLException)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 BundleBinding (org.apache.jackrabbit.core.persistence.util.BundleBinding)1