d1759377955a57f4c7362308bc78565694a87680neil_a_wilson/*
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * CDDL HEADER START
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * The contents of this file are subject to the terms of the
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * Common Development and Distribution License, Version 1.0 only
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * (the "License"). You may not use this file except in compliance
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * with the License.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * or http://forgerock.org/license/CDDLv1.0.html.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * See the License for the specific language governing permissions
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * and limitations under the License.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * When distributing Covered Code, include this CDDL HEADER in each
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * file and include the License file at legal-notices/CDDLv1_0.txt.
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * If applicable, add the following below this CDDL HEADER, with the
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * fields enclosed by brackets "[]" replaced with your own identifying
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * information:
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * Portions Copyright [yyyy] [name of copyright owner]
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * CDDL HEADER END
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
05b42f00b813c3dc70cbb80d62089f9cc0f6f549ludovicp * Copyright 2006-2008 Sun Microsystems, Inc.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilsonpackage org.opends.server.plugins;
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignacimport java.io.IOException;
d1759377955a57f4c7362308bc78565694a87680neil_a_wilsonimport java.util.ArrayList;
d1759377955a57f4c7362308bc78565694a87680neil_a_wilsonimport java.util.List;
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignacimport java.util.Set;
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignacimport org.opends.messages.Message;
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swiftimport org.opends.server.admin.std.server.PluginCfg;
d1759377955a57f4c7362308bc78565694a87680neil_a_wilsonimport org.opends.server.api.plugin.DirectoryServerPlugin;
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboliimport org.opends.server.api.plugin.PluginResult;
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignacimport org.opends.server.api.plugin.PluginType;
d1759377955a57f4c7362308bc78565694a87680neil_a_wilsonimport org.opends.server.config.ConfigException;
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignacimport org.opends.server.controls.ControlDecoder;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swiftimport org.opends.server.protocols.asn1.ASN1;
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignacimport org.opends.server.protocols.asn1.ASN1Reader;
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignacimport org.opends.server.protocols.asn1.ASN1Writer;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swiftimport org.opends.server.types.*;
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonimport org.opends.server.types.operation.*;
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignacimport static org.opends.server.protocols.asn1.ASN1Constants.*;
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson/**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * This class defines a very simple pre-operation plugin that sleeps for up to
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * five seconds for add, compare, delete, extended, modify, modify DN, and
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * search operations (and therefore not for abandon, bind, and unbind
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * operations, since those operations cannot be cancelled). While it is
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * sleeping, it also checks for a request to cancel the associated operation and
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * will respond to it accordingly.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilsonpublic class DelayPreOpPlugin
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift extends DirectoryServerPlugin<PluginCfg>
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson{
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * The OID for the delay request control, which is used to flag operations
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * that should be delayed.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson public static final String OID_DELAY_REQUEST = "1.3.6.1.4.1.26027.1.999.1";
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /**
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * The control used by this plugin.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift */
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift public static class DelayRequestControl extends Control
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /**
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * ControlDecoder implentation to decode this control from a ByteString.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift */
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift private final static class Decoder
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift implements ControlDecoder<DelayRequestControl>
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /**
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * {@inheritDoc}
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift */
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignac @Override
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift public DelayRequestControl decode(boolean isCritical, ByteString value)
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift throws DirectoryException
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ASN1Reader reader = ASN1.getReader(value);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift try
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift long delay = reader.readInteger();
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift return new DelayRequestControl(isCritical, delay);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift catch (Exception e)
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift // TODO: Need a better message
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift throw new DirectoryException(ResultCode.PROTOCOL_ERROR, null, e);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignac @Override
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift public String getOID()
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift return OID_DELAY_REQUEST;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /**
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * The Control Decoder that can be used to decode this control.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift */
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift public static final ControlDecoder<DelayRequestControl> DECODER =
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift new Decoder();
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift private long delayDuration;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /**
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignac * Constructs a new control of this class.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift *
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignac * @param isCritical
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignac * Indicates whether support for this control should be considered
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignac * a critical part of the server processing.
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignac * @param delayDuration
80f9ce2386be52767bcbb60953ab2fcfd4395ea4JnRouvignac * The requested delay duration.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift */
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift public DelayRequestControl(boolean isCritical, long delayDuration)
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift super(OID_DELAY_REQUEST, isCritical);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift this.delayDuration = delayDuration;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /**
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * Writes this control's value to an ASN.1 writer. The value (if any)
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * must be written as an ASN1OctetString.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift *
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * @param writer The ASN.1 writer to use.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * @throws IOException If a problem occurs while writing to the stream.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift */
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift @Override
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift protected void writeValue(ASN1Writer writer) throws IOException {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift writer.writeStartSequence(UNIVERSAL_OCTET_STRING_TYPE);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift writer.writeInteger(delayDuration);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift writer.writeEndSequence();
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /**
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * Retrieves the delay duration.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift *
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift * @return The delay duration.
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift */
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift public long getDelayDuration()
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift return delayDuration;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * Creates a new instance of this Directory Server plugin. Every
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * plugin must implement a default constructor (it is the only one
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * that will be used to create plugins defined in the
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * configuration), and every plugin constructor must call
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * <CODE>super()</CODE> as its first element.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson public DelayPreOpPlugin()
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson super();
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * {@inheritDoc}
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson @Override()
54e2384a2c22191e7df5a2bbf25778dcbcf64368neil_a_wilson public void initializePlugin(Set<PluginType> pluginTypes,
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift PluginCfg configuration)
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson throws ConfigException
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson // This plugin may only be used as a pre-operation plugin.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson for (PluginType t : pluginTypes)
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson switch (t)
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson case PRE_OPERATION_ADD:
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson case PRE_OPERATION_BIND:
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson case PRE_OPERATION_COMPARE:
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson case PRE_OPERATION_DELETE:
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson case PRE_OPERATION_EXTENDED:
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson case PRE_OPERATION_MODIFY:
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson case PRE_OPERATION_MODIFY_DN:
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson case PRE_OPERATION_SEARCH:
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson // This is fine.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson break;
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson default:
53247d28ba99538f841a13ea2cde01c3faa3ef36kenneth_suter throw new ConfigException(Message.raw("Invalid plugin type " + t +
53247d28ba99538f841a13ea2cde01c3faa3ef36kenneth_suter " for delay pre-op plugin."));
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * {@inheritDoc}
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson @Override()
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli public PluginResult.PreOperation
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson doPreOperation(PreOperationAddOperation addOperation)
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli throws CanceledOperationException {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson return doPreOperationInternal(addOperation);
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * {@inheritDoc}
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson @Override()
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli public PluginResult.PreOperation
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli doPreOperation(PreOperationBindOperation bindOperation)
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli try
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli {
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli return doPreOperationInternal(bindOperation);
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli }
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli catch(CanceledOperationException coe)
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli {
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli // Bind ops can't be canceled. Just ignore.
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli return PluginResult.PreOperation.continueOperationProcessing();
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * {@inheritDoc}
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson @Override()
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli public PluginResult.PreOperation
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli doPreOperation(PreOperationCompareOperation compareOperation)
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli throws CanceledOperationException {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson return doPreOperationInternal(compareOperation);
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * {@inheritDoc}
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson @Override()
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli public PluginResult.PreOperation
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson doPreOperation(PreOperationDeleteOperation deleteOperation)
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli throws CanceledOperationException {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson return doPreOperationInternal(deleteOperation);
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * {@inheritDoc}
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson @Override()
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli public PluginResult.PreOperation
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson doPreOperation(PreOperationExtendedOperation extendedOperation)
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli throws CanceledOperationException {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson return doPreOperationInternal(extendedOperation);
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * {@inheritDoc}
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson @Override()
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli public PluginResult.PreOperation
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson doPreOperation(PreOperationModifyOperation modifyOperation)
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli throws CanceledOperationException {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson return doPreOperationInternal(modifyOperation);
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * {@inheritDoc}
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson @Override()
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli public PluginResult.PreOperation
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson doPreOperation(PreOperationModifyDNOperation modifyDNOperation)
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli throws CanceledOperationException {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson return doPreOperationInternal(modifyDNOperation);
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * {@inheritDoc}
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson @Override()
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli public PluginResult.PreOperation
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson doPreOperation(PreOperationSearchOperation searchOperation)
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli throws CanceledOperationException {
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson return doPreOperationInternal(searchOperation);
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * Looks for a delay request control in the operation, and if one is found
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * then sleep in 10 millisecond increments up to the length of time specified
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * in the control value. If the operation receives a cancel request during
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * this time, then the control will stop sleeping immediately.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * @param operation The operation to be processed.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * @return The result of the plugin processing.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli private PluginResult.PreOperation
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson doPreOperationInternal(PreOperationOperation operation)
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift throws CanceledOperationException
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift DelayRequestControl control;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift try
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift control = operation.getRequestControl(DelayRequestControl.DECODER);
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift catch (Exception e)
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift return PluginResult.PreOperation.stopProcessing(
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ResultCode.PROTOCOL_ERROR,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift Message.raw("Unable to decode the delay request control: " +
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift e));
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift if(control != null)
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift long delayDuration = control.getDelayDuration();
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift if (delayDuration <= 0)
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift return PluginResult.PreOperation.continueOperationProcessing();
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift long stopSleepTime = System.currentTimeMillis() + delayDuration;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift while (System.currentTimeMillis() < stopSleepTime)
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift operation.checkIfCanceled(false);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift try
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift Thread.sleep(10);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift } catch (Exception e) {}
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
04a13ed0142e4ee74842a64dd3d65153eaeb3d0cboli return PluginResult.PreOperation.continueOperationProcessing();
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * Creates a delay request control with the specified delay.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * @param delay The length of time in milliseconds to sleep.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * @return The appropriate delay request control.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson public static Control createDelayControl(long delay)
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift return new DelayRequestControl(false, delay);
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson /**
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * Retrieves a list containing a delay request LDAP control with the specified
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * delay.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * @param delay The length of time in milliseconds to sleep.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson *
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson * @return A list containing the appropriate delay request LDAP control.
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson */
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift public static List<Control> createDelayControlList(long delay)
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ArrayList<Control> controlList = new ArrayList<Control>(1);
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift controlList.add(new DelayRequestControl(false, delay));
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson return controlList;
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson }
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson}
d1759377955a57f4c7362308bc78565694a87680neil_a_wilson