| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ServerManagementContext; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | /** |
| | | * Aggregation property definition. |
| | |
| | | public ConfigChangeResult applyConfigurationChange(ServerManagedObject<? extends S> mo) { |
| | | try { |
| | | if (targetIsEnabledCondition.evaluate(mo)) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | } catch (ConfigException e) { |
| | | // This should not happen - ignore it and throw an exception |
| | |
| | | throw new IllegalStateException("Attempting to delete a referenced " |
| | | + relationDefinition.getChildDefinition().getUserFriendlyName()); |
| | | } else { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | DN expectedDN = DNBuilder.create(childPath); |
| | | if (!configEntry.getName().equals(expectedDN)) { |
| | | // Doesn't apply to us. |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | } |
| | | |
| | | // Cached objects are guaranteed to be from previous acceptable |
| | | // callback. |
| | | // Cached objects are guaranteed to be from previous acceptable callback |
| | | ConfigChangeResult result = listener.applyConfigurationAdd(cachedManagedObject); |
| | | |
| | | // Now apply post constraint call-backs. |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | } else { |
| | | // The dependent entry was not found. |
| | | configRepository.deregisterChangeListener(configEntry.getName(), this); |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | } |
| | | |
| | |
| | | if (configEntry.getName().equals(dn)) { |
| | | finalizeChangeListener(); |
| | | } |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | public boolean configDeleteIsAcceptable(Entry configEntry, LocalizableMessageBuilder unacceptableReason) { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | * A set of messages describing the changes that were made, any |
| | | * action that may be required, or any problems that were encountered. |
| | | */ |
| | | private List<LocalizableMessage> messages; |
| | | private List<LocalizableMessage> messages = new ArrayList<LocalizableMessage>(); |
| | | |
| | | /** |
| | | * Indicates whether one or more of the changes requires |
| | |
| | | /** |
| | | * The result code to return to the client from this configuration change. |
| | | */ |
| | | private ResultCode resultCode; |
| | | private ResultCode resultCode = ResultCode.SUCCESS; |
| | | |
| | | /** |
| | | * Creates a new config change result object with the provided information. |
| | | * |
| | | * @param resultCode |
| | | * The result code for this config change result. |
| | | * @param adminActionRequired |
| | | * Indicates whether administrative action is required for one or |
| | | * more of the changes to take effect. |
| | | */ |
| | | public ConfigChangeResult(ResultCode resultCode, boolean adminActionRequired) { |
| | | this.resultCode = resultCode; |
| | | this.adminActionRequired = adminActionRequired; |
| | | this.messages = new ArrayList<LocalizableMessage>(); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new config change result object with the provided information. |
| | | * |
| | | * @param resultCode |
| | | * The result code for this config change result. |
| | | * @param adminActionRequired |
| | | * Indicates whether administrative action is required for one or |
| | | * more of the changes to take effect. |
| | | * @param messages |
| | | * A set of messages that provide additional information about |
| | | * the change processing. |
| | | */ |
| | | public ConfigChangeResult(ResultCode resultCode, boolean adminActionRequired, List<LocalizableMessage> messages) { |
| | | this.resultCode = resultCode; |
| | | this.adminActionRequired = adminActionRequired; |
| | | this.messages = messages; |
| | | public ConfigChangeResult() { |
| | | // nothing more to do |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return A string representation of this config change result. |
| | | */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | toString(buffer); |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | /** |
| | | * Create a new configuration delete listener adaptor for an optional |
| | | * relation. |
| | | * @param serverContext TODO |
| | | * @param serverContext |
| | | * The server context. |
| | | * @param path |
| | | * The managed object path of the parent. |
| | | * @param relation |
| | |
| | | |
| | | /** |
| | | * Create a new configuration delete listener adaptor for an set relation. |
| | | * @param serverContext TODO |
| | | * @param serverContext |
| | | * The server context. |
| | | * @param path |
| | | * The managed object path of the parent. |
| | | * @param relation |
| | |
| | | DN expectedDN = DNBuilder.create(childPath); |
| | | if (!configEntry.getName().equals(expectedDN)) { |
| | | // Doesn't apply to us. |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.spi.ConfigurationRepository; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS |
| | | * Portions copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.spi.ConfigDeleteListener; |
| | | import org.forgerock.opendj.config.server.spi.ConfigurationRepository; |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldif.LDIF; |
| | | import org.forgerock.opendj.server.config.client.ConnectionHandlerCfgClient; |
| | |
| | | private static final class DummyChangeListener implements ConfigurationChangeListener<TestChildCfg> { |
| | | |
| | | public ConfigChangeResult applyConfigurationChange(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | public boolean isConfigurationChangeAcceptable(TestChildCfg configuration, |
| | |
| | | private static final class DummyDeleteListener implements ConfigurationDeleteListener<TestChildCfg> { |
| | | |
| | | public ConfigChangeResult applyConfigurationDelete(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | public boolean isConfigurationDeleteAcceptable(TestChildCfg configuration, |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.spi.ConfigDeleteListener; |
| | | import org.forgerock.opendj.config.server.spi.ConfigurationRepository; |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldif.LDIF; |
| | | import org.mockito.ArgumentCaptor; |
| | | import org.testng.annotations.AfterClass; |
| | |
| | | private static class AddListener implements ConfigurationAddListener<TestChildCfg> { |
| | | |
| | | public ConfigChangeResult applyConfigurationAdd(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | public boolean isConfigurationAddAcceptable(TestChildCfg configuration, |
| | |
| | | private static class DeleteListener implements ConfigurationDeleteListener<TestChildCfg> { |
| | | |
| | | public ConfigChangeResult applyConfigurationDelete(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | public boolean isConfigurationDeleteAcceptable(TestChildCfg configuration, |
| | |
| | | private static class ChangeListener implements ConfigurationChangeListener<TestChildCfg> { |
| | | |
| | | public ConfigChangeResult applyConfigurationChange(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | public boolean isConfigurationChangeAcceptable(TestChildCfg configuration, |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.spi.ConfigurationRepository; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.mockito.ArgumentCaptor; |
| | | import org.testng.Assert; |
| | |
| | | private TestChildCfg childCfg; |
| | | |
| | | public ConfigChangeResult applyConfigurationAdd(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | /** Gets the child configuration checking that it has the expected name. */ |
| | |
| | | private TestChildCfg childCfg; |
| | | |
| | | public ConfigChangeResult applyConfigurationChange(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | /** Gets the child configuration checking that it has the expected name. */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package com.example.opendj; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigurationChangeListener; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import com.example.opendj.server.ExamplePluginCfg; |
| | | |
| | |
| | | // The new configuration has already been validated. |
| | | |
| | | // Update was successful, no restart required. |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |