test_class.declarator: PRINCIPAL_NAME = "principalName"
test_class.modifier: private static final
test_class.original_string: private static final String PRINCIPAL_NAME = "principalName";
test_class.type: String
test_class.var_name: PRINCIPAL_NAME
test_class.declarator: bitsProvider
test_class.modifier: private
test_class.original_string: private PrivilegeBitsProvider bitsProvider;
test_class.type: PrivilegeBitsProvider
test_class.var_name: bitsProvider
test_class.declarator: restrictionProvider
test_class.modifier: private
test_class.original_string: private RestrictionProvider restrictionProvider;
test_class.type: RestrictionProvider
test_class.var_name: restrictionProvider
test_class.declarator: isACE
test_class.modifier: private
test_class.original_string: private TypePredicate isACE;
test_class.type: TypePredicate
test_class.var_name: isACE
test_class.declarator: isGrantACE
test_class.modifier: private
test_class.original_string: private TypePredicate isGrantACE;
test_class.type: TypePredicate
test_class.var_name: isGrantACE
test_class.file: oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionStoreEditorTest.java
test_class.identifier: PermissionStoreEditorTest
test_class.superclass: extends AbstractSecurityTest
test_case.body: @Test
      public void testUpdatePermissionEntriesDoesNotRemoveCollisions() {
          NodeState ace = mockACE(PRINCIPAL_NAME);
          NodeState nodeState = mockNodeState(ace);
  
          NodeBuilder child = mock(NodeBuilder.class);
          when(child.setProperty(anyString(), any())).thenReturn(child);
          when(child.setProperty(anyString(), any(), any(Type.class))).thenReturn(child);
          NodeBuilder parent = mock(NodeBuilder.class);
          when(parent.getChildNodeNames()).thenReturn(ImmutableSet.of("collision", "entry"));
          when(parent.getChildNode(anyString())).thenReturn(child);
          when(parent.child(anyString())).thenReturn(child);
  
          NodeBuilder principalRoot = when(mock(NodeBuilder.class).child(anyString())).thenReturn(parent).getMock();
          NodeBuilder permissionsRoot = mock(NodeBuilder.class);
          when(permissionsRoot.child(PRINCIPAL_NAME)).thenReturn(principalRoot);
  
          PermissionStoreEditor editor = createPermissionStoreEditor(nodeState, permissionsRoot);
          editor.updatePermissionEntries();
  
          // only the existing 'entry' child gets removed. the collision is not touched
          verify(child, times(1)).remove();
      }
test_case.class_method_signature: PermissionStoreEditorTest.testUpdatePermissionEntriesDoesNotRemoveCollisions()
test_case.full_signature: @Test public void testUpdatePermissionEntriesDoesNotRemoveCollisions()
test_case.identifier: testUpdatePermissionEntriesDoesNotRemoveCollisions
test_case.invocations: mockACE mockNodeState mock thenReturn when setProperty anyString any thenReturn when setProperty anyString any any mock thenReturn when getChildNodeNames of thenReturn when getChildNode anyString thenReturn when child anyString getMock thenReturn when child mock anyString mock thenReturn when child createPermissionStoreEditor updatePermissionEntries remove verify times
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUpdatePermissionEntriesDoesNotRemoveCollisions()
focal_class.declarator: log = LoggerFactory.getLogger(PermissionStoreEditor.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(PermissionStoreEditor.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: accessControlledPath
focal_class.modifier: private final
focal_class.original_string: private final String accessControlledPath;
focal_class.type: String
focal_class.var_name: accessControlledPath
focal_class.declarator: nodeName
focal_class.modifier: private final
focal_class.original_string: private final String nodeName;
focal_class.type: String
focal_class.var_name: nodeName
focal_class.declarator: entries = Maps.newHashMap()
focal_class.modifier: private final
focal_class.original_string: private final Map<String, List<AcEntry>> entries = Maps.newHashMap();
focal_class.type: Map<String, List<AcEntry>>
focal_class.var_name: entries
focal_class.declarator: permissionRoot
focal_class.modifier: private final
focal_class.original_string: private final NodeBuilder permissionRoot;
focal_class.type: NodeBuilder
focal_class.var_name: permissionRoot
focal_class.declarator: bitsProvider
focal_class.modifier: private final
focal_class.original_string: private final PrivilegeBitsProvider bitsProvider;
focal_class.type: PrivilegeBitsProvider
focal_class.var_name: bitsProvider
focal_class.file: oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionStoreEditor.java
focal_class.identifier: PermissionStoreEditor
focal_class.interfaces: implements AccessControlConstants, PermissionConstants
focal_class.class_method_signature: PermissionStoreEditor.PermissionStoreEditor(@NotNull String aclPath, @NotNull String name,
                            @NotNull NodeState node, @NotNull NodeBuilder permissionRoot,
                            @NotNull TypePredicate isACE, @NotNull TypePredicate isGrantACE,
                            @NotNull PrivilegeBitsProvider bitsProvider,
                            @NotNull RestrictionProvider restrictionProvider,
                            @NotNull TreeProvider treeProvider)
focal_class.full_signature:   PermissionStoreEditor(@NotNull String aclPath, @NotNull String name,
                            @NotNull NodeState node, @NotNull NodeBuilder permissionRoot,
                            @NotNull TypePredicate isACE, @NotNull TypePredicate isGrantACE,
                            @NotNull PrivilegeBitsProvider bitsProvider,
                            @NotNull RestrictionProvider restrictionProvider,
                            @NotNull TreeProvider treeProvider)
focal_class.identifier: PermissionStoreEditor
focal_class.parameters: (@NotNull String aclPath, @NotNull String name,
                            @NotNull NodeState node, @NotNull NodeBuilder permissionRoot,
                            @NotNull TypePredicate isACE, @NotNull TypePredicate isGrantACE,
                            @NotNull PrivilegeBitsProvider bitsProvider,
                            @NotNull RestrictionProvider restrictionProvider,
                            @NotNull TreeProvider treeProvider)
focal_class.signature:  PermissionStoreEditor(@NotNull String aclPath, @NotNull String name,
                            @NotNull NodeState node, @NotNull NodeBuilder permissionRoot,
                            @NotNull TypePredicate isACE, @NotNull TypePredicate isGrantACE,
                            @NotNull PrivilegeBitsProvider bitsProvider,
                            @NotNull RestrictionProvider restrictionProvider,
                            @NotNull TreeProvider treeProvider)
focal_class.class_method_signature: PermissionStoreEditor.getPath()
focal_class.full_signature: @NotNull String getPath()
focal_class.identifier: getPath
focal_class.modifiers: @NotNull
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getPath()
focal_class.class_method_signature: PermissionStoreEditor.isEmpty()
focal_class.full_signature:  boolean isEmpty()
focal_class.identifier: isEmpty
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isEmpty()
focal_class.class_method_signature: PermissionStoreEditor.removePermissionEntries(@NotNull PermissionStoreEditor otherEditor)
focal_class.full_signature:  void removePermissionEntries(@NotNull PermissionStoreEditor otherEditor)
focal_class.identifier: removePermissionEntries
focal_class.parameters: (@NotNull PermissionStoreEditor otherEditor)
focal_class.return: void
focal_class.signature: void removePermissionEntries(@NotNull PermissionStoreEditor otherEditor)
focal_class.class_method_signature: PermissionStoreEditor.removePermissionEntries()
focal_class.full_signature:  void removePermissionEntries()
focal_class.identifier: removePermissionEntries
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void removePermissionEntries()
focal_class.class_method_signature: PermissionStoreEditor.updatePermissionEntries()
focal_class.full_signature:  void updatePermissionEntries()
focal_class.identifier: updatePermissionEntries
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void updatePermissionEntries()
focal_class.class_method_signature: PermissionStoreEditor.updateEntries(@NotNull NodeBuilder parent, @NotNull List<AcEntry> list)
focal_class.full_signature: private void updateEntries(@NotNull NodeBuilder parent, @NotNull List<AcEntry> list)
focal_class.identifier: updateEntries
focal_class.modifiers: private
focal_class.parameters: (@NotNull NodeBuilder parent, @NotNull List<AcEntry> list)
focal_class.return: void
focal_class.signature: void updateEntries(@NotNull NodeBuilder parent, @NotNull List<AcEntry> list)
focal_class.class_method_signature: PermissionStoreEditor.updateNumEntries(@NotNull String principalName, @NotNull NodeBuilder principalRoot, int cnt)
focal_class.full_signature: private static void updateNumEntries(@NotNull String principalName, @NotNull NodeBuilder principalRoot, int cnt)
focal_class.identifier: updateNumEntries
focal_class.modifiers: private static
focal_class.parameters: (@NotNull String principalName, @NotNull NodeBuilder principalRoot, int cnt)
focal_class.return: void
focal_class.signature: void updateNumEntries(@NotNull String principalName, @NotNull NodeBuilder principalRoot, int cnt)
focal_method.body: void updatePermissionEntries() {
          for (Map.Entry<String, List<AcEntry>> entry: entries.entrySet()) {
              String principalName = entry.getKey();
              NodeBuilder principalRoot = permissionRoot.child(principalName);
              if (!principalRoot.hasProperty(JCR_PRIMARYTYPE)) {
                  principalRoot.setProperty(JCR_PRIMARYTYPE, NT_REP_PERMISSION_STORE, Type.NAME);
              }
              NodeBuilder parent = principalRoot.child(nodeName);
              if (!parent.hasProperty(JCR_PRIMARYTYPE)) {
                  parent.setProperty(JCR_PRIMARYTYPE, NT_REP_PERMISSION_STORE, Type.NAME);
              }
  
              // check if current parent already has the correct path
              if (parent.hasProperty(REP_ACCESS_CONTROLLED_PATH)) {
                  if (!PermissionUtil.checkACLPath(parent, accessControlledPath)) {
                      // hash collision, find a new child
                      NodeBuilder child = null;
                      int idx = 0;
                      for (String childName : parent.getChildNodeNames()) {
                          if (childName.charAt(0) != 'c') {
                              continue;
                          }
                          child = parent.getChildNode(childName);
                          if (PermissionUtil.checkACLPath(child, accessControlledPath)) {
                              break;
                          }
                          child = null;
                          idx++;
                      }
                      while (child == null) {
                          String name = 'c' + String.valueOf(idx++);
                          child = parent.getChildNode(name);
                          if (child.exists()) {
                              child = null;
                          } else {
                              child = parent.child(name);
                              child.setProperty(JCR_PRIMARYTYPE, NT_REP_PERMISSION_STORE, Type.NAME);
                          }
                      }
                      parent = child;
                      parent.setProperty(REP_ACCESS_CONTROLLED_PATH, accessControlledPath);
                  }
              } else {
                  // new parent
                  parent.setProperty(REP_ACCESS_CONTROLLED_PATH, accessControlledPath);
              }
              updateEntries(parent, entry.getValue());
  
              if (parent.isNew()) {
                  updateNumEntries(principalName, principalRoot, +1);
              }
          }
      }
focal_method.class_method_signature: PermissionStoreEditor.updatePermissionEntries()
focal_method.full_signature:  void updatePermissionEntries()
focal_method.identifier: updatePermissionEntries
focal_method.invocations: entrySet getKey child hasProperty setProperty child hasProperty setProperty hasProperty checkACLPath getChildNodeNames charAt getChildNode checkACLPath valueOf getChildNode exists child setProperty setProperty setProperty updateEntries getValue isNew updateNumEntries
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void updatePermissionEntries()