com.ibm.as400.access
Class JobLog

java.lang.Object
  extended by com.ibm.as400.access.JobLog
All Implemented Interfaces:
Serializable

public class JobLog
extends Object
implements Serializable

Represents a job log on the system. This class is used to get a list of messages in a job log or to write messages to a job log.

QueuedMessage objects have many attributes. Only some of theses attribute values are set, depending on how a QueuedMessage object is created. The following is a list of attributes whose values can be set on QueuedMessage objects returned in a list of job log messages:

See Also:
QueuedMessage, Serialized Form

Field Summary
Modifier and Type Field and Description
static int ALERT_OPTION
           
static int CCSID_CONVERSION_STATUS_DATA
           
static int CCSID_CONVERSION_STATUS_TEXT
           
static int CCSID_FOR_DATA
           
static int CCSID_FOR_TEXT
           
static int DEFAULT_REPLY
           
static int MESSAGE
           
static int MESSAGE_FILE_LIBRARY_USED
           
static int MESSAGE_HELP
           
static int MESSAGE_HELP_WITH_FORMATTING_CHARACTERS
           
static int MESSAGE_HELP_WITH_REPLACEMENT_DATA
           
static int MESSAGE_HELP_WITH_REPLACEMENT_DATA_AND_FORMATTING_CHARACTERS
           
static int MESSAGE_WITH_REPLACEMENT_DATA
           
static int RECEIVING_MODULE_NAME
           
static int RECEIVING_PROCEDURE_NAME
           
static int RECEIVING_PROGRAM_NAME
           
static int RECEIVING_STATEMENT_NUMBERS
           
static int RECEIVING_TYPE
           
static int REPLACEMENT_DATA
           
static int REPLY_STATUS
           
static int REQUEST_LEVEL
           
static int REQUEST_STATUS
           
static int SENDER_TYPE
           
static int SENDING_MODULE_NAME
           
static int SENDING_PROCEDURE_NAME
           
static int SENDING_PROGRAM_NAME
           
static int SENDING_STATEMENT_NUMBERS
           
static int SENDING_USER_PROFILE
           
 
Constructor Summary
Constructor and Description
JobLog()
          Constructs a JobLog object.
JobLog(AS400 system)
          Constructs a JobLog object.
JobLog(AS400 system, String name, String user, String number)
          Constructs a JobLog object.
 
Method Summary
Modifier and Type Method and Description
 void addAttributeToRetrieve(int attribute)
          Adds a message attribute that will be retrieved for each joblog.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener.
 void addVetoableChangeListener(VetoableChangeListener listener)
          Adds a VetoableChangeListener.
 void clearAttributesToRetrieve()
          Clears the message attributes to be retrieved for a given Joblog.
 void close()
          Closes the message list on the system.
 int getLength()
          Returns the number of messages in the job log.
 boolean getListDirection()
          Returns the list direction.
 Enumeration getMessages()
          Returns the list of messages in the job log.
 QueuedMessage[] getMessages(int listOffset, int number)
          Returns a subset of the list of messages in the job log.
 String getName()
          Returns the job name.
 String getNumber()
          Returns the job number.
 byte[] getStartingMessageKey()
          Returns the starting message key.
 AS400 getSystem()
          Returns the system object representing the system on which the job log exists.
 String getUser()
          Returns the job user name.
 void load()
          Loads the list of messages on the system.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the PropertyChangeListener.
 void removeVetoableChangeListener(VetoableChangeListener listener)
          Removes the VetoableChangeListener.
 void setListDirection(boolean listDirection)
          Sets the list direction.
 void setName(String name)
          Sets the job name.
 void setNumber(String number)
          Sets the job number.
 void setStartingMessageKey(byte[] startingMessageKey)
          Sets the message key used to begin searching for messages to list from the corresponding entry in the job log.
 void setSystem(AS400 system)
          Sets the system.
 void setUser(String user)
          Sets the job user name.
static void writeMessage(AS400 system, String messageID, int messageType)
          Writes a program message to the job log for the job in which the program is running.
static void writeMessage(AS400 system, String messageID, int messageType, byte[] substitutionData)
          Writes a program message to the job log for the job in which the program is running.
static void writeMessage(AS400 system, String messageID, int messageType, String messageFile)
          Writes a program message to the job log for the job in which the program is running.
static void writeMessage(AS400 system, String messageID, int messageType, String messageFile, byte[] substitutionData)
          Writes a program message to the job log for the job in which the program is running.
static void writeMessage(AS400 system, String messageID, int messageType, String messageFile, byte[] substitutionData, boolean onThread)
          Writes a program message to the job log for the job in which the program is running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALERT_OPTION

public static final int ALERT_OPTION
See Also:
Constant Field Values

REPLACEMENT_DATA

public static final int REPLACEMENT_DATA
See Also:
Constant Field Values

MESSAGE

public static final int MESSAGE
See Also:
Constant Field Values

MESSAGE_WITH_REPLACEMENT_DATA

public static final int MESSAGE_WITH_REPLACEMENT_DATA
See Also:
Constant Field Values

MESSAGE_HELP

public static final int MESSAGE_HELP
See Also:
Constant Field Values

MESSAGE_HELP_WITH_REPLACEMENT_DATA

public static final int MESSAGE_HELP_WITH_REPLACEMENT_DATA
See Also:
Constant Field Values

MESSAGE_HELP_WITH_FORMATTING_CHARACTERS

public static final int MESSAGE_HELP_WITH_FORMATTING_CHARACTERS
See Also:
Constant Field Values

MESSAGE_HELP_WITH_REPLACEMENT_DATA_AND_FORMATTING_CHARACTERS

public static final int MESSAGE_HELP_WITH_REPLACEMENT_DATA_AND_FORMATTING_CHARACTERS
See Also:
Constant Field Values

DEFAULT_REPLY

public static final int DEFAULT_REPLY
See Also:
Constant Field Values

SENDER_TYPE

public static final int SENDER_TYPE
See Also:
Constant Field Values

SENDING_PROGRAM_NAME

public static final int SENDING_PROGRAM_NAME
See Also:
Constant Field Values

SENDING_MODULE_NAME

public static final int SENDING_MODULE_NAME
See Also:
Constant Field Values

SENDING_PROCEDURE_NAME

public static final int SENDING_PROCEDURE_NAME
See Also:
Constant Field Values

SENDING_STATEMENT_NUMBERS

public static final int SENDING_STATEMENT_NUMBERS
See Also:
Constant Field Values

SENDING_USER_PROFILE

public static final int SENDING_USER_PROFILE
See Also:
Constant Field Values

RECEIVING_TYPE

public static final int RECEIVING_TYPE
See Also:
Constant Field Values

RECEIVING_PROGRAM_NAME

public static final int RECEIVING_PROGRAM_NAME
See Also:
Constant Field Values

RECEIVING_MODULE_NAME

public static final int RECEIVING_MODULE_NAME
See Also:
Constant Field Values

RECEIVING_PROCEDURE_NAME

public static final int RECEIVING_PROCEDURE_NAME
See Also:
Constant Field Values

RECEIVING_STATEMENT_NUMBERS

public static final int RECEIVING_STATEMENT_NUMBERS
See Also:
Constant Field Values

MESSAGE_FILE_LIBRARY_USED

public static final int MESSAGE_FILE_LIBRARY_USED
See Also:
Constant Field Values

REPLY_STATUS

public static final int REPLY_STATUS
See Also:
Constant Field Values

REQUEST_STATUS

public static final int REQUEST_STATUS
See Also:
Constant Field Values

REQUEST_LEVEL

public static final int REQUEST_LEVEL
See Also:
Constant Field Values

CCSID_FOR_TEXT

public static final int CCSID_FOR_TEXT
See Also:
Constant Field Values

CCSID_CONVERSION_STATUS_TEXT

public static final int CCSID_CONVERSION_STATUS_TEXT
See Also:
Constant Field Values

CCSID_FOR_DATA

public static final int CCSID_FOR_DATA
See Also:
Constant Field Values

CCSID_CONVERSION_STATUS_DATA

public static final int CCSID_CONVERSION_STATUS_DATA
See Also:
Constant Field Values
Constructor Detail

JobLog

public JobLog()
Constructs a JobLog object. The system must be provided later. The job information defaults to the server job in which the program is run.


JobLog

public JobLog(AS400 system)
Constructs a JobLog object. The job information defaults to the server job in which the program is run.

Parameters:
system - The system object representing the system on which the job log exists.

JobLog

public JobLog(AS400 system,
              String name,
              String user,
              String number)
Constructs a JobLog object.

Parameters:
system - The system object representing the system on which the job log exists.
name - The job name.
user - The job user name.
number - The job number.
Method Detail

addAttributeToRetrieve

public void addAttributeToRetrieve(int attribute)
                            throws IOException
Adds a message attribute that will be retrieved for each joblog. This method allows the Joblog objects that are retrieved from this Joblog list to have some of their message attributes choosen by the caller.

The list of message attributes is maintained internally even when this JobList is closed and re-used. To start over with a new set of job attributes to retrieve, call clearAttributesToRetrieve(). This will set all attributes to null including the default attributes.

Parameters:
attribute - The message attribute to retrieve. Possible values are all joblog attributes in the api document for the Open List of Job Log Messages (QGYOLJBL) API.
Throws:
IOException

clearAttributesToRetrieve

public void clearAttributesToRetrieve()
Clears the message attributes to be retrieved for a given Joblog. This removes all of the joblog attributes that would be retrieved including the default message attributes. If all message attributes are cleared a call to addAttributeToRetrieve must be called or an exception will be thrown.

See Also:
addAttributeToRetrieve(int)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener. The specified PropertyChangeListener's propertyChange() method will be called each time the value of any bound property is changed.

Parameters:
listener - The listener.
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a VetoableChangeListener. The specified VetoableChangeListener's vetoableChange() method will be called each time the value of any constrained property is changed.

Parameters:
listener - The listener.
See Also:
removeVetoableChangeListener(java.beans.VetoableChangeListener)

close

public void close()
           throws AS400SecurityException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException
Closes the message list on the system. This releases any system resources previously in use by this message list.

Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.

getLength

public int getLength()
Returns the number of messages in the job log. This method implicitly calls load().

Returns:
The number of messages, or 0 if no list was retrieved.
See Also:
load()

getListDirection

public boolean getListDirection()
Returns the list direction.

Returns:
true if the messages will be sorted oldest to newest; false if they will be sorted newest to oldest. The default is true.

getMessages

public Enumeration getMessages()
                        throws AS400SecurityException,
                               ErrorCompletingRequestException,
                               InterruptedException,
                               IOException,
                               ObjectDoesNotExistException
Returns the list of messages in the job log.

Returns:
An Enumeration of QueuedMessage objects.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.

getMessages

public QueuedMessage[] getMessages(int listOffset,
                                   int number)
                            throws AS400SecurityException,
                                   ErrorCompletingRequestException,
                                   InterruptedException,
                                   IOException,
                                   ObjectDoesNotExistException
Returns a subset of the list of messages in the job log. This method allows the user to retrieve the message list from the system in pieces. If a call to load() is made (either implicitly or explicitly), then the messages at a given offset will change, so a subsequent call to getMessages() with the same listOffset and number will most likely not return the same QueuedMessages as the previous call.

Parameters:
listOffset - The offset into the list of messages. This value must be greater than 0 and less than the list length, or specify -1 to retrieve all of the messages.
number - The number of messages to retrieve out of the list, starting at the specified listOffset. This value must be greater than or equal to 0 and less than or equal to the list length. If the listOffset is -1, this parameter is ignored.
Returns:
The array of retrieved QueuedMessage objects. The length of this array may not necessarily be equal to number, depending upon the size of the list on the system, and the specified listOffset.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
See Also:
QueuedMessage

getName

public String getName()
Returns the job name.

Returns:
The job name, or "*" if none has been set.
See Also:
setName(java.lang.String)

getNumber

public String getNumber()
Returns the job number.

Returns:
The job number, or "" if none has been set.
See Also:
setNumber(java.lang.String)

getStartingMessageKey

public byte[] getStartingMessageKey()
Returns the starting message key.

Returns:
The key.
See Also:
setStartingMessageKey(byte[])

getSystem

public AS400 getSystem()
Returns the system object representing the system on which the job log exists.

Returns:
The system object representing the system on which the job log exists. If the system has not been set, null is returned.
See Also:
setSystem(com.ibm.as400.access.AS400)

getUser

public String getUser()
Returns the job user name.

Returns:
The job user name, or "" if none has been set.
See Also:
setUser(java.lang.String)

load

public void load()
          throws AS400SecurityException,
                 ErrorCompletingRequestException,
                 InterruptedException,
                 IOException,
                 ObjectDoesNotExistException
Loads the list of messages on the system. This method informs the system to build a list of messages. This method blocks until the system returns the total number of messages it has compiled. A subsequent call to getMessages() will retrieve the actual message information and attributes for each message in the list from the system.

This method updates the list length.

Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
See Also:
getLength()

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the PropertyChangeListener. If the PropertyChangeListener is not on the list, nothing is done.

Parameters:
listener - The listener object.

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes the VetoableChangeListener. If the VetoableChangeListener is not on the list, nothing is done.

Parameters:
listener - The listener object.

setListDirection

public void setListDirection(boolean listDirection)
Sets the list direction.

Parameters:
listDirection - true to sort the messages oldest to newest; false to sort them newest to oldest. The default is true.

setName

public void setName(String name)
             throws PropertyVetoException
Sets the job name. This cannot be changed if the object has established a connection to the system.

Parameters:
name - The job name.
Throws:
PropertyVetoException - If any of the registered listeners vetos the property change.

setNumber

public void setNumber(String number)
               throws PropertyVetoException
Sets the job number. This cannot be changed if the object has established a connection to the system.

Parameters:
number - The job number.
Throws:
PropertyVetoException - If any of the registered listeners vetos the property change.

setStartingMessageKey

public void setStartingMessageKey(byte[] startingMessageKey)
Sets the message key used to begin searching for messages to list from the corresponding entry in the job log. Any valid message key will work, including MessageQueue.OLDEST and MessageQueue#NEWEST.

Parameters:
startingMessageKey - The key. Specify null to set it back to the default, which will be OLDEST or NEWEST based on the list direction.

setSystem

public void setSystem(AS400 system)
               throws PropertyVetoException
Sets the system. This cannot be changed if the object has established a connection to the system.

Parameters:
system - The system object representing the system on which the job log exists.
Throws:
PropertyVetoException - If any of the registered listeners vetos the property change.

setUser

public void setUser(String user)
             throws PropertyVetoException
Sets the job user name. This cannot be changed if the object has established a connection to the system.

Parameters:
user - The job user name.
Throws:
PropertyVetoException - If any of the registered listeners vetos the property change.

writeMessage

public static void writeMessage(AS400 system,
                                String messageID,
                                int messageType)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
Writes a program message to the job log for the job in which the program is running.
Note: The program runs in the job of the Remote Command Host Server (QZRCSRVS) unless it is invoked "on-thread" on the system.

Parameters:
system - The system object representing the system on which the job log exists. If the system specifies localhost, the message is written to the job log of the process from which this method is called. Otherwise the message is written to the QZRCSRVS job.
messageID - The message ID. The message must be in the default message file /QSYS.LIB/QCPFMSG.MSGF.
messageType - The message type. Possible values are:
  • AS400Message.COMPLETION
  • AS400Message.DIAGNOSTIC
  • AS400Message.INFORMATIONAL
  • AS400Message.ESCAPE
The message type must be AS400Message.INFORMATIONAL for an immediate message.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                String messageID,
                                int messageType,
                                byte[] substitutionData)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
Writes a program message to the job log for the job in which the program is running.
Note: The program runs in the job of the Remote Command Host Server (QZRCSRVS) unless it is invoked "on-thread" on the system.

Parameters:
system - The system. If the system specifies localhost, the message is written to the job log of the process from which this method is called. Otherwise the message is written to the QZRCSRVS job.
messageID - The message ID. The message must be in the default message file /QSYS.LIB/QCPFMSG.MSGF.
messageType - The message type. Possible values are:
  • AS400Message.COMPLETION
  • AS400Message.DIAGNOSTIC
  • AS400Message.INFORMATIONAL
  • AS400Message.ESCAPE
The message type must be AS400Message.INFORMATIONAL for an immediate message.
substitutionData - The substitution data. The substitution data can be from 0-32767 bytes for a conventional message and from 1-6000 bytes for an immediate message.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                String messageID,
                                int messageType,
                                String messageFile)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
Writes a program message to the job log for the job in which the program is running.
Note: The program runs in the job of the Remote Command Host Server (QZRCSRVS) unless it is invoked "on-thread" on the system.

Parameters:
system - The system. If the system specifies localhost, the message is written to the job log of the process from which this method is called. Otherwise the message is written to the QZRCSRVS job.
messageID - The message ID.
messageType - The message type. Possible values are:
  • AS400Message.COMPLETION
  • AS400Message.DIAGNOSTIC
  • AS400Message.INFORMATIONAL
  • AS400Message.ESCAPE
The message type must be AS400Message.INFORMATIONAL for an immediate message.
messageFile - The integrated file system path name of the message file.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                String messageID,
                                int messageType,
                                String messageFile,
                                byte[] substitutionData)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
Writes a program message to the job log for the job in which the program is running.
Note: The program runs in the job of the Remote Command Host Server (QZRCSRVS) unless it is invoked "on-thread" on the system.

Parameters:
system - The system. If the system specifies localhost, the message is written to the job log of the process from which this method is called. Otherwise the message is written to the QZRCSRVS job.
messageID - The message ID.
messageType - The message type. Possible values are:
  • AS400Message.COMPLETION
  • AS400Message.DIAGNOSTIC
  • AS400Message.INFORMATIONAL
  • AS400Message.ESCAPE
The message type must be AS400Message.INFORMATIONAL for an immediate message.
messageFile - The integrated file system path name of the message file.
substitutionData - The substitution data. The substitution data can be from 0-32767 bytes for a conventional message and from 1-6000 bytes for an immediate message.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                String messageID,
                                int messageType,
                                String messageFile,
                                byte[] substitutionData,
                                boolean onThread)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
Writes a program message to the job log for the job in which the program is running. The message is sent to the Remote Command Host Server (QZRCSRVS) unless true is specified for the onThread parameter and is invoked while running on the system.

Parameters:
system - The system. The system cannot be null.
messageID - The message ID. The message ID cannot be null.
messageType - The message type. Possible values are:
  • AS400Message.COMPLETION
  • AS400Message.DIAGNOSTIC
  • AS400Message.INFORMATIONAL
  • AS400Message.ESCAPE
The message type must be AS400Message.INFORMATIONAL for an immediate message.
messageFile - The integrated file system path name of the message file. If null is specified, the message file used is /QSYS.LIB/QCPFMSG.MSGF.
substitutionData - The substitution data. The substitution data can be from 0-32767 bytes for a conventional message and from 1-6000 bytes for an immediate message. If null is specified, no substitution data is used.
onThread - Whether or not to stay on thread when calling the API to write the message to the job log. true to write the message to the current job's job log, false to write the message to the Remote Command Host Server job's job log. Note that this parameter is meaningless unless this Java program is running on the system and the system object is using native optimizations.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
See Also:
ProgramCall.isStayOnThread()