From 86d41f41f4a30d00354c17adf8c1d03d3e1180d7 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 13 Feb 2014 16:17:31 +0000
Subject: [PATCH] OPENDJ-1308 Migrate schema support
---
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java | 5
opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java | 7 +
/dev/null | 123 ------------------------------
opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java | 31 +++++--
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestAttributeType.java | 4
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java | 4
opendj3-server-dev/src/server/org/opends/server/plugins/EntryUUIDPlugin.java | 13 +-
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewAttributePanel.java | 4
opendj3-server-dev/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java | 1
opendj3-server-dev/src/server/org/opends/server/types/AttributeType.java | 13 ++-
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/AttributeTypeConstants.java | 3
11 files changed, 48 insertions(+), 160 deletions(-)
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
index c8c374e..5a7f34d 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
@@ -24,7 +24,6 @@
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2014 ForgeRock AS
*/
-
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
@@ -93,7 +92,7 @@
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.api.SubstringMatchingRule;
import org.opends.server.types.AttributeType;
-import org.opends.server.types.AttributeUsage;
+import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
import org.opends.server.util.ServerConstants;
@@ -101,7 +100,6 @@
/**
* The panel that displays a custom attribute definition.
- *
*/
public class CustomAttributePanel extends SchemaElementPanel
{
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewAttributePanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewAttributePanel.java
index c6a5c60..3775723 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewAttributePanel.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewAttributePanel.java
@@ -24,7 +24,6 @@
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2014 ForgeRock AS
*/
-
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
@@ -74,7 +73,7 @@
import org.opends.server.api.SubstringMatchingRule;
import org.opends.server.config.ConfigConstants;
import org.opends.server.types.AttributeType;
-import org.opends.server.types.AttributeUsage;
+import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
import org.opends.server.util.ServerConstants;
@@ -83,7 +82,6 @@
/**
* The panel displayed when the user wants to define a new attribute in the
* schema.
- *
*/
public class NewAttributePanel extends StatusGenericPanel
{
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java
index 4729830..124746a 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java
@@ -22,8 +22,8 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
-
package org.opends.guitools.controlpanel.ui.renderer;
import static org.opends.messages.AdminToolMessages.*;
@@ -35,13 +35,12 @@
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
-import org.opends.server.types.AttributeUsage;
+import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.ObjectClassType;
/**
* The cell renderer to be used to render schema elements in a combo box.
- *
*/
public class SchemaElementComboBoxCellRenderer extends CustomListCellRenderer
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java b/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
index 37c260e..69d89cd 100644
--- a/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
@@ -51,6 +51,10 @@
import javax.management.MBeanServerFactory;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.schema.AttributeUsage;
+import org.forgerock.util.Reject;
+import org.forgerock.util.Utils;
import org.opends.server.admin.AdministrationConnector;
import org.opends.server.admin.AdministrationDataSync;
import org.opends.server.admin.ClassLoaderProvider;
@@ -74,7 +78,6 @@
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.extensions.JMXAlertHandler;
import org.opends.server.loggers.*;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.monitors.BackendMonitor;
import org.opends.server.monitors.ConnectionHandlerMonitor;
import org.opends.server.protocols.internal.InternalClientConnection;
@@ -83,8 +86,6 @@
import org.opends.server.tools.ConfigureWindowsService;
import org.opends.server.types.*;
import org.opends.server.util.*;
-import org.forgerock.util.Reject;
-import org.forgerock.util.Utils;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
diff --git a/opendj3-server-dev/src/server/org/opends/server/plugins/EntryUUIDPlugin.java b/opendj3-server-dev/src/server/org/opends/server/plugins/EntryUUIDPlugin.java
index 71dd769..b1b0665 100644
--- a/opendj3-server-dev/src/server/org/opends/server/plugins/EntryUUIDPlugin.java
+++ b/opendj3-server-dev/src/server/org/opends/server/plugins/EntryUUIDPlugin.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.plugins;
-
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -36,21 +34,22 @@
import java.util.UUID;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.PluginCfgDefn;
import org.opends.server.admin.std.server.EntryUUIDPluginCfg;
import org.opends.server.admin.std.server.PluginCfg;
-import org.opends.server.api.plugin.*;
+import org.opends.server.api.plugin.DirectoryServerPlugin;
+import org.opends.server.api.plugin.PluginResult;
+import org.opends.server.api.plugin.PluginType;
import org.opends.server.config.ConfigException;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.operation.PreOperationAddOperation;
import static org.opends.messages.PluginMessages.*;
import static org.opends.server.util.StaticUtils.*;
-
-
/**
* This class implements a Directory Server plugin that will add the entryUUID
* attribute to an entry whenever it is added or imported as per RFC 4530. For
@@ -239,6 +238,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isConfigurationChangeAcceptable(
EntryUUIDPluginCfg configuration,
List<LocalizableMessage> unacceptableReasons)
@@ -271,6 +271,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ConfigChangeResult applyConfigurationChange(
EntryUUIDPluginCfg configuration)
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java b/opendj3-server-dev/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
index 12e1526..132c573 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/protocol/ModifyCommonMsg.java
@@ -34,6 +34,7 @@
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteStringBuilder;
+import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.replication.common.CSN;
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java b/opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java
index 5a069f3..66566e2 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java
@@ -25,9 +25,6 @@
* Portions Copyright 2011-2014 ForgeRock AS
*/
package org.opends.server.schema;
-import org.forgerock.i18n.LocalizableMessage;
-
-
import java.util.ArrayList;
import java.util.HashMap;
@@ -35,6 +32,11 @@
import java.util.LinkedList;
import java.util.List;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.LocalizableMessageBuilder;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteSequence;
+import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.admin.std.server.*;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.api.ApproximateMatchingRule;
@@ -44,19 +46,13 @@
import org.opends.server.api.SubstringMatchingRule;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
-
-import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ByteSequence;
-import static org.opends.messages.SchemaMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
+import static org.opends.messages.SchemaMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-import static org.opends.server.config.ConfigConstants.*;
-
-
/**
* This class defines the attribute type description syntax, which is used to
@@ -106,6 +102,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void
initializeSyntax(AttributeTypeDescriptionAttributeSyntaxCfg configuration)
throws ConfigException, InitializationException
@@ -156,6 +153,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getSyntaxName()
{
return SYNTAX_ATTRIBUTE_TYPE_NAME;
@@ -166,6 +164,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getOID()
{
return SYNTAX_ATTRIBUTE_TYPE_OID;
@@ -176,6 +175,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String getDescription()
{
return SYNTAX_ATTRIBUTE_TYPE_DESCRIPTION;
@@ -186,6 +186,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public EqualityMatchingRule getEqualityMatchingRule()
{
return defaultEqualityMatchingRule;
@@ -196,6 +197,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public OrderingMatchingRule getOrderingMatchingRule()
{
return defaultOrderingMatchingRule;
@@ -206,6 +208,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public SubstringMatchingRule getSubstringMatchingRule()
{
return defaultSubstringMatchingRule;
@@ -216,6 +219,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ApproximateMatchingRule getApproximateMatchingRule()
{
// There is no approximate matching rule by default.
@@ -227,6 +231,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean valueIsAcceptable(ByteSequence value,
LocalizableMessageBuilder invalidReason)
{
@@ -1507,6 +1512,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ConfigChangeResult applyConfigurationChange(
AttributeTypeDescriptionAttributeSyntaxCfg configuration)
{
@@ -1521,6 +1527,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isConfigurationChangeAcceptable(
AttributeTypeDescriptionAttributeSyntaxCfg configuration,
List<LocalizableMessage> unacceptableReasons)
@@ -1544,6 +1551,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isBinary()
{
return false;
@@ -1554,6 +1562,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isHumanReadable()
{
return true;
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/AttributeType.java b/opendj3-server-dev/src/server/org/opends/server/types/AttributeType.java
index 9eec58f..bb4d9d8 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/AttributeType.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/AttributeType.java
@@ -26,11 +26,13 @@
*/
package org.opends.server.types;
-import org.forgerock.opendj.ldap.ByteString;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.api.ApproximateMatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.EqualityMatchingRule;
@@ -39,11 +41,8 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.schema.AttributeTypeSyntax;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import static org.opends.server.util.ServerConstants.*;
import static org.forgerock.util.Reject.*;
-
-
+import static org.opends.server.util.ServerConstants.*;
/**
* This class defines a data structure for storing and interacting
@@ -399,6 +398,7 @@
* @return The definition string used to create this attribute
* type.
*/
+ @Override
public String getDefinition()
{
return definition;
@@ -428,6 +428,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType recreateFromDefinition(Schema schema)
throws DirectoryException
{
@@ -686,6 +687,7 @@
* @param buffer The buffer to which the information should be
* appended.
*/
+ @Override
protected void toStringContent(StringBuilder buffer)
{
if (superiorType != null)
@@ -749,6 +751,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int compareTo(AttributeType o) {
return getNormalizedPrimaryNameOrOID().compareTo(
o.getNormalizedPrimaryNameOrOID());
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/AttributeUsage.java b/opendj3-server-dev/src/server/org/opends/server/types/AttributeUsage.java
deleted file mode 100644
index 7be0b57..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/types/AttributeUsage.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- */
-package org.opends.server.types;
-
-
-
-/**
- * This enumeration defines the set of possible attribute usage values
- * that may apply to an attribute type, as defined in RFC 2252.
- */
-@org.opends.server.types.PublicAPI(
- stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
- mayInstantiate=false,
- mayExtend=false,
- mayInvoke=true)
-public enum AttributeUsage
-{
- /**
- * The attribute usage intended for user-defined attribute types.
- */
- USER_APPLICATIONS("userApplications", false),
-
-
-
- /**
- * The attribute usage intended for standard operational attributes.
- */
- DIRECTORY_OPERATION("directoryOperation", true),
-
-
-
- /**
- * The attribute usage intended for non-standard operational
- * attributes shared among multiple DSAs.
- */
- DISTRIBUTED_OPERATION("distributedOperation", true),
-
-
-
- /**
- * The attribute usage intended for non-standard operational
- * attributes used by a single DSA.
- */
- DSA_OPERATION("dSAOperation", true);
-
-
-
- // The string representation of this attribute usage.
- private final String usageString;
-
- // Flag indicating whether or not the usage should be categorized as
- // operational.
- private final boolean isOperational;
-
-
-
- /**
- * Creates a new attribute usage with the provided string
- * representation.
- *
- * @param usageString
- * The string representation of this attribute usage.
- * @param isOperational
- * <code>true</code> if attributes having this attribute
- * usage are operational, or <code>false</code>
- * otherwise.
- */
- private AttributeUsage(String usageString, boolean isOperational)
- {
- this.usageString = usageString;
- this.isOperational = isOperational;
- }
-
-
-
- /**
- * Retrieves a string representation of this attribute usage.
- *
- * @return A string representation of this attribute usage.
- */
- public String toString()
- {
- return usageString;
- }
-
-
-
- /**
- * Determine whether or not attributes having this attribute usage
- * are operational.
- *
- * @return Returns <code>true</code> if attributes having this
- * attribute usage are operational, or <code>false</code>
- * otherwise.
- */
- public boolean isOperational() {
- return isOperational;
- }
-}
-
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/AttributeTypeConstants.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/AttributeTypeConstants.java
index bd8c613..061aa91 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/AttributeTypeConstants.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/AttributeTypeConstants.java
@@ -21,12 +21,13 @@
* CDDL HEADER END
*
*
- * Copyright 2013 ForgeRock AS
+ * Copyright 2013-2014 ForgeRock AS
*/
package org.opends.server.types;
import java.util.Arrays;
+import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.schema.OIDSyntax;
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestAttributeType.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestAttributeType.java
index c92e6f2..187eec6 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestAttributeType.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestAttributeType.java
@@ -32,6 +32,7 @@
import java.util.List;
import java.util.Map;
+import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.api.ApproximateMatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.EqualityMatchingRule;
@@ -43,8 +44,6 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-
-
/**
* This class defines a set of tests for the
* {@link org.opends.server.types.AttributeType} class.
@@ -93,6 +92,7 @@
/**
* {@inheritDoc}
*/
+ @Override
protected void resetBuilder() {
this.superiorType = null;
this.syntax = null;
--
Gitblit v1.10.0