001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2008 Sun Microsystems, Inc. 015 * Portions Copyright 2014 ForgeRock AS. 016 */ 017package org.opends.server.backends.task; 018 019import org.forgerock.i18n.LocalizableMessage; 020import static org.opends.messages.TaskMessages.*; 021 022 023/** 024 * This enumeration defines the various ways that a task can behave if it is 025 * dependent upon another task and that earlier task is done running but did not 026 * complete successfully. 027 */ 028public enum FailedDependencyAction 029{ 030 /** 031 * The action that indicates that the dependent task should be processed 032 * anyway. 033 */ 034 PROCESS(INFO_FAILED_DEPENDENCY_ACTION_PROCESS.get()), 035 036 037 038 /** 039 * The action that indicates that the dependent task should be canceled. 040 */ 041 CANCEL(INFO_FAILED_DEPENDENCY_ACTION_CANCEL.get()), 042 043 044 045 /** 046 * The action that indicates that the dependent task should be disabled so 047 * that an administrator will have to re-enable it before it can start. 048 */ 049 DISABLE(INFO_FAILED_DEPENDENCY_ACTION_DISABLE.get()); 050 051 052 /** 053 * Returns the default action. 054 * 055 * @return the default action 056 */ 057 public static FailedDependencyAction defaultValue() { 058 return CANCEL; 059 } 060 061 /** 062 * Retrieves the failed dependency action that corresponds to the provided 063 * string value. 064 * 065 * @param s The string value for which to retrieve the corresponding 066 * failed dependency action. 067 * 068 * @return The corresponding failed dependency action, or <CODE>null</CODE> 069 * if none could be associated with the provided string. 070 */ 071 public static FailedDependencyAction fromString(String s) 072 { 073 String lowerString = s.toLowerCase(); 074 if (lowerString.equals("process") || 075 lowerString.equals(INFO_FAILED_DEPENDENCY_ACTION_PROCESS.get(). 076 toString().toLowerCase())) 077 { 078 return PROCESS; 079 } 080 else if (lowerString.equals("cancel") || 081 lowerString.equals(INFO_FAILED_DEPENDENCY_ACTION_CANCEL.get(). 082 toString().toLowerCase())) 083 { 084 return CANCEL; 085 } 086 else if (lowerString.equals("disable") || 087 lowerString.equals(INFO_FAILED_DEPENDENCY_ACTION_DISABLE.get(). 088 toString().toLowerCase())) 089 { 090 return DISABLE; 091 } 092 else 093 { 094 return null; 095 } 096 } 097 098 private LocalizableMessage name; 099 100 /** 101 * Gets the display name of this action. 102 * 103 * @return LocalizableMessage representing the name of this action 104 */ 105 public LocalizableMessage getDisplayName() { 106 return name; 107 } 108 109 private FailedDependencyAction(LocalizableMessage name) { 110 this.name = name; 111 } 112} 113