001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.directory.api.ldap.extras.controls.ad;
021
022import org.apache.directory.api.ldap.model.message.Control;
023
024/**
025 * The DirSync control, as described in http://tools.ietf.org/html/draft-armijo-ldap-dirsync-00.
026 * We use the same control for both the SearchRequest and the SearchResultDone. Here is the
027 * ASN/1 description of the SearchRequest control :
028 * 
029 * <pre>
030 * Repl    Control ::= SEQUENCE {
031 *     controlType             1.2.840.113556.1.4.841
032 *     controlValue            replControlValue
033 *     criticality             TRUE
034 * }
035 * 
036 * the control value can be one of the two structures :
037 * 
038 * Client side :
039 * realReplControlValue ::= SEQUENCE {
040 *     parentsFirst            integer
041 *     maxReturnLength         integer
042 *     cookie                  OCTET STRING
043 * }
044 * 
045 * or
046 * 
047 * server side :
048 * realReplControlValue ::= SEQUENCE {
049 *     flag                  integer
050 *     maxReturnLength       integer
051 *     cookie                OCTET STRING
052 * }
053 * </pre> 
054 *
055 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
056 *
057 */
058public interface AdDirSync extends Control
059{
060    /** This control OID */
061    static final String OID = "1.2.840.113556.1.4.841";
062    
063    /**
064     * @return 1 if the parents are guaranteed to be returned before the children.
065     */
066    int getParentFirst();
067    
068    
069    /**
070     * @param parentFirst The parentFirst flag. A value of 1 will tell the server to return the parents first.
071     */
072    void setParentFirst( int parentFirst );
073    
074    
075    /**
076     * @return The maximum length of attributes to be returned
077     */
078    int getMaxReturnLength();
079    
080    
081    /**
082     * @param maxReturnLength The maximum length of attributes to be returned
083     */
084    void setMaxReturnLength( int maxReturnLength );
085    
086    
087    /**
088     * @return The cookie used while processing the successive DirSync operations
089     */
090    byte[] getCookie();
091    
092    
093    /**
094     * @param cookie The cookie to send to the server. It's the value found in the response control. Should be null
095     * for the first control.
096     */
097    void setCookie( byte[] cookie );
098    
099    
100    /**
101     * @return The flag returned by the server. One of :
102     * <ul>
103     * <li>LDAP_DIRSYNC_OBJECT_SECURITY (0x0001)</li>
104     * <li>LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER (0x0800)</li>
105     * <li>LDAP_DIRSYNC_PUBLIC_DATA_ONLY (0x2000)(</li>
106     * <li>LDAP_DIRSYNC_INCREMENTAL_VALUES (0x7FFFFFFF)</li>
107     * </ul>
108     */
109    AdDirSyncFlag getFlag();
110    
111    
112    /**
113     * @param flag The flag. 
114     */
115    void setFlag( AdDirSyncFlag flag );
116}