}
protected void mount(String creds, String wsp, String root, String config,
String filter, boolean remount) {
if (!isConnected()) {
throw new ExecutionException("Not connected to repository.");
}
if (!isLoggedIn()) {
login(creds, wsp);
}
if (isMounted()) {
if (remount) {
unmount();
} else {
log.info("Filesystem already mounted.");
return;
}
}
if (root == null) {
root = getProperty(KEY_DEFAULT_MOUNTPOINT);
}
if (config == null) {
config = getProperty(KEY_DEFAULT_CONFIG_XML);
}
if (filter == null) {
filter = getProperty(KEY_DEFAULT_FILTER_XML);
}
try {
StringBuffer uri = new StringBuffer(getProperty(KEY_DEFAULT_URI));
uri.append("/").append(session.getWorkspace().getName());
if (root != null && !"/".equals(root)) {
uri.append(root);
}
RepositoryAddress mp =
new RepositoryAddress(uri.toString());
log.info("Mounting JcrFs on {}", mp.toString());
ExportRoot exportRoot = ExportRoot.findRoot(getPlatformFile("", true));
MetaInf inf = exportRoot == null ? null : exportRoot.getMetaInf();
// get config
VaultFsConfig jcrfsConfig = null;
if (config != null) {
File configFile = new File(config);
if (configFile.canRead()) {
jcrfsConfig = AbstractVaultFsConfig.load(configFile);
log.info("using {}", configFile.getCanonicalPath());
}
}
if (jcrfsConfig == null && inf != null) {
jcrfsConfig = inf.getConfig();
if (jcrfsConfig != null) {
log.info("using config from {}", exportRoot.getMetaDir().getPath());
}
}
if (jcrfsConfig == null) {
log.info("using embeded default config");
}
// get workspace filter
WorkspaceFilter wspFilter = null;
if (filter != null) {
File filterFile = new File(filter);
if (filterFile.canRead()) {
wspFilter = new DefaultWorkspaceFilter();
((DefaultWorkspaceFilter) wspFilter).load(filterFile);
log.info("using {}", filterFile.getCanonicalPath());
}
}
if (wspFilter == null && inf != null) {
wspFilter = inf.getFilter();
if (wspFilter != null) {
log.info("using filter from {}", exportRoot.getMetaDir().getPath());
}
}
if (wspFilter == null) {
log.info("using embeded default filter");
}
fs = Mounter.mount(jcrfsConfig, wspFilter, mp, null, session);
} catch (Exception e) {
throw new ExecutionException("Unable to mount filesystem.", e);
}
try {
// install aggregate context
ctxAfct = new AggregateExecutionContext(this, "agg", fs.getAggregateManager().getRoot());
console.addContext(ctxAfct);
} catch (RepositoryException e) {
log.error("Internal error during mount. unmounting.");
try {
fs.unmount();
} catch (RepositoryException e1) {
// ignore
}
fs = null;
throw new ExecutionException("Error during mount.", e);
}
// install vault fs context
ctxJcrfs = new VaultFsExecutionContext(this, "vlt", fs.getRoot());
console.addContext(ctxJcrfs);