public class RemoteContentHelper extends Object
Constructor and Description |
---|
RemoteContentHelper(RequestExecutionContext context,
RequestParameters params)
Creates a remote helper for request content.
|
RemoteContentHelper(RequestExecutionContext context,
RequestParameters params,
RuntimeService runtime)
Creates a remote helper for request content using the given
RuntimeService.
|
Modifier and Type | Method and Description |
---|---|
void |
closeOutputContent(ContentHandle contentHandle)
Closes the content associated with the given content handle.
|
void |
deleteOutputContent(List contentNames)
Deletes the list of request output content from the content store,
if it exists.
|
void |
deleteOutputContent(String contentName)
Deletes the request output content from the content store,
if it exists.
|
byte[] |
getBinaryContent(ContentHandle contentHandle,
int maxBytes)
Gets at most
maxBytes bytes from the binary content. |
List |
getOutputContentDetail()
Gets details for all output content for the request.
|
ContentDetail |
getOutputContentDetail(String contentName)
Gets details for the specified output content for the request.
|
RequestExecutionContext |
getRequestExecutionContext()
Gets the request execution content for this helper.
|
RuntimeService |
getRuntimeService()
Gets the RuntimeService used by this helper.
|
char[] |
getTextContent(ContentHandle contentHandle,
int maxChars)
Gets at most
maxChars characters from the text output content. |
void |
log(Level level,
String message)
Logs the message at the given level.
|
ContentHandle |
openOutputContent(RuntimeServiceHandle runtimeHandle,
String contentName,
ContentType contentType,
EnumSet options)
Opens output content for read or write.
|
boolean |
outputContentExists(String contentName)
Determines if the output content exists for the request.
|
void |
write(ContentHandle contentHandle,
byte[] data)
Appends the bytes to the output content during job execution.
|
void |
write(ContentHandle contentHandle,
char[] data)
Appends the characters to the output content during job execution.
|
void |
write(ContentHandle contentHandle,
String data)
Appends the string to the output content during job execution.
|
void |
writeln(ContentHandle contentHandle,
String data)
Appends the string followed by a line feed character to the
output content during job execution.
|
public RemoteContentHelper(RequestExecutionContext context, RequestParameters params) throws NamingException, SchedulerException
context
- request execution context passed to the job executable.params
- request parameters passed to the job executable.NamingException
- if error setting up initial context for
remote RuntimeService lookup.SchedulerException
- if unable to perform JNDI lookup of
remote RuntimeService.public RemoteContentHelper(RequestExecutionContext context, RequestParameters params, RuntimeService runtime) throws SchedulerException
context
- request execution context passed to the job executable.params
- request parameters passed to the job executable.runtime
- remote runtime service EJB for log/output.SchedulerException
public void log(Level level, String message) throws RequestNotFoundException, RuntimeServiceException
level
- log level for the message.message
- message to log.RequestNotFoundException
- if request does not exist.RuntimeServiceException
- if runtime service subsystem error.public ContentHandle openOutputContent(RuntimeServiceHandle runtimeHandle, String contentName, ContentType contentType, EnumSet options) throws NotFoundException, RequestNotFoundException, RuntimeServiceException, ValidationException
closeOutputContent
must be called after
finished reading or writing of the content.
The runtimeHandle
is cached while the content is open
and that handle must remain open and valid through
closeOutputContent
.
runtimeHandle
- runtime service handle from previous open call.contentName
- name of the output content.contentType
- type of the output content.
ContentType.Unknow
can be passed.options
- an EnumSet<ContentOpenOptions>
of options
specifying how to open the request output.NotFoundException
- if the content for read does not exist.RequestNotFoundException
- if the request does not exist.RuntimeServiceException
- if runtime service subsystem error.ValidationException
- if the write is invalid.public void closeOutputContent(ContentHandle contentHandle) throws IllegalArgumentException, RequestNotFoundException, RuntimeServiceException
The runtime service handle that was passed to
openOutputContent
can be closed upon return from this method.
contentHandle
- content handle from previous call to
openOutputContent
.IllegalArgumentException
- if handle is invalid.RequestNotFoundException
- if the request was not found.RuntimeServiceException
- if runtime service subsystem error.public void writeln(ContentHandle contentHandle, String data) throws IllegalArgumentException, NotFoundException, RuntimeServiceException, ValidationException
The content must be open for write, and the runtime service
handle that was passed to openOutputContent
must be valid.
contentHandle
- content handle from previous call to
openOutputContent
.data
- string to write to the output content, followed by
line feed character.IllegalArgumentException
- if the content handle is invalid.NotFoundException
- if the content does not exist.RuntimeServiceException
- if runtime service subsystem error.ValidationException
- if it is invalid to write to the content,
meaning the content type is binary or the content was created from
an import.public void write(ContentHandle contentHandle, String data) throws IllegalArgumentException, NotFoundException, RuntimeServiceException, ValidationException
The content must be open for write, and the runtime service handle
that was passed to openOutputContent
must be valid.
contentHandle
- content handle from previous call to
openOutputContent
.data
- string to write to the output content.IllegalArgumentException
- if content handle is invalid.NotFoundException
- if content does not exist.RuntimeServiceException
- if runtime service subsystem error.ValidationException
- if it is invalid to write to the content,
meaning the content type is binary or the content was created from
an import.public void write(ContentHandle contentHandle, char[] data) throws IllegalArgumentException, NotFoundException, RuntimeServiceException, ValidationException
The content must be open for write, and the runtime service handle
that was passed to openOutputContent
must be valid.
contentHandle
- content handle from previous call to
openOutputContent
.data
- characters to append.IllegalArgumentException
- if content handle is invalid.NotFoundException
- if content does not exist.RuntimeServiceException
- if runtime service subsystem error.ValidationException
- if it is invalid to write to the content,
meaning the content type is binary or the content was created from
an import.public void write(ContentHandle contentHandle, byte[] data) throws IllegalArgumentException, NotFoundException, RuntimeServiceException, ValidationException
The content must be open for write, and the runtime service handle
that was passed to openOutputContent
must be valid.
contentHandle
- content handle from previous call to
openOutputContent
.data
- bytes to append.IllegalArgumentException
- if content handle is invalid.NotFoundException
- if content does not exist.RuntimeServiceException
- if runtime service subsystem error.ValidationException
- if it is invalid to write to the content,
meaning the content type is binary or the content was created from
an import.public byte[] getBinaryContent(ContentHandle contentHandle, int maxBytes) throws IllegalArgumentException, RequestNotFoundException, RuntimeServiceException, ValidationException
maxBytes
bytes from the binary content.
The content must be open for read, and the runtime service handle
that was passed to openOutputContent
must be valid.
contentHandle
- content handle from previous open call.maxBytes
- maximum number of bytes to get.IllegalArgumentException
- if handle is invalid.RequestNotFoundException
- if the request was not foundRuntimeServiceException
- if runtime service subsystem error.ValidationException
public char[] getTextContent(ContentHandle contentHandle, int maxChars) throws IllegalArgumentException, RuntimeServiceException, RequestNotFoundException
maxChars
characters from the text output content.
The content must be open for read, and the runtime service handle
that was passed to openOutputContent
must be valid.
contentHandle
- content handle from previous call to
openOutputContent
.maxChars
- maximum number of characters to get.IllegalArgumentException
- if handle is invalid.RuntimeServiceException
- if runtime service subsystem error.RequestNotFoundException
- if the request was not foundpublic boolean outputContentExists(String contentName) throws RequestNotFoundException, RuntimeServiceException
contentName
- name of output content.true
if the content exists;
false
if the content does not exist.RequestNotFoundException
- if the request was not foundRuntimeServiceException
- if runtime service subsystem error.public ContentDetail getOutputContentDetail(String contentName) throws RuntimeServiceException, RequestNotFoundException
contentName
- name of output content.null
if the content does not exist.RuntimeServiceException
- if runtime service subsystem error.RequestNotFoundException
- if the request was not foundpublic List getOutputContentDetail() throws RequestNotFoundException, RuntimeServiceException
List<ContentDetail>
of details for all output
content for the request. The list will be empty if there is no
output content.RequestNotFoundException
- if the request was not foundRuntimeServiceException
- if runtime service subsystem error.public void deleteOutputContent(List contentNames) throws RequestNotFoundException, RuntimeServiceException
contentNames
- List<String>
of names of output content.RequestNotFoundException
- if the request was not foundRuntimeServiceException
- if runtime service subsystem error.public void deleteOutputContent(String contentName) throws RequestNotFoundException, RuntimeServiceException
contentName
- name of output content.RequestNotFoundException
- if the request was not foundRuntimeServiceException
- if runtime service subsystem error.public RuntimeService getRuntimeService()
public RequestExecutionContext getRequestExecutionContext()