Examples of LDIFImportConfig


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 = getIndexLDIF();
      LDIFImportConfig ldifImportConfig = null;
      try
      {
        ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
        LDIFReader reader = new LDIFReader(ldifImportConfig);
        Entry indexEntry = reader.readEntry();
        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<Attribute> odsAttrs = indexEntry.getAttributes();
        for (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);
        }

        final StringBuilder sb = new StringBuilder();
        sb.append(getConfigCommandLineName());
        Collection<String> args =
          getObfuscatedCommandLineArguments(getDSConfigCommandLineArguments());
        for (String arg : args)
        {
          sb.append(" "+CommandBuilder.escapeValue(arg));
        }

        ctx.createSubcontext(indexEntry.getDN().toString(), attrs);
      }
      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

    LDIFReader reader = null;
    try
    {
      try
      {
        LDIFImportConfig importConfig =
          new LDIFImportConfig(f.getAbsolutePath());

        reader = new LDIFReader(importConfig);
      }
      catch (Throwable t)
      {
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

   * {@inheritDoc}
   */
  public Entry getEntry() throws OpenDsException
  {
    Entry entry = null;
    LDIFImportConfig ldifImportConfig = null;
    try
    {
      String ldif = getLDIF();

      ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
      LDIFReader reader = new LDIFReader(ldifImportConfig);
      entry = reader.readEntry(checkSchema());
      addValuesInRDN(entry);
    }
    catch (IOException ioe)
    {
      throw new OfflineUpdateException(
          ERR_CTRL_PANEL_ERROR_CHECKING_ENTRY.get(ioe.toString()), ioe);
    }
    finally
    {
      if (ldifImportConfig != null)
      {
        ldifImportConfig.close();
      }
    }
    return entry;
  }
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

      }
    }

    private void createIndex() throws OpenDsException
    {
      LDIFImportConfig ldifImportConfig = null;
      try
      {
        String topEntryDN =
          "cn=VLV Index,"+Utilities.getRDNString("ds-cfg-backend-id",
          backendName.getText())+",cn=Backends,cn=config";
        boolean topEntryExists =
          DirectoryServer.getConfigHandler().entryExists(
              DN.decode(topEntryDN));

        if (!topEntryExists)
        {
          String completeLDIF =
          Utilities.makeLdif(
          "dn: "+topEntryDN,
          "objectClass: top",
          "objectClass: ds-cfg-branch",
          "cn: VLV Index", "") + ldif;
          ldifImportConfig =
            new LDIFImportConfig(new StringReader(completeLDIF));
        }
        else
        {
          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

    };

    String ldifString = TestCaseUtils.makeLdif(entryLines);
    ByteArrayInputStream bais =
         new ByteArrayInputStream(ldifString.getBytes("UTF-8"));
    LDIFImportConfig importConfig = new LDIFImportConfig(bais);

    for (Entry e : TestCaseUtils.makeEntries(entryLines))
    {
      plugin.doLDIFImport(importConfig, e);
    }
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

   * @param ldif of the entries to parse.
   * @return a List of EntryS parsed from the ldif string.
   * @see #makeLdif
   */
  public static List<Entry> entriesFromLdifString(String ldif) throws Exception {
    LDIFImportConfig ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
    LDIFReader reader = new LDIFReader(ldifImportConfig);

    List<Entry> entries = new ArrayList<Entry>();
    Entry entry;
    while ((entry = reader.readEntry()) != null) {
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

      {
        // This could be some other kind of file, like ".svn".
        continue;
      }

      LDIFImportConfig importConfig = new LDIFImportConfig(f.getAbsolutePath());
      LDIFReader reader = new LDIFReader(importConfig);
      Entry e = reader.readEntry();
      reader.close();

      if (e == null)
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

      {
        // This could be some other kind of file, like ".svn".
        continue;
      }

      LDIFImportConfig importConfig = new LDIFImportConfig(f.getAbsolutePath());
      LDIFReader reader = new LDIFReader(importConfig);
      Entry e = reader.readEntry();
      reader.close();

      if (e == null)
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

      {
        // This could be some other kind of file, like ".svn".
        continue;
      }

      LDIFImportConfig importConfig = new LDIFImportConfig(f.getAbsolutePath());
      LDIFReader reader = new LDIFReader(importConfig);
      Entry e = reader.readEntry();
      reader.close();

      if (e == null)
View Full Code Here

Examples of org.nasutekds.server.types.LDIFImportConfig

      Class<T> theClass, String[] inputLDIF) throws Exception {
    List<Object[]> changes = new LinkedList<Object[]>();
    for (String ldifString : inputLDIF) {
      byte[] bytes = StaticUtils.getBytes(ldifString);

      LDIFReader reader = new LDIFReader(new LDIFImportConfig(
          new ByteArrayInputStream(bytes)));
      ChangeRecordEntry change = reader.readChangeRecord(false);

      Assert.assertNotNull(change);
      Assert.assertTrue(theClass.isInstance(change));
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.