import org.apache.jackrabbit.core.config.RepositoryConfig;
import org.apache.jackrabbit.core.config.RepositoryConfigurationParser;
import org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory;
-import org.argeo.ArgeoException;
import org.argeo.jcr.ArgeoJcrConstants;
import org.argeo.jcr.ArgeoJcrException;
import org.springframework.core.io.ClassPathResource;
* Jackrabbit repositories
*/
public class JackrabbitRepositoryFactory implements RepositoryFactory, ArgeoJcrConstants {
-
private final static Log log = LogFactory.getLog(JackrabbitRepositoryFactory.class);
private Resource fileRepositoryConfiguration = new ClassPathResource("/org/argeo/jackrabbit/repository-h2.xml");
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({ "rawtypes" })
public Repository getRepository(Map parameters) throws RepositoryException {
// // check if can be found by alias
// Repository repository = super.getRepository(parameters);
repository = createRemoteRepository(uri);
else if (uri.startsWith("file"))// http, https
repository = createFileRepository(uri, parameters);
- else if (uri.startsWith("vm")) {
- log.warn("URI "
- + uri
- + " should have been managed by generic JCR repository factory");
- repository = getRepositoryByAlias(getAliasFromURI(uri));
- }
- else
+ else if (uri.startsWith("vm")) {
+ log.warn("URI " + uri + " should have been managed by generic JCR repository factory");
+ repository = getRepositoryByAlias(getAliasFromURI(uri));
+ } else
throw new ArgeoJcrException("Unrecognized URI format " + uri);
}
params.put(JcrUtils.REPOSITORY_URI, uri);
Repository repository = new Jcr2davRepositoryFactory().getRepository(params);
if (repository == null)
- throw new ArgeoException("Remote Davex repository " + uri + " not found");
+ throw new ArgeoJcrException("Remote Davex repository " + uri + " not found");
log.info("Initialized remote Jackrabbit repository from uri " + uri);
return repository;
}
String dirPath = uri.substring("file:".length());
File homeDir = new File(dirPath);
if (homeDir.exists() && !homeDir.isDirectory())
- throw new ArgeoException("Repository home " + dirPath + " is not a directory");
+ throw new ArgeoJcrException("Repository home " + dirPath + " is not a directory");
if (!homeDir.exists())
homeDir.mkdirs();
configurationIn = fileRepositoryConfiguration.getInputStream();
log.info("Initialized file Jackrabbit repository from uri " + uri);
return repository;
} catch (Exception e) {
- throw new ArgeoException("Cannot create repository " + uri, e);
+ throw new ArgeoJcrException("Cannot create repository " + uri, e);
} finally {
IOUtils.closeQuietly(configurationIn);
}
alias = alias.substring(0, alias.length() - 1);
return alias;
} catch (URISyntaxException e) {
- throw new ArgeoException("Cannot interpret URI " + uri, e);
+ throw new ArgeoJcrException("Cannot interpret URI " + uri, e);
}
}