@@ -639,8 +639,9 @@ public int getCCSID(boolean retrieveAll) throws IOException
639
639
if (errorRC_ == IFSReturnCodeRep .FILE_NOT_FOUND || errorRC_ == IFSReturnCodeRep .PATH_NOT_FOUND )
640
640
throw new ExtendedIOException (path_ , ExtendedIOException .PATH_NOT_FOUND );
641
641
642
- // Cannot create file handle to object, so let us try the other way
643
- return getCCSID ();
642
+ // Cannot create file handle to object, so let us try the other way only
643
+ if (retrieveAll )
644
+ return getCCSID ();
644
645
}
645
646
}
646
647
catch (AS400SecurityException e ) {
@@ -668,44 +669,52 @@ public int getCCSID() throws IOException
668
669
{
669
670
// In 7.5 and prior releases, need to create user handle for IFS tables to be initialized.
670
671
userHandle = (getSystem ().getVRM () <= 0x00070500 ) ? system_ .createUserHandle () : 0 ;
671
-
672
- try
673
- {
674
- byte [] path = getConverter ().stringToByteArray (path_ );
675
-
676
- IFSLookupReq req = new IFSLookupReq (path , preferredServerCCSID_ , userHandle , IFSLookupReq .OA12 , IFSObjAttrs1 .OWNERANAME_ASP_FLAS , 0 );
677
- ds = (ClientAccessDataStream ) server_ .sendAndReceive (req );
678
- }
679
- catch (ConnectionDroppedException e )
672
+ if (userHandle == UNINITIALIZED )
680
673
{
681
- Trace .log (Trace .ERROR , "Byte stream server connection lost." );
682
- connectionDropped (e );
683
- }
684
- catch (InterruptedException e )
685
- {
686
- Trace .log (Trace .ERROR , "Interrupted" );
687
- InterruptedIOException throwException = new InterruptedIOException (e .getMessage ());
688
- throwException .initCause (e );
689
- throw throwException ;
690
- }
691
-
692
- int rc = 0 ;
693
- if (ds instanceof IFSLookupRep )
694
- {
695
- objectHandle = ((IFSLookupRep ) ds ).getHandle ();
696
- retrieveAttributes (ds , objectHandle );
697
- }
698
- else if (ds instanceof IFSReturnCodeRep )
699
- {
700
- rc = ((IFSReturnCodeRep ) ds ).getReturnCode ();
701
- if (rc != IFSReturnCodeRep .SUCCESS ) Trace .log (Trace .ERROR , "IFSReturnCodeRep return code" , rc );
702
-
703
- throw new ExtendedIOException (path_ , rc );
674
+ IFSListAttrsRep reply = listObjAttrs2 (); // the 'ccsid' field is in the OA2 structure
675
+ if (reply != null )
676
+ fileDataCCSID_ = reply .getCCSID (serverDatastreamLevel_ );
704
677
}
705
678
else
706
679
{
707
- Trace .log (Trace .ERROR , "Unknown reply data stream" , ds .getReqRepID ());
708
- throw new InternalErrorException (Integer .toHexString (ds .getReqRepID ()), InternalErrorException .DATA_STREAM_UNKNOWN );
680
+ try
681
+ {
682
+ byte [] path = getConverter ().stringToByteArray (path_ );
683
+
684
+ IFSLookupReq req = new IFSLookupReq (path , preferredServerCCSID_ , userHandle , IFSLookupReq .OA12 , IFSObjAttrs1 .OWNERANAME_ASP_FLAS , 0 );
685
+ ds = (ClientAccessDataStream ) server_ .sendAndReceive (req );
686
+ }
687
+ catch (ConnectionDroppedException e )
688
+ {
689
+ Trace .log (Trace .ERROR , "Byte stream server connection lost." );
690
+ connectionDropped (e );
691
+ }
692
+ catch (InterruptedException e )
693
+ {
694
+ Trace .log (Trace .ERROR , "Interrupted" );
695
+ InterruptedIOException throwException = new InterruptedIOException (e .getMessage ());
696
+ throwException .initCause (e );
697
+ throw throwException ;
698
+ }
699
+
700
+ int rc = 0 ;
701
+ if (ds instanceof IFSLookupRep )
702
+ {
703
+ objectHandle = ((IFSLookupRep ) ds ).getHandle ();
704
+ retrieveAttributes (ds , objectHandle );
705
+ }
706
+ else if (ds instanceof IFSReturnCodeRep )
707
+ {
708
+ rc = ((IFSReturnCodeRep ) ds ).getReturnCode ();
709
+ if (rc != IFSReturnCodeRep .SUCCESS ) Trace .log (Trace .ERROR , "IFSReturnCodeRep return code" , rc );
710
+
711
+ throw new ExtendedIOException (path_ , rc );
712
+ }
713
+ else
714
+ {
715
+ Trace .log (Trace .ERROR , "Unknown reply data stream" , ds .getReqRepID ());
716
+ throw new InternalErrorException (Integer .toHexString (ds .getReqRepID ()), InternalErrorException .DATA_STREAM_UNKNOWN );
717
+ }
709
718
}
710
719
}
711
720
finally
@@ -1496,44 +1505,50 @@ public int getASP() throws IOException, AS400SecurityException
1496
1505
{
1497
1506
// In 7.5 and prior releases, need to create user handle for IFS tables to be initialized.
1498
1507
userHandle = (getSystem ().getVRM () <= 0x00070500 ) ? system_ .createUserHandle () : 0 ;
1499
-
1500
- try
1501
- {
1502
- // Issue a Look up request to create an object handle.
1503
- IFSLookupReq req = new IFSLookupReq (pathname , preferredServerCCSID_ , userHandle , IFSLookupReq .OA12 , IFSObjAttrs1 .OWNERANAME_ASP_FLAS , 0 );
1504
- ds = (ClientAccessDataStream ) server_ .sendAndReceive (req );
1505
- }
1506
- catch (ConnectionDroppedException e )
1507
- {
1508
- Trace .log (Trace .ERROR , "Byte stream server connection lost." );
1509
- connectionDropped (e );
1510
- }
1511
- catch (InterruptedException e )
1512
- {
1513
- Trace .log (Trace .ERROR , "Interrupted" );
1514
- InterruptedIOException throwException = new InterruptedIOException (e .getMessage ());
1515
- throwException .initCause (e );
1516
- throw throwException ;
1517
- }
1518
-
1519
- rc = 0 ;
1520
- if (ds instanceof IFSLookupRep )
1508
+ if (userHandle == UNINITIALIZED )
1521
1509
{
1522
- objectHandle = ((IFSLookupRep ) ds ).getHandle ();
1523
- retrieveAttributes (ds , objectHandle ); //@AC7A
1524
- }
1525
- else if (ds instanceof IFSReturnCodeRep )
1526
- {
1527
- rc = ((IFSReturnCodeRep ) ds ).getReturnCode ();
1528
- if (rc != IFSReturnCodeRep .SUCCESS )
1529
- Trace .log (Trace .ERROR , "IFSReturnCodeRep return code" , rc );
1530
-
1531
- throw new ExtendedIOException (path_ , rc );
1510
+ // Not sure what to do here...20.0.7 returned -1. So we do that same in 20.0.8.
1532
1511
}
1533
1512
else
1534
1513
{
1535
- Trace .log (Trace .ERROR , "Unknown reply data stream" , ds .getReqRepID ());
1536
- throw new InternalErrorException (Integer .toHexString (ds .getReqRepID ()), InternalErrorException .DATA_STREAM_UNKNOWN );
1514
+ try
1515
+ {
1516
+ // Issue a Look up request to create an object handle.
1517
+ IFSLookupReq req = new IFSLookupReq (pathname , preferredServerCCSID_ , userHandle , IFSLookupReq .OA12 , IFSObjAttrs1 .OWNERANAME_ASP_FLAS , 0 );
1518
+ ds = (ClientAccessDataStream ) server_ .sendAndReceive (req );
1519
+ }
1520
+ catch (ConnectionDroppedException e )
1521
+ {
1522
+ Trace .log (Trace .ERROR , "Byte stream server connection lost." );
1523
+ connectionDropped (e );
1524
+ }
1525
+ catch (InterruptedException e )
1526
+ {
1527
+ Trace .log (Trace .ERROR , "Interrupted" );
1528
+ InterruptedIOException throwException = new InterruptedIOException (e .getMessage ());
1529
+ throwException .initCause (e );
1530
+ throw throwException ;
1531
+ }
1532
+
1533
+ rc = 0 ;
1534
+ if (ds instanceof IFSLookupRep )
1535
+ {
1536
+ objectHandle = ((IFSLookupRep ) ds ).getHandle ();
1537
+ retrieveAttributes (ds , objectHandle ); //@AC7A
1538
+ }
1539
+ else if (ds instanceof IFSReturnCodeRep )
1540
+ {
1541
+ rc = ((IFSReturnCodeRep ) ds ).getReturnCode ();
1542
+ if (rc != IFSReturnCodeRep .SUCCESS )
1543
+ Trace .log (Trace .ERROR , "IFSReturnCodeRep return code" , rc );
1544
+
1545
+ throw new ExtendedIOException (path_ , rc );
1546
+ }
1547
+ else
1548
+ {
1549
+ Trace .log (Trace .ERROR , "Unknown reply data stream" , ds .getReqRepID ());
1550
+ throw new InternalErrorException (Integer .toHexString (ds .getReqRepID ()), InternalErrorException .DATA_STREAM_UNKNOWN );
1551
+ }
1537
1552
}
1538
1553
}
1539
1554
finally
@@ -1566,43 +1581,58 @@ public String getOwnerNameByUserHandle(boolean forceRetrieve) throws IOException
1566
1581
{
1567
1582
// In 7.5 and prior releases, need to create user handle for IFS tables to be initialized.
1568
1583
userHandle = (getSystem ().getVRM () <= 0x00070500 ) ? system_ .createUserHandle () : 0 ;
1569
-
1570
- try
1571
- {
1572
- // Issue a Look up request to create an object handle.
1573
- IFSLookupReq req = new IFSLookupReq (pathname , preferredServerCCSID_ , userHandle , IFSLookupReq .OA12 , IFSObjAttrs1 .OWNERANAME_ASP_FLAS , 0 );
1574
- ds = (ClientAccessDataStream ) server_ .sendAndReceive (req );
1575
- }
1576
- catch (ConnectionDroppedException e )
1577
- {
1578
- Trace .log (Trace .ERROR , "Byte stream server connection lost." );
1579
- connectionDropped (e );
1580
- }
1581
- catch (InterruptedException e )
1582
- {
1583
- Trace .log (Trace .ERROR , "Interrupted" );
1584
- InterruptedIOException throwException = new InterruptedIOException (e .getMessage ());
1585
- throwException .initCause (e );
1586
- throw throwException ;
1587
- }
1588
-
1589
- // Verify that we got a handle back.
1590
- rc = 0 ;
1591
- if (ds instanceof IFSLookupRep )
1584
+ if (userHandle == UNINITIALIZED )
1592
1585
{
1593
- objectHandle = ((IFSLookupRep ) ds ).getHandle ();
1594
- retrieveAttributes (ds , objectHandle ); //@AC7A
1586
+ IFSListAttrsRep reply = listObjAttrs1 (IFSObjAttrs1 .OWNER_NAME_FLAG , 0 );
1587
+ if (reply != null )
1588
+ fileOwnerName_ = reply .getOwnerName (system_ .getCcsid ());
1589
+ else
1590
+ {
1591
+ if (Trace .traceOn_ ) Trace .log (Trace .WARNING , "getOwnerNameByUserHandle: IFSReturnCodeRep return code" , errorRC_ );
1592
+
1593
+ if (errorRC_ == IFSReturnCodeRep .FILE_NOT_FOUND || errorRC_ == IFSReturnCodeRep .PATH_NOT_FOUND )
1594
+ throw new ExtendedIOException (path_ , ExtendedIOException .PATH_NOT_FOUND );
1595
+ }
1595
1596
}
1596
- else if (ds instanceof IFSReturnCodeRep )
1597
- {
1598
- rc = ((IFSReturnCodeRep ) ds ).getReturnCode ();
1599
- if (rc != IFSReturnCodeRep .SUCCESS ) Trace .log (Trace .ERROR , "IFSReturnCodeRep return code" , rc );
1600
- throw new ExtendedIOException (path_ , rc );
1601
- }
1602
1597
else
1603
1598
{
1604
- Trace .log (Trace .ERROR , "Unknown reply data stream" , ds .getReqRepID ());
1605
- throw new InternalErrorException (Integer .toHexString (ds .getReqRepID ()), InternalErrorException .DATA_STREAM_UNKNOWN );
1599
+ try
1600
+ {
1601
+ // Issue a Look up request to create an object handle.
1602
+ IFSLookupReq req = new IFSLookupReq (pathname , preferredServerCCSID_ , userHandle , IFSLookupReq .OA12 , IFSObjAttrs1 .OWNERANAME_ASP_FLAS , 0 );
1603
+ ds = (ClientAccessDataStream ) server_ .sendAndReceive (req );
1604
+ }
1605
+ catch (ConnectionDroppedException e )
1606
+ {
1607
+ Trace .log (Trace .ERROR , "Byte stream server connection lost." );
1608
+ connectionDropped (e );
1609
+ }
1610
+ catch (InterruptedException e )
1611
+ {
1612
+ Trace .log (Trace .ERROR , "Interrupted" );
1613
+ InterruptedIOException throwException = new InterruptedIOException (e .getMessage ());
1614
+ throwException .initCause (e );
1615
+ throw throwException ;
1616
+ }
1617
+
1618
+ // Verify that we got a handle back.
1619
+ rc = 0 ;
1620
+ if (ds instanceof IFSLookupRep )
1621
+ {
1622
+ objectHandle = ((IFSLookupRep ) ds ).getHandle ();
1623
+ retrieveAttributes (ds , objectHandle ); //@AC7A
1624
+ }
1625
+ else if (ds instanceof IFSReturnCodeRep )
1626
+ {
1627
+ rc = ((IFSReturnCodeRep ) ds ).getReturnCode ();
1628
+ if (rc != IFSReturnCodeRep .SUCCESS ) Trace .log (Trace .ERROR , "IFSReturnCodeRep return code" , rc );
1629
+ throw new ExtendedIOException (path_ , rc );
1630
+ }
1631
+ else
1632
+ {
1633
+ Trace .log (Trace .ERROR , "Unknown reply data stream" , ds .getReqRepID ());
1634
+ throw new InternalErrorException (Integer .toHexString (ds .getReqRepID ()), InternalErrorException .DATA_STREAM_UNKNOWN );
1635
+ }
1606
1636
}
1607
1637
}
1608
1638
finally
@@ -1633,44 +1663,50 @@ public String getFileSystemType() throws IOException, AS400SecurityException
1633
1663
try
1634
1664
{
1635
1665
userHandle = (getSystem ().getVRM () <= 0x00070500 ) ? system_ .createUserHandle () : 0 ;
1636
-
1637
- try
1638
- {
1639
- // Issue a Look up request to create an object handle.
1640
- IFSLookupReq req = new IFSLookupReq (pathname , preferredServerCCSID_ , userHandle , IFSLookupReq .OA12 , IFSObjAttrs1 .OWNERANAME_ASP_FLAS , 0 );
1641
- ds = (ClientAccessDataStream ) server_ .sendAndReceive (req );
1642
- }
1643
- catch (ConnectionDroppedException e )
1666
+ if (userHandle == UNINITIALIZED )
1644
1667
{
1645
- Trace .log (Trace .ERROR , "Byte stream server connection lost." );
1646
- connectionDropped (e );
1647
- }
1648
- catch (InterruptedException e )
1649
- {
1650
- Trace .log (Trace .ERROR , "Interrupted" );
1651
- InterruptedIOException throwException = new InterruptedIOException (e .getMessage ());
1652
- throwException .initCause (e );
1653
- throw throwException ;
1654
- }
1655
-
1656
- rc = 0 ;
1657
- if (ds instanceof IFSLookupRep )
1658
- {
1659
- objectHandle = ((IFSLookupRep ) ds ).getHandle ();
1660
- retrieveAttributes (ds , objectHandle ); //@AC7A
1661
- }
1662
- else if (ds instanceof IFSReturnCodeRep )
1663
- {
1664
- rc = ((IFSReturnCodeRep ) ds ).getReturnCode ();
1665
- if (rc != IFSReturnCodeRep .SUCCESS )
1666
- Trace .log (Trace .ERROR , "IFSReturnCodeRep return code" , rc );
1667
-
1668
- throw new ExtendedIOException (path_ , rc );
1668
+ // Not sure what to do here...20.0.7 returned null string. For 20.0.8, return unknown.
1669
1669
}
1670
1670
else
1671
1671
{
1672
- Trace .log (Trace .ERROR , "Unknown reply data stream" , ds .getReqRepID ());
1673
- throw new InternalErrorException (Integer .toHexString (ds .getReqRepID ()), InternalErrorException .DATA_STREAM_UNKNOWN );
1672
+ try
1673
+ {
1674
+ // Issue a Look up request to create an object handle.
1675
+ IFSLookupReq req = new IFSLookupReq (pathname , preferredServerCCSID_ , userHandle , IFSLookupReq .OA12 , IFSObjAttrs1 .OWNERANAME_ASP_FLAS , 0 );
1676
+ ds = (ClientAccessDataStream ) server_ .sendAndReceive (req );
1677
+ }
1678
+ catch (ConnectionDroppedException e )
1679
+ {
1680
+ Trace .log (Trace .ERROR , "Byte stream server connection lost." );
1681
+ connectionDropped (e );
1682
+ }
1683
+ catch (InterruptedException e )
1684
+ {
1685
+ Trace .log (Trace .ERROR , "Interrupted" );
1686
+ InterruptedIOException throwException = new InterruptedIOException (e .getMessage ());
1687
+ throwException .initCause (e );
1688
+ throw throwException ;
1689
+ }
1690
+
1691
+ rc = 0 ;
1692
+ if (ds instanceof IFSLookupRep )
1693
+ {
1694
+ objectHandle = ((IFSLookupRep ) ds ).getHandle ();
1695
+ retrieveAttributes (ds , objectHandle ); //@AC7A
1696
+ }
1697
+ else if (ds instanceof IFSReturnCodeRep )
1698
+ {
1699
+ rc = ((IFSReturnCodeRep ) ds ).getReturnCode ();
1700
+ if (rc != IFSReturnCodeRep .SUCCESS )
1701
+ Trace .log (Trace .ERROR , "IFSReturnCodeRep return code" , rc );
1702
+
1703
+ throw new ExtendedIOException (path_ , rc );
1704
+ }
1705
+ else
1706
+ {
1707
+ Trace .log (Trace .ERROR , "Unknown reply data stream" , ds .getReqRepID ());
1708
+ throw new InternalErrorException (Integer .toHexString (ds .getReqRepID ()), InternalErrorException .DATA_STREAM_UNKNOWN );
1709
+ }
1674
1710
}
1675
1711
}
1676
1712
finally
0 commit comments