org.netbeans.modules.glassfish.tooling.TaskEvent Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.glassfish.tooling;
import java.util.HashMap;
import java.util.Map;
/**
* Events that caused state of GlassFish server administration command execution
* change.
*
* @author Tomas Kraus, Peter Benedikovic
*/
public enum TaskEvent {
////////////////////////////////////////////////////////////////////////////
// Enum values //
////////////////////////////////////////////////////////////////////////////
/** Task queued for execution. */
SUBMIT,
/** Start of task. */
START,
/** Exception in task. */
EXCEPTION,
/** Illegal task state. */
ILLEGAL_STATE,
/** Missing server process. */
PROCESS_NOT_EXISTS,
/** Process not running. */
PROCESS_NOT_RUNNING,
/** Server command running. */
CMD_RUNNING,
/** Server command exception. */
CMD_EXCEPTION,
/** Server command completed. */
CMD_COMPLETED,
/** Server command failed. */
CMD_FAILED,
/** Authorization failed on HTTP protocol level (401 or 403 response).
* This is usually handled by java.net.Authenticator. */
AUTH_FAILED_HTTP,
/** Authorization failed on asadmin response level (response
* in Manifest). Here java.net.Authenticator does nothing. */
AUTH_FAILED,
/** Empty message received. */
EMPTY_MESSAGE,
/** Java VM not found. */
NO_JAVA_VM,
/** Java VM version is wrong. */
WRONG_JAVA_VM,
/** Java VM execution failed. */
JAVA_VM_EXEC_FAILED,
/** Signals wrong proxy settings. */
BAD_GATEWAY;
////////////////////////////////////////////////////////////////////////////
// Class attributes //
////////////////////////////////////////////////////////////////////////////
/** A String
representation of SUBMIT value. */
private static final String SUBMIT_STR = "Submit";
/** A String
representation of START value. */
private static final String START_STR = "Start";
/** A String
representation of EXCEPTION value. */
private static final String EXCEPTION_STR = "Exception";
/** A String
representation of ILLEGAL_STATE value. */
private static final String ILLEGAL_STATE_STR = "IllegalState";
/** A String
representation of PROCESS_NOT_EXISTS value. */
private static final String PROCESS_NOT_EXISTS_STR = "ProcessNotExists";
/** A String
representation of PROCESS_NOT_RUNNING value. */
private static final String PROCESS_NOT_RUNNING_STR = "ProcessNotRunning";
/** A String
representation of CMD_RUNNING value. */
private static final String CMD_RUNNING_STR = "CmdRunning";
/** A String
representation of CMD_EXCEPTION value. */
private static final String CMD_EXCEPTION_STR = "CmdException";
/** A String
representation of CMD_COMPLETED value. */
private static final String CMD_COMPLETED_STR = "CmdCompleted";
/** A String
representation of CMD_FAILED value. */
private static final String CMD_FAILED_STR = "CmdFailed";
/** A String
representation of AUTH_FAILED_HTTP value. */
private static final String AUTH_FAILED_HTTP_STR = "AuthFailedHttp";
/** A String
representation of AUTH_FAILED value. */
private static final String AUTH_FAILED_STR = "AuthFailed";
/** A String
representation of EMPTY_MESSAGE value. */
private static final String EMPTY_MESSAGE_STR = "EmptyMessage";
/** A String
representation of NO_JAVA_VM value. */
private static final String NO_JAVA_VM_STR = "NoJavaVm";
/** A String
representation of NO_JAVA_VM value. */
private static final String WRONG_JAVA_VM_STR = "WrongJavaVm";
/** A String
representation of JAVA_VM_EXEC_FAILED value. */
private static final String JAVA_VM_EXEC_FAILED_STR = "JavaVmExecFailed";
/** A String
representation of BAD_GATEWAY value. */
private static final String BAD_GATEWAY_STR = "BadGateway";
/**
* Stored String
values for backward String
* conversion.
*/
private static final Map stringValuesMap
= new HashMap<>(values().length);
// Initialize backward String conversion Map
.
static {
for (TaskEvent state : TaskEvent.values()) {
stringValuesMap.put(state.toString().toUpperCase(), state);
}
}
////////////////////////////////////////////////////////////////////////////
// Static methods //
////////////////////////////////////////////////////////////////////////////
/**
* Returns a TaskEvent
with a value represented by the
* specified String
. The TaskEvent
returned
* represents existing value only if specified String
* matches any String
returned by toString
method.
* Otherwise null
value is returned.
*
* @param eventStr Value containing TaskEvent
* toString
representation.
* @return TaskEvent
value represented by String
* or null
if value was not recognized.
*/
public static TaskEvent toValue(String eventStr) {
if (eventStr != null) {
return (stringValuesMap.get(eventStr.toUpperCase()));
} else {
return null;
}
}
////////////////////////////////////////////////////////////////////////////
// Methods //
////////////////////////////////////////////////////////////////////////////
/**
* Convert TaskEvent
value to String
.
*
* @return A String
representation of the value of this object.
*/
@Override
public String toString() {
switch (this) {
case SUBMIT: return SUBMIT_STR;
case START: return START_STR;
case EXCEPTION: return EXCEPTION_STR;
case ILLEGAL_STATE: return ILLEGAL_STATE_STR;
case PROCESS_NOT_EXISTS: return PROCESS_NOT_EXISTS_STR;
case PROCESS_NOT_RUNNING: return PROCESS_NOT_RUNNING_STR;
case CMD_RUNNING: return CMD_RUNNING_STR;
case CMD_EXCEPTION: return CMD_EXCEPTION_STR;
case CMD_COMPLETED: return CMD_COMPLETED_STR;
case CMD_FAILED: return CMD_FAILED_STR;
case AUTH_FAILED_HTTP: return AUTH_FAILED_HTTP_STR;
case AUTH_FAILED: return AUTH_FAILED_STR;
case EMPTY_MESSAGE: return EMPTY_MESSAGE_STR;
case NO_JAVA_VM: return NO_JAVA_VM_STR;
case WRONG_JAVA_VM: return WRONG_JAVA_VM_STR;
case JAVA_VM_EXEC_FAILED: return JAVA_VM_EXEC_FAILED_STR;
case BAD_GATEWAY: return BAD_GATEWAY_STR;
// This is unrecheable. Returned null value means that some
// enum value is not handled correctly.
default: return null;
}
}
}