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     */
020    
021    package org.apache.directory.shared.ldap.message.internal;
022    
023    import org.apache.directory.shared.ldap.message.ResultCodeEnum;
024    import org.apache.directory.shared.ldap.name.DN;
025    
026    
027    /**
028     * LDAPv3 result structure embedded into Responses. See section 4.1.10 in <a
029     * href="">RFC 2251</a> for a description of the LDAPResult ASN.1 structure,
030     * here's a snippet from it:
031     * 
032     * <pre>
033     *   The LDAPResult is the construct used in this protocol to return
034     *   success or failure indications from servers to clients. In response
035     *   to various requests servers will return responses containing fields
036     *   of type LDAPResult to indicate the final status of a protocol
037     *   operation request.
038     * </pre>
039     * 
040     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
041     * @version $Revision: 918756 $
042     */
043    public interface InternalLdapResult
044    {
045        /**
046         * Gets the result code enumeration associated with the response.
047         * Corresponds to the <b> resultCode </b> field within the LDAPResult ASN.1
048         * structure.
049         * 
050         * @return the result code enum value.
051         */
052        ResultCodeEnum getResultCode();
053    
054    
055        /**
056         * Sets the result code enumeration associated with the response.
057         * Corresponds to the <b> resultCode </b> field within the LDAPResult ASN.1
058         * structure.
059         * 
060         * @param resultCode
061         *            the result code enum value.
062         */
063        void setResultCode( ResultCodeEnum resultCode );
064    
065    
066        /**
067         * Gets the lowest entry in the directory that was matched. For result codes
068         * of noSuchObject, aliasProblem, invalidDNSyntax and
069         * aliasDereferencingProblem, the matchedDN field is set to the name of the
070         * lowest entry (object or alias) in the directory that was matched. If no
071         * aliases were dereferenced while attempting to locate the entry, this will
072         * be a truncated form of the name provided, or if aliases were
073         * dereferenced, of the resulting name, as defined in section 12.5 of X.511
074         * [8]. The matchedDN field is to be set to a zero length string with all
075         * other result codes.
076         * 
077         * @return the Dn of the lowest matched entry.
078         */
079        DN getMatchedDn();
080    
081    
082        /**
083         * Sets the lowest entry in the directory that was matched.
084         * 
085         * @see #getMatchedDn()
086         * @param dn
087         *            the Dn of the lowest matched entry.
088         */
089        void setMatchedDn( DN dn );
090    
091    
092        /**
093         * Gets the descriptive error message associated with the error code. May be
094         * null for SUCCESS, COMPARETRUE, COMPAREFALSE and REFERRAL operations.
095         * 
096         * @return the descriptive error message.
097         */
098        String getErrorMessage();
099    
100    
101        /**
102         * Sets the descriptive error message associated with the error code. May be
103         * null for SUCCESS, COMPARETRUE, and COMPAREFALSE operations.
104         * 
105         * @param errorMessage
106         *            the descriptive error message.
107         */
108        void setErrorMessage( String errorMessage );
109    
110    
111        /**
112         * Gets whether or not this result represents a Referral. For referrals the
113         * error code is set to REFERRAL and the referral property is not null.
114         * 
115         * @return true if this result represents a referral.
116         */
117        boolean isReferral();
118    
119    
120        /**
121         * Gets the Referral associated with this LdapResult if the resultCode
122         * property is set to the REFERRAL ResultCodeEnum.
123         * 
124         * @return the referral on REFERRAL errors, null on all others.
125         */
126        InternalReferral getReferral();
127    
128    
129        /**
130         * Sets the Referral associated with this LdapResult if the resultCode
131         * property is set to the REFERRAL ResultCodeEnum. Setting this property
132         * will result in a true return from isReferral and the resultCode should be
133         * set to REFERRAL.
134         * 
135         * @param referral
136         *            optional referral on REFERRAL errors.
137         */
138        void setReferral( InternalReferral referral );
139    }