- protected void initImpl() throws Exception {
- if (repository != null) {
- // we are just wrapping another repository
- importNodeTypeDefinitions(repository);
- return;
- }
-
- // remote repository
- if (uri != null && !uri.trim().equals("")) {
- Map<String, String> params = new HashMap<String, String>();
- params.put(org.apache.jackrabbit.commons.JcrUtils.REPOSITORY_URI,
- uri);
- repository = new Jcr2davRepositoryFactory().getRepository(params);
- if (repository == null)
- throw new ArgeoException("Remote Davex repository " + uri
- + " not found");
- log.info("Initialized Jackrabbit repository " + repository
- + " from URI " + uri);
- // do not perform further initialization since we assume that the
- // remote repository has been properly configured
- return;
- }
-
- // local repository
- if (inMemory && homeDirectory.exists()) {
- FileUtils.deleteDirectory(homeDirectory);
- log.warn("Deleted Jackrabbit home directory " + homeDirectory);
- }
-
- RepositoryConfig config;
- Properties vars = getConfigurationProperties();
- InputStream in = configuration.getInputStream();
- try {
- vars.put(RepositoryConfigurationParser.REPOSITORY_HOME_VARIABLE,
- homeDirectory.getCanonicalPath());
- config = RepositoryConfig.create(new InputSource(in), vars);
- } catch (Exception e) {
- throw new RuntimeException("Cannot read configuration", e);
- } finally {
- IOUtils.closeQuietly(in);
- }