From 96c591639566638a424e08d4d98ed5fd1489487d Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 08 Jun 2016 08:32:09 +0000
Subject: [PATCH] code cleanup
---
opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java | 66 +++++++++-----------------------
1 files changed, 19 insertions(+), 47 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java b/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java
index 8aa4976..c2fec3e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java
@@ -22,7 +22,6 @@
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -98,24 +97,18 @@
*/
public static String getSchemaDirectoryPath()
{
- File schemaDir =
- DirectoryServer.getEnvironmentConfig().getSchemaDirectory();
- if (schemaDir != null) {
- return schemaDir.getAbsolutePath();
- }
- return null;
+ File schemaDir = DirectoryServer.getEnvironmentConfig().getSchemaDirectory();
+ return schemaDir != null ? schemaDir.getAbsolutePath() : null;
}
/**
- * Retrieves a reference to the schema information that has been read from the
- * server configuration. Note that this information will not be complete
- * until the <CODE>initializeMatchingRules</CODE>,
- * <CODE>initializeAttributeSyntaxes</CODE>, and
- * <CODE>initializeAttributeTypesAndObjectClasses</CODE> methods have been
- * called.
+ * Retrieves a reference to the schema information that has been read from the server
+ * configuration.
+ * <p>
+ * Note that this information will not be complete until the {@link #initializeMatchingRules()},
+ * {@link #initializeAttributeSyntaxes()} methods have been called.
*
- * @return A reference to the schema information that has been read from the
- * server configuration.
+ * @return A reference to the schema information that has been read from the server configuration.
*/
public Schema getSchema()
{
@@ -154,8 +147,7 @@
public void initializeAttributeSyntaxes()
throws ConfigException, InitializationException
{
- AttributeSyntaxConfigManager syntaxConfigManager =
- new AttributeSyntaxConfigManager(serverContext);
+ AttributeSyntaxConfigManager syntaxConfigManager = new AttributeSyntaxConfigManager(serverContext);
syntaxConfigManager.initializeAttributeSyntaxes();
}
@@ -192,48 +184,30 @@
// and make sure that it exists and is a directory. Get a list of the files
// in that directory sorted in alphabetic order.
String schemaInstanceDirPath = getSchemaDirectoryPath();
- File schemaInstanceDir = null;
-
- try
- {
- if (schemaInstanceDirPath != null)
- {
- schemaInstanceDir = new File(schemaInstanceDirPath);
- }
- } catch (Exception e)
- {
- schemaInstanceDir = null;
- }
+ File schemaInstanceDir = schemaInstanceDirPath != null ? new File(schemaInstanceDirPath) : null;
long oldestModificationTime = -1L;
long youngestModificationTime = -1L;
- String[] fileNames;
+ List<String> fileNames;
try
{
- if (schemaInstanceDir == null || ! schemaInstanceDir.exists())
+ if (schemaInstanceDir == null || !schemaInstanceDir.exists())
{
- LocalizableMessage message =
- ERR_CONFIG_SCHEMA_NO_SCHEMA_DIR.get(schemaInstanceDirPath);
- throw new InitializationException(message);
+ throw new InitializationException(ERR_CONFIG_SCHEMA_NO_SCHEMA_DIR.get(schemaInstanceDirPath));
}
- if (! schemaInstanceDir.isDirectory())
+ if (!schemaInstanceDir.isDirectory())
{
- LocalizableMessage message =
- ERR_CONFIG_SCHEMA_DIR_NOT_DIRECTORY.get(schemaInstanceDirPath);
- throw new InitializationException(message);
+ throw new InitializationException(ERR_CONFIG_SCHEMA_DIR_NOT_DIRECTORY.get(schemaInstanceDirPath));
}
- FilenameFilter filter = new SchemaFileFilter();
- File[] schemaInstanceDirFiles =
- schemaInstanceDir.listFiles(filter);
- int fileNumber = schemaInstanceDirFiles.length ;
- ArrayList<String> fileList = new ArrayList<>(fileNumber);
+ File[] schemaInstanceDirFiles = schemaInstanceDir.listFiles(new SchemaFileFilter());
+ fileNames = new ArrayList<>(schemaInstanceDirFiles.length);
for (File f : schemaInstanceDirFiles)
{
if (f.isFile())
{
- fileList.add(f.getName());
+ fileNames.add(f.getName());
}
long modificationTime = f.lastModified();
@@ -250,9 +224,7 @@
}
}
- fileNames = new String[fileList.size()];
- fileList.toArray(fileNames);
- Arrays.sort(fileNames);
+ Collections.sort(fileNames);
}
catch (InitializationException ie)
{
--
Gitblit v1.10.0