private Boolean autocreateWorkspaces = false;
private Executor systemExecutor;
+ private Credentials adminCredentials;
public void afterPropertiesSet() throws Exception {
// remote repository
throw new ArgeoException("Remote Davex repository " + uri
+ " not found");
log.info("Initialized Jackrabbit repository " + repository
- + " from uri " + uri);
+ + " from URI " + uri);
// do not perform further initialization since we assume that the
// remote repository has been properly configured
return;
else
repository = RepositoryImpl.create(config);
- importNodeTypeDefinitions(repository);
+ if (cndFiles != null && cndFiles.size() > 0)
+ importNodeTypeDefinitions(repository);
log.info("Initialized Jackrabbit repository " + repository + " in "
+ homeDirectory + " with config " + configuration);
* will be thrown.
*/
protected void importNodeTypeDefinitions(final Repository repository) {
+ final Credentials credentialsToUse;
if (systemExecutor == null) {
- log.warn("No system executor found");
- return;
+ if (adminCredentials == null)
+ throw new ArgeoException(
+ "No system executor or admin credentials found");
+ credentialsToUse = adminCredentials;
+ } else {
+ credentialsToUse = null;
}
- systemExecutor.execute(new Runnable() {
+ Runnable action = new Runnable() {
public void run() {
Reader reader = null;
Session session = null;
try {
- session = repository.login();
+ session = repository.login(credentialsToUse);
+ processNewSession(session);
// Load cnds as resources
for (String resUrl : cndFiles) {
Resource res = resourceLoader.getResource(resUrl);
JcrUtils.logoutQuietly(session);
}
}
- });
+ };
+ if (systemExecutor != null)
+ systemExecutor.execute(action);
+ else
+ action.run();
}
-
+
public void destroy() throws Exception {
if (repository != null) {
if (repository instanceof JackrabbitRepository)
try {
NamespaceHelper namespaceHelper = new NamespaceHelper(session);
namespaceHelper.registerNamespaces(namespaces);
+
} catch (Exception e) {
throw new ArgeoException("Cannot process new session", e);
}
this.systemExecutor = systemExecutor;
}
+ public void setAdminCredentials(Credentials adminCredentials) {
+ this.adminCredentials = adminCredentials;
+ }
+
}