public class RestApi
extends java.lang.Object
implements java.beans.PropertyChangeListener
Modifier and Type | Class and Description |
---|---|
static class |
RestApi.ErrorType
For each REST API, an error handler can be implemented.
|
Constructor and Description |
---|
RestApi(java.nio.file.Path projectDirectory,
java.lang.String projectName)
Create a new REST API with the given project directory and project name.
|
RestApi(java.lang.String projectName)
Create a new REST API with the given project name.
|
Modifier and Type | Method and Description |
---|---|
Api |
getApi()
Get the REST API definitions for the REST API.
|
java.lang.String |
getErrorHandlerFlowName(RestApi.ErrorType type)
Get the name of the error handler subflow for this REST API and given error type.
|
java.util.Map<RestApi.ErrorType,MessageFlow> |
getImplementedErrorHandlers()
Retrieve a read-only map containing all implemented error handlers.
|
java.util.Map<java.lang.String,MessageFlow> |
getImplementedOperations()
Retrieve a read-only map containing all implemented operations.
|
Operation |
getOperation(java.lang.String operationName)
Get an operation from the REST API definitions using the name of that operation.
|
java.lang.String |
getOperationFlowName(Operation operation)
Get the name of the operation subflow for this REST API and given operation.
|
java.lang.String |
getOperationFlowName(java.lang.String operationName)
Get the name of the operation subflow for this REST API and given operation.
|
java.util.List<Operation> |
getOperations()
Get a list of all the operations that are defined in the REST API definitions.
|
java.nio.file.Path |
getProjectDirectory()
Get the project directory for the REST API.
|
java.lang.String |
getProjectName()
Get the project name for the REST API.
|
java.util.List<MessageFlow> |
getSubFlows()
Retrieve a read-only list containing all sub flows.
|
MessageFlow |
implementErrorHandler(RestApi.ErrorType type)
Implement an error handler in the REST API.
|
MessageFlow |
implementOperation(java.lang.String operationName)
Implement an operation in the REST API.
|
boolean |
isErrorHandlerImplemented(RestApi.ErrorType type)
Determine whether or not an error handler has been implemented.
|
boolean |
isHTTPSEnabled()
Determine whether or not HTTPS is enabled for this REST API.
|
boolean |
isOperationImplemented(java.lang.String operationName)
Determine whether or not an operation has been implemented.
|
static RestApi |
load(java.nio.file.Path projectDirectory,
java.lang.String projectName)
Load an existing REST API from the specified project directory with the specified
project name.
|
void |
propertyChange(java.beans.PropertyChangeEvent evt)
Run whenever there is a property change we're listening for
|
void |
save()
Save the REST API and its message flow, sub flows, REST API definitions and descriptor to disk.
|
void |
save(boolean overwrite)
Save the REST API and its message flow, sub flows, REST API definitions and descriptor to disk.
|
void |
saveFlow(MessageFlow flow,
boolean overwrite)
Save a flow (either a message flow or sub flow) to disk.
|
void |
saveToZip(java.nio.file.Path zipFile)
Serialize the REST API to a project interchange ZIP file that can be imported
into the Integration Toolkit.
|
RestApi |
setApi(Api api)
Set the REST API definitions for the REST API.
|
void |
setHTTPSEnabled(boolean enabled)
Specify whether or not this REST API should enable HTTPS instead of HTTP.
|
RestApi |
setProjectDirectory(java.nio.file.Path projectDirectory)
Set the project directory for the REST API.
|
RestApi |
setProjectName(java.lang.String projectName)
Set the project name for the REST API.
|
boolean |
unimplementOperation(java.lang.String operationName)
Unimplement an already implemented operation in the REST API.
|
public RestApi(java.nio.file.Path projectDirectory, java.lang.String projectName) throws RestApiException
projectDirectory
- the directory of the new REST API project.projectName
- the name of the new REST API project.RestApiException
- if an error occurred initialising the REST API.public RestApi(java.lang.String projectName) throws RestApiException
projectName
- the name of the new REST API project.RestApiException
- if an error occurred initialising the REST API.public static RestApi load(java.nio.file.Path projectDirectory, java.lang.String projectName) throws RestApiException, ApiException
projectDirectory
- the directory of the existing REST API project.projectName
- the name of the existing REST API project.RestApiException
ApiException
public java.nio.file.Path getProjectDirectory()
public RestApi setProjectDirectory(java.nio.file.Path projectDirectory)
projectDirectory
- the project directory for the REST API.public java.lang.String getProjectName()
public java.lang.String getErrorHandlerFlowName(RestApi.ErrorType type) throws RestApiException
type
- the type of the error handler.RestApiException
- if the project name has not been set.public RestApi setProjectName(java.lang.String projectName)
projectName
- the project name for the REST API.public Api getApi()
public RestApi setApi(Api api) throws RestApiException
api
- the REST API definitions for the REST API.RestApiException
- if the REST API definitions are not valid for use with this REST API.public void saveFlow(MessageFlow flow, boolean overwrite) throws RestApiException
flow
- the message flow or sub flow to save to disk.RestApiException
- if an error occurs saving the message flow or sub flow to disk.public java.util.List<Operation> getOperations() throws RestApiException
RestApiException
- if no REST API definitions have been set.public Operation getOperation(java.lang.String operationName) throws RestApiException
operationName
- the name of the operation.RestApiException
- if the operation does not exist or no REST API definitions have been set.public MessageFlow implementOperation(java.lang.String operationName) throws RestApiException
operationName
- the name of the operation to implement.RestApiException
- if an error occurred implementing the operation.public boolean unimplementOperation(java.lang.String operationName) throws RestApiException
operationName
- the name of the operation to unimplemented.RestApiException
- if an error occurred unimplementing the operation.public java.util.Map<java.lang.String,MessageFlow> getImplementedOperations()
public boolean isOperationImplemented(java.lang.String operationName)
operationName
- the name of the operation to check.public MessageFlow implementErrorHandler(RestApi.ErrorType type) throws RestApiException
type
- the type of the error to implement a handler for.RestApiException
- if an error occurred implementing the operation.public java.util.Map<RestApi.ErrorType,MessageFlow> getImplementedErrorHandlers()
public boolean isErrorHandlerImplemented(RestApi.ErrorType type)
type
- the type of the error handler to check.public java.util.List<MessageFlow> getSubFlows()
public void save() throws RestApiException
RestApiException
- if an error occurs saving the REST API to disk.public void save(boolean overwrite) throws RestApiException
overwrite
- set to true if all user implemented files should be forcibly overwritten, false if not.RestApiException
- if an error occurs saving the REST API to disk.public void saveToZip(java.nio.file.Path zipFile) throws RestApiException
zipFile
- to project interchange ZIP file to create.RestApiException
- if an error occurs creating the project interchange ZIP file.public void setHTTPSEnabled(boolean enabled)
enabled
- true to enable HTTPS, false to enable HTTP.public boolean isHTTPSEnabled()
public java.lang.String getOperationFlowName(Operation operation)
operation
- the operation.public java.lang.String getOperationFlowName(java.lang.String operationName)
operationName
- the name of the operation.public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
evt
- the PropertyChangeEvent