mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
17.02.2015 891b6b1cf89c7bbcd9796d4d664665ec2ec89dfe
OPENDJ-2561 Rebuild-index: vlv cannot seem to be rebuilt

The code was trying to find an AttributeIndex
even though it was provided a VLV index name ("vlv.people-by-lastname").
The fix is to only look for an AttributeIndex
once we know the index name could not be found by any other means.
1 files modified
16 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java 16 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/OnDiskMergeImporter.java
@@ -363,7 +363,7 @@
     *
     * @throws InitializationException
     *           if rebuildList contains an invalid/non-existing attribute/index name.
     **/
     */
    private static final Set<String> buildUserDefinedIndexNames(EntryContainer entryContainer,
        Collection<String> rebuildList) throws InitializationException
    {
@@ -371,10 +371,11 @@
      for (String name : rebuildList)
      {
        final String parts[] = name.split("\\.");
        final AttributeIndex attrIndex = findAttributeIndex(entryContainer, parts[0]);
        if (parts.length == 1)
        {
          // Add all indexes of this attribute
          // for example: "cn" or "sn"
          final AttributeIndex attrIndex = findAttributeIndex(entryContainer, parts[0]);
          for (Tree index : attrIndex.getNameToIndexes().values())
          {
            indexNames.add(index.getName().getIndexId());
@@ -383,14 +384,18 @@
        else if (parts.length == 2)
        {
          // First, assume the supplied name is a valid index name ...
          // for example: "cn.substring", "vlv.someVlvIndex", "cn.caseIgnoreMatch"
          // or "cn.caseIgnoreSubstringsMatch:6"
          final SelectIndexName selector = new SelectIndexName();
          visitIndexes(entryContainer, visitOnlyIndexes(Arrays.asList(name), selector));
          indexNames.addAll(selector.getSelectedIndexNames());
          if (selector.getSelectedIndexNames().isEmpty())
          {
            // ... if not, assume the supplied name identify an attributeType.indexType
            // for example: aliases like "cn.substring" could not be found by the previous step
            try
            {
              final AttributeIndex attrIndex = findAttributeIndex(entryContainer, parts[0]);
              indexNames.addAll(getIndexNames(IndexType.valueOf(parts[1].toUpperCase()), attrIndex));
            }
            catch (IllegalArgumentException e)
@@ -3351,27 +3356,22 @@
    }
  }
  private static int visitIndexes(final EntryContainer entryContainer, IndexVisitor visitor)
  private static void visitIndexes(final EntryContainer entryContainer, IndexVisitor visitor)
  {
    int nbVisited = 0;
    for (AttributeIndex attribute : entryContainer.getAttributeIndexes())
    {
      for (MatchingRuleIndex index : attribute.getNameToIndexes().values())
      {
        visitor.visitAttributeIndex(index);
        nbVisited++;
      }
    }
    for (VLVIndex index : entryContainer.getVLVIndexes())
    {
      visitor.visitVLVIndex(index);
      nbVisited++;
    }
    visitor.visitSystemIndex(entryContainer.getDN2ID());
    visitor.visitSystemIndex(entryContainer.getID2ChildrenCount());
    visitor.visitSystemIndex(entryContainer.getDN2URI());
    nbVisited += 2;
    return nbVisited;
  }
  /** Visitor pattern allowing to process all type of indexes. */