Root root = new SystemRoot(store, EmptyHook.INSTANCE, workspaceName,
securityProvider, new QueryEngineSettings(),
new CompositeQueryIndexProvider(new PropertyIndexProvider(),
new NodeTypeIndexProvider()));
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});
}
ConfigurationParameters params = userConfiguration.getParameters();
String adminId = params.getConfigValue(PARAM_ADMIN_ID, DEFAULT_ADMIN_ID);
if (userManager.getAuthorizable(adminId) == null) {
boolean omitPw = params.getConfigValue(PARAM_OMIT_ADMIN_PW, false);
userManager.createUser(adminId, (omitPw) ? null : adminId);
}