test_class.declarator: userMgr
test_class.modifier: private
test_class.original_string: private UserManager userMgr;
test_class.type: UserManager
test_class.var_name: userMgr
test_class.declarator: config
test_class.modifier: private
test_class.original_string: private ConfigurationParameters config;
test_class.type: ConfigurationParameters
test_class.var_name: config
test_class.file: oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserInitializerTest.java
test_class.identifier: UserInitializerTest
test_class.superclass: extends AbstractSecurityTest
test_case.body: @Test
      public void testSecondInit() {
          NodeBuilder builder = spy(getTreeProvider().asNodeState(root.getTree(PathUtils.ROOT_PATH)).builder());
  
          UserInitializer ui = new UserInitializer(getSecurityProvider());
          ui.initialize(builder, adminSession.getWorkspaceName());
  
          verify(builder, never()).child(anyString());
      }
test_case.class_method_signature: UserInitializerTest.testSecondInit()
test_case.full_signature: @Test public void testSecondInit()
test_case.identifier: testSecondInit
test_case.invocations: spy builder asNodeState getTreeProvider getTree getSecurityProvider initialize getWorkspaceName child verify never anyString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSecondInit()
focal_class.declarator: log = LoggerFactory.getLogger(UserInitializer.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(UserInitializer.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: securityProvider
focal_class.modifier: private final
focal_class.original_string: private final SecurityProvider securityProvider;
focal_class.type: SecurityProvider
focal_class.var_name: securityProvider
focal_class.declarator: queryIndexProvider = new CompositeQueryIndexProvider(new PropertyIndexProvider(),
              new NodeTypeIndexProvider())
focal_class.modifier: private
focal_class.original_string: private QueryIndexProvider queryIndexProvider = new CompositeQueryIndexProvider(new PropertyIndexProvider(),
              new NodeTypeIndexProvider());
focal_class.type: QueryIndexProvider
focal_class.var_name: queryIndexProvider
focal_class.file: oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserInitializer.java
focal_class.identifier: UserInitializer
focal_class.interfaces: implements WorkspaceInitializer, UserConstants, QueryIndexProviderAware
focal_class.class_method_signature: UserInitializer.UserInitializer(@NotNull SecurityProvider securityProvider)
focal_class.full_signature:   UserInitializer(@NotNull SecurityProvider securityProvider)
focal_class.identifier: UserInitializer
focal_class.parameters: (@NotNull SecurityProvider securityProvider)
focal_class.signature:  UserInitializer(@NotNull SecurityProvider securityProvider)
focal_class.class_method_signature: UserInitializer.initialize(NodeBuilder builder, String workspaceName)
focal_class.full_signature: @Override public void initialize(NodeBuilder builder, String workspaceName)
focal_class.identifier: initialize
focal_class.modifiers: @Override public
focal_class.parameters: (NodeBuilder builder, String workspaceName)
focal_class.return: void
focal_class.signature: void initialize(NodeBuilder builder, String workspaceName)
focal_class.class_method_signature: UserInitializer.setQueryIndexProvider(QueryIndexProvider provider)
focal_class.full_signature: @Override public void setQueryIndexProvider(QueryIndexProvider provider)
focal_class.identifier: setQueryIndexProvider
focal_class.modifiers: @Override public
focal_class.parameters: (QueryIndexProvider provider)
focal_class.return: void
focal_class.signature: void setQueryIndexProvider(QueryIndexProvider provider)
focal_method.body: @Override
      public void initialize(NodeBuilder builder, String workspaceName) {
          // squeeze node state before it is passed to store (OAK-2411)
          NodeState base = squeeze(builder.getNodeState());
          MemoryNodeStore store = new MemoryNodeStore(base);
  
          Root root = RootFactory.createSystemRoot(store, EmptyHook.INSTANCE, workspaceName,
                  securityProvider,  queryIndexProvider);
  
          UserConfiguration userConfiguration = securityProvider.getConfiguration(UserConfiguration.class);
          UserManager userManager = userConfiguration.getUserManager(root, NamePathMapper.DEFAULT);
  
          String errorMsg = "Failed to initialize user content.";
          try {
              Tree rootTree = root.getTree(PathUtils.ROOT_PATH);
              checkState(rootTree.exists());
              Tree index = TreeUtil.getOrAddChild(rootTree, IndexConstants.INDEX_DEFINITIONS_NAME, JcrConstants.NT_UNSTRUCTURED);
  
              if (!index.hasChild("authorizableId")) {
                  Tree authorizableId = IndexUtils.createIndexDefinition(index, "authorizableId", true,
                          new String[]{REP_AUTHORIZABLE_ID},
                          NT_REP_AUTHORIZABLE);
                  authorizableId.setProperty("info",
                          "Oak index used by the user management " + 
                          "to enforce uniqueness of rep:authorizableId property values.");
              }
              if (!index.hasChild("principalName")) {
                  Tree principalName = IndexUtils.createIndexDefinition(index, "principalName", true,
                          new String[]{REP_PRINCIPAL_NAME},
                          NT_REP_AUTHORIZABLE);
                  principalName.setProperty("info",
                          "Oak index used by the user management " +
                          "to enforce uniqueness of rep:principalName property values, " +
                          "and to quickly search a principal by name if it was constructed manually.");
              }
              if (!index.hasChild("repMembers")) {
                  Tree members = IndexUtils.createIndexDefinition(index, "repMembers", false,
                          new String[]{REP_MEMBERS},
                          NT_REP_MEMBER_REFERENCES);
                  members.setProperty("info",
                          "Oak index used by the user management to lookup group membership.");
              }
  
              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);
              }
              String anonymousId = Strings.emptyToNull(params.getConfigValue(PARAM_ANONYMOUS_ID, DEFAULT_ANONYMOUS_ID, String.class));
              if (anonymousId != null && userManager.getAuthorizable(anonymousId) == null) {
                  userManager.createUser(anonymousId, null);
              }
              if (root.hasPendingChanges()) {
                  root.commit();
              }
          } catch (RepositoryException | CommitFailedException e) {
              log.error(errorMsg, e);
              throw new RuntimeException(e);
          }
  
          NodeState target = store.getRoot();
          target.compareAgainstBaseState(base, new ApplyDiff(builder));
      }
focal_method.class_method_signature: UserInitializer.initialize(NodeBuilder builder, String workspaceName)
focal_method.full_signature: @Override public void initialize(NodeBuilder builder, String workspaceName)
focal_method.identifier: initialize
focal_method.invocations: squeeze getNodeState createSystemRoot getConfiguration getUserManager getTree checkState exists getOrAddChild hasChild createIndexDefinition setProperty hasChild createIndexDefinition setProperty hasChild createIndexDefinition setProperty getParameters getConfigValue getAuthorizable getConfigValue createUser emptyToNull getConfigValue getAuthorizable createUser hasPendingChanges commit error getRoot compareAgainstBaseState
focal_method.modifiers: @Override public
focal_method.parameters: (NodeBuilder builder, String workspaceName)
focal_method.return: void
focal_method.signature: void initialize(NodeBuilder builder, String workspaceName)