Package org.nasutekds.server.config

Examples of org.nasutekds.server.config.ConfigException


    }
    catch (DirectoryException de)
    {
      Message message = ERR_CANNOT_DECODE_BACKEND_BASE_DN.get(
          DN_BACKEND_BASE, de.getMessageObject());
      throw new ConfigException(message, de);
    }
    catch (Exception e)
    {
      Message message = ERR_CANNOT_DECODE_BACKEND_BASE_DN.get(
          DN_BACKEND_BASE, getExceptionMessage(e));
      throw new ConfigException(message, e);
    }

    ConfigEntry baseEntry = null;
    try
    {
      baseEntry = DirectoryServer.getConfigEntry(backendBaseDN);
    }
    catch (ConfigException ce)
    {
      Message message = ERR_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY.get(
          DN_BACKEND_BASE, ce.getMessage());
      throw new ConfigException(message, ce);
    }
    catch (Exception e)
    {
      Message message = ERR_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY.get(
          DN_BACKEND_BASE, getExceptionMessage(e));
      throw new ConfigException(message, e);
    }


    // Iterate through the immediate children, attempting to parse them as
    // backends.
    TreeMap<String,TreeSet<DN>> backendMap = new TreeMap<String,TreeSet<DN>>();
    for (ConfigEntry configEntry : baseEntry.getChildren().values())
    {
      // Get the backend ID attribute from the entry.  If there isn't one, then
      // skip the entry.
      String backendID = null;
      try
      {
        Message msg = INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID.get();
        StringConfigAttribute idStub =
             new StringConfigAttribute(ATTR_BACKEND_ID, msg,
                                       true, false, true);
        StringConfigAttribute idAttr =
             (StringConfigAttribute) configEntry.getConfigAttribute(idStub);
        if (idAttr == null)
        {
          continue;
        }
        else
        {
          backendID = idAttr.activeValue();
        }
      }
      catch (ConfigException ce)
      {
        Message message = ERR_CANNOT_DETERMINE_BACKEND_ID.get(
            String.valueOf(configEntry.getDN()), ce.getMessage());
        throw new ConfigException(message, ce);
      }
      catch (Exception e)
      {
        Message message = ERR_CANNOT_DETERMINE_BACKEND_ID.get(
            String.valueOf(configEntry.getDN()), getExceptionMessage(e));
        throw new ConfigException(message, e);
      }


      // Get the base DN attribute from the entry.  If there isn't one, then
      // just skip this entry.
      TreeSet<DN> baseDNs = new TreeSet<DN>();
      try
      {
        Message msg = INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BASE_DNS.get();
        DNConfigAttribute baseDNStub =
             new DNConfigAttribute(ATTR_BACKEND_BASE_DN, msg,
                                   true, true, true);
        DNConfigAttribute baseDNAttr =
             (DNConfigAttribute) configEntry.getConfigAttribute(baseDNStub);
        if (baseDNAttr != null)
        {
          baseDNs.addAll(baseDNAttr.activeValues());
        }
      }
      catch (Exception e)
      {
        Message message = ERR_CANNOT_DETERMINE_BASES_FOR_BACKEND.get(
            String.valueOf(configEntry.getDN()), getExceptionMessage(e));
        throw new ConfigException(message, e);
      }

      backendMap.put(backendID, baseDNs);
    }
View Full Code Here


              }

              Message message = ERR_CONFIG_VATTR_INVALID_SEARCH_FILTER.get(
                      filterString, String.valueOf(cfg.dn()),
                      de.getMessageObject());
              throw new ConfigException(message, de);
            }
          }

          if (cfg.getAttributeType().isSingleValue())
          {
            if (provider.isMultiValued())
            {
              Message message = ERR_CONFIG_VATTR_SV_TYPE_WITH_MV_PROVIDER.
                  get(String.valueOf(cfg.dn()),
                      cfg.getAttributeType().getNameOrOID(), className);
              throw new ConfigException(message);
            }
            else if (cfg.getConflictBehavior() ==
                     VirtualAttributeCfgDefn.ConflictBehavior.
                          MERGE_REAL_AND_VIRTUAL)
            {
              Message message = ERR_CONFIG_VATTR_SV_TYPE_WITH_MERGE_VALUES.
                  get(String.valueOf(cfg.dn()),
                      cfg.getAttributeType().getNameOrOID());
              throw new ConfigException(message);
            }
          }

          VirtualAttributeRule rule =
               new VirtualAttributeRule(cfg.getAttributeType(), provider,
View Full Code Here

    int minLength = configuration.getMinPasswordLength();
    if ((maxLength > 0) && (minLength > 0) && (minLength > maxLength))
    {
      Message message =
          ERR_PWLENGTHVALIDATOR_MIN_GREATER_THAN_MAX.get(minLength, maxLength);
      throw new ConfigException(message);
    }
  }
View Full Code Here

        int equalPos = line.indexOf('=');
        if (equalPos < 0)
        {
          Message message =
              ERR_BACKUPINFO_NO_DELIMITER.get(line, backupPath);
          throw new ConfigException(message);
        }
        else if (equalPos == 0)
        {
          Message message =
              ERR_BACKUPINFO_NO_NAME.get(line, backupPath);
          throw new ConfigException(message);
        }

        String name  = line.substring(0, equalPos);
        String value = line.substring(equalPos+1);

        if (name.equals(PROPERTY_BACKUP_ID))
        {
          if (backupID == null)
          {
            backupID = value;
          }
          else
          {
            Message message = ERR_BACKUPINFO_MULTIPLE_BACKUP_IDS.get(
                backupPath, backupID, value);
            throw new ConfigException(message);
          }
        }
        else if (name.equals(PROPERTY_BACKUP_DATE))
        {
          SimpleDateFormat dateFormat =
               new SimpleDateFormat(DATE_FORMAT_GMT_TIME);
          dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
          backupDate = dateFormat.parse(value);
        }
        else if (name.equals(PROPERTY_IS_INCREMENTAL))
        {
          isIncremental = Boolean.valueOf(value);
        }
        else if (name.equals(PROPERTY_IS_COMPRESSED))
        {
          isCompressed = Boolean.valueOf(value);
        }
        else if (name.equals(PROPERTY_IS_ENCRYPTED))
        {
          isEncrypted = Boolean.valueOf(value);
        }
        else if (name.equals(PROPERTY_UNSIGNED_HASH))
        {
          unsignedHash = Base64.decode(value);
        }
        else if (name.equals(PROPERTY_SIGNED_HASH))
        {
          signedHash = Base64.decode(value);
        }
        else if (name.equals(PROPERTY_DEPENDENCY))
        {
          dependencies.add(value);
        }
        else if (name.startsWith(PROPERTY_CUSTOM_PREFIX))
        {
          String propertyName =
               name.substring(PROPERTY_CUSTOM_PREFIX.length());
          backupProperties.put(propertyName, value);
        }
        else
        {
          Message message = ERR_BACKUPINFO_UNKNOWN_PROPERTY.get(
              backupPath, name, value);
          throw new ConfigException(message);
        }
      }
    }
    catch (ConfigException ce)
    {
      throw ce;
    }
    catch (Exception e)
    {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }

      Message message = ERR_BACKUPINFO_CANNOT_DECODE.get(
          backupPath, getExceptionMessage(e));
      throw new ConfigException(message, e);
    }


    // There must have been at least a backup ID and backup date
    // specified.
    if (backupID == null)
    {
      Message message = ERR_BACKUPINFO_NO_BACKUP_ID.get(backupPath);
      throw new ConfigException(message);
    }

    if (backupDate == null)
    {
      Message message =
          ERR_BACKUPINFO_NO_BACKUP_DATE.get(backupID, backupPath);
      throw new ConfigException(message);
    }


    return new BackupInfo(backupDirectory, backupID, backupDate,
                          isIncremental, isCompressed, isEncrypted,
View Full Code Here

    {
      if (attrType.getEqualityMatchingRule() == null)
      {
        Message message = ERR_CONFIG_INDEX_TYPE_NEEDS_MATCHING_RULE.get(
            String.valueOf(attrType), "equality");
        throw new ConfigException(message);
      }

      Indexer equalityIndexer = new EqualityIndexer(attrType);
      this.equalityIndex = new Index(name + ".equality",
                                     equalityIndexer,
                                     state,
                                     indexEntryLimit,
                                     cursorEntryLimit,
                                     false,
                                     env,
                                     entryContainer);
    }

    if (indexConfig.getIndexType().contains(
            LocalDBIndexCfgDefn.IndexType.PRESENCE))
    {
      Indexer presenceIndexer = new PresenceIndexer(attrType);
      this.presenceIndex = new Index(name + ".presence",
                                     presenceIndexer,
                                     state,
                                     indexEntryLimit,
                                     cursorEntryLimit,
                                     false,
                                     env,
                                     entryContainer);
    }

    if (indexConfig.getIndexType().contains(
            LocalDBIndexCfgDefn.IndexType.SUBSTRING))
    {
      if (attrType.getSubstringMatchingRule() == null)
      {
        Message message = ERR_CONFIG_INDEX_TYPE_NEEDS_MATCHING_RULE.get(
            String.valueOf(attrType), "substring");
        throw new ConfigException(message);
      }

      Indexer substringIndexer = new SubstringIndexer(attrType,
                                         indexConfig.getSubstringLength());
      this.substringIndex = new Index(name + ".substring",
                                     substringIndexer,
                                     state,
                                     indexEntryLimit,
                                     cursorEntryLimit,
                                     false,
                                     env,
                                     entryContainer);
    }

    if (indexConfig.getIndexType().contains(
            LocalDBIndexCfgDefn.IndexType.ORDERING))
    {
      if (attrType.getOrderingMatchingRule() == null)
      {
        Message message = ERR_CONFIG_INDEX_TYPE_NEEDS_MATCHING_RULE.get(
            String.valueOf(attrType), "ordering");
        throw new ConfigException(message);
      }

      Indexer orderingIndexer = new OrderingIndexer(attrType);
      this.orderingIndex = new Index(name + ".ordering",
                                     orderingIndexer,
                                     state,
                                     indexEntryLimit,
                                     cursorEntryLimit,
                                     false,
                                     env,
                                     entryContainer);
    }
    if (indexConfig.getIndexType().contains(
        LocalDBIndexCfgDefn.IndexType.APPROXIMATE))
    {
      if (attrType.getApproximateMatchingRule() == null)
      {
        Message message = ERR_CONFIG_INDEX_TYPE_NEEDS_MATCHING_RULE.get(
            String.valueOf(attrType), "approximate");
        throw new ConfigException(message);
      }

      Indexer approximateIndexer = new ApproximateIndexer(attrType);
      this.approximateIndex = new Index(name + ".approximate",
                                        approximateIndexer,
                                        state,
                                        indexEntryLimit,
                                        cursorEntryLimit,
                                        false,
                                        env,
                                        entryContainer);
    }
    if (indexConfig.getIndexType().contains(
        LocalDBIndexCfgDefn.IndexType.EXTENSIBLE))
    {
      Set<String> extensibleRules =
              indexConfig.getIndexExtensibleMatchingRule();
      if(extensibleRules == null || extensibleRules.size() == 0)
      {
        Message message = ERR_CONFIG_INDEX_TYPE_NEEDS_MATCHING_RULE.get(
            String.valueOf(attrType), "extensible");
        throw new ConfigException(message);
      }
      extensibleIndexes = new ExtensibleMatchingRuleIndex();
      //Iterate through the Set and create the index only if necessary.
      //Collation equality and Ordering matching rules share the same
      //indexer and index. A Collation substring matching rule is treated
View Full Code Here

    String backupID = backupInfo.getBackupID();
    if (backups.containsKey(backupID))
    {
      Message message =
          ERR_BACKUPDIRECTORY_ADD_DUPLICATE_ID.get(backupID, path);
      throw new ConfigException(message);
    }

    backups.put(backupID, backupInfo);
  }
View Full Code Here

  {
    if (! backups.containsKey(backupID))
    {
      Message message =
          ERR_BACKUPDIRECTORY_NO_SUCH_BACKUP.get(backupID, path);
      throw new ConfigException(message);
    }

    for (BackupInfo backup : backups.values())
    {
      if (backup.dependsOn(backupID))
      {
        Message message = ERR_BACKUPDIRECTORY_UNRESOLVED_DEPENDENCY.
            get(backupID, path, backup.getBackupID());
        throw new ConfigException(message);
      }
    }

    backups.remove(backupID);
  }
View Full Code Here

    File descriptorFile = new File(descriptorFilePath);
    if (! descriptorFile.exists())
    {
      Message message = ERR_BACKUPDIRECTORY_NO_DESCRIPTOR_FILE.get(
          descriptorFilePath);
      throw new ConfigException(message);
    }


    // Open the file for reading.  The first line should be the DN of
    // the associated configuration entry.
    BufferedReader reader =
         new BufferedReader(new FileReader(descriptorFile));
    String line = reader.readLine();
    if ((line == null) || (line.length() == 0))
    {
      Message message =
        ERR_BACKUPDIRECTORY_CANNOT_READ_CONFIG_ENTRY_DN.
            get(descriptorFilePath);
      throw new ConfigException(message);
    }
    else if (! line.startsWith(PROPERTY_BACKEND_CONFIG_DN))
    {
      Message message = ERR_BACKUPDIRECTORY_FIRST_LINE_NOT_DN.get(
          descriptorFilePath, line);
      throw new ConfigException(message);
    }

    String dnString =
         line.substring(PROPERTY_BACKEND_CONFIG_DN.length() + 1);
    DN configEntryDN;
    try
    {
      configEntryDN = DN.decode(dnString);
    }
    catch (DirectoryException de)
    {
      Message message = ERR_BACKUPDIRECTORY_CANNOT_DECODE_DN.get(
          dnString, descriptorFilePath, de.getMessageObject());
      throw new ConfigException(message, de);
    }
    catch (Exception e)
    {
      Message message = ERR_BACKUPDIRECTORY_CANNOT_DECODE_DN.get(
          dnString, descriptorFilePath, getExceptionMessage(e));
      throw new ConfigException(message, e);
    }


    // Create the backup directory structure from what we know so far.
    BackupDirectory backupDirectory =
View Full Code Here

    }
    catch(Exception e)
    {
      Message msg = ERR_JEB_CONFIG_VLV_INDEX_BAD_FILTER.get(
          config.getFilter(), name, stackTraceToSingleLineString(e));
      throw new ConfigException(msg);
    }

    String[] sortAttrs = config.getSortOrder().split(" ");
    SortKey[] sortKeys = new SortKey[sortAttrs.length];
    OrderingMatchingRule[] orderingRules =
        new OrderingMatchingRule[sortAttrs.length];
    boolean[] ascending = new boolean[sortAttrs.length];
    for(int i = 0; i < sortAttrs.length; i++)
    {
      try
      {
        if(sortAttrs[i].startsWith("-"))
        {
          ascending[i] = false;
          sortAttrs[i] = sortAttrs[i].substring(1);
        }
        else
        {
          ascending[i] = true;
          if(sortAttrs[i].startsWith("+"))
          {
            sortAttrs[i] = sortAttrs[i].substring(1);
          }
        }
      }
      catch(Exception e)
      {
        Message msg =
            ERR_JEB_CONFIG_VLV_INDEX_UNDEFINED_ATTR.get(
                    String.valueOf(sortKeys[i]), name);
        throw new ConfigException(msg);
      }

      AttributeType attrType =
          DirectoryServer.getAttributeType(sortAttrs[i].toLowerCase());
      if(attrType == null)
      {
        Message msg =
            ERR_JEB_CONFIG_VLV_INDEX_UNDEFINED_ATTR.get(sortAttrs[i], name);
        throw new ConfigException(msg);
      }
      sortKeys[i] = new SortKey(attrType, ascending[i]);
      orderingRules[i] = attrType.getOrderingMatchingRule();
    }
View Full Code Here


        default:
          Message message =
              ERR_PLUGIN_7BIT_INVALID_PLUGIN_TYPE.get(t.toString());
          throw new ConfigException(message);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.nasutekds.server.config.ConfigException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.