View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  
21  package org.apache.directory.api.ldap.extras.controls.vlv;
22  
23  
24  /**
25   * Enumeration of the result codes of a Virtual List View response control as specified in draft-ietf-ldapext-ldapv3-vlv-09.
26   *
27   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
28   */
29  public enum VirtualListViewResultCode
30  {
31      /** A success */
32      SUCCESS(0, "Success"),
33  
34      /** The operation failed dur to some internal error */
35      OPERATIONSERROR(1, "Server internal failure"),
36  
37      /** teh time limit has been exceeded */
38      TIMELIMITEXCEEDED(3, "Timelimit exceeded"),
39  
40      /** The admin limit has been exceeded */
41      ADMINLIMITEXCEEDED(11, "Admin limit exceeded"),
42  
43      /** The matching rule is inappropriate */
44      INAPPROPRIATEMATCHING(18, "Unrecognized or inappropriate matching rule"),
45  
46      /** The access right are insufficient */
47      INSUFFICIENTACCESSRIGHTS(50, "Insufficient access rights"),
48  
49      /** Unwilling to perform the operation */
50      UNWILLINGTOPERFORM(53, "Unwilling to perform"),
51  
52      /** No Sort Control provided */
53      SORTCONTROLMISSING(60, "Sort control missing"),
54  
55      /** The offset is incorrect */
56      OFFSETRANGEERROR(61, "Offset range error"),
57      
58      /** SS is missing */
59      OPENLDAP_SSSMISSING(76, "SSS missing"), // OpenLDAP-specific error code
60      
61      /** The range is invalid */
62      OPENLDAP_RANGEERRROR(77, "Range error"), // OpenLDAP-specific error code
63  
64      /** Another error */
65      OTHER(80, "Other");
66  
67      /** The associated value */
68      private int value;
69      
70      /** The associated description */
71      private String desc;
72  
73  
74      VirtualListViewResultCode( int value, String desc )
75      {
76          this.value = value;
77          this.desc = desc;
78      }
79  
80  
81      /**
82       * @return The associated integer value
83       */
84      public int getValue()
85      {
86          return value;
87      }
88  
89  
90      /**
91       * @return The associated description
92       */
93      public String getDesc()
94      {
95          return desc;
96      }
97  
98  
99      /**
100      * returns the enum value representing the given code.
101      * 
102      * @param code the result code
103      * @return returns the corresponding ResultCode, throws IllegalArgumentException when there
104      *         is no matching ResultCode exists for the given value.
105      */
106     public static VirtualListViewResultCode get( int code )
107     {
108         switch ( code )
109         {
110             case 0:
111                 return SUCCESS;
112 
113             case 1:
114                 return OPERATIONSERROR;
115 
116             case 3:
117                 return TIMELIMITEXCEEDED;
118 
119             case 11:
120                 return ADMINLIMITEXCEEDED;
121 
122             case 18:
123                 return INAPPROPRIATEMATCHING;
124 
125             case 50:
126                 return INSUFFICIENTACCESSRIGHTS;
127 
128             case 53:
129                 return UNWILLINGTOPERFORM;
130 
131             case 60:
132                 return SORTCONTROLMISSING;
133 
134             case 61:
135                 return OFFSETRANGEERROR;
136                 
137             case 76:
138                 return OPENLDAP_SSSMISSING;
139 
140             case 77:
141                 return OPENLDAP_RANGEERRROR;
142 
143             case 80:
144                 return OTHER;
145 
146             default:
147                 throw new IllegalArgumentException( "Unknown VLV response result code " + code );
148         }
149     }
150 }