001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2006-2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.types;
028
029
030
031 import static org.opends.server.util.StaticUtils.*;
032
033
034
035 /**
036 * This class implements an enumeration that may be used to control
037 * the writability mode for the entire server or for a specific
038 * backend. The writability mode may be "enabled", "disabled", or
039 * "internal-only".
040 */
041 @org.opends.server.types.PublicAPI(
042 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
043 mayInstantiate=false,
044 mayExtend=false,
045 mayInvoke=true)
046 public enum WritabilityMode
047 {
048 /**
049 * Indicates that all write operations should be allowed.
050 */
051 ENABLED("enabled"),
052
053
054
055 /**
056 * Indicates that all write operations should be rejected.
057 */
058 DISABLED("disabled"),
059
060
061
062 /**
063 * Indicates that write operations from clients will be rejected,
064 * but internal operations and updates through synchronization will
065 * be allowed.
066 */
067 INTERNAL_ONLY("internal-only");
068
069
070
071 // The human-readable name for this writability mode.
072 private String modeName;
073
074
075
076 /**
077 * Creates a new writability mode with the provided name.
078 *
079 * @param modeName The human-readable name for this writability
080 * mode.
081 */
082 private WritabilityMode(String modeName)
083 {
084 this.modeName = modeName;
085 }
086
087
088
089 /**
090 * Retrieves the writability mode for the specified name.
091 *
092 * @param modeName The name of the writability mode to retrieve.
093 *
094 * @return The requested writability mode, or <CODE>null</CODE> if
095 * the provided value is not the name of a valid mode.
096 */
097 public static WritabilityMode modeForName(String modeName)
098 {
099 String lowerName = toLowerCase(modeName);
100 if (lowerName.equals("enabled"))
101 {
102 return WritabilityMode.ENABLED;
103 }
104 else if (lowerName.equals("disabled"))
105 {
106 return WritabilityMode.DISABLED;
107 }
108 else if (lowerName.equals("internal-only"))
109 {
110 return WritabilityMode.INTERNAL_ONLY;
111 }
112 else
113 {
114 return null;
115 }
116 }
117
118
119
120 /**
121 * Retrieves a string representation of this writability mode.
122 *
123 * @return A string representation of this writability mode.
124 */
125 public String toString()
126 {
127 return modeName;
128 }
129 }
130