branch.merge(EmptyHook.INSTANCE);
} catch (CommitFailedException e) {
throw new RuntimeException(e);
}
// TODO reconsider
Root root = new RootImpl(store, commitHook, workspaceName, SystemSubject.INSTANCE, new OpenSecurityProvider(), indexProvider);
UserConfiguration userConfiguration = securityProvider.getConfiguration(UserConfiguration.class);
UserManager userManager = userConfiguration.getUserManager(root, NamePathMapper.DEFAULT);
String errorMsg = "Failed to initialize user content.";
try {
NodeUtil rootTree = checkNotNull(new NodeUtil(root.getTree("/")));
NodeUtil index = rootTree.getOrAddChild(IndexConstants.INDEX_DEFINITIONS_NAME, JcrConstants.NT_UNSTRUCTURED);
if (!index.hasChild("authorizableId")) {
IndexUtils.createIndexDefinition(index, "authorizableId", true, new String[]{REP_AUTHORIZABLE_ID}, null);
}
if (!index.hasChild("principalName")) {
IndexUtils.createIndexDefinition(index, "principalName", true,
new String[]{REP_PRINCIPAL_NAME},
new String[]{NT_REP_AUTHORIZABLE});
}
if (!index.hasChild("members")) {
IndexUtils.createIndexDefinition(index, "members", false, new String[]{UserConstants.REP_MEMBERS}, null);
}
ConfigurationParameters params = userConfiguration.getParameters();
String adminId = params.getConfigValue(PARAM_ADMIN_ID, DEFAULT_ADMIN_ID);
if (userManager.getAuthorizable(adminId) == null) {
userManager.createUser(adminId, params.getNullableConfigValue(PARAM_ADMIN_PW, adminId));
}
String anonymousId = params.getConfigValue(PARAM_ANONYMOUS_ID, DEFAULT_ANONYMOUS_ID);
if (userManager.getAuthorizable(anonymousId) == null) {
userManager.createUser(anonymousId, null);
}
if (root.hasPendingChanges()) {
root.commit();
}
} catch (RepositoryException e) {
log.error(errorMsg, e);
throw new RuntimeException(e);
} catch (CommitFailedException e) {