| | |
| | | */ |
| | | package org.opends.server.replication.common; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.replication.plugin.MultimasterReplication; |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.workflowelement.externalchangelog.ECLWorkflowElement; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | |
| | |
| | | */ |
| | | public class LastCookieVirtualProvider |
| | | extends VirtualAttributeProvider<UserDefinedVirtualAttributeCfg> |
| | | implements ConfigurationChangeListener<UserDefinedVirtualAttributeCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private final ReplicationServer replicationServer; |
| | | |
| | | /** |
| | | * Creates a new instance of this member virtual attribute provider. |
| | | * |
| | | * @param replicationServer |
| | | * The replication server. |
| | | */ |
| | | public LastCookieVirtualProvider() |
| | | public LastCookieVirtualProvider(ReplicationServer replicationServer) |
| | | { |
| | | super(); |
| | | |
| | | // All initialization should be performed in the |
| | | // initializeVirtualAttributeProvider method. |
| | | this.replicationServer = replicationServer; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | { |
| | | try |
| | | { |
| | | ECLWorkflowElement eclwe = (ECLWorkflowElement) |
| | | DirectoryServer.getWorkflowElement("EXTERNAL CHANGE LOG"); |
| | | if (eclwe!=null) |
| | | if (replicationServer != null) |
| | | { |
| | | // Set a list of excluded domains (also exclude 'cn=changelog' itself) |
| | | Set<String> excludedDomains = |
| | | MultimasterReplication.getECLDisabledDomains(); |
| | | Set<String> excludedDomains = MultimasterReplication.getECLDisabledDomains(); |
| | | excludedDomains.add(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT); |
| | | |
| | | final ReplicationServer rs = eclwe.getReplicationServer(); |
| | | String newestCookie = rs.getNewestECLCookie(excludedDomains).toString(); |
| | | String newestCookie = replicationServer.getNewestECLCookie(excludedDomains).toString(); |
| | | return Attributes.create(rule.getAttributeType(), newestCookie); |
| | | } |
| | | } |
| | |
| | | searchOperation.appendErrorMessage(message); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | UserDefinedVirtualAttributeCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | UserDefinedVirtualAttributeCfg configuration) |
| | | { |
| | | return new ConfigChangeResult(ResultCode.OTHER, false); |
| | | } |
| | | } |