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

neil_a_wilson
30.27.2007 472ab9f6983def2889f0a4d29a477b1de6349e90
Make sure that the modifyTimestamp in the schema entry gets updated when the
add schema file task is used to update the server schema.

OpenDS Issue Number: 1170
3 files modified
49 ■■■■■ changed files
opends/src/server/org/opends/server/backends/SchemaBackend.java 13 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tasks/AddSchemaFileTask.java 3 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/tasks/AddSchemaFileTaskTestCase.java 33 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/SchemaBackend.java
@@ -218,6 +218,9 @@
  // The set of supported features for this backend.
  private HashSet<String> supportedFeatures;
  // The time that the schema was last modified.
  private long modifyTime;
  /**
@@ -768,6 +771,16 @@
                               valueSet));
    operationalAttrs.put(createTimestampType, attrList);
    if (DirectoryServer.getSchema().getYoungestModificationTime() != modifyTime)
    {
      synchronized (this)
      {
        modifyTime = DirectoryServer.getSchema().getYoungestModificationTime();
        modifyTimestamp =
             GeneralizedTimeSyntax.createGeneralizedTimeValue(modifyTime);
      }
    }
    valueSet = new LinkedHashSet<AttributeValue>(1);
    valueSet.add(modifiersName);
    attrList = new ArrayList<Attribute>(1);
opends/src/server/org/opends/server/tasks/AddSchemaFileTask.java
@@ -29,8 +29,8 @@
import java.io.File;
import java.util.TreeSet;
import java.util.List;
import java.util.TreeSet;
import java.util.concurrent.locks.Lock;
import org.opends.server.backends.task.Task;
@@ -226,6 +226,7 @@
        }
      }
      schema.setYoungestModificationTime(System.currentTimeMillis());
      DirectoryServer.setSchema(schema);
      return TaskState.COMPLETED_SUCCESSFULLY;
    }
opends/tests/unit-tests-testng/src/server/org/opends/server/tasks/AddSchemaFileTaskTestCase.java
@@ -80,6 +80,15 @@
  public void testAddValidSchemaFile()
         throws Exception
  {
    // Get the last modified timestamp from the schema and then sleep for two
    // milliseconds to make sure that any potential updates to the last
    // modification time that it won't have any chance of happening in the same
    // millisecond as the last update.
    long beforeModifyTimestamp =
              DirectoryServer.getSchema().getYoungestModificationTime();
    Thread.sleep(2);
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testAddValidSchemaFileMatch",
                                    "1.3.6.1.4.1.26027.1.999.23");
@@ -144,6 +153,8 @@
    Task task = getCompletedTask(DN.decode(taskDNStr));
    assertEquals(task.getTaskState(), TaskState.COMPLETED_SUCCESSFULLY);
    assertFalse(DirectoryServer.getSchema().getYoungestModificationTime() ==
                     beforeModifyTimestamp);
  }
@@ -158,6 +169,15 @@
  public void testAddMultipleValidSchemaFiles()
         throws Exception
  {
    // Get the last modified timestamp from the schema and then sleep for two
    // milliseconds to make sure that any potential updates to the last
    // modification time that it won't have any chance of happening in the same
    // millisecond as the last update.
    long beforeModifyTimestamp =
              DirectoryServer.getSchema().getYoungestModificationTime();
    Thread.sleep(2);
    String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath();
@@ -267,6 +287,8 @@
    Task task = getCompletedTask(DN.decode(taskDNStr));
    assertEquals(task.getTaskState(), TaskState.COMPLETED_SUCCESSFULLY);
    assertFalse(DirectoryServer.getSchema().getYoungestModificationTime() ==
                     beforeModifyTimestamp);
  }
@@ -351,6 +373,15 @@
  public void testAddEmptySchemaFile()
         throws Exception
  {
    // Get the last modified timestamp from the schema and then sleep for two
    // milliseconds to make sure that any potential updates to the last
    // modification time that it won't have any chance of happening in the same
    // millisecond as the last update.
    long beforeModifyTimestamp =
              DirectoryServer.getSchema().getYoungestModificationTime();
    Thread.sleep(2);
    String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath();
    File emptyFile = new File(schemaDirectory, "05-empty.ldif");
@@ -380,6 +411,8 @@
    Task task = getCompletedTask(DN.decode(taskDNStr));
    assertEquals(task.getTaskState(), TaskState.COMPLETED_SUCCESSFULLY);
    assertFalse(DirectoryServer.getSchema().getYoungestModificationTime() ==
                     beforeModifyTimestamp);
  }