Skip to content

Commit 9e6671c

Browse files
ThePrezZhanghze
andcommitted
(WIP) IFS extended attributes
Co-Authored-By: Zhanghze <[email protected]> Signed-off-by: Jesse Gorzinski <[email protected]>
1 parent 7fa346c commit 9e6671c

8 files changed

+587
-23
lines changed

src/main/java/com/ibm/as400/access/IFSFile.java

+28-4
Original file line numberDiff line numberDiff line change
@@ -1497,8 +1497,8 @@ public String getOwnerName()
14971497
return impl_.getOwnerNameByUserHandle(false); //@AC7
14981498
}
14991499
else
1500-
//return impl_.getOwnerName(); //@AE8D
1501-
//@AE8A
1500+
//return impl_.getOwnerName();
1501+
//TODO
15021502
{
15031503
String pathUpperCase = path_.toUpperCase(system_.getLocale());
15041504
if (pathUpperCase.startsWith("/QSYS.LIB") && !pathUpperCase.endsWith(".FILE")) {
@@ -1794,7 +1794,7 @@ For further information, refer to the specification of the QDBRTVFD (Retrieve Da
17941794
public boolean isSourcePhysicalFile()
17951795
throws AS400Exception, AS400SecurityException, IOException
17961796
{
1797-
String pathUpperCase = path_.toUpperCase(system_.getLocale()); //@AE8A
1797+
String pathUpperCase = path_.toUpperCase(system_.getLocale()); //TODO fix path lower case issue
17981798
if (!pathUpperCase.endsWith(".FILE") ||
17991799
pathUpperCase.indexOf("/QSYS.LIB") == -1 ||
18001800
!getSubtype().equals("PF"))
@@ -3741,6 +3741,30 @@ public String toString()
37413741
{
37423742
return path_;
37433743
}
3744-
3744+
3745+
//TODO get Text 'description' of file/directory
3746+
public String getText() throws IOException, AS400SecurityException {
3747+
if (impl_ == null)
3748+
chooseImpl();
3749+
return impl_.getText();
3750+
}
3751+
3752+
public String getCodePage() throws IOException, AS400SecurityException {
3753+
if (impl_ == null)
3754+
chooseImpl();
3755+
return impl_.getCodePage();
3756+
}
3757+
3758+
public Hashtable getEAs() throws IOException, AS400SecurityException {
3759+
if (impl_ == null)
3760+
chooseImpl();
3761+
return impl_.getExtendedAttributes();
3762+
}
3763+
/*
3764+
public void setText(String fileText) {
3765+
if (impl_ == null)
3766+
impl_.setText(fileText);
3767+
}
3768+
*/
37453769
}
37463770

src/main/java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java

+188-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import java.io.IOException;
3131
import java.io.InterruptedIOException;
32+
import java.util.Hashtable;
3233
import java.util.Vector;
3334

3435

@@ -80,6 +81,7 @@ class IFSFileDescriptorImplRemote
8081
String fileOwnerName_ = null;
8182
boolean isDirectory_ = false;
8283
//@AC7 End
84+
Hashtable fileText_ = null; //TODO
8385

8486
// Static initialization code.
8587
static
@@ -2111,7 +2113,7 @@ else if (ds instanceof IFSReturnCodeRep)
21112113
//@AC7A Start
21122114
private void retrieveAttributes(ClientAccessDataStream ds, int objectHandle) throws IOException, AS400SecurityException {
21132115
fileAsp_ = ((IFSLookupRep) ds).getASP();
2114-
//if (isDirectory_) { @AE8D
2116+
//if (isDirectory_) { TODO remove
21152117
fileOwnerName_ = ((IFSLookupRep) ds).getOwnerName(system_.getCcsid());
21162118
fileDataCCSID_ = ((IFSLookupRep) ds).getCCSID(serverDatastreamLevel_);
21172119
//}
@@ -2165,6 +2167,191 @@ else if (ds instanceof IFSReturnCodeRep)
21652167
}
21662168
}
21672169
//@AC7A End
2170+
2171+
//TODO
2172+
/*
2173+
public IFSGetEAsRep listEAs() throws IOException, AS400SecurityException {
2174+
IFSGetEAsRep reply = null;
2175+
int fileHandle = UNINITIALIZED;
2176+
boolean usedGlobalHandle = false;
2177+
try {
2178+
// Open the file, and obtain a file handle.
2179+
if (fileHandle_ != UNINITIALIZED)
2180+
{
2181+
fileHandle = fileHandle_;
2182+
usedGlobalHandle = true;
2183+
}
2184+
else
2185+
{
2186+
fileHandle = createFileHandle(); //@KKBC
2187+
if (fileHandle == UNINITIALIZED)
2188+
{
2189+
if (Trace.traceOn_) Trace.log(Trace.ERROR, "Unable to create handle to file " + path_ + ". IFSReturnCodeRep return code", errorRC_);
2190+
return null;
2191+
}
2192+
}
2193+
IFSGetEAsReq req = new IFSGetEAsReq(fileHandle, serverDatastreamLevel_);
2194+
2195+
int rc = 0;
2196+
ClientAccessDataStream ds = null;
2197+
try
2198+
{
2199+
ds = (ClientAccessDataStream) server_.sendAndReceive(req);
2200+
}
2201+
catch(ConnectionDroppedException e)
2202+
{
2203+
Trace.log(Trace.ERROR, "Byte stream server connection lost.");
2204+
connectionDropped(e);
2205+
}
2206+
catch(InterruptedException e)
2207+
{
2208+
Trace.log(Trace.ERROR, "Interrupted");
2209+
InterruptedIOException throwException = new InterruptedIOException(e.getMessage());
2210+
try {
2211+
throwException.initCause(e);
2212+
} catch (Throwable t) {}
2213+
throw throwException;
2214+
}
2215+
2216+
if (ds instanceof IFSGetEAsRep)
2217+
{
2218+
reply = (IFSGetEAsRep) ds;
2219+
return reply;
2220+
}
2221+
else if (ds instanceof IFSReturnCodeRep)
2222+
{
2223+
rc = ((IFSReturnCodeRep) ds).getReturnCode();
2224+
if (rc != IFSReturnCodeRep.SUCCESS)
2225+
{
2226+
Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);
2227+
throw new ExtendedIOException(path_, rc);
2228+
}
2229+
}
2230+
else
2231+
{
2232+
// Unknown data stream.
2233+
Trace.log(Trace.ERROR, "Unknown reply data stream", ds.data_);
2234+
throw new
2235+
InternalErrorException(Integer.toHexString(ds.getReqRepID()),
2236+
InternalErrorException.DATA_STREAM_UNKNOWN);
2237+
}
2238+
}
2239+
finally {
2240+
if(!usedGlobalHandle && fileHandle != UNINITIALIZED)
2241+
close(fileHandle);
2242+
}
2243+
return reply;
2244+
}*/
2245+
2246+
public IFSGetEAsRep getExtendedAttributes(byte[][] eaNamelist, int eaNameLength, int ccsid) throws IOException, AS400SecurityException {
2247+
IFSGetEAsRep reply = null;
2248+
ClientAccessDataStream ds = null;
2249+
connect();
2250+
//create user handle
2251+
int userHandle = UNINITIALIZED, objectHandle = UNINITIALIZED, nodeObjectHandle = UNINITIALIZED;
2252+
try{
2253+
userHandle = system_.createUserHandle();
2254+
try
2255+
{
2256+
byte[] path = getConverter().stringToByteArray(path_);
2257+
//IFSLookupReq req = new IFSLookupReq(path, preferredServerCCSID_, userHandle, IFSLookupReq.OA2, 0, 0);
2258+
//IFSLookupReq req = new IFSLookupReq(path, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0); //@AC7A
2259+
IFSLookupReq req = new IFSLookupReq(path, preferredServerCCSID_,userHandle);
2260+
ds = (ClientAccessDataStream) server_.sendAndReceive(req);
2261+
int rc = 0;
2262+
if (ds instanceof IFSLookupRep)
2263+
{
2264+
objectHandle = ((IFSLookupRep) ds).getHandle();
2265+
//Open Node to get object request;
2266+
IFSOpenNodeReq nodeReq = new IFSOpenNodeReq(objectHandle, serverDatastreamLevel_);
2267+
ds = null;
2268+
ds = (ClientAccessDataStream) server_.sendAndReceive(nodeReq);
2269+
if (ds instanceof IFSOpenNodeRep) {
2270+
nodeObjectHandle = ((IFSOpenNodeRep) ds).getObjectHandle();
2271+
IFSGetEAsReq eaReq = new IFSGetEAsReq(nodeObjectHandle, eaNamelist, eaNameLength, ccsid, serverDatastreamLevel_);
2272+
ds = (ClientAccessDataStream) server_.sendAndReceive(eaReq);
2273+
if (ds instanceof IFSGetEAsRep) {
2274+
reply = (IFSGetEAsRep) ds;
2275+
} else if (ds instanceof IFSReturnCodeRep)
2276+
{
2277+
rc = ((IFSReturnCodeRep) ds).getReturnCode();
2278+
if (rc != IFSReturnCodeRep.SUCCESS)
2279+
{
2280+
Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);
2281+
}
2282+
throw new ExtendedIOException(path_, rc);
2283+
}
2284+
else
2285+
{
2286+
// Unknown data stream.
2287+
Trace.log(Trace.ERROR, "Unknown reply data stream",
2288+
ds.getReqRepID());
2289+
throw new
2290+
InternalErrorException(Integer.toHexString(ds.getReqRepID()),
2291+
InternalErrorException.DATA_STREAM_UNKNOWN);
2292+
}
2293+
} else if (ds instanceof IFSReturnCodeRep)
2294+
{
2295+
rc = ((IFSReturnCodeRep) ds).getReturnCode();
2296+
if (rc != IFSReturnCodeRep.SUCCESS)
2297+
{
2298+
Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);
2299+
}
2300+
throw new ExtendedIOException(path_, rc);
2301+
}
2302+
else
2303+
{
2304+
// Unknown data stream.
2305+
Trace.log(Trace.ERROR, "Unknown reply data stream",
2306+
ds.getReqRepID());
2307+
throw new
2308+
InternalErrorException(Integer.toHexString(ds.getReqRepID()),
2309+
InternalErrorException.DATA_STREAM_UNKNOWN);
2310+
}
2311+
}
2312+
else if (ds instanceof IFSReturnCodeRep)
2313+
{
2314+
rc = ((IFSReturnCodeRep) ds).getReturnCode();
2315+
if (rc != IFSReturnCodeRep.SUCCESS)
2316+
{
2317+
Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc);
2318+
}
2319+
throw new ExtendedIOException(path_, rc);
2320+
}
2321+
else
2322+
{
2323+
// Unknown data stream.
2324+
Trace.log(Trace.ERROR, "Unknown reply data stream",
2325+
ds.getReqRepID());
2326+
throw new
2327+
InternalErrorException(Integer.toHexString(ds.getReqRepID()),
2328+
InternalErrorException.DATA_STREAM_UNKNOWN);
2329+
}
2330+
2331+
} catch(ConnectionDroppedException e)
2332+
{
2333+
Trace.log(Trace.ERROR, "Byte stream server connection lost.");
2334+
connectionDropped(e);
2335+
}
2336+
catch(InterruptedException e)
2337+
{
2338+
Trace.log(Trace.ERROR, "Interrupted");
2339+
InterruptedIOException throwException = new InterruptedIOException(e.getMessage());
2340+
try {
2341+
throwException.initCause(e);
2342+
} catch (Throwable t) {}
2343+
throw throwException;
2344+
}
2345+
}finally{
2346+
if(nodeObjectHandle != UNINITIALIZED)
2347+
freeHandle(nodeObjectHandle);
2348+
if(objectHandle != UNINITIALIZED)
2349+
freeHandle(objectHandle);
2350+
}
2351+
return reply;
2352+
}
2353+
2354+
21682355

21692356
}
21702357

src/main/java/com/ibm/as400/access/IFSFileImpl.java

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package com.ibm.as400.access;
2121

2222
import java.io.IOException;
23+
import java.util.Hashtable;
2324

2425
/**
2526
Specifies the methods which the implementation objects for the IFSFile class
@@ -97,6 +98,9 @@ int renameTo(IFSFileImpl file)
9798
int getCCSID(boolean retrieveAll) throws IOException, AS400SecurityException;
9899
String getOwnerName(boolean retrieveAll) throws IOException, AS400SecurityException;
99100
//@AC7 End
101+
String getText() throws IOException, AS400SecurityException;
102+
String getCodePage() throws IOException, AS400SecurityException;
103+
Hashtable getExtendedAttributes() throws IOException, AS400SecurityException;
100104

101105
}
102106

src/main/java/com/ibm/as400/access/IFSFileImplProxy.java

+19
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.io.IOException;
2222
import java.lang.reflect.InvocationTargetException;
23+
import java.util.Hashtable;
2324

2425

2526
/**
@@ -715,4 +716,22 @@ public void setSystem(AS400Impl system)
715716
}
716717
}
717718

719+
@Override
720+
public String getText() {
721+
// TODO Auto-generated method stub
722+
throw new UnsupportedOperationException();
723+
}
724+
725+
@Override
726+
public String getCodePage() {
727+
// TODO Auto-generated method stub
728+
throw new UnsupportedOperationException();
729+
}
730+
731+
@Override
732+
public Hashtable getExtendedAttributes() {
733+
// TODO Auto-generated method stub
734+
throw new UnsupportedOperationException();
735+
}
736+
718737
}

0 commit comments

Comments
 (0)