001    /*
002     * Copyright 2010-2015 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2010-2015 UnboundID Corp.
007     *
008     * This program is free software; you can redistribute it and/or modify
009     * it under the terms of the GNU General Public License (GPLv2 only)
010     * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011     * as published by the Free Software Foundation.
012     *
013     * This program is distributed in the hope that it will be useful,
014     * but WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program; if not, see <http://www.gnu.org/licenses>.
020     */
021    package com.unboundid.ldap.listener;
022    
023    
024    
025    import com.unboundid.ldap.protocol.SearchResultEntryProtocolOp;
026    import com.unboundid.ldap.sdk.Control;
027    import com.unboundid.util.Extensible;
028    import com.unboundid.util.ThreadSafety;
029    import com.unboundid.util.ThreadSafetyLevel;
030    import com.unboundid.util.ObjectPair;
031    
032    
033    
034    /**
035     * This interface may be implemented by a class which wishes to intercept and
036     * alter search result entries in some way before they are returned to the
037     * client, and/or to prevent them from being returned altogether.  Search entry
038     * transformers may be enabled or disabled by adding them to or removing them
039     * from an {@link LDAPListenerClientConnection}.
040     */
041    @Extensible()
042    @ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
043    public interface SearchEntryTransformer
044    {
045      /**
046       * Transforms the provided search result entry and/or set of controls to alter
047       * what will be returned to the client.
048       *
049       * @param  messageID  The message ID for the associated search operation.
050       * @param  entry      The search result entry to be processed.  It will not be
051       *                    {@code null}.
052       * @param  controls   The set of controls to be processed.  It will not be
053       *                    {@code null} but may be empty if there are no controls.
054       *
055       * @return  An {@link ObjectPair} containing a possibly updated entry and set
056       *          of controls, or {@code null} to indicate that the entry should not
057       *          be returned to the client.
058       */
059      ObjectPair<SearchResultEntryProtocolOp,Control[]> transformEntry(
060           final int messageID, final SearchResultEntryProtocolOp entry,
061           final Control[] controls);
062    }