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.model.message.controls; 021 022import org.apache.directory.api.i18n.I18n; 023 024/** 025 * Enumeration of the result codes of a SortResult defined in <a href="http://tools.ietf.org/html/rfc2891">RFC 2891</a> 026 * for server side sort control. 027 * 028 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 029 */ 030public enum SortResultCode 031{ 032 SUCCESS( 0, "Results are sorted"), 033 034 OPERATIONSERROR( 1, "Server internal failure"), 035 036 TIMELIMITEXCEEDED( 3, "Timelimit reached before sorting was completed"), 037 038 STRONGAUTHREQUIRED( 8, "Refused to return sorted results via insecure protocol"), 039 040 ADMINLIMITEXCEEDED( 11, "Too many matching entries for the server to sort"), 041 042 NOSUCHATTRIBUTE( 16, "Unrecognized attribute type in sort key"), 043 044 INAPPROPRIATEMATCHING( 18, "Unrecognized or inappropriate matching rule in sort key"), 045 046 INSUFFICIENTACCESSRIGHTS( 50, "Refused to return sorted results to this client"), 047 048 BUSY( 51, "Too busy to process"), 049 050 UNWILLINGTOPERFORM( 53, "Unable to sort"), 051 052 OTHER( 80, "Other"); 053 054 int val; 055 String desc; 056 057 SortResultCode( int val, String desc ) 058 { 059 this.val = val; 060 this.desc = desc; 061 } 062 063 /** 064 * @return The internet value 065 */ 066 public int getVal() 067 { 068 return val; 069 } 070 071 072 /** 073 * returns the enum value representing the given code. 074 * 075 * @param code the result code 076 * @return returns the corresponding ResultCode, throws IllegalArgumentException when there 077 * is no matching ResultCode exists for the given value. 078 */ 079 public static SortResultCode get( int code ) 080 { 081 switch ( code ) 082 { 083 case 0: 084 return SUCCESS; 085 086 case 1: 087 return OPERATIONSERROR; 088 089 case 3: 090 return TIMELIMITEXCEEDED; 091 092 case 8: 093 return STRONGAUTHREQUIRED; 094 095 case 11: 096 return ADMINLIMITEXCEEDED; 097 098 case 16: 099 return NOSUCHATTRIBUTE; 100 101 case 18: 102 return INAPPROPRIATEMATCHING; 103 104 case 50: 105 return INSUFFICIENTACCESSRIGHTS; 106 107 case 51: 108 return BUSY; 109 110 case 53: 111 return UNWILLINGTOPERFORM; 112 113 case 80: 114 return OTHER; 115 116 default: 117 throw new IllegalArgumentException( I18n.err( I18n.ERR_13514_UNKNOWN_SORT_RESPONSE_RESULT, code ) ); 118 } 119 } 120}