OPENDJ-1932 CR-6839 Improve management context API
Great thanks to JNR!
Here is the CR thread link: http://sources.forgerock.org/cru/CR-6839#c74225
* org.forgerock.opendj.config.client.DriverBasedManagementContext
** Old ManagementContext abstract class. It represents now a driver based management context.
** No other changes in this file
* org.forgerock.opendj.config.client.ManagementContext
** Changed to interface
* org.forgerock.opendj.config.client.ldap.LDAPManagementContext
** Add inner wrapper class which allow close() method overwrite.
* org.opends.guitools.controlpanel.ui.AbstractIndexPanel
* org.opends.guitools.controlpanel.ui.AbstractVLVIndexPanel
* org.opends.guitools.controlpanel.ui.NewBaseDNPanel
* org.opends.server.tools.BackendCreationHelper
** Consequences of this API change + refactoring
1 files added
6 files modified
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at legal-notices/CDDLv1_0.txt. |
| | | * If applicable, add the following below this CDDL HEADER, with the |
| | | * fields enclosed by brackets "[]" replaced with your own identifying |
| | | * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.client; |
| | | |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.Configuration; |
| | | import org.forgerock.opendj.config.ConfigurationClient; |
| | | import org.forgerock.opendj.config.DefinitionDecodingException; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.ManagedObjectPath; |
| | | import org.forgerock.opendj.config.OptionalRelationDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.client.spi.Driver; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.server.config.client.RootCfgClient; |
| | | |
| | | /** |
| | | * Driver based client management connection context. |
| | | */ |
| | | public abstract class DriverBasedManagementContext implements ManagementContext { |
| | | |
| | | /** |
| | | * Creates a new management context. |
| | | */ |
| | | protected DriverBasedManagementContext() { |
| | | // No implementation required. |
| | | } |
| | | |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, String name) |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, |
| | | LdapException { |
| | | return getDriver().deleteManagedObject(parent, rd, name); |
| | | } |
| | | |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, OptionalRelationDefinition<C, S> rd) throws |
| | | ManagedObjectNotFoundException, OperationRejectedException, LdapException { |
| | | return getDriver().deleteManagedObject(parent, rd); |
| | | } |
| | | |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd, String name) |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, LdapException { |
| | | return getDriver().deleteManagedObject(parent, rd, name); |
| | | } |
| | | |
| | | @Override |
| | | @SuppressWarnings("unchecked") |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getManagedObject( |
| | | ManagedObjectPath<C, S> path) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | | ManagedObjectNotFoundException, LdapException { |
| | | // Be careful to handle the root configuration. |
| | | if (path.isEmpty()) { |
| | | return (ManagedObject<C>) getRootConfigurationManagedObject(); |
| | | } |
| | | |
| | | return getDriver().getManagedObject(path); |
| | | } |
| | | |
| | | @Override |
| | | public final <P> P getPropertyValue(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd) |
| | | throws DefinitionDecodingException, LdapException, ManagedObjectNotFoundException { |
| | | Set<P> values = getPropertyValues(path, pd); |
| | | if (values.isEmpty()) { |
| | | return null; |
| | | } else { |
| | | return values.iterator().next(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public final <P> SortedSet<P> getPropertyValues(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd) |
| | | throws DefinitionDecodingException, LdapException, ManagedObjectNotFoundException { |
| | | return getDriver().getPropertyValues(path, pd); |
| | | } |
| | | |
| | | @Override |
| | | public final RootCfgClient getRootConfiguration() { |
| | | return getRootConfigurationManagedObject().getConfiguration(); |
| | | } |
| | | |
| | | @Override |
| | | public final ManagedObject<RootCfgClient> getRootConfigurationManagedObject() { |
| | | return getDriver().getRootConfigurationManagedObject(); |
| | | } |
| | | |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd) throws |
| | | ManagedObjectNotFoundException, LdapException { |
| | | return listManagedObjects(parent, rd, rd.getChildDefinition()); |
| | | } |
| | | |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws |
| | | ManagedObjectNotFoundException, LdapException { |
| | | return getDriver().listManagedObjects(parent, rd, d); |
| | | } |
| | | |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd) throws |
| | | ManagedObjectNotFoundException, LdapException { |
| | | return getDriver().listManagedObjects(parent, rd, rd.getChildDefinition()); |
| | | } |
| | | |
| | | @Override |
| | | public final boolean managedObjectExists(ManagedObjectPath<?, ?> path) throws ManagedObjectNotFoundException, |
| | | LdapException { |
| | | return getDriver().managedObjectExists(path); |
| | | } |
| | | |
| | | /** |
| | | * Gets the driver associated with this management context. |
| | | * |
| | | * @return Returns the driver associated with this management context. |
| | | */ |
| | | protected abstract Driver getDriver(); |
| | | |
| | | @Override |
| | | public final void close() { |
| | | getDriver().close(); |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.client; |
| | | |
| | | import java.io.Closeable; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | |
| | | import org.forgerock.opendj.server.config.client.RootCfgClient; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.Configuration; |
| | | import org.forgerock.opendj.config.ConfigurationClient; |
| | |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.PropertyException; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.client.spi.Driver; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.server.config.client.RootCfgClient; |
| | | |
| | | /** |
| | | * Client management connection context. |
| | | */ |
| | | public abstract class ManagementContext implements Closeable { |
| | | |
| | | /** |
| | | * Creates a new management context. |
| | | */ |
| | | protected ManagementContext() { |
| | | // No implementation required. |
| | | } |
| | | public interface ManagementContext extends Closeable { |
| | | |
| | | /** |
| | | * Deletes the named instantiable child managed object from the named parent |
| | |
| | | * @throws LdapException |
| | | * If any other error occurs. |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, String name) |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, |
| | | LdapException { |
| | | return getDriver().deleteManagedObject(parent, rd, name); |
| | | } |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, LdapException; |
| | | |
| | | /** |
| | | * Deletes the optional child managed object from the named parent managed |
| | |
| | | * @throws LdapException |
| | | * If any other error occurs. |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, OptionalRelationDefinition<C, S> rd) throws |
| | | ManagedObjectNotFoundException, OperationRejectedException, LdapException { |
| | | return getDriver().deleteManagedObject(parent, rd); |
| | | } |
| | | ManagedObjectNotFoundException, OperationRejectedException, LdapException; |
| | | |
| | | /** |
| | | * Deletes s set child managed object from the named parent managed object. |
| | |
| | | * @throws LdapException |
| | | * If any other error occurs. |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd, String name) |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, LdapException { |
| | | return getDriver().deleteManagedObject(parent, rd, name); |
| | | } |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, LdapException; |
| | | |
| | | /** |
| | | * Gets the named managed object. |
| | |
| | | * @throws LdapException |
| | | * If any other error occurs. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getManagedObject( |
| | | <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getManagedObject( |
| | | ManagedObjectPath<C, S> path) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | | ManagedObjectNotFoundException, LdapException { |
| | | // Be careful to handle the root configuration. |
| | | if (path.isEmpty()) { |
| | | return (ManagedObject<C>) getRootConfigurationManagedObject(); |
| | | } |
| | | |
| | | return getDriver().getManagedObject(path); |
| | | } |
| | | ManagedObjectNotFoundException, LdapException; |
| | | |
| | | /** |
| | | * Gets the effective value of a property in the named managed object. |
| | |
| | | * @throws LdapException |
| | | * If any other error occurs. |
| | | */ |
| | | public final <P> P getPropertyValue(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd) |
| | | throws DefinitionDecodingException, LdapException, ManagedObjectNotFoundException { |
| | | Set<P> values = getPropertyValues(path, pd); |
| | | if (values.isEmpty()) { |
| | | return null; |
| | | } else { |
| | | return values.iterator().next(); |
| | | } |
| | | } |
| | | <P> P getPropertyValue(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd) |
| | | throws DefinitionDecodingException, LdapException, ManagedObjectNotFoundException; |
| | | |
| | | /** |
| | | * Gets the effective values of a property in the named managed object. |
| | |
| | | * @throws LdapException |
| | | * If any other error occurs. |
| | | */ |
| | | public final <P> SortedSet<P> getPropertyValues(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd) |
| | | throws DefinitionDecodingException, LdapException, ManagedObjectNotFoundException { |
| | | return getDriver().getPropertyValues(path, pd); |
| | | } |
| | | <P> SortedSet<P> getPropertyValues(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd) |
| | | throws DefinitionDecodingException, LdapException, ManagedObjectNotFoundException; |
| | | |
| | | /** |
| | | * Gets the root configuration client associated with this management |
| | |
| | | * @return Returns the root configuration client associated with this |
| | | * management context. |
| | | */ |
| | | public final RootCfgClient getRootConfiguration() { |
| | | return getRootConfigurationManagedObject().getConfiguration(); |
| | | } |
| | | RootCfgClient getRootConfiguration(); |
| | | |
| | | /** |
| | | * Gets the root configuration managed object associated with this |
| | |
| | | * @return Returns the root configuration managed object associated with |
| | | * this management context. |
| | | */ |
| | | public final ManagedObject<RootCfgClient> getRootConfigurationManagedObject() { |
| | | return getDriver().getRootConfigurationManagedObject(); |
| | | } |
| | | ManagedObject<RootCfgClient> getRootConfigurationManagedObject(); |
| | | |
| | | /** |
| | | * Lists the child managed objects of the named parent managed object. |
| | |
| | | * @throws LdapException |
| | | * If any other error occurs. |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd) throws |
| | | ManagedObjectNotFoundException, LdapException { |
| | | return listManagedObjects(parent, rd, rd.getChildDefinition()); |
| | | } |
| | | ManagedObjectNotFoundException, LdapException; |
| | | |
| | | /** |
| | | * Lists the child managed objects of the named parent managed object which |
| | |
| | | * @throws LdapException |
| | | * If any other error occurs. |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws |
| | | ManagedObjectNotFoundException, LdapException { |
| | | return getDriver().listManagedObjects(parent, rd, d); |
| | | } |
| | | ManagedObjectNotFoundException, LdapException; |
| | | |
| | | /** |
| | | * Lists the child managed objects of the named parent managed object. |
| | |
| | | * @throws LdapException |
| | | * If any other error occurs. |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd) throws |
| | | ManagedObjectNotFoundException, LdapException { |
| | | return getDriver().listManagedObjects(parent, rd, rd.getChildDefinition()); |
| | | } |
| | | ManagedObjectNotFoundException, LdapException; |
| | | |
| | | /** |
| | | * Determines whether or not the named managed object exists. |
| | |
| | | * @throws LdapException |
| | | * If any other error occurs. |
| | | */ |
| | | public final boolean managedObjectExists(ManagedObjectPath<?, ?> path) throws ManagedObjectNotFoundException, |
| | | LdapException { |
| | | return getDriver().managedObjectExists(path); |
| | | } |
| | | |
| | | /** |
| | | * Gets the driver associated with this management context. |
| | | * |
| | | * @return Returns the driver associated with this management context. |
| | | */ |
| | | protected abstract Driver getDriver(); |
| | | |
| | | /** |
| | | * Closes this management context. |
| | | */ |
| | | @Override |
| | | public final void close() { |
| | | getDriver().close(); |
| | | } |
| | | |
| | | boolean managedObjectExists(ManagedObjectPath<?, ?> path) throws ManagedObjectNotFoundException, LdapException; |
| | | } |
| | |
| | | import java.io.FileReader; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.SortedSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.Configuration; |
| | | import org.forgerock.opendj.config.ConfigurationClient; |
| | | import org.forgerock.opendj.config.DefinitionDecodingException; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.LDAPProfile; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.ManagedObjectPath; |
| | | import org.forgerock.opendj.config.OptionalRelationDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.client.DriverBasedManagementContext; |
| | | import org.forgerock.opendj.config.client.ManagedObject; |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.config.client.OperationRejectedException; |
| | | import org.forgerock.opendj.config.client.spi.Driver; |
| | | import org.forgerock.opendj.ldap.AbstractConnectionWrapper; |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.ldap.MemoryBackend; |
| | | import org.forgerock.opendj.ldap.requests.UnbindRequest; |
| | | import org.forgerock.opendj.ldif.LDIF; |
| | | import org.forgerock.opendj.ldif.LDIFEntryReader; |
| | | import org.forgerock.opendj.ldif.LDIFEntryWriter; |
| | | import org.forgerock.opendj.server.config.client.RootCfgClient; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An LDAP management connection context. |
| | | */ |
| | | public final class LDAPManagementContext extends ManagementContext { |
| | | public final class LDAPManagementContext extends DriverBasedManagementContext { |
| | | |
| | | private static final class ManagementContextWrapper implements ManagementContext { |
| | | private final ManagementContext delegate; |
| | | private final List<IOException> exceptions; |
| | | |
| | | private ManagementContextWrapper(ManagementContext result, List<IOException> exceptions) { |
| | | this.delegate = result; |
| | | this.exceptions = exceptions; |
| | | } |
| | | |
| | | @Override |
| | | public boolean managedObjectExists(ManagedObjectPath<?, ?> path) throws ManagedObjectNotFoundException, |
| | | LdapException { |
| | | return delegate.managedObjectExists(path); |
| | | } |
| | | |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd) throws ManagedObjectNotFoundException, |
| | | LdapException { |
| | | return delegate.listManagedObjects(parent, rd); |
| | | } |
| | | |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws ManagedObjectNotFoundException, |
| | | LdapException { |
| | | return delegate.listManagedObjects(parent, rd, d); |
| | | } |
| | | |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd) |
| | | throws ManagedObjectNotFoundException, LdapException { |
| | | return delegate.listManagedObjects(parent, rd); |
| | | } |
| | | |
| | | @Override |
| | | public ManagedObject<RootCfgClient> getRootConfigurationManagedObject() { |
| | | return delegate.getRootConfigurationManagedObject(); |
| | | } |
| | | |
| | | @Override |
| | | public RootCfgClient getRootConfiguration() { |
| | | return delegate.getRootConfiguration(); |
| | | } |
| | | |
| | | @Override |
| | | public <P> SortedSet<P> getPropertyValues(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd) |
| | | throws DefinitionDecodingException, LdapException, ManagedObjectNotFoundException { |
| | | return delegate.getPropertyValues(path, pd); |
| | | } |
| | | |
| | | @Override |
| | | public <P> P getPropertyValue(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd) |
| | | throws DefinitionDecodingException, LdapException, ManagedObjectNotFoundException { |
| | | return delegate.getPropertyValue(path, pd); |
| | | } |
| | | |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getManagedObject( |
| | | ManagedObjectPath<C, S> path) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | | ManagedObjectNotFoundException, LdapException { |
| | | return delegate.getManagedObject(path); |
| | | } |
| | | |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd, String name) |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, LdapException { |
| | | return delegate.deleteManagedObject(parent, rd, name); |
| | | } |
| | | |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, OptionalRelationDefinition<C, S> rd) |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, LdapException { |
| | | return delegate.deleteManagedObject(parent, rd); |
| | | } |
| | | |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, String name) |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, LdapException { |
| | | return delegate.deleteManagedObject(parent, rd, name); |
| | | } |
| | | |
| | | @Override |
| | | public void close() throws IOException { |
| | | delegate.close(); |
| | | if (!exceptions.isEmpty()) { |
| | | throw exceptions.get(0); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | |
| | | return context; |
| | | } |
| | | |
| | | /** |
| | | * Returns a LDIF management context on the provided LDIF file. |
| | | * |
| | | * @param ldifFile |
| | | * The LDIF file to manage |
| | | * @param profile |
| | | * The LDAP profile |
| | | * @param exceptions |
| | | * Contains {@code IOException} that may occurred during management context close. |
| | | * Could be {@code null} |
| | | * @return A LDIF file management context |
| | | * @throws IOException |
| | | * If problems occurs while reading the file. |
| | | */ |
| | | public static ManagementContext newLDIFManagementContext(final File ldifFile, final LDAPProfile profile, |
| | | private static ManagementContext newLDIFManagementContext(final File ldifFile, final LDAPProfile profile, |
| | | final List<IOException> exceptions) throws IOException { |
| | | final BufferedReader configReader = new BufferedReader(new FileReader(ldifFile)); |
| | | try { |
| | |
| | | */ |
| | | public static ManagementContext newLDIFManagementContext(final File ldifFile, final LDAPProfile profile) |
| | | throws IOException { |
| | | return newLDIFManagementContext(ldifFile, profile, null); |
| | | final List<IOException> exceptions = new ArrayList<>(); |
| | | return new ManagementContextWrapper(newLDIFManagementContext(ldifFile, profile, exceptions), exceptions); |
| | | } |
| | | |
| | | /** The LDAP management context driver. */ |
| | |
| | | import java.awt.Container; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.io.IOException; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | |
| | | throws OpenDsException |
| | | { |
| | | getInfo().initializeConfigurationFramework(); |
| | | try |
| | | final File configFile = Installation.getLocal().getCurrentConfigurationFile(); |
| | | final LDAPProfile ldapProfile = LDAPProfile.getInstance(); |
| | | try (ManagementContext context = LDAPManagementContext.newLDIFManagementContext(configFile, ldapProfile)) |
| | | { |
| | | final List<IOException> exceptions = new ArrayList<>(); |
| | | final ManagementContext context = LDAPManagementContext.newLDIFManagementContext( |
| | | Installation.getLocal().getCurrentConfigurationFile(), LDAPProfile.getInstance(), exceptions); |
| | | final BackendCfgClient backend = context.getRootConfiguration().getBackend(backendName); |
| | | if (backend instanceof LocalDBBackendCfgClient) |
| | | { |
| | |
| | | updateBackendIndexOnline( |
| | | (PluggableBackendCfgClient) backend, indexToModify, attributeName, indexTypes, indexEntryLimit); |
| | | } |
| | | context.close(); |
| | | Utilities.throwFirstFrom(exceptions); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | |
| | | import java.awt.event.ActionListener; |
| | | import java.awt.event.ItemEvent; |
| | | import java.awt.event.ItemListener; |
| | | import java.io.IOException; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.LinkedHashSet; |
| | |
| | | final List<VLVSortOrder> sortOrder) throws OpenDsException |
| | | { |
| | | getInfo().initializeConfigurationFramework(); |
| | | try |
| | | final File configFile = Installation.getLocal().getCurrentConfigurationFile(); |
| | | final LDAPProfile ldapProfile = LDAPProfile.getInstance(); |
| | | try (ManagementContext context = LDAPManagementContext.newLDIFManagementContext(configFile, ldapProfile)) |
| | | { |
| | | final List<IOException> exceptions = new ArrayList<>(); |
| | | final ManagementContext context = LDAPManagementContext.newLDIFManagementContext( |
| | | Installation.getLocal().getCurrentConfigurationFile(), LDAPProfile.getInstance(), exceptions); |
| | | final BackendCfgClient backend = context.getRootConfiguration().getBackend(backendName); |
| | | if (backend instanceof LocalDBBackendCfgClient) |
| | | { |
| | |
| | | updateVLVBackendIndexOnline((PluggableBackendCfgClient) backend, vlvIndexName, indexToModify, baseDN, filter, |
| | | searchScope, sortOrder); |
| | | } |
| | | context.close(); |
| | | Utilities.throwFirstFrom(exceptions); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | |
| | | try |
| | | { |
| | | getInfo().initializeConfigurationFramework(); |
| | | final List<IOException> exceptions = new ArrayList<>(); |
| | | final org.forgerock.opendj.config.client.ManagementContext context = |
| | | org.forgerock.opendj.config.client.ldap.LDAPManagementContext.newLDIFManagementContext( |
| | | Installation.getLocal().getCurrentConfigurationFile(), LDAPProfile.getInstance(), exceptions); |
| | | final File config = Installation.getLocal().getCurrentConfigurationFile(); |
| | | final LDAPProfile profile = LDAPProfile.getInstance(); |
| | | try (org.forgerock.opendj.config.client.ManagementContext context = |
| | | org.forgerock.opendj.config.client.ldap.LDAPManagementContext.newLDIFManagementContext(config, profile)) |
| | | { |
| | | final org.forgerock.opendj.server.config.client.BackendCfgClient backend = |
| | | context.getRootConfiguration().getBackend(backendName); |
| | | final SortedSet<org.forgerock.opendj.ldap.DN> baseDNs = backend.getBaseDN(); |
| | | baseDNs.add(org.forgerock.opendj.ldap.DN.valueOf(newBaseDN)); |
| | | backend.setBaseDN(baseDNs); |
| | | backend.commit(); |
| | | context.close(); |
| | | Utilities.throwFirstFrom(exceptions); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.LinkedList; |
| | |
| | | ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg> backendType) throws Exception |
| | | { |
| | | Utilities.initializeConfigurationFramework(); |
| | | final List<IOException> exceptions = new ArrayList<>(); |
| | | final ManagementContext context = LDAPManagementContext.newLDIFManagementContext( |
| | | Installation.getLocal().getCurrentConfigurationFile(), LDAPProfile.getInstance(), exceptions); |
| | | final File configFile = Installation.getLocal().getCurrentConfigurationFile(); |
| | | final LDAPProfile ldapProfile = LDAPProfile.getInstance(); |
| | | try (ManagementContext context = LDAPManagementContext.newLDIFManagementContext(configFile, ldapProfile)) |
| | | { |
| | | createBackend(context.getRootConfiguration(), backendName, baseDNs, backendType); |
| | | context.close(); |
| | | Utilities.throwFirstFrom(exceptions); |
| | | } |
| | | } |
| | | |
| | | /** |