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

Jean-Noël Rouvignac
29.39.2016 aab06371ebecd75d655436cf6045fffc8302c2e0
*.java: Replaced DirectoryServer.getAttributeTypeOrNull(String) != null by DirectoryServer.getAttributeType(String).isPlaceHolder()
14 files modified
138 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/admin/AttributeTypePropertyDefinition.java 6 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VerifyJob.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/controls/ServerSideSortRequestControl.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/core/SubentryPasswordPolicy.java 20 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java 18 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/extensions/SMTPAccountStatusNotificationHandler.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectAttributeToUserAttributeCertificateMapper.java 10 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/plugins/AttributeCleanupPlugin.java 14 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java 14 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java 16 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/admin/AttributeTypePropertyDefinition.java
@@ -161,10 +161,8 @@
    ifNull(value);
    String name = value.trim();
    AttributeType type = isCheckSchema
        ? DirectoryServer.getAttributeTypeOrNull(name)
        : DirectoryServer.getAttributeType(name);
    if (type == null) {
    AttributeType type = DirectoryServer.getAttributeType(name);
    if (isCheckSchema && type.isPlaceHolder()) {
      throw PropertyException.illegalPropertyValueException(this, value);
    }
    try {
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java
@@ -176,8 +176,8 @@
      AttributeType thatType = rdn.getAttributeType(0);
      if (!typePatterns[0].equals("*"))
      {
        AttributeType thisType = DirectoryServer.getAttributeTypeOrNull(typePatterns[0]);
        if (thisType == null || !thisType.equals(thatType))
        AttributeType thisType = DirectoryServer.getAttributeType(typePatterns[0]);
        if (thisType.isPlaceHolder() || !thisType.equals(thatType))
        {
          return false;
        }
@@ -208,8 +208,8 @@
    for (int i = 0; i < numValues; i++)
    {
      AttributeType type = DirectoryServer.getAttributeTypeOrNull(typePatterns[i]);
      if (type == null)
      AttributeType type = DirectoryServer.getAttributeType(typePatterns[i]);
      if (type.isPlaceHolder())
      {
        return false;
      }
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -308,8 +308,8 @@
          return false;
        }
        AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(sortAttrs[i]);
        if(attrType == null)
        AttributeType attrType = DirectoryServer.getAttributeType(sortAttrs[i]);
        if (attrType.isPlaceHolder())
        {
          unacceptableReasons.add(ERR_CONFIG_VLV_INDEX_UNDEFINED_ATTR.get(sortAttrs[i], cfg.getName()));
          return false;
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
@@ -330,8 +330,8 @@
        throw new ConfigException(ERR_CONFIG_VLV_INDEX_UNDEFINED_ATTR.get(sortKeys[i], getName()));
      }
      final AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(sortAttrs[i]);
      if (attrType == null)
      final AttributeType attrType = DirectoryServer.getAttributeType(sortAttrs[i]);
      if (attrType.isPlaceHolder())
      {
        throw new ConfigException(ERR_CONFIG_VLV_INDEX_UNDEFINED_ATTR.get(sortAttrs[i], getName()));
      }
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VerifyJob.java
@@ -52,6 +52,7 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.backends.VerifyConfig;
import org.opends.server.backends.pluggable.AttributeIndex.MatchingRuleIndex;
import org.opends.server.backends.pluggable.spi.Cursor;
@@ -60,7 +61,6 @@
import org.opends.server.backends.pluggable.spi.SequentialCursor;
import org.opends.server.backends.pluggable.spi.StorageRuntimeException;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -220,8 +220,8 @@
          }
          else
          {
            AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(lowerName);
            if (attrType == null)
            AttributeType attrType = DirectoryServer.getAttributeType(lowerName);
            if (attrType.isPlaceHolder())
            {
              throw new StorageRuntimeException(ERR_ATTRIBUTE_INDEX_NOT_CONFIGURED.get(index).toString());
            }
opendj-server-legacy/src/main/java/org/opends/server/controls/ServerSideSortRequestControl.java
@@ -109,8 +109,8 @@
        {
          reader.readStartSequence();
          String attrName = reader.readOctetStringAsString();
          AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attrName);
          if (attrType == null)
          AttributeType attrType = DirectoryServer.getAttributeType(attrName);
          if (attrType.isPlaceHolder())
          {
            //This attribute is not defined in the schema. There is no point
            //iterating over the next attribute and return a partially sorted result.
@@ -441,8 +441,8 @@
    ArrayList<SortKey> sortKeys = new ArrayList<>();
    for(String[] decodedKey : decodedKeyList)
    {
      AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(decodedKey[0]);
      if (attrType == null)
      AttributeType attrType = DirectoryServer.getAttributeType(decodedKey[0]);
      if (attrType.isPlaceHolder())
      {
        //This attribute is not defined in the schema. There is no point
        //iterating over the next attribute and return a partially sorted result.
opendj-server-legacy/src/main/java/org/opends/server/core/SubentryPasswordPolicy.java
@@ -30,7 +30,12 @@
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
import java.util.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.concurrent.atomic.AtomicBoolean;
import org.forgerock.i18n.LocalizableMessage;
@@ -46,7 +51,14 @@
import org.opends.server.api.PasswordGenerator;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.api.PasswordValidator;
import org.opends.server.types.*;
import org.opends.server.types.Attribute;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Operation;
import org.opends.server.types.SubEntry;
/**
 * This class represents subentry password policy based on Password Policy for
@@ -174,8 +186,8 @@
    String value = getAttrValue(entry, PWD_ATTR_ATTRIBUTE);
    if (value != null && value.length() > 0)
    {
      this.pPasswordAttribute = DirectoryServer.getAttributeTypeOrNull(value);
      if (this.pPasswordAttribute == null)
      this.pPasswordAttribute = DirectoryServer.getAttributeType(value);
      if (this.pPasswordAttribute.isPlaceHolder())
      {
        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            ERR_PWPOLICY_UNDEFINED_PASSWORD_ATTRIBUTE.get(this.passwordPolicySubentryDN, value));
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
@@ -58,6 +58,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.util.Reject;
import org.opends.admin.ads.ADSContext;
import org.opends.server.admin.server.ConfigurationChangeListener;
@@ -79,7 +80,6 @@
import org.opends.server.tools.LDAPConnectionOptions;
import org.opends.server.tools.LDAPReader;
import org.opends.server.tools.LDAPWriter;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.Base64;
import org.opends.server.util.SelectableCertificateKeyManager;
@@ -235,14 +235,14 @@
    this.serverContext = serverContext;
    if (!schemaInitDone) {
      // Initialize various schema references.
      attrKeyID = DirectoryServer.getAttributeTypeOrNull(ATTR_CRYPTO_KEY_ID);
      attrPublicKeyCertificate = DirectoryServer.getAttributeTypeOrNull(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
      attrTransformation = DirectoryServer.getAttributeTypeOrNull(ATTR_CRYPTO_CIPHER_TRANSFORMATION_NAME);
      attrMacAlgorithm = DirectoryServer.getAttributeTypeOrNull(ATTR_CRYPTO_MAC_ALGORITHM_NAME);
      attrSymmetricKey = DirectoryServer.getAttributeTypeOrNull(ATTR_CRYPTO_SYMMETRIC_KEY);
      attrInitVectorLength = DirectoryServer.getAttributeTypeOrNull(ATTR_CRYPTO_INIT_VECTOR_LENGTH_BITS);
      attrKeyLength = DirectoryServer.getAttributeTypeOrNull(ATTR_CRYPTO_KEY_LENGTH_BITS);
      attrCompromisedTime = DirectoryServer.getAttributeTypeOrNull(ATTR_CRYPTO_KEY_COMPROMISED_TIME);
      attrKeyID = DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID);
      attrPublicKeyCertificate = DirectoryServer.getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
      attrTransformation = DirectoryServer.getAttributeType(ATTR_CRYPTO_CIPHER_TRANSFORMATION_NAME);
      attrMacAlgorithm = DirectoryServer.getAttributeType(ATTR_CRYPTO_MAC_ALGORITHM_NAME);
      attrSymmetricKey = DirectoryServer.getAttributeType(ATTR_CRYPTO_SYMMETRIC_KEY);
      attrInitVectorLength = DirectoryServer.getAttributeType(ATTR_CRYPTO_INIT_VECTOR_LENGTH_BITS);
      attrKeyLength = DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_LENGTH_BITS);
      attrCompromisedTime = DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_COMPROMISED_TIME);
      ocCertRequest = DirectoryServer.getObjectClass("ds-cfg-self-signed-cert-request"); // TODO: ConfigConstants
      ocInstanceKey = DirectoryServer.getObjectClass(OC_CRYPTO_INSTANCE_KEY);
      ocCipherKey = DirectoryServer.getObjectClass(OC_CRYPTO_CIPHER_KEY);
opendj-server-legacy/src/main/java/org/opends/server/extensions/SMTPAccountStatusNotificationHandler.java
@@ -392,8 +392,8 @@
              else if (lowerTokenStr.startsWith("notification-user-attr:"))
              {
                String attrName = lowerTokenStr.substring(23);
                AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attrName);
                if (attrType == null)
                AttributeType attrType = DirectoryServer.getAttributeType(attrName);
                if (attrType.isPlaceHolder())
                {
                  throw new ConfigException(
                                 ERR_SMTP_ASNH_TEMPLATE_UNDEFINED_ATTR_TYPE.get(
opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectAttributeToUserAttributeCertificateMapper.java
@@ -50,6 +50,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.CertificateMapperCfg;
import org.opends.server.admin.std.server.SubjectAttributeToUserAttributeCertificateMapperCfg;
@@ -59,7 +60,6 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -399,8 +399,8 @@
        return null;
      }
      AttributeType userAttrType = DirectoryServer.getAttributeTypeOrNull(userAttrName);
      if (userAttrType == null)
      AttributeType userAttrType = DirectoryServer.getAttributeType(userAttrName);
      if (userAttrType.isPlaceHolder())
      {
        ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION);
        ccr.addMessage(ERR_SATUACM_NO_SUCH_ATTR.get(mapStr, cfgEntryDN, userAttrName));
@@ -429,7 +429,7 @@
   */
  private static String normalizeAttributeName(String attrName)
  {
    AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attrName);
    return attrType != null ? attrType.getNormalizedNameOrOID() : attrName;
    AttributeType attrType = DirectoryServer.getAttributeType(attrName);
    return attrType.isPlaceHolder() ? attrName : attrType.getNormalizedNameOrOID();
  }
}
opendj-server-legacy/src/main/java/org/opends/server/plugins/AttributeCleanupPlugin.java
@@ -29,7 +29,13 @@
import static org.opends.messages.PluginMessages.*;
import static com.forgerock.opendj.util.StaticUtils.toLowerCase;
import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
@@ -46,7 +52,9 @@
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.opends.server.types.InitializationException;
import org.opends.server.types.RawAttribute;
import org.opends.server.types.RawModification;
import org.opends.server.types.operation.PreParseAddOperation;
import org.opends.server.types.operation.PreParseModifyOperation;
@@ -306,7 +314,7 @@
          ? toAttr
          : toAttr.substring(semicolonPos + 1);
      if (DirectoryServer.getAttributeTypeOrNull(toAttrType) == null)
      if (DirectoryServer.getAttributeType(toAttrType).isPlaceHolder())
      {
        messages.add(ERR_PLUGIN_ATTR_CLEANUP_ATTRIBUTE_MISSING.get(toAttr));
        isValid = false;
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
@@ -74,7 +74,15 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.*;
import org.opends.server.types.Attribute;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.IndexType;
import org.opends.server.types.Modification;
import org.opends.server.types.SearchFilter;
import org.opends.server.types.SearchResultEntry;
import org.opends.server.types.operation.PostOperationDeleteOperation;
import org.opends.server.types.operation.PostOperationModifyDNOperation;
import org.opends.server.types.operation.PreOperationAddOperation;
@@ -346,8 +354,8 @@
       * type has to be present in the attributeType list.
       */
      AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attr);
      if (attrType == null || !theAttributeTypes.contains(attrType))
      AttributeType attrType = DirectoryServer.getAttributeType(attr);
      if (attrType.isPlaceHolder() || !theAttributeTypes.contains(attrType))
      {
        isAcceptable = false;
        unacceptableReasons.add(ERR_PLUGIN_REFERENT_ATTR_NOT_LISTED.get(attr));
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -2501,8 +2501,8 @@
    }
    AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attrTypeName);
    if (attrType == null)
    AttributeType attrType = DirectoryServer.getAttributeType(attrTypeName);
    if (attrType.isPlaceHolder())
    {
      // This should not happen
      // The server doesn't have this attribute type defined.
@@ -2547,8 +2547,8 @@
   */
  public Set<String> getReferralURLs()
  {
    AttributeType referralType = DirectoryServer.getAttributeTypeOrNull(ATTR_REFERRAL_URL);
    if (referralType == null)
    AttributeType referralType = DirectoryServer.getAttributeType(ATTR_REFERRAL_URL);
    if (referralType.isPlaceHolder())
    {
      // This should not happen -- The server doesn't have a ref attribute type defined.
      logger.trace("No %s attribute type is defined in the server schema.", ATTR_REFERRAL_URL);
@@ -2608,8 +2608,8 @@
   */
  public DN getAliasedDN() throws DirectoryException
  {
    AttributeType aliasType = DirectoryServer.getAttributeTypeOrNull(ATTR_REFERRAL_URL);
    if (aliasType == null)
    AttributeType aliasType = DirectoryServer.getAttributeType(ATTR_REFERRAL_URL);
    if (aliasType.isPlaceHolder())
    {
      // This should not happen -- The server doesn't have an aliasedObjectName attribute type defined.
      logger.trace("No %s attribute type is defined in the server schema.", ATTR_ALIAS_DN);
@@ -4525,8 +4525,8 @@
          options = null;
        }
        AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(name);
        if (attrType == null)
        AttributeType attrType = DirectoryServer.getAttributeType(name);
        if (attrType.isPlaceHolder())
        {
          // Unrecognized attribute type - do best effort search.
          for (Map.Entry<AttributeType, List<Attribute>> e :
opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java
@@ -27,7 +27,6 @@
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -48,6 +47,7 @@
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
@@ -2056,8 +2056,8 @@
  private static AttributeType getAttributeType(String attrType, StringBuilder lowerType)
  {
    AttributeType attributeType = DirectoryServer.getAttributeTypeOrNull(lowerType.toString());
    if (attributeType == null)
    AttributeType attributeType = DirectoryServer.getAttributeType(lowerType.toString());
    if (attributeType.isPlaceHolder())
    {
      String typeStr = attrType.substring(0, lowerType.length());
      attributeType = DirectoryServer.getAttributeType(typeStr);