public class RemoteRestAdminCommand extends AdminCommandEventBrokerImpl<GfSseInboundEvent>
Arguments to the command are supplied using a ParameterMap passed to the executeCommand method. ParameterMap is a MultiMap where each key can have multiple values, although this class only supports a single value for each option. Operands for the command are stored as the option named "DEFAULT" and can have multiple values.
Before a command can be executed, the metadata for the command (in the form of a CommandModel) is required. The getCommandModel method will fetch the metadata from the server, save it, and return it. If the CommandModel for a command is known independently (e.g., stored in a local cache, or known a priori), it can be set using the setCommandModel method. If the metadata isn't known when the exectureCommand method is called, it will fetch the metadata from the server before executing the command.
Any files returned by the command will be stored in the current directory. The setFileOutputDirectory method can be used to control where returned files are saved.
| Modifier and Type | Field and Description |
|---|---|
protected String |
authToken |
static String |
COMMAND_MODEL_MATCH_HEADER |
protected String |
host |
protected Logger |
logger |
protected String |
name |
protected List<String> |
operands |
protected org.glassfish.api.admin.ParameterMap |
options |
protected String |
output |
protected String |
password |
protected int |
port |
protected boolean |
prohibitDirectoryUploads |
protected String |
scope |
protected boolean |
secure |
protected String |
user |
| Constructor and Description |
|---|
RemoteRestAdminCommand(String name,
String host,
int port) |
RemoteRestAdminCommand(String name,
String host,
int port,
boolean secure,
String user,
String password,
Logger logger) |
RemoteRestAdminCommand(String name,
String host,
int port,
boolean secure,
String user,
String password,
Logger logger,
String scope,
String authToken,
boolean prohibitDirectoryUploads)
Construct a new remote command object.
|
| Modifier and Type | Method and Description |
|---|---|
protected javax.ws.rs.client.Invocation.Builder |
addAdditionalHeaders(javax.ws.rs.client.Invocation.Builder request)
Adds any headers needed for the current environment to the admin
request.
|
protected AuthenticationInfo |
authenticationInfo() |
void |
closeSse(String message,
org.glassfish.api.ActionReport.ExitCode exitCode) |
protected static SSLContext |
createStandardSslContext(boolean interactive) |
String |
executeCommand(org.glassfish.api.admin.ParameterMap opts) |
protected void |
fetchCommandModel() |
String |
findPropertyInReport(String key) |
org.glassfish.api.ActionReport |
getActionReport() |
protected String |
getCanonicalHost() |
org.glassfish.api.admin.CommandModel |
getCommandModel()
Get the CommandModel for the command from the server.
|
protected String |
getFromEnvironment(String name)
Subclasses can override to supply parameter values from environment.
|
String |
getManPage() |
static int |
getReadTimeout() |
protected SSLContext |
getSslContext() |
String |
getUsage()
Get the usage text.
|
List<Header> |
headers()
Return a modifiable list of headers to be added to the request.
|
boolean |
isCommandModelFromCache()
If command model was load from local cache.
|
static void |
preinit()
CLI can use this method to inicialise internal structures of used services
like jersey and ssl in parallel with other logic
|
protected void |
processHeaders(javax.ws.rs.core.Response headers)
Process any headers needed from the reply to the admin
request.
|
org.glassfish.api.admin.ParameterMap |
processParams(org.glassfish.api.admin.ParameterMap opts)
Run the command using the specified arguments.
|
protected boolean |
refetchInvalidModel()
If admin model is invalid, will be automatically refetched?
|
protected String |
reportAuthenticationException()
Return the error message to be used in the AuthenticationException.
|
protected boolean |
retryUsingSecureConnection(String host,
int port)
Called when a non-secure connection attempt fails and it appears
that the server requires a secure connection.
|
protected void |
setActionReport(org.glassfish.api.ActionReport ar) |
void |
setCommandModel(org.glassfish.api.admin.CommandModel commandModel)
Set the CommandModel used by this command.
|
void |
setConnectTimeout(int connectTimeout)
Set the connect timeout for the URLConnection.
|
void |
setFileOutputDirectory(File dir)
Set the directory in which any returned files will be stored.
|
void |
setInteractive(boolean state)
Set the interactive mode for the command.
|
void |
setOmitCache(boolean omitCache)
Omit local
AdminCache to process command metadata. |
void |
setReadTimeout(int readTimeout)
Set the read timeout for the URLConnection.
|
void |
setResponseFormatType(String responseFormatType)
Set the response type used in requests to the server.
|
void |
setUserOut(OutputStream userOut)
If set, the raw response from the command is written to the
specified stream.
|
protected boolean |
updateAuthentication()
Return true if we're successful in collecting new information
(and thus the caller should try the request again).
|
protected boolean |
useSse() |
fireEvent, fireEvent, listening, registerListener, unregisterListenerpublic static final String COMMAND_MODEL_MATCH_HEADER
protected String output
protected String name
protected String host
protected int port
protected boolean secure
protected String user
protected String password
protected Logger logger
protected String scope
protected String authToken
protected boolean prohibitDirectoryUploads
protected org.glassfish.api.admin.ParameterMap options
public RemoteRestAdminCommand(String name, String host, int port) throws org.glassfish.api.admin.CommandException
org.glassfish.api.admin.CommandExceptionpublic RemoteRestAdminCommand(String name, String host, int port, boolean secure, String user, String password, Logger logger) throws org.glassfish.api.admin.CommandException
org.glassfish.api.admin.CommandExceptionpublic RemoteRestAdminCommand(String name, String host, int port, boolean secure, String user, String password, Logger logger, String scope, String authToken, boolean prohibitDirectoryUploads) throws org.glassfish.api.admin.CommandException
org.glassfish.api.admin.CommandExceptionpublic void closeSse(String message, org.glassfish.api.ActionReport.ExitCode exitCode)
public void setResponseFormatType(String responseFormatType)
public void setUserOut(OutputStream userOut)
public void setCommandModel(org.glassfish.api.admin.CommandModel commandModel)
public void setReadTimeout(int readTimeout)
public static int getReadTimeout()
public org.glassfish.api.ActionReport getActionReport()
public void setConnectTimeout(int connectTimeout)
public void setInteractive(boolean state)
public void setOmitCache(boolean omitCache)
AdminCache to process command metadata.
If true it will download the metadata from remote server.falsepublic org.glassfish.api.admin.CommandModel getCommandModel()
throws org.glassfish.api.admin.CommandException
org.glassfish.api.admin.CommandException - if the server can't be contactedpublic boolean isCommandModelFromCache()
public void setFileOutputDirectory(File dir)
public List<Header> headers()
protected boolean useSse()
throws org.glassfish.api.admin.CommandException
org.glassfish.api.admin.CommandExceptionpublic String executeCommand(org.glassfish.api.admin.ParameterMap opts) throws org.glassfish.api.admin.CommandException
org.glassfish.api.admin.CommandExceptionprotected void setActionReport(org.glassfish.api.ActionReport ar)
public org.glassfish.api.admin.ParameterMap processParams(org.glassfish.api.admin.ParameterMap opts)
throws org.glassfish.api.admin.CommandException
org.glassfish.api.admin.CommandExceptionprotected boolean updateAuthentication()
protected boolean refetchInvalidModel()
protected String getFromEnvironment(String name)
protected boolean retryUsingSecureConnection(String host, int port)
protected String reportAuthenticationException()
protected SSLContext getSslContext()
protected static SSLContext createStandardSslContext(boolean interactive)
protected javax.ws.rs.client.Invocation.Builder addAdditionalHeaders(javax.ws.rs.client.Invocation.Builder request)
request - protected void processHeaders(javax.ws.rs.core.Response headers)
protected AuthenticationInfo authenticationInfo()
public String getUsage()
public String getManPage() throws org.glassfish.api.admin.CommandException
org.glassfish.api.admin.CommandExceptionprotected void fetchCommandModel()
throws org.glassfish.api.admin.CommandException
org.glassfish.api.admin.CommandExceptionprotected String getCanonicalHost()
public static void preinit()
Copyright © 2013. All Rights Reserved.