Hide DirectoryServer.getDefaultAttributeType(String, Syntax) the best possible.
DirectoryServer.java:
Extracted method getAttributeTypeOrDefault(String, String, Syntax) to replace getDefaultAttributeType(String, Syntax).
| | |
| | | { |
| | | attrTypeSyntax = CoreSchema.getAttributeTypeDescriptionSyntax(); |
| | | } |
| | | |
| | | AttributeType attributeAttrType = schema.getAttributeType(ATTR_ATTRIBUTE_TYPES_LC); |
| | | if (attributeAttrType == null) |
| | | { |
| | | attributeAttrType = |
| | | DirectoryServer.getDefaultAttributeType(ATTR_ATTRIBUTE_TYPES, |
| | | attrTypeSyntax); |
| | | } |
| | | AttributeType attributeAttrType = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_ATTRIBUTE_TYPES_LC, ATTR_ATTRIBUTE_TYPES, attrTypeSyntax); |
| | | |
| | | // loop on the attribute types in the entry just received |
| | | // and add them in the existing schema. |
| | |
| | | { |
| | | ocSyntax = CoreSchema.getObjectClassDescriptionSyntax(); |
| | | } |
| | | |
| | | AttributeType objectclassAttrType = |
| | | schema.getAttributeType(ATTR_OBJECTCLASSES_LC); |
| | | if (objectclassAttrType == null) |
| | | { |
| | | objectclassAttrType = |
| | | DirectoryServer.getDefaultAttributeType(ATTR_OBJECTCLASSES, |
| | | ocSyntax); |
| | | } |
| | | AttributeType objectclassAttrType = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_OBJECTCLASSES_LC, ATTR_OBJECTCLASSES, ocSyntax); |
| | | |
| | | oidList.clear(); |
| | | List<Attribute> ocList = newSchemaEntry.getAttribute(objectclassAttrType); |
| | |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | import com.sleepycat.je.DatabaseException; |
| | |
| | | Object statValue = method.invoke(stats); |
| | | |
| | | // Create an attribute from the statistic. |
| | | AttributeType attrType = |
| | | DirectoryServer.getDefaultAttributeType(attrName, |
| | | integerSyntax); |
| | | monitorAttrs.add(Attributes.create(attrType, String |
| | | .valueOf(statValue))); |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName, attrName, integerSyntax); |
| | | monitorAttrs.add(Attributes.create(attrType, String.valueOf(statValue))); |
| | | } catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | |
| | | // Remove the 'get' from the method name and add the prefix. |
| | | String attrName = attrPrefix + method.getName().substring(3); |
| | | |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(attrName, integerSyntax); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName, attrName, integerSyntax); |
| | | monitorAttrs.add(Attributes.create(attrType, String.valueOf(method.invoke(stats)))); |
| | | } |
| | | catch (Exception e) |
| | |
| | | import org.opends.server.api.ConfigChangeListener; |
| | | import org.opends.server.api.ConfigDeleteListener; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | |
| | | public void putConfigAttribute(ConfigAttribute attribute) |
| | | { |
| | | String name = attribute.getName(); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(name.toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(name, attribute.getSyntax()); |
| | | } |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault( |
| | | name.toLowerCase(), name, attribute.getSyntax()); |
| | | |
| | | List<Attribute> attrs = new ArrayList<>(2); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, name); |
| | |
| | | */ |
| | | public static AttributeType getAttributeTypeOrDefault(String lowerName) |
| | | { |
| | | return getAttributeTypeOrDefault(lowerName, lowerName); |
| | | return getAttributeTypeOrDefault(lowerName, lowerName, getDefaultAttributeSyntax()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static AttributeType getAttributeTypeOrDefault(String lowerName, String upperName) |
| | | { |
| | | AttributeType type = getAttributeTypeOrNull(lowerName); |
| | | if (type == null) |
| | | return getAttributeTypeOrDefault(lowerName, upperName, getDefaultAttributeSyntax()); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the attribute type for the provided lowercase name or OID. It will return a generated |
| | | * "default" version with the uppercase name or OID if the requested attribute type is not defined |
| | | * in the schema. |
| | | * |
| | | * @param lowerName |
| | | * The lowercase name or OID for the attribute type to retrieve. |
| | | * @param upperName |
| | | * The uppercase name or OID for the attribute type to generate. |
| | | * @param syntax |
| | | * The syntax for the attribute type to generate. |
| | | * @return The requested attribute type, or a generated "default" version if there is no attribute |
| | | * with the specified type defined in the server schema |
| | | */ |
| | | public static AttributeType getAttributeTypeOrDefault(String lowerName, String upperName, Syntax syntax) |
| | | { |
| | | AttributeType attrType = getAttributeTypeOrNull(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | type = getDefaultAttributeType(upperName, getDefaultAttributeSyntax()); |
| | | attrType = getDefaultAttributeType(upperName, syntax); |
| | | } |
| | | return type; |
| | | return attrType; |
| | | } |
| | | |
| | | /** |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 X-ORIGIN 'RFC 2256' )"; |
| | | |
| | | directoryServer.objectClassAttributeType = |
| | | new AttributeType(definition, "objectClass", |
| | | Collections.singleton("objectClass"), |
| | | OBJECTCLASS_ATTRIBUTE_TYPE_OID, null, null, |
| | | oidSyntax, AttributeUsage.USER_APPLICATIONS, |
| | | false, false, false, false); |
| | | newAttributeType(definition, "objectClass", OBJECTCLASS_ATTRIBUTE_TYPE_OID, oidSyntax); |
| | | try |
| | | { |
| | | directoryServer.schema.registerAttributeType( |
| | |
| | | * Causes the Directory Server to construct a new attribute type definition |
| | | * with the provided name and syntax. This should only be used if there is no |
| | | * real attribute type for the specified name. |
| | | * <p> |
| | | * TODO remove once we switch to the SDK Schema |
| | | * <p> |
| | | * FIXME move to {@link org.opends.server.types.Schema}? |
| | | * |
| | | * @param name The name to use for the attribute type, as provided by the |
| | | * user. |
| | | * @param name The name to use for the attribute type, as provided by the user. |
| | | * @param syntax The syntax to use for the attribute type. |
| | | * |
| | | * @return The constructed attribute type definition. |
| | |
| | | syntax.getOID() + " )"; |
| | | |
| | | // Temporary attribute types are immediately dirty. |
| | | return new AttributeType(definition, name, Collections.singleton(name), |
| | | oid, null, null, syntax, |
| | | AttributeUsage.USER_APPLICATIONS, false, false, |
| | | false, false).setDirty(); |
| | | return newAttributeType(definition, name, oid, syntax).setDirty(); |
| | | } |
| | | |
| | | private static AttributeType newAttributeType(String definition, String name, String oid, Syntax syntax) |
| | | { |
| | | return new AttributeType(definition, name, Collections.singleton(name), oid, null, null, syntax, |
| | | AttributeUsage.USER_APPLICATIONS, false, false, false, false); |
| | | } |
| | | |
| | | /** |
| | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.ALERT_DESCRIPTION_DISK_FULL; |
| | | import static org.opends.server.util.ServerConstants.ALERT_DESCRIPTION_DISK_SPACE_LOW; |
| | | import static org.opends.server.util.ServerConstants.ALERT_TYPE_DISK_FULL; |
| | | import static org.opends.server.util.ServerConstants.ALERT_TYPE_DISK_SPACE_LOW; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.DiskSpaceMonitorHandler; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.api.ServerShutdownListener; |
| | |
| | | |
| | | private Attribute attr(String name, Syntax syntax, Object value) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(name, syntax); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(name, name, syntax); |
| | | return Attributes.create(attrType, String.valueOf(value)); |
| | | } |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.extensions.ParallelWorkQueue; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | |
| | | |
| | | private void putAttribute(ArrayList<Attribute> monitorAttrs, String attrName, Object value) |
| | | { |
| | | AttributeType attrType = getDefaultAttributeType(attrName, getDefaultIntegerSyntax()); |
| | | AttributeType attrType = getAttributeTypeOrDefault(attrName, attrName, getDefaultIntegerSyntax()); |
| | | monitorAttrs.add(Attributes.create(attrType, String.valueOf(value))); |
| | | } |
| | | } |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.extensions.TraditionalWorkQueue; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | |
| | | |
| | | private void putAttribute(ArrayList<Attribute> monitorAttrs, String attrName, Object value) |
| | | { |
| | | AttributeType attrType = getDefaultAttributeType(attrName, getDefaultIntegerSyntax()); |
| | | AttributeType attrType = getAttributeTypeOrDefault(attrName, attrName, getDefaultIntegerSyntax()); |
| | | monitorAttrs.add(Attributes.create(attrType, String.valueOf(value))); |
| | | } |
| | | } |
| | |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | // we'll start the server. |
| | | TestCaseUtils.startServer(); |
| | | |
| | | AttributeType dummy = DirectoryServer.getDefaultAttributeType( |
| | | "x-test-integer-type", DirectoryServer.getDefaultIntegerSyntax()); |
| | | String attrName = "x-test-integer-type"; |
| | | AttributeType dummy = getAttributeTypeOrDefault(attrName, attrName, getDefaultIntegerSyntax()); |
| | | DirectoryServer.getSchema().registerAttributeType(dummy, true); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | AT_DC = DirectoryServer.getAttributeTypeOrNull("dc"); |
| | | AT_CN = DirectoryServer.getAttributeTypeOrNull("cn"); |
| | | |
| | | AttributeType dummy = DirectoryServer.getDefaultAttributeType( |
| | | "x-test-integer-type", DirectoryServer |
| | | .getDefaultIntegerSyntax()); |
| | | String attrName = "x-test-integer-type"; |
| | | AttributeType dummy = getAttributeTypeOrDefault(attrName, attrName, getDefaultIntegerSyntax()); |
| | | DirectoryServer.getSchema().registerAttributeType(dummy, true); |
| | | |
| | | AV_DC_ORG = ByteString.valueOf("org"); |