import javax.jcr.RepositoryException;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jackrabbit.core.RepositoryContext;
import org.apache.jackrabbit.core.cache.CacheManager;
import org.apache.jackrabbit.core.config.RepositoryConfig;
import org.apache.jackrabbit.core.config.RepositoryConfigurationParser;
+import org.argeo.api.NodeConstants;
import org.argeo.cms.CmsException;
import org.argeo.cms.internal.kernel.CmsPaths;
import org.argeo.jcr.ArgeoJcrException;
-import org.argeo.node.NodeConstants;
import org.xml.sax.InputSource;
/** Can interpret properties in order to create an actual JCR repository. */
public class RepositoryBuilder {
private final static Log log = LogFactory.getLog(RepositoryBuilder.class);
- public RepositoryContext createRepositoryContext(Dictionary<String, ?> properties) throws RepositoryException {
+ public RepositoryContext createRepositoryContext(Dictionary<String, ?> properties)
+ throws RepositoryException, IOException {
RepositoryConfig repositoryConfig = createRepositoryConfig(properties);
RepositoryContext repositoryContext = createJackrabbitRepository(repositoryConfig);
RepositoryImpl repository = repositoryContext.getRepository();
return repositoryContext;
}
- RepositoryConfig createRepositoryConfig(Dictionary<String, ?> properties) throws RepositoryException {
+ RepositoryConfig createRepositoryConfig(Dictionary<String, ?> properties) throws RepositoryException, IOException {
JackrabbitType type = JackrabbitType.valueOf(prop(properties, RepoConf.type).toString());
ClassLoader cl = getClass().getClassLoader();
- InputStream in = null;
- try {
- final String base = "/org/argeo/cms/internal/jcr";
- in = cl.getResourceAsStream(base + "/repository-" + type.name() + ".xml");
-
+ final String base = "/org/argeo/cms/internal/jcr";
+ try (InputStream in = cl.getResourceAsStream(base + "/repository-" + type.name() + ".xml")) {
if (in == null)
throw new ArgeoJcrException("Repository configuration not found");
InputSource config = new InputSource(in);
Properties jackrabbitVars = getConfigurationProperties(type, properties);
RepositoryConfig repositoryConfig = RepositoryConfig.create(config, jackrabbitVars);
return repositoryConfig;
- } finally {
- IOUtils.closeQuietly(in);
}
}