com.ibm.as400.access

Class JobLog

  • java.lang.Object
    • com.ibm.as400.access.JobLog
  • All Implemented Interfaces:
    java.io.Serializable


    public class JobLog
    extends java.lang.Object
    implements java.io.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 these 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:

    • 0101 Alert option
    • 0201 Replacement data or impromptu message text
    • 0301 Message
    • 0302 Message with replacement data
    • 0401 Message help
    • 0402 Message help with replacement data
    • 0403 Message help with formatting characters
    • 0404 Message help with replacement data and formatting characters
    • 0501 Default reply
    • 0602 Sender type
    • 0603 Sending program name
    • 0604 Sending module name
    • 0605 Sending procedure name
    • 0606 Number of sending statement numbers
    • 0607 Sending user profile
    • 0702 Receiving type
    • 0703 Receiving program name
    • 0704 Receiving module name
    • 0705 Receiving procedure name
    • 0706 Number of receiving statement numbers
    • 0801 Message file library used
    • 1001 Reply status
    • 1101 Request status
    • 1201 Request level
    • 1301 Coded character set identifier (CCSID) for text
    • 1302 CCSID conversion status indicator for text
    • 1303 Coded character set identifier (CCSID) for data
    • 1304 CCSID conversion status indicator for data
    See Also:
    QueuedMessage, Serialized Form
    • 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,
              java.lang.String name,
              java.lang.String user,
              java.lang.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 java.io.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 chosen 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:
        java.io.IOException - If an error occurs while communicating with the system.
      • 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(java.beans.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(java.beans.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)
      • 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 QueuedMessage[] getMessages(int listOffset,
                                  int number)
                                    throws AS400SecurityException,
                                           ErrorCompletingRequestException,
                                           java.lang.InterruptedException,
                                           java.io.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 list 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 in the list of messages (0-based). This value must be greater than or equal to 0 and less than the list length; or specify -1 to retrieve all of the messages. Note: Prior to JTOpen 7.2, this parameter was incorrectly described.
        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.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.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 java.lang.String getName()
        Returns the job name.
        Returns:
        The job name, or "*" if none has been set.
        See Also:
        setName(java.lang.String)
      • getNumber

        public java.lang.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 java.lang.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,
                         java.lang.InterruptedException,
                         java.io.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.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.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(java.beans.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(java.beans.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(java.lang.String name)
                     throws java.beans.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:
        java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.
      • setNumber

        public void setNumber(java.lang.String number)
                       throws java.beans.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:
        java.beans.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 java.beans.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:
        java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.
      • setUser

        public void setUser(java.lang.String user)
                     throws java.beans.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:
        java.beans.PropertyVetoException - If any of the registered listeners vetos the property change.
      • writeMessage

        public static void writeMessage(AS400 system,
                        java.lang.String messageID,
                        int messageType)
                                 throws AS400SecurityException,
                                        ErrorCompletingRequestException,
                                        java.lang.InterruptedException,
                                        java.io.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.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.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,
                        java.lang.String messageID,
                        int messageType,
                        byte[] substitutionData)
                                 throws AS400SecurityException,
                                        ErrorCompletingRequestException,
                                        java.lang.InterruptedException,
                                        java.io.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.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.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,
                        java.lang.String messageID,
                        int messageType,
                        java.lang.String messageFile)
                                 throws AS400SecurityException,
                                        ErrorCompletingRequestException,
                                        java.lang.InterruptedException,
                                        java.io.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.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.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,
                        java.lang.String messageID,
                        int messageType,
                        java.lang.String messageFile,
                        byte[] substitutionData)
                                 throws AS400SecurityException,
                                        ErrorCompletingRequestException,
                                        java.lang.InterruptedException,
                                        java.io.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.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.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,
                        java.lang.String messageID,
                        int messageType,
                        java.lang.String messageFile,
                        byte[] substitutionData,
                        boolean onThread)
                                 throws AS400SecurityException,
                                        ErrorCompletingRequestException,
                                        java.lang.InterruptedException,
                                        java.io.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.
        java.lang.InterruptedException - If this thread is interrupted.
        java.io.IOException - If an error occurs while communicating with the system.
        ObjectDoesNotExistException - If the object does not exist on the system.
        See Also:
        ProgramCall.isStayOnThread()
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Closes the list on the system when this object is garbage collected.
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable