directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1063973 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls: ./ EntryChange.java PagedResults.java SimpleEntryChange.java SimplePagedResults.java
Date Thu, 27 Jan 2011 03:24:15 GMT
Author: akarasulu
Date: Thu Jan 27 03:24:15 2011
New Revision: 1063973

URL: http://svn.apache.org/viewvc?rev=1063973&view=rev
Log:
moving cleaned up control interfaces and simple implementations to model

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/EntryChange.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/PagedResults.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/SimpleEntryChange.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/SimplePagedResults.java

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/EntryChange.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/EntryChange.java?rev=1063973&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/EntryChange.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/EntryChange.java
Thu Jan 27 03:24:15 2011
@@ -0,0 +1,107 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.model.message.controls;
+
+
+import org.apache.directory.shared.ldap.codec.search.controls.ChangeType;
+import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.name.Dn;
+
+
+/**
+ * A response control that may be returned by Persistent Search entry responses.
+ * It contains addition change information to describe the exact change that
+ * occurred to an entry. The exact details of this control are covered in section
+ * 5 of this (yes) expired draft: <a
+ * href="http://www3.ietf.org/proceedings/01aug/I-D/draft-ietf-ldapext-psearch-03.txt">
+ * Persistent Search Draft v03</a> which is printed out below for convenience:
+ *
+ * <pre>
+ *    5.  Entry Change Notification Control
+ *
+ *    This control provides additional information about the change the caused
+ *    a particular entry to be returned as the result of a persistent search.
+ *    The controlType is &quot;2.16.840.1.113730.3.4.7&quot;.  If the client set
the
+ *    returnECs boolean to TRUE in the PersistentSearch control, servers MUST
+ *    include an EntryChangeNotification control in the Controls portion of
+ *    each SearchResultEntry that is returned due to an entry being added,
+ *    deleted, or modified.
+ *
+ *               EntryChangeNotification ::= SEQUENCE
+ *               {
+ *                         changeType ENUMERATED
+ *                         {
+ *                                 add             (1),
+ *                                 delete          (2),
+ *                                 modify          (4),
+ *                                 modDN           (8)
+ *                         },
+ *                         previousDN   LDAPDN OPTIONAL,     -- modifyDN ops. only
+ *                         changeNumber INTEGER OPTIONAL     -- if supported
+ *               }
+ *
+ *    changeType indicates what LDAP operation caused the entry to be
+ *    returned.
+ *
+ *    previousDN is present only for modifyDN operations and gives the Dn of
+ *    the entry before it was renamed and/or moved.  Servers MUST include this
+ *    optional field only when returning change notifications as a result of
+ *    modifyDN operations.
+ *
+ *    changeNumber is the change number [CHANGELOG] assigned by a server for
+ *    the change.  If a server supports an LDAP Change Log it SHOULD include
+ *    this field.
+ * </pre>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface EntryChange extends Control
+{
+    int UNDEFINED_CHANGE_NUMBER = -1;
+
+    /** The EntryChange control */
+    String OID = "2.16.840.1.113730.3.4.7";
+
+
+    /**
+     * @return The ChangeType
+     */
+    ChangeType getChangeType();
+
+
+    /**
+     * Set the ChangeType
+     *
+     * @param changeType Add, Delete; Modify or ModifyDN
+     */
+    void setChangeType( ChangeType changeType );
+
+
+    Dn getPreviousDn();
+
+
+    void setPreviousDn( Dn previousDn );
+
+
+    long getChangeNumber();
+
+
+    void setChangeNumber( long changeNumber );
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/PagedResults.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/PagedResults.java?rev=1063973&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/PagedResults.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/PagedResults.java
Thu Jan 27 03:24:15 2011
@@ -0,0 +1,91 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.model.message.controls;
+
+
+import org.apache.directory.shared.ldap.model.message.Control;
+
+
+/**
+ * A request/response control used to implement a simple paging of search
+ * results. This is an implementation of RFC 2696 :
+ * <a href="http://www.faqs.org/rfcs/rfc2696.html">LDAP Control Extension for Simple
Paged Results Manipulation</a>
+ * <br/>
+ * <pre>
+ *    This control is included in the searchRequest and searchResultDone
+ *    messages as part of the controls field of the LDAPMessage, as defined
+ *    in Section 4.1.12 of [LDAPv3]. The structure of this control is as
+ *    follows:
+ *
+ * pagedResultsControl ::= SEQUENCE {
+ *         controlType     1.2.840.113556.1.4.319,
+ *         criticality     BOOLEAN DEFAULT FALSE,
+ *         controlValue    searchControlValue
+ * }
+ *
+ * The searchControlValue is an OCTET STRING wrapping the BER-encoded
+ * version of the following SEQUENCE:
+ *
+ * realSearchControlValue ::= SEQUENCE {
+ *         size            INTEGER (0..maxInt),
+ *                                 -- requested page size from client
+ *                                 -- result set size estimate from server
+ *         cookie          OCTET STRING
+ * }
+ *
+ * </pre>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface PagedResults extends Control
+{
+    /** The Paged Search Control OID */
+    String OID = "1.2.840.113556.1.4.319";
+
+
+    /**
+     * @return The requested or returned number of entries
+     */
+    int getSize();
+
+    /**
+     * Set the number of entry requested or returned
+     *
+     * @param size The number of entries
+     */
+    void setSize( int size );
+
+    /**
+     * @return The stored cookie
+     */
+    byte[] getCookie();
+
+    /**
+     * Set the cookie
+     *
+     * @param cookie The cookie to store in this control
+     */
+    void setCookie( byte[] cookie );
+
+    /**
+     * @return The integer value for the current cookie
+     */
+    int getCookieValue();
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/SimpleEntryChange.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/SimpleEntryChange.java?rev=1063973&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/SimpleEntryChange.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/SimpleEntryChange.java
Thu Jan 27 03:24:15 2011
@@ -0,0 +1,135 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.model.message.controls;
+
+
+import org.apache.directory.shared.ldap.codec.controls.BasicControlImpl;
+import org.apache.directory.shared.ldap.codec.search.controls.ChangeType;
+import org.apache.directory.shared.ldap.model.name.Dn;
+
+
+/**
+ * A simple implementation of the EntryChange response control.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SimpleEntryChange extends BasicControlImpl implements EntryChange
+{
+
+    private ChangeType changeType = ChangeType.ADD;
+
+    private long changeNumber = UNDEFINED_CHANGE_NUMBER;
+
+    /** The previous Dn */
+    private Dn previousDn = null;
+
+
+    /**
+     *
+     * Creates a new instance of EntryChangeControl.
+     *
+     */
+    public SimpleEntryChange()
+    {
+        super( OID );
+    }
+
+
+    public ChangeType getChangeType()
+    {
+        return changeType;
+    }
+
+
+    public void setChangeType( ChangeType changeType )
+    {
+        this.changeType = changeType;
+    }
+
+
+    public Dn getPreviousDn()
+    {
+        return previousDn;
+    }
+
+
+    public void setPreviousDn( Dn previousDn )
+    {
+        this.previousDn = previousDn;
+    }
+
+
+    public long getChangeNumber()
+    {
+        return changeNumber;
+    }
+
+
+    public void setChangeNumber( long changeNumber )
+    {
+        this.changeNumber = changeNumber;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"})
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        EntryChange otherControl = ( EntryChange ) o;
+
+        return ( changeNumber == otherControl.getChangeNumber() ) &&
+             ( changeType == otherControl.getChangeType() ) &&
+             ( previousDn.equals( otherControl.getPreviousDn() ) );
+    }
+
+    
+    /**
+     * Return a String representing this EntryChangeControl.
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Entry Change Control\n" );
+        sb.append( "        oid : " ).append( getOid() ).append( '\n' );
+        sb.append( "        critical : " ).append( isCritical() ).append( '\n' );
+        sb.append( "        changeType   : '" ).append( changeType ).append( "'\n" );
+        sb.append( "        previousDN   : '" ).append( previousDn ).append( "'\n" );
+
+        if ( changeNumber == UNDEFINED_CHANGE_NUMBER )
+        {
+            sb.append( "        changeNumber : '" ).append( "UNDEFINED" ).append( "'\n" );
+        }
+        else
+        {
+            sb.append( "        changeNumber : '" ).append( changeNumber ).append( "'\n"
);
+        }
+
+        return sb.toString();
+    }
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/SimplePagedResults.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/SimplePagedResults.java?rev=1063973&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/SimplePagedResults.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/controls/SimplePagedResults.java
Thu Jan 27 03:24:15 2011
@@ -0,0 +1,166 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.model.message.controls;
+
+
+import org.apache.directory.shared.ldap.codec.controls.BasicControlImpl;
+import org.apache.directory.shared.util.StringConstants;
+import org.apache.directory.shared.util.Strings;
+
+import java.util.Arrays;
+
+
+/**
+ * A request/response control used to implement a simple paging of search
+ * results. This is an implementation of RFC 2696 :
+ * <a href="http://www.faqs.org/rfcs/rfc2696.html">LDAP Control Extension for Simple
Paged Results Manipulation</a>
+ * <br/>
+ * <pre>
+ *    This control is included in the searchRequest and searchResultDone
+ *    messages as part of the controls field of the LDAPMessage, as defined
+ *    in Section 4.1.12 of [LDAPv3]. The structure of this control is as
+ *    follows:
+ *
+ * pagedResultsControl ::= SEQUENCE {
+ *         controlType     1.2.840.113556.1.4.319,
+ *         criticality     BOOLEAN DEFAULT FALSE,
+ *         controlValue    searchControlValue
+ * }
+ * 
+ * The searchControlValue is an OCTET STRING wrapping the BER-encoded
+ * version of the following SEQUENCE:
+ * 
+ * realSearchControlValue ::= SEQUENCE {
+ *         size            INTEGER (0..maxInt),
+ *                                 -- requested page size from client
+ *                                 -- result set size estimate from server
+ *         cookie          OCTET STRING
+ * }
+ * 
+ * </pre>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SimplePagedResults extends BasicControlImpl implements PagedResults
+{
+
+    /** The number of entries to return, or returned */
+    private int size;
+
+    /** The exchanged cookie */
+    private byte[] cookie = StringConstants.EMPTY_BYTES;
+
+
+    /**
+     * Creates a new instance of PagedResultsDecorator.
+     */
+    public SimplePagedResults()
+    {
+        super( OID );
+    }
+
+
+    public int getSize()
+    {
+        return size;
+    }
+
+
+    public void setSize( int size )
+    {
+        this.size = size;
+    }
+
+
+    public byte[] getCookie()
+    {
+        return cookie;
+    }
+
+
+    public void setCookie( byte[] cookie )
+    {
+        this.cookie = cookie;
+    }
+
+
+    public int getCookieValue()
+    {
+        int value = 0;
+
+        switch ( cookie.length )
+        {
+            case 1:
+                value = cookie[0] & 0x00FF;
+                break;
+
+            case 2:
+                value = ( ( cookie[0] & 0x00FF ) << 8 ) + ( cookie[1] & 0x00FF
);
+                break;
+
+            case 3:
+                value = ( ( cookie[0] & 0x00FF ) << 16 ) + ( ( cookie[1] &
0x00FF ) << 8 ) + ( cookie[2] & 0x00FF );
+                break;
+
+            case 4:
+                value = ( ( cookie[0] & 0x00FF ) << 24 ) + ( ( cookie[1] &
0x00FF ) << 16 )
+                    + ( ( cookie[2] & 0x00FF ) << 8 ) + ( cookie[3] & 0x00FF
);
+                break;
+
+        }
+
+        return value;
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     */
+    @SuppressWarnings( { "EqualsWhichDoesntCheckParameterClass" } )
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+
+        PagedResults otherControl = ( PagedResults ) o;
+
+        return ( size == otherControl.getSize() ) && Arrays.equals( cookie, otherControl.getCookie()
);
+    }
+
+
+    /**
+     * Return a String representing this PagedSearchControl.
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Paged Search Control\n" );
+        sb.append( "        oid : " ).append( getOid() ).append( '\n' );
+        sb.append( "        critical : " ).append( isCritical() ).append( '\n' );
+        sb.append( "        size   : '" ).append( size ).append( "'\n" );
+        sb.append( "        cookie   : '" ).append( Strings.dumpBytes(cookie) ).append( "'\n"
);
+
+        return sb.toString();
+    }
+}



Mime
View raw message