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

IFS fixes for retrieving attributes using profile token #232

Merged
merged 5 commits into from
Jan 22, 2025
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
310 changes: 173 additions & 137 deletions src/main/java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,9 @@ public int getCCSID(boolean retrieveAll) throws IOException
if (errorRC_ == IFSReturnCodeRep.FILE_NOT_FOUND || errorRC_ == IFSReturnCodeRep.PATH_NOT_FOUND)
throw new ExtendedIOException(path_, ExtendedIOException.PATH_NOT_FOUND);

// Cannot create file handle to object, so let us try the other way
return getCCSID();
// Cannot create file handle to object, so let us try the other way only
if (retrieveAll)
return getCCSID();
}
}
catch (AS400SecurityException e) {
Expand Down Expand Up @@ -668,44 +669,52 @@ public int getCCSID() throws IOException
{
// In 7.5 and prior releases, need to create user handle for IFS tables to be initialized.
userHandle = (getSystem().getVRM() <= 0x00070500) ? system_.createUserHandle() : 0;

try
{
byte[] path = getConverter().stringToByteArray(path_);

IFSLookupReq req = new IFSLookupReq(path, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0);
ds = (ClientAccessDataStream) server_.sendAndReceive(req);
}
catch(ConnectionDroppedException e)
if (userHandle == UNINITIALIZED)
{
Trace.log(Trace.ERROR, "Byte stream server connection lost.");
connectionDropped(e);
}
catch(InterruptedException e)
{
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(e.getMessage());
throwException.initCause(e);
throw throwException;
}

int rc = 0;
if (ds instanceof IFSLookupRep)
{
objectHandle = ((IFSLookupRep) ds).getHandle();
retrieveAttributes(ds, objectHandle);
}
else if (ds instanceof IFSReturnCodeRep)
{
rc = ((IFSReturnCodeRep) ds).getReturnCode();
if (rc != IFSReturnCodeRep.SUCCESS) Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);

throw new ExtendedIOException(path_, rc);
IFSListAttrsRep reply = listObjAttrs2(); // the 'ccsid' field is in the OA2 structure
if (reply != null)
fileDataCCSID_ = reply.getCCSID(serverDatastreamLevel_);
}
else
{
Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID());
throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN);
try
{
byte[] path = getConverter().stringToByteArray(path_);

IFSLookupReq req = new IFSLookupReq(path, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0);
ds = (ClientAccessDataStream) server_.sendAndReceive(req);
}
catch(ConnectionDroppedException e)
{
Trace.log(Trace.ERROR, "Byte stream server connection lost.");
connectionDropped(e);
}
catch(InterruptedException e)
{
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(e.getMessage());
throwException.initCause(e);
throw throwException;
}

int rc = 0;
if (ds instanceof IFSLookupRep)
{
objectHandle = ((IFSLookupRep) ds).getHandle();
retrieveAttributes(ds, objectHandle);
}
else if (ds instanceof IFSReturnCodeRep)
{
rc = ((IFSReturnCodeRep) ds).getReturnCode();
if (rc != IFSReturnCodeRep.SUCCESS) Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);

throw new ExtendedIOException(path_, rc);
}
else
{
Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID());
throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN);
}
}
}
finally
Expand Down Expand Up @@ -1496,44 +1505,50 @@ public int getASP() throws IOException, AS400SecurityException
{
// In 7.5 and prior releases, need to create user handle for IFS tables to be initialized.
userHandle = (getSystem().getVRM() <= 0x00070500) ? system_.createUserHandle() : 0;

try
{
// Issue a Look up request to create an object handle.
IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0);
ds = (ClientAccessDataStream) server_.sendAndReceive(req);
}
catch(ConnectionDroppedException e)
{
Trace.log(Trace.ERROR, "Byte stream server connection lost.");
connectionDropped(e);
}
catch(InterruptedException e)
{
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(e.getMessage());
throwException.initCause(e);
throw throwException;
}

rc = 0;
if (ds instanceof IFSLookupRep)
if (userHandle == UNINITIALIZED)
{
objectHandle = ((IFSLookupRep) ds).getHandle();
retrieveAttributes(ds, objectHandle); //@AC7A
}
else if (ds instanceof IFSReturnCodeRep)
{
rc = ((IFSReturnCodeRep) ds).getReturnCode();
if (rc != IFSReturnCodeRep.SUCCESS)
Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);

throw new ExtendedIOException(path_, rc);
// Not sure what to do here...20.0.7 returned -1. So we do that same in 20.0.8.
}
else
{
Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID());
throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN);
try
{
// Issue a Look up request to create an object handle.
IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0);
ds = (ClientAccessDataStream) server_.sendAndReceive(req);
}
catch(ConnectionDroppedException e)
{
Trace.log(Trace.ERROR, "Byte stream server connection lost.");
connectionDropped(e);
}
catch(InterruptedException e)
{
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(e.getMessage());
throwException.initCause(e);
throw throwException;
}

rc = 0;
if (ds instanceof IFSLookupRep)
{
objectHandle = ((IFSLookupRep) ds).getHandle();
retrieveAttributes(ds, objectHandle); //@AC7A
}
else if (ds instanceof IFSReturnCodeRep)
{
rc = ((IFSReturnCodeRep) ds).getReturnCode();
if (rc != IFSReturnCodeRep.SUCCESS)
Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);

throw new ExtendedIOException(path_, rc);
}
else
{
Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID());
throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN);
}
}
}
finally
Expand Down Expand Up @@ -1566,43 +1581,58 @@ public String getOwnerNameByUserHandle(boolean forceRetrieve) throws IOException
{
// In 7.5 and prior releases, need to create user handle for IFS tables to be initialized.
userHandle = (getSystem().getVRM() <= 0x00070500) ? system_.createUserHandle() : 0;

try
{
// Issue a Look up request to create an object handle.
IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0);
ds = (ClientAccessDataStream) server_.sendAndReceive(req);
}
catch(ConnectionDroppedException e)
{
Trace.log(Trace.ERROR, "Byte stream server connection lost.");
connectionDropped(e);
}
catch(InterruptedException e)
{
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(e.getMessage());
throwException.initCause(e);
throw throwException;
}

// Verify that we got a handle back.
rc = 0;
if (ds instanceof IFSLookupRep)
if (userHandle == UNINITIALIZED)
{
objectHandle = ((IFSLookupRep) ds).getHandle();
retrieveAttributes(ds, objectHandle); //@AC7A
IFSListAttrsRep reply = listObjAttrs1(IFSObjAttrs1.OWNER_NAME_FLAG, 0);
if (reply != null)
fileOwnerName_ = reply.getOwnerName(system_.getCcsid());
else
{
if (Trace.traceOn_) Trace.log(Trace.WARNING, "getOwnerNameByUserHandle: IFSReturnCodeRep return code", errorRC_);

if (errorRC_ == IFSReturnCodeRep.FILE_NOT_FOUND || errorRC_ == IFSReturnCodeRep.PATH_NOT_FOUND)
throw new ExtendedIOException(path_, ExtendedIOException.PATH_NOT_FOUND);
}
}
else if (ds instanceof IFSReturnCodeRep)
{
rc = ((IFSReturnCodeRep) ds).getReturnCode();
if (rc != IFSReturnCodeRep.SUCCESS) Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);
throw new ExtendedIOException(path_, rc);
}
else
{
Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID());
throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN);
try
{
// Issue a Look up request to create an object handle.
IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0);
ds = (ClientAccessDataStream) server_.sendAndReceive(req);
}
catch(ConnectionDroppedException e)
{
Trace.log(Trace.ERROR, "Byte stream server connection lost.");
connectionDropped(e);
}
catch(InterruptedException e)
{
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(e.getMessage());
throwException.initCause(e);
throw throwException;
}

// Verify that we got a handle back.
rc = 0;
if (ds instanceof IFSLookupRep)
{
objectHandle = ((IFSLookupRep) ds).getHandle();
retrieveAttributes(ds, objectHandle); //@AC7A
}
else if (ds instanceof IFSReturnCodeRep)
{
rc = ((IFSReturnCodeRep) ds).getReturnCode();
if (rc != IFSReturnCodeRep.SUCCESS) Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);
throw new ExtendedIOException(path_, rc);
}
else
{
Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID());
throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN);
}
}
}
finally
Expand Down Expand Up @@ -1633,44 +1663,50 @@ public String getFileSystemType() throws IOException, AS400SecurityException
try
{
userHandle = (getSystem().getVRM() <= 0x00070500) ? system_.createUserHandle() : 0;

try
{
// Issue a Look up request to create an object handle.
IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0);
ds = (ClientAccessDataStream) server_.sendAndReceive(req);
}
catch(ConnectionDroppedException e)
if (userHandle == UNINITIALIZED)
{
Trace.log(Trace.ERROR, "Byte stream server connection lost.");
connectionDropped(e);
}
catch(InterruptedException e)
{
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(e.getMessage());
throwException.initCause(e);
throw throwException;
}

rc = 0;
if (ds instanceof IFSLookupRep)
{
objectHandle = ((IFSLookupRep) ds).getHandle();
retrieveAttributes(ds, objectHandle); //@AC7A
}
else if (ds instanceof IFSReturnCodeRep)
{
rc = ((IFSReturnCodeRep) ds).getReturnCode();
if (rc != IFSReturnCodeRep.SUCCESS)
Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);

throw new ExtendedIOException(path_, rc);
// Not sure what to do here...20.0.7 returned null string. For 20.0.8, return unknown.
}
else
{
Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID());
throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN);
try
{
// Issue a Look up request to create an object handle.
IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0);
ds = (ClientAccessDataStream) server_.sendAndReceive(req);
}
catch(ConnectionDroppedException e)
{
Trace.log(Trace.ERROR, "Byte stream server connection lost.");
connectionDropped(e);
}
catch(InterruptedException e)
{
Trace.log(Trace.ERROR, "Interrupted");
InterruptedIOException throwException = new InterruptedIOException(e.getMessage());
throwException.initCause(e);
throw throwException;
}

rc = 0;
if (ds instanceof IFSLookupRep)
{
objectHandle = ((IFSLookupRep) ds).getHandle();
retrieveAttributes(ds, objectHandle); //@AC7A
}
else if (ds instanceof IFSReturnCodeRep)
{
rc = ((IFSReturnCodeRep) ds).getReturnCode();
if (rc != IFSReturnCodeRep.SUCCESS)
Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);

throw new ExtendedIOException(path_, rc);
}
else
{
Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID());
throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN);
}
}
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ public ProfileTokenEnhancedInfo(ProfileTokenEnhancedInfo enhancedInfo) {
enhancedInfo.localPort_);
}

public String getVerificationID() { return verificationID_; }
public String getVerificationID() {
return (verificationID_ != null) ? verificationID_ : ProfileTokenCredential.DEFAULT_VERIFICATION_ID;
}
public String getRemoteIPAddress() { return remoteIPAddress_; }
public int getRemotePort() { return remotePort_; }
public String getLocalIPAddress() { return localIPAddress_; }
Expand Down
Loading