Skip to content

Commit

Permalink
Enhancement PTF
Browse files Browse the repository at this point in the history
Enhancement to PTF class is returning more data from the API. The superseded by PTF is returned with the PTFR0100 format (which is the basic info format), and just needed to be captured from the output. The superseded PTF chain needed the implementation of the PTFR1000 format. A superseded PTF chain is all the PTFs that are superseded by this PTF. Also updated wording for getSupersedingPTF function to better articulate what it actually returns compared to getSupersededByPTF.

Signed-off-by: Justin Nelson <nelsoncj@us.ibm.com>
  • Loading branch information
nelsoncj-ibm authored and ThePrez committed Aug 8, 2023
1 parent d46e6b4 commit 618632c
Showing 1 changed file with 80 additions and 2 deletions.
82 changes: 80 additions & 2 deletions src/main/java/com/ibm/as400/access/PTF.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class PTF
private String licGroup_;
private String saveFile_;
private String supersedingPTF_;
private String supersededByPTF_;
private String targetRelease_;
//private String supersededByPTFID_; // V5R2
//private String currentServerIPLSource_; // V5R3
Expand All @@ -70,6 +71,7 @@ public class PTF
private boolean loaded600_ = false;
private boolean loaded700_ = false;
private boolean loaded800_ = false;
private boolean loaded1000_ = false;
// private boolean loaded900_ = false;
private int chunkSize_ = 8192;

Expand Down Expand Up @@ -100,6 +102,9 @@ public class PTF

// PTFR0800
private PTFExitProgram[] exitPrograms_;

// PTFR10000
private PTF[] superseded_;

// PTFR0900
// private PTFPrecondition[] preconditions_;
Expand Down Expand Up @@ -1245,8 +1250,8 @@ public Date getStatusDate()


/**
* Returns the PTF ID of the PTF that supersedes this PTF. This will be ""
* if there is no superseding PTF, or if the superseding PTF is not known.
* Returns the PTF ID of the most recent supersede of this PTF that exists on the system.
* This will be "" if there is no superseding PTF, or if the superseding PTF is not known.
* @return The PTF ID.
* @throws AS400Exception If an error occurs.
* @throws AS400SecurityException If a security or authority error occurs.
Expand All @@ -1268,6 +1273,56 @@ public String getSupersedingPTF()
if (!loaded_ && !partiallyLoadedGroup_) refresh(100); //@L12A
return supersedingPTF_;
}

/**
* Returns the PTF ID that has replaced this PTF.
* This will be "" if there is no superseding PTF, or if the superseding PTF is not known.
* @return The PTF ID.
* @throws AS400Exception If an error occurs.
* @throws AS400SecurityException If a security or authority error occurs.
* @throws ErrorCompletingRequestException If an error occurs before the request is completed.
* @throws InterruptedException If this thread is interrupted.
* @throws IOException If an error occurs while communicating with the system.
* @throws ObjectDoesNotExistException If the object does not exist.
* @see #getDependentPTFs
* @see #getRequisitePTFs
**/
public String getSupersededByPTF()
throws AS400Exception,
AS400SecurityException,
ErrorCompletingRequestException,
InterruptedException,
IOException,
ObjectDoesNotExistException
{
if (!loaded_ && !partiallyLoadedGroup_) refresh(100);
return supersededByPTF_;
}

/**
* Retrieves the list of PTFs that are supserseded by this PTF.
* If there are no supserseded PTFs, an array of size 0 will be returned.
* @return The PTF ID.
* @throws AS400Exception If an error occurs.
* @throws AS400SecurityException If a security or authority error occurs.
* @throws ErrorCompletingRequestException If an error occurs before the request is completed.
* @throws InterruptedException If this thread is interrupted.
* @throws IOException If an error occurs while communicating with the system.
* @throws ObjectDoesNotExistException If the object does not exist.
* @see #getDependentPTFs
* @see #getRequisitePTFs
**/
public PTF[] getSupersededPTFs()
throws AS400Exception,
AS400SecurityException,
ErrorCompletingRequestException,
InterruptedException,
IOException,
ObjectDoesNotExistException
{
if (!loaded1000_) refresh(1000);
return superseded_;
}


/**
Expand Down Expand Up @@ -1694,6 +1749,7 @@ public void refresh()
refresh(600);
refresh(700);
refresh(800);
refresh(1000);
}


Expand Down Expand Up @@ -1742,6 +1798,10 @@ private void refresh(int whichFormat)
format = "PTFR0800";
len = baseSize_+12+chunkSize_; // 108+12+(29*numberOfExitPrograms)
break;
case 1000:
format = "PTFR1000";
len = baseSize_+12+chunkSize_; // 108+12+(7*numberOfSuperseded)
break;
// case 900:
// format = "PTFR0900";
// len = baseSize_+12+chunkSize_; // 108+12+(30*numberOfPreconditions)
Expand Down Expand Up @@ -1832,6 +1892,7 @@ private void refresh(int whichFormat)
statusDate_ = null;
}
licGroup_ = conv.byteArrayToString(output, 101, 7).trim();
supersededByPTF_ = conv.byteArrayToString(output, 108, 7).trim();
if (output.length >= 115)
{
// V5R2 and higher
Expand Down Expand Up @@ -2026,6 +2087,23 @@ else if (whichFormat == 800)
}
loaded800_ = true;
}
else if (whichFormat == 1000)
{
int offset = BinaryConverter.byteArrayToInt(output, 8);
int entryOffset = BinaryConverter.byteArrayToInt(output, offset);
offset += 4;
int numSupers = BinaryConverter.byteArrayToInt(output, offset);
offset += 4;
int entryLength = BinaryConverter.byteArrayToInt(output, offset);
superseded_ = new PTF[numSupers];
for (int i=0; i<numSupers; ++i)
{
offset = entryOffset + (i*entryLength);
String supPTFID = conv.byteArrayToString(output, offset, 7);
superseded_[i] = new PTF(system_, productID_, supPTFID, ptfReleaseLevel_, ptfProductOption_, ptfProductLoad_);
}
loaded1000_ = true;
}
// else if (whichFormat == 900)
// {
// int offset = BinaryConverter.byteArrayToInt(output, 8);
Expand Down

0 comments on commit 618632c

Please sign in to comment.