Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getMessageOption() and setMessageOption() to ProgramCallDocument #187

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/java/com/ibm/as400/data/PcmlDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,15 @@ synchronized AS400Message[] getMessageList(String name) throws PcmlException
return getProgramNode(name).getMessageList();
}

/**
Returns the option for how many messages will be retrieved for the specified program.
@return A constant indicating how many messages will be retrieved.
**/
synchronized int getMessageOption(String name) throws PcmlException
{
return getProgramNode(name).getMessageOption();
}

/**
Returns the ProgramCall object that was used in the most recent invocation of {@link #callProgram() callProgram()}.
@return The ProgramCall object; null if callProgram has not been called.
Expand Down Expand Up @@ -692,6 +701,18 @@ boolean getThreadsafeOverride(String program) // @C6A
return getProgramNode(program).getThreadsafeOverride(); // @C6A
} // @C6A

/**
Specifies the option for how many messages should be retrieved for the specified program. By default, to preserve
compatability, only the messages sent to the program caller and only up to ten messages are retrieved.
This property will only take effect on systems that support the new option.
@param messageOption A constant indicating how many messages to retrieve.
**/
synchronized void setMessageOption(String program, int messageOption)
throws PcmlException
{
getProgramNode(program).setMessageOption(messageOption);
}

// Add a subtree to the document's hashtable.
// This is called to complete the document cloneing process.
void addToHashtable(PcmlDocNode newChild) // @C5A
Expand Down
29 changes: 27 additions & 2 deletions src/main/java/com/ibm/as400/data/PcmlProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400Message;
import com.ibm.as400.access.ExtendedIllegalArgumentException;
import com.ibm.as400.access.ProgramCall;
import com.ibm.as400.access.ServiceProgramCall; // @B1A
import com.ibm.as400.access.ProgramParameter;
Expand Down Expand Up @@ -91,6 +92,7 @@ class PcmlProgram extends PcmlDocNode
private AS400Message[] msgList; // Array of AS400Message @C1C
private int m_IntReturnValue; // Int return value for a service program call @B1A @C1C
private int m_Errno; // Errno for a service program call @B1A @C1C
private int m_MessageOption;

/**
*/
Expand All @@ -102,6 +104,7 @@ public PcmlProgram()
m_IntReturnValue = 0; // @C1A
m_Errno = 0; // @C1A
m_ThreadsafeOverrideCalled = false; // @D2A
m_MessageOption = AS400Message.MESSAGE_OPTION_UP_TO_10;
}

// Constructor
Expand All @@ -116,6 +119,7 @@ public PcmlProgram(PcmlAttributeList attrs) // @C3C
m_IntReturnValue = 0; // @C1A
m_Errno = 0; // @C1A
m_ThreadsafeOverrideCalled = false; // @D2A
m_MessageOption = AS400Message.MESSAGE_OPTION_UP_TO_10;

// **********************************
// Set attribute values
Expand Down Expand Up @@ -682,6 +686,8 @@ else if (getEntrypoint() != null) // @D1A
m_pgmCall.setThreadSafe(getThreadsafeOverride()); // @C6A
}

m_pgmCall.setMessageOption(getMessageOption());

//
// Call the target program
//
Expand All @@ -692,11 +698,15 @@ else if (getEntrypoint() != null) // @D1A
if (Trace.isTraceOn()) Trace.log(Trace.PCML, "Completed program call: " + m_pgmCall.getProgram());

//
// If the program signalled a message, save the message list.
// Save the message list in all cases
//
msgList = m_pgmCall.getMessageList();

//
// If the program signaled a message, stop processing here.
//
if (m_pgmRc != true)
{
msgList = m_pgmCall.getMessageList();
return m_pgmRc;
}

Expand Down Expand Up @@ -883,6 +893,21 @@ AS400Message[] getMessageList()
return msgList;
}

int getMessageOption()
{
return m_MessageOption;
}

void setMessageOption(int messageOption)
{
// Validate the messageOption parameter.
if (messageOption < 0 || messageOption > 2)
{
throw new ExtendedIllegalArgumentException("messageOption (" + messageOption + ")", ExtendedIllegalArgumentException.PARAMETER_VALUE_NOT_VALID);
}
m_MessageOption = messageOption;
}

/**
Returns whether or not this element is defined as a service program entrypoint.

Expand Down
41 changes: 40 additions & 1 deletion src/main/java/com/ibm/as400/data/ProgramCallDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,25 @@ public AS400Message[] getMessageList(String name)
return m_pcmlDoc.getMessageList(name);
}

/**
Returns the option for how many messages will be retrieved for the specified program.

@param name The name of the &lt;program&gt; element in the PCML document.
@return A constant indicating how many messages will be retrieved. Valid values are:
<ul>
<li>{@link AS400Message#MESSAGE_OPTION_UP_TO_10 MESSAGE_OPTION_UP_TO_10}
<li>{@link AS400Message#MESSAGE_OPTION_NONE MESSAGE_OPTION_NONE}
<li>{@link AS400Message#MESSAGE_OPTION_ALL MESSAGE_OPTION_ALL}
</ul>
@exception PcmlException
If an error occurs.
**/
public int getMessageOption(String name)
throws PcmlException
{
return m_pcmlDoc.getMessageOption(name);
}

/**
Returns the number of bytes reserved for output for the named element.

Expand Down Expand Up @@ -1351,6 +1370,27 @@ public boolean getThreadsafeOverride(String program)
return m_pcmlDoc.getThreadsafeOverride(program); // @C6A
}

/**
Specifies the option for how many messages should be retrieved for the specified program. By default, to preserve
compatability, only the messages sent to the program caller and only up to ten messages are retrieved.
This property will only take effect on systems that support the new option.

@param program The name of the &lt;program&gt; element in the PCML document.
@param messageOption A constant indicating how many messages to retrieve. Valid values are:
<ul>
<li>AS400Message.MESSAGE_OPTION_UP_TO_10
<li>AS400Message.MESSAGE_OPTION_NONE
<li>AS400Message.MESSAGE_OPTION_ALL
</ul>
@exception PcmlException
If an error occurs.
**/
public void setMessageOption(String program, int messageOption)
throws PcmlException
{
m_pcmlDoc.setMessageOption(program, messageOption);
}


/**
Saves a PcmlDocument as a serialized resource.
Expand Down Expand Up @@ -2013,5 +2053,4 @@ public int getTimeout() {
return m_timeOut;
}
//@Y6A End

}