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.backends.task;
028
029 import org.opends.messages.Message;
030 import static org.opends.messages.TaskMessages.*;
031
032
033 /**
034 * This enumeration defines the various ways that a task can behave if it is
035 * dependent upon another task and that earlier task is done running but did not
036 * complete successfully.
037 */
038 public enum FailedDependencyAction
039 {
040 /**
041 * The action that indicates that the dependent task should be processed
042 * anyway.
043 */
044 PROCESS(INFO_FAILED_DEPENDENCY_ACTION_PROCESS.get()),
045
046
047
048 /**
049 * The action that indicates that the dependent task should be canceled.
050 */
051 CANCEL(INFO_FAILED_DEPENDENCY_ACTION_CANCEL.get()),
052
053
054
055 /**
056 * The action that indicates that the dependent task should be disabled so
057 * that an administrator will have to re-enable it before it can start.
058 */
059 DISABLE(INFO_FAILED_DEPENDENCY_ACTION_DISABLE.get());
060
061
062 /**
063 * Returns the default action.
064 *
065 * @return the default action
066 */
067 public static FailedDependencyAction defaultValue() {
068 return CANCEL;
069 }
070
071 /**
072 * Retrieves the failed dependency action that corresponds to the provided
073 * string value.
074 *
075 * @param s The string value for which to retrieve the corresponding
076 * failed dependency action.
077 *
078 * @return The corresponding failed dependency action, or <CODE>null</CODE>
079 * if none could be associated with the provided string.
080 */
081 public static FailedDependencyAction fromString(String s)
082 {
083 String lowerString = s.toLowerCase();
084 if (lowerString.equals("process") ||
085 lowerString.equals(INFO_FAILED_DEPENDENCY_ACTION_PROCESS.get().
086 toString().toLowerCase()))
087 {
088 return PROCESS;
089 }
090 else if (lowerString.equals("cancel") ||
091 lowerString.equals(INFO_FAILED_DEPENDENCY_ACTION_CANCEL.get().
092 toString().toLowerCase()))
093 {
094 return CANCEL;
095 }
096 else if (lowerString.equals("disable") ||
097 lowerString.equals(INFO_FAILED_DEPENDENCY_ACTION_DISABLE.get().
098 toString().toLowerCase()))
099 {
100 return DISABLE;
101 }
102 else
103 {
104 return null;
105 }
106 }
107
108 private Message name;
109
110 /**
111 * Gets the display name of this action.
112 *
113 * @return Message representing the name of this action
114 */
115 public Message getDisplayName() {
116 return name;
117 }
118
119 private FailedDependencyAction(Message name) {
120 this.name = name;
121 }
122 }
123