Search in sources :

Example 6 with LocalFileSystem

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

the class SearchIndex method createSynonymProviderConfigResource.

/**
 * Creates a file system resource to the synonym provider configuration.
 *
 * @return a file system resource or <code>null</code> if no path was
 *         configured.
 * @throws FileSystemException if an exception occurs accessing the file
 *                             system.
 * @throws IOException         if another exception occurs.
 */
protected FileSystemResource createSynonymProviderConfigResource() throws FileSystemException, IOException {
    if (synonymProviderConfigPath != null) {
        FileSystemResource fsr;
        // simple sanity check
        if (synonymProviderConfigPath.endsWith(FileSystem.SEPARATOR)) {
            throw new FileSystemException("Invalid synonymProviderConfigPath: " + synonymProviderConfigPath);
        }
        if (fs == null) {
            fs = new LocalFileSystem();
            int lastSeparator = synonymProviderConfigPath.lastIndexOf(FileSystem.SEPARATOR_CHAR);
            if (lastSeparator != -1) {
                File root = new File(path, synonymProviderConfigPath.substring(0, lastSeparator));
                ((LocalFileSystem) fs).setRoot(root.getCanonicalFile());
                fs.init();
                fsr = new FileSystemResource(fs, synonymProviderConfigPath.substring(lastSeparator + 1));
            } else {
                ((LocalFileSystem) fs).setPath(path);
                fs.init();
                fsr = new FileSystemResource(fs, synonymProviderConfigPath);
            }
            synonymProviderConfigFs = fs;
        } else {
            fsr = new FileSystemResource(fs, synonymProviderConfigPath);
        }
        return fsr;
    } else {
        // path not configured
        return null;
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) LocalFileSystem(org.apache.jackrabbit.core.fs.local.LocalFileSystem) FileSystemResource(org.apache.jackrabbit.core.fs.FileSystemResource) File(java.io.File)

Example 7 with LocalFileSystem

use of org.apache.jackrabbit.core.fs.local.LocalFileSystem 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 8 with LocalFileSystem

use of org.apache.jackrabbit.core.fs.local.LocalFileSystem 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)

Example 9 with LocalFileSystem

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

the class MultiDataStore method init.

/**
 * {@inheritDoc}
 */
public void init(String homeDir) throws RepositoryException {
    if (delayedDelete) {
        // First initialize the identifiersToDeleteFile
        LocalFileSystem fileSystem = new LocalFileSystem();
        fileSystem.setRoot(new File(homeDir));
        identifiersToDeleteFile = new FileSystemResource(fileSystem, FileSystem.SEPARATOR + IDENTIFIERS_TO_DELETE_FILE_KEY);
    }
    moveDataTaskThread = new Thread(new MoveDataTask(), "Jackrabbit-MulitDataStore-MoveDataTaskThread");
    moveDataTaskThread.setDaemon(true);
    moveDataTaskThread.start();
    log.info("MultiDataStore-MoveDataTask thread started; first run scheduled at " + moveDataTaskNextRun.getTime());
    if (delayedDelete) {
        try {
            // delayedDeleteSleep timeout ...
            if (identifiersToDeleteFile != null && identifiersToDeleteFile.exists() && (identifiersToDeleteFile.lastModified() + (delayedDeleteSleep * 1000)) < System.currentTimeMillis()) {
                deleteDelayedIdentifiersTaskThread = new Thread(// Start immediately ...
                new DeleteDelayedIdentifiersTask(0L), "Jackrabbit-MultiDataStore-DeleteDelayedIdentifiersTaskThread");
                deleteDelayedIdentifiersTaskThread.setDaemon(true);
                deleteDelayedIdentifiersTaskThread.start();
                log.info("Old entries in the " + IDENTIFIERS_TO_DELETE_FILE_KEY + " File found. DeleteDelayedIdentifiersTask-Thread started now.");
            }
        } catch (FileSystemException e) {
            throw new RepositoryException("I/O error while reading from '" + identifiersToDeleteFile.getPath() + "'", e);
        }
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) LocalFileSystem(org.apache.jackrabbit.core.fs.local.LocalFileSystem) RepositoryException(javax.jcr.RepositoryException) FileSystemResource(org.apache.jackrabbit.core.fs.FileSystemResource) 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