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;
}
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;
}
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());
}
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);
}
}
};
}
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);
}
}
Aggregations