Search in sources :

Example 1 with FileSystem

use of org.apache.jackrabbit.core.fs.FileSystem in project jackrabbit-oak by apache.

the class RepositoryUpgrade method loadProperties.

private Properties loadProperties(String path) throws RepositoryException {
    Properties properties = new Properties();
    FileSystem filesystem = source.getFileSystem();
    try {
        if (filesystem.exists(path)) {
            InputStream stream = filesystem.getInputStream(path);
            try {
                properties.load(stream);
            } finally {
                stream.close();
            }
        }
    } catch (FileSystemException e) {
        throw new RepositoryException(e);
    } catch (IOException e) {
        throw new RepositoryException(e);
    }
    return properties;
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) InputStream(java.io.InputStream) FileSystem(org.apache.jackrabbit.core.fs.FileSystem) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException) Properties(java.util.Properties) NodeStateCopier.copyProperties(org.apache.jackrabbit.oak.plugins.migration.NodeStateCopier.copyProperties)

Example 2 with FileSystem

use of org.apache.jackrabbit.core.fs.FileSystem 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 3 with FileSystem

use of org.apache.jackrabbit.core.fs.FileSystem in project jackrabbit by apache.

the class RepositoryImpl method createVersionManager.

/**
 * Creates the version manager.
 *
 * @param vConfig the versioning config
 * @return the newly created version manager
 * @throws RepositoryException if an error occurs
 */
protected InternalVersionManagerImpl createVersionManager(VersioningConfig vConfig, DelegatingObservationDispatcher delegatingDispatcher) throws RepositoryException {
    FileSystem fs = vConfig.getFileSystem();
    PersistenceManager pm = createPersistenceManager(vConfig.getHomeDir(), fs, vConfig.getPersistenceManagerConfig());
    ISMLocking ismLocking = vConfig.getISMLocking();
    return new InternalVersionManagerImpl(pm, fs, context.getNodeTypeRegistry(), delegatingDispatcher, SYSTEM_ROOT_NODE_ID, VERSION_STORAGE_NODE_ID, ACTIVITIES_NODE_ID, context.getItemStateCacheFactory(), ismLocking, context.getNodeIdFactory());
}
Also used : ISMLocking(org.apache.jackrabbit.core.state.ISMLocking) PersistenceManager(org.apache.jackrabbit.core.persistence.PersistenceManager) IterablePersistenceManager(org.apache.jackrabbit.core.persistence.IterablePersistenceManager) FileSystem(org.apache.jackrabbit.core.fs.FileSystem) InternalVersionManagerImpl(org.apache.jackrabbit.core.version.InternalVersionManagerImpl)

Example 4 with FileSystem

use of org.apache.jackrabbit.core.fs.FileSystem in project jackrabbit by apache.

the class RepositoryConfigurationParser method getFileSystemFactory.

/**
 * Creates and returns a factory object that creates {@link FileSystem}
 * instances based on the bean configuration at the named element.
 *
 * @param parent parent element
 * @param name name of the bean configuration element
 * @return file system factory
 * @throws ConfigurationException if the bean configuration is invalid
 */
protected FileSystemFactory getFileSystemFactory(Element parent, String name) throws ConfigurationException {
    final BeanConfig config = parseBeanConfig(parent, name);
    return new FileSystemFactory() {

        public FileSystem getFileSystem() throws RepositoryException {
            try {
                FileSystem fs = config.newInstance(FileSystem.class);
                fs.init();
                return fs;
            } catch (FileSystemException e) {
                throw new RepositoryException("File system initialization failure.", e);
            }
        }
    };
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) FileSystem(org.apache.jackrabbit.core.fs.FileSystem) RepositoryException(javax.jcr.RepositoryException) FileSystemFactory(org.apache.jackrabbit.core.fs.FileSystemFactory)

Example 5 with FileSystem

use of org.apache.jackrabbit.core.fs.FileSystem in project jackrabbit by apache.

the class RepositoryConfig method init.

/**
 * Initializes the repository configuration. This method loads the
 * configurations for all available workspaces.
 *
 * @throws ConfigurationException on initialization errors
 * @throws IllegalStateException if the repository configuration has already
 *                               been initialized
 */
public void init() throws ConfigurationException, IllegalStateException {
    // fsf is used below and this might be a DatabaseAware FileSystem
    try {
        cf.registerDataSources(dsc);
    } catch (RepositoryException e) {
        throw new ConfigurationException("failed to register data sources", e);
    }
    if (!workspaces.isEmpty()) {
        throw new IllegalStateException("Repository configuration has already been initialized.");
    }
    // Get the physical workspace root directory (create it if not found)
    File directory = new File(workspaceDirectory);
    if (!directory.exists()) {
        boolean directoryCreated = directory.mkdirs();
        if (!directoryCreated) {
            throw new ConfigurationException("Cannot create workspace root directory " + directory);
        }
    }
    // Get all workspace subdirectories
    if (workspaceConfigDirectory != null) {
        // rather than in physical workspace root directory on disk
        try {
            FileSystem fs = fsf.getFileSystem();
            try {
                if (!fs.exists(workspaceConfigDirectory)) {
                    fs.createFolder(workspaceConfigDirectory);
                } else {
                    String[] dirNames = fs.listFolders(workspaceConfigDirectory);
                    for (String dir : dirNames) {
                        String configDir = workspaceConfigDirectory + FileSystem.SEPARATOR + dir;
                        WorkspaceConfig wc = loadWorkspaceConfig(fs, configDir);
                        if (wc != null) {
                            addWorkspaceConfig(wc);
                        }
                    }
                }
            } finally {
                fs.close();
            }
        } catch (Exception e) {
            throw new ConfigurationException("error while loading workspace configurations from path " + workspaceConfigDirectory, e);
        }
    } else {
        // search for workspace configurations in physical workspace root
        // directory on disk
        File[] files = directory.listFiles();
        if (files == null) {
            throw new ConfigurationException("Invalid workspace root directory: " + workspaceDirectory);
        }
        for (File file : files) {
            WorkspaceConfig wc = loadWorkspaceConfig(file);
            if (wc != null) {
                addWorkspaceConfig(wc);
            }
        }
    }
    if (!workspaces.containsKey(defaultWorkspace)) {
        if (!workspaces.isEmpty()) {
            log.warn("Potential misconfiguration. No configuration found " + "for default workspace: " + defaultWorkspace);
        }
        // create initial default workspace
        createWorkspaceConfig(defaultWorkspace, (StringBuffer) null);
    }
}
Also used : TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) FileSystem(org.apache.jackrabbit.core.fs.FileSystem) RepositoryException(javax.jcr.RepositoryException) File(java.io.File) TransformerException(javax.xml.transform.TransformerException) RepositoryException(javax.jcr.RepositoryException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException)

Aggregations

FileSystem (org.apache.jackrabbit.core.fs.FileSystem)13 RepositoryException (javax.jcr.RepositoryException)8 IOException (java.io.IOException)5 FileSystemException (org.apache.jackrabbit.core.fs.FileSystemException)5 FileSystemResource (org.apache.jackrabbit.core.fs.FileSystemResource)4 File (java.io.File)3 OutputStreamWriter (java.io.OutputStreamWriter)3 MemoryFileSystem (org.apache.jackrabbit.core.fs.mem.MemoryFileSystem)3 PrivilegeDefinitionWriter (org.apache.jackrabbit.spi.commons.privilege.PrivilegeDefinitionWriter)3 OutputStream (java.io.OutputStream)2 Writer (java.io.Writer)2 ArrayList (java.util.ArrayList)2 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)2 TransformerException (javax.xml.transform.TransformerException)2 RetentionRegistryImpl (org.apache.jackrabbit.core.retention.RetentionRegistryImpl)2 Name (org.apache.jackrabbit.spi.Name)2 NameFactory (org.apache.jackrabbit.spi.NameFactory)2 PrivilegeDefinition (org.apache.jackrabbit.spi.PrivilegeDefinition)2 PathResolver (org.apache.jackrabbit.spi.commons.conversion.PathResolver)2 PrivilegeDefinitionImpl (org.apache.jackrabbit.spi.commons.privilege.PrivilegeDefinitionImpl)2