From 8e1f955e67af8e580b63fa5466861c057c25c36e Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Mon, 30 May 2016 10:43:13 +0000
Subject: [PATCH] OPENDJ-2987 Refactor ServerSchemaElement, SomeSchemaElement and CommonsSchemaElements classes This is a step toward future removal of SomeSchemaElement and CommonSchemaElements classes - Add more responsabilities in ServerSchemaElement class - SomeSchemaElement class delegates several methods to ServerSchemaElement class - Update javadoc of SomeSchemaElement and CommonSchemaElements classes
---
opendj-server-legacy/src/main/java/org/opends/server/schema/SomeSchemaElement.java | 39 ++++++++++++++-------------------------
1 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/SomeSchemaElement.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/SomeSchemaElement.java
index 72e98ee..51936d9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/SomeSchemaElement.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/SomeSchemaElement.java
@@ -28,23 +28,20 @@
import org.forgerock.opendj.ldap.schema.SchemaElement;
import org.opends.server.config.ConfigConstants;
import org.opends.server.core.ServerContext;
-import org.opends.server.types.CommonSchemaElements;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
-import org.opends.server.util.ServerConstants;
/**
- * Represents a schema element which is either a SDK attribute type or an objectclass from the server.
+ * Represents a schema element which is either an attribute type or an object class.
* <p>
- * In absence of a common interface, this class allows to process all elements in the same way,
- * and to provide useful server-oriented methods like {@code getSchemaFile()} or
- * {@code getOrigin()}.
+ * Allows to share the methods getOID(), getNameOrOID(), getNames() and a setter on extra properties.
*/
-@RemoveOnceSDKSchemaIsUsed("This class is a temporary mechanism"
- + " to manage in the same way SDK and server schema element classes")
+@RemoveOnceSDKSchemaIsUsed("Some retrieval methods can be provided by ServerSchemaElement class. Others are only" +
+ "necessary for the control panel code, including the setter methods: specific control panel class could handle it.")
public class SomeSchemaElement implements SchemaElement
{
private ObjectClass objectClass;
private AttributeType attributeType;
+ private ServerSchemaElement element;
/**
* Builds SomeSchemaElement.
@@ -100,9 +97,13 @@
return attributeType != null;
}
- private SchemaElement asSchemaElement()
+ private ServerSchemaElement asSchemaElement()
{
- return attributeType != null ? attributeType : objectClass;
+ if (element == null)
+ {
+ element = attributeType != null ? new ServerSchemaElement(attributeType) : new ServerSchemaElement(objectClass);
+ }
+ return element;
}
/**
@@ -162,14 +163,7 @@
*/
public String getDefinitionWithFileName()
{
- final String schemaFile = getSchemaFile();
- final String definition = toString();
- if (schemaFile != null)
- {
- int pos = definition.lastIndexOf(')');
- return definition.substring(0, pos).trim() + " " + SCHEMA_PROPERTY_FILENAME + " '" + schemaFile + "' )";
- }
- return definition;
+ return asSchemaElement().getDefinitionWithFileName();
}
/**
@@ -179,7 +173,7 @@
*/
public String getSchemaFile()
{
- return getExtraPropertySingleValue(ServerConstants.SCHEMA_PROPERTY_FILENAME);
+ return asSchemaElement().getSchemaFile();
}
/**
@@ -201,12 +195,7 @@
*/
public String getOrigin()
{
- return getExtraPropertySingleValue(ServerConstants.SCHEMA_PROPERTY_ORIGIN);
- }
-
- private String getExtraPropertySingleValue(String schemaPropertyOrigin)
- {
- return CommonSchemaElements.getSingleValueProperty(asSchemaElement(), schemaPropertyOrigin);
+ return asSchemaElement().getOrigin();
}
/**
--
Gitblit v1.10.0