+ // restart repository
+ if (restartAndClearCaches) {
+ JackrabbitDataModelMigration
+ .clearRepositoryCaches(repositoryConfig);
+ ((JackrabbitRepository) repository).shutdown();
+ createJackrabbitRepository();
+ }
+
+ // set data model version
+ try {
+ session = login();
+ } catch (RepositoryException e) {
+ throw new ArgeoException("Cannot login to migrated repository", e);
+ }
+
+ for (JackrabbitDataModelMigration dataModelMigration : new TreeSet<JackrabbitDataModelMigration>(
+ dataModelMigrations)) {
+ try {
+ if (session.itemExists(dataModelMigration
+ .getDataModelNodePath())) {
+ Node dataModelNode = session.getNode(dataModelMigration
+ .getDataModelNodePath());
+ dataModelNode.setProperty(
+ ArgeoNames.ARGEO_DATA_MODEL_VERSION,
+ dataModelMigration.getTargetVersion());
+ session.save();
+ }
+ } catch (Exception e) {
+ log.error("Cannot set model version", e);
+ }
+ }
+ JcrUtils.logoutQuietly(session);
+
+ }
+
+ /** Lazy init. */
+ protected File getHomeDirectory() {
+ try {
+ if (homeDirectory == null) {
+ if (inMemory) {
+ homeDirectory = new File(
+ System.getProperty("java.io.tmpdir")
+ + File.separator
+ + System.getProperty("user.name")
+ + File.separator + "jackrabbit-"
+ + UUID.randomUUID());
+ homeDirectory.mkdirs();
+ // will it work if directory is not empty?
+ homeDirectory.deleteOnExit();
+ }
+ }
+
+ return homeDirectory.getCanonicalFile();
+ } catch (IOException e) {
+ throw new ArgeoException("Cannot get canonical file for "
+ + homeDirectory, e);
+ }
+ }
+
+ public void dispose() throws Exception {
+ long begin = System.currentTimeMillis();
+ if (repository != null) {
+ if (repository instanceof JackrabbitRepository)
+ ((JackrabbitRepository) repository).shutdown();
+ else if (repository instanceof RepositoryImpl)
+ ((RepositoryImpl) repository).shutdown();
+ else if (repository instanceof TransientRepository)
+ ((TransientRepository) repository).shutdown();
+ }
+
+ if (inMemory)
+ if (getHomeDirectory().exists()) {
+ FileUtils.deleteDirectory(getHomeDirectory());
+ if (log.isDebugEnabled())
+ log.debug("Deleted Jackrabbit home directory "
+ + getHomeDirectory());
+ }
+
+ double duration = ((double) (System.currentTimeMillis() - begin)) / 1000;
+ if (uri != null && !uri.trim().equals(""))
+ log.info("Destroyed Jackrabbit repository with uri " + uri);
+ else
+ log.info("Destroyed Jackrabbit repository in " + duration
+ + " s, home: " + getHomeDirectory() + ", config "
+ + configuration);
+ }
+
+ /**
+ * @deprecated explicitly declare {@link #dispose()} as destroy-method
+ * instead.
+ */
+ public void destroy() throws Exception {
+ log.error("## Declare destroy-method=\"dispose\". in the Jackrabbit container bean");
+ }
+
+ /** @deprecated explicitly declare {@link #init()} as init-method instead. */
+ public void afterPropertiesSet() throws Exception {
+ log.error("## Declare init-method=\"init\". in the Jackrabbit container bean");
+ }
+
+ protected Properties getConfigurationProperties() {