Examples of LDIFImportConfig


Examples of org.nasutekds.server.types.LDIFImportConfig

                             ExistingFileBehavior.OVERWRITE);
      LDIFReader reader = null;
      Entry schemaEntry = null;
      try
      {
        reader = new LDIFReader(new LDIFImportConfig(schemaFile));
        schemaEntry = reader.readEntry();

        for (AttributeType attribute : attributes)
        {
          Modification mod = new Modification(ModificationType.ADD,
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

          ExistingFileBehavior.OVERWRITE);
    LDIFReader reader = null;
    Entry schemaEntry = null;
    try
    {
      reader = new LDIFReader(new LDIFImportConfig(schemaFile));
      schemaEntry = reader.readEntry();

      Modification mod = new Modification(ModificationType.DELETE,
          Attributes.create(
              getSchemaFileAttributeName(schemaElement).toLowerCase(),
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

    }

    private void createBackend(String backendName, String baseDN)
    throws OpenDsException
    {
      LDIFImportConfig ldifImportConfig = null;
      try
      {
        String ldif = getBackendLdif(backendName);

        ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
        LDIFReader reader = new LDIFReader(ldifImportConfig);
        Entry backendConfigEntry;
        while ((backendConfigEntry = reader.readEntry()) != null)
        {
          DirectoryServer.getConfigHandler().addEntry(backendConfigEntry, null);
        }
        DirectoryServer.getConfigHandler().writeUpdatedConfig();
      }
      catch (IOException ioe)
      {
        throw new OfflineUpdateException(
            ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(ioe.toString()),
            ioe);
      }
      finally
      {
        if (ldifImportConfig != null)
        {
          ldifImportConfig.close();
        }
      }
    }
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

    }

    private void createAdditionalIndexes(String backendName)
    throws OpenDsException
    {
      LDIFImportConfig ldifImportConfig = null;
      try
      {
        String ldif = getAdditionalIndexLdif(backendName);

        ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
        LDIFReader reader = new LDIFReader(ldifImportConfig);
        Entry indexEntry;
        while ((indexEntry = reader.readEntry()) != null)
        {
          DirectoryServer.getConfigHandler().addEntry(indexEntry, null);
        }
        DirectoryServer.getConfigHandler().writeUpdatedConfig();
      }
      catch (IOException ioe)
      {
        throw new OfflineUpdateException(
            ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(ioe.toString()),
            ioe);
      }
      finally
      {
        if (ldifImportConfig != null)
        {
          ldifImportConfig.close();
        }
      }
    }
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

      // Instead of adding indexes using management framework, use this approach
      // so that we have to define the additional indexes only in the method
      // getBackendLdif.
      String ldif = getAdditionalIndexLdif(backendName);
      LDIFImportConfig ldifImportConfig = null;
      try
      {
        ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
        LDIFReader reader = new LDIFReader(ldifImportConfig);
        Entry indexEntry;
        while ((indexEntry = reader.readEntry()) != null)
        {
          ArrayList<String> args = new ArrayList<String>();
          args.add("create-local-db-index");
          args.add("--backend-name");
          args.add(backendName);
          args.add("--type");
          args.add("generic");

          argsArray.add(args);
          Attributes attrs = new BasicAttributes();

          BasicAttribute oc = new BasicAttribute("objectClass");
          Iterator<AttributeValue> it =
            indexEntry.getObjectClassAttribute().iterator();

          while (it.hasNext())
          {
            oc.add(it.next().getValue().toString());
          }
          attrs.put(oc);

          List<org.nasutekds.server.types.Attribute> odsAttrs =
            indexEntry.getAttributes();
          for (org.nasutekds.server.types.Attribute odsAttr : odsAttrs)
          {
            String attrName = odsAttr.getName();
            BasicAttribute attr = new BasicAttribute(attrName);
            it = odsAttr.iterator();
            while (it.hasNext())
            {
              attr.add(it.next().getValue().toString());
            }
            attrs.put(attr);

            if (attrName.equalsIgnoreCase("ds-cfg-attribute"))
            {
              args.add("--index-name");
              AttributeValue value =
                odsAttr.iterator().next();
              args.add(value.getValue().toString());
            }
            else if (attrName.equalsIgnoreCase("ds-cfg-index-type"))
            {
              it = odsAttr.iterator();
              while (it.hasNext())
              {
                args.add("--set");
                args.add("index-type:"+it.next().getValue().toString());
              }
            }
          }
          args.addAll(getConnectionCommandLineArguments());
          args.add(getNoPropertiesFileArgument());
          args.add("--no-prompt");

          dns.add(indexEntry.getDN().toString());
          attributes.add(attrs);
        }

        StringBuilder sb = new StringBuilder();
        for (List<String> args : argsArray)
        {
          sb.append(getEquivalentCommandLine(getCommandLinePath("dsconfig"),
              getObfuscatedCommandLineArguments(args)));
          sb.append("<br><br>");
        }
        final String cmdLines = sb.toString();
        SwingUtilities.invokeLater(new Runnable()
        {
          public void run()
          {
            getProgressDialog().appendProgressHtml(Utilities.applyFont(
             INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_CREATE_ADDITIONAL_INDEXES.get()+
             "<br><br><b>"+cmdLines+"</b>",
             ColorAndFontConstants.progressFont));
            getProgressDialog().appendProgressHtml(
                Utilities.getProgressWithPoints(
                    INFO_CTRL_PANEL_CREATING_ADDITIONAL_INDEXES_PROGRESS.get(),
                    ColorAndFontConstants.progressFont));
          }
        });

        for (int i=0; i<dns.size(); i++)
        {
          ctx.createSubcontext(dns.get(i), attributes.get(i));
        }

        SwingUtilities.invokeLater(new Runnable()
        {
          public void run()
          {
            getProgressDialog().appendProgressHtml(
                Utilities.getProgressDone(ColorAndFontConstants.progressFont)+
                "<br><br>");
          }
        });
      }
      catch (Throwable t)
      {
        throw new OnlineUpdateException(
            ERR_CTRL_PANEL_ERROR_UPDATING_CONFIGURATION.get(t.toString()), t);
      }
      finally
      {
        if (ldifImportConfig != null)
        {
          ldifImportConfig.close();
        }
      }
    }
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

    }


    // Create the LDIF import configuration that will be used to read the source
    // data.
    LDIFImportConfig importConfig;
    if (ldifFile.isPresent())
    {
      importConfig = new LDIFImportConfig(ldifFile.getValues());
    }
    else
    {
      importConfig = new LDIFImportConfig(System.in);
    }


    // Create the LDIF export configuration that will be used to write the
    // matching entries.
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

              sourceFile.getValue());
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
    }

    LDIFImportConfig importConfig = new LDIFImportConfig(sourceFile.getValue());
    LDIFReader sourceReader;
    try
    {
      sourceReader = new LDIFReader(importConfig);
    }
    catch (IOException ioe)
    {
      Message message = ERR_LDIFMODIFY_CANNOT_OPEN_SOURCE.get(
              sourceFile.getValue(),
                                  String.valueOf(ioe));
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
    }


    File changes = new File(changesFile.getValue());
    if (! changes.exists())
    {
      Message message = ERR_LDIFMODIFY_CHANGES_DOES_NOT_EXIST.get(
              changesFile.getValue());
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
    }

    importConfig = new LDIFImportConfig(changesFile.getValue());
    LDIFReader changeReader;
    try
    {
      changeReader = new LDIFReader(importConfig);
    }
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

   * @throws DirectoryException  When needed.
   */
  @Override
  protected void importBackend(InputStream input) throws DirectoryException
  {
    LDIFImportConfig importConfig = null;

    Backend backend = retrievesBackend(baseDn);

    try
    {
      if (!backend.supportsLDIFImport())
      {
        Message message = ERR_INIT_IMPORT_NOT_SUPPORTED.get(
            backend.getBackendID().toString());
        if (ieContext.getException() == null)
          ieContext.setException(new DirectoryException(ResultCode.OTHER,
              message));
      }
      else
      {
        importConfig =
          new LDIFImportConfig(input);
        List<DN> includeBranches = new ArrayList<DN>();
        includeBranches.add(this.baseDn);
        importConfig.setIncludeBranches(includeBranches);
        importConfig.setAppendToExistingData(false);
        importConfig.setSkipDNValidation(true);
        // Allow fractional replication ldif import plugin to be called
        importConfig.setInvokeImportPlugins(true);
        // Reset the follow import flag and message before starting the import
        importErrorMessageId = -1;
        followImport = true;

        // TODO How to deal with rejected entries during the import
        importConfig.writeRejectedEntries(
            getFileForPath("logs" + File.separator +
            "replInitRejectedEntries").getAbsolutePath(),
            ExistingFileBehavior.OVERWRITE);

        // Process import
        preBackendImport(backend);
        backend.importLDIF(importConfig);

        stateSavingDisabled = false;
      }
    }
    catch(Exception e)
    {
      if (ieContext.getException() == null)
        ieContext.setException(new DirectoryException(
            ResultCode.OTHER,
            ERR_INIT_IMPORT_FAILURE.get(e.getLocalizedMessage())));
    }
    finally
    {
      try
      {
        // Cleanup
        if (importConfig != null)
        {
          importConfig.close();
          closeBackendImport(backend); // Re-enable backend
          backend = retrievesBackend(baseDn);
        }

        loadDataState();
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

                "dn: cn=external changelog," + configDn,
                "objectClass: top",
                "objectClass: ds-cfg-external-changelog-domain",
                "cn: external changelog",
                "ds-cfg-enabled: " + (!getBackend().isPrivateBackend()));
            LDIFImportConfig ldifImportConfig = new LDIFImportConfig(
                new StringReader(ldif));
            LDIFReader reader = new LDIFReader(ldifImportConfig);
            Entry eclEntry = reader.readEntry();
            DirectoryServer.getConfigHandler().addEntry(eclEntry, null);
            ldifImportConfig.close();
          }
        }
      }
      eclDomCfg = domCfg.getExternalChangelogDomain();
      if (eclDomain != null)
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

    /**
     * @return the LDIF result of applying changesLdif to changesLdif
     */
    private String applyChangesToLdif(String baseLdif, String changesLdif) throws Exception {
      LDIFReader baseReader = new LDIFReader(new LDIFImportConfig(new StringReader(baseLdif)));
      LDIFReader changesReader = new LDIFReader(new LDIFImportConfig(new StringReader(changesLdif)));

      ByteArrayOutputStream updatedEntriesStream = new ByteArrayOutputStream();
      LDIFWriter ldifWriter = new LDIFWriter(new LDIFExportConfig(updatedEntriesStream));

      List<Message> errors = new ArrayList<Message>();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.