11package ch .cyberduck .core .irods ;
22
3- import java .io .IOException ;
4- import java .util .List ;
3+ import ch .cyberduck .core .ListProgressListener ;
4+ import ch .cyberduck .core .Path ;
5+ import ch .cyberduck .core .PathAttributes ;
6+ import ch .cyberduck .core .exception .BackgroundException ;
7+ import ch .cyberduck .core .exception .NotfoundException ;
8+ import ch .cyberduck .core .features .AttributesAdapter ;
9+ import ch .cyberduck .core .features .AttributesFinder ;
10+ import ch .cyberduck .core .io .Checksum ;
511
612import org .apache .commons .io .FilenameUtils ;
713import org .apache .commons .lang3 .StringUtils ;
1319import org .irods .irods4j .low_level .api .GenQuery1Columns ;
1420import org .irods .irods4j .low_level .api .IRODSException ;
1521
16- /*
17- * Copyright (c) 2002-2016 iterate GmbH. All rights reserved.
18- * https://cyberduck.io/
19- *
20- * This program is free software; you can redistribute it and/or modify
21- * it under the terms of the GNU General Public License as published by
22- * the Free Software Foundation; either version 2 of the License, or
23- * (at your option) any later version.
24- *
25- * This program is distributed in the hope that it will be useful,
26- * but WITHOUT ANY WARRANTY; without even the implied warranty of
27- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28- * GNU General Public License for more details.
29- */
30-
31- import ch .cyberduck .core .ListProgressListener ;
32- import ch .cyberduck .core .Path ;
33- import ch .cyberduck .core .PathAttributes ;
34- import ch .cyberduck .core .exception .BackgroundException ;
35- import ch .cyberduck .core .exception .NotfoundException ;
36- import ch .cyberduck .core .features .AttributesAdapter ;
37- import ch .cyberduck .core .features .AttributesFinder ;
38- import ch .cyberduck .core .io .Checksum ;
22+ import java .io .IOException ;
23+ import java .util .List ;
3924
4025
4126public class IRODSAttributesFinderFeature implements AttributesFinder , AttributesAdapter <List <String >> {
@@ -49,44 +34,45 @@ public IRODSAttributesFinderFeature(final IRODSSession session) {
4934 @ Override
5035 public PathAttributes find (final Path file , final ListProgressListener listener ) throws BackgroundException {
5136 try {
52- final PathAttributes [] attributes = new PathAttributes [1 ];
37+ final PathAttributes [] attributes = new PathAttributes [1 ];
5338 final IRODSConnection conn = session .getClient ();
5439 if (!IRODSFilesystem .exists (this .session .getClient ().getRcComm (), file .getAbsolute ())) {
5540 throw new NotfoundException (file .getAbsolute ());
5641 }
57- String logicalPath = file .getAbsolute ();
58- String parentPath = FilenameUtils .getFullPathNoEndSeparator (logicalPath );
59- String fileName = FilenameUtils .getName (logicalPath );
42+ String logicalPath = file .getAbsolute ();
43+ String parentPath = FilenameUtils .getFullPathNoEndSeparator (logicalPath );
44+ String fileName = FilenameUtils .getName (logicalPath );
6045 if (Versioning .compareVersions (conn .getRcComm ().relVersion .substring (4 ), "4.3.4" ) > 0 ) {
61- String query = String .format ("select DATA_MODIFY_TIME, DATA_CREATE_TIME, DATA_SIZE, DATA_CHECKSUM, DATA_OWNER_NAME, DATA_OWNER_ZONE where COLL_NAME = '%s' and DATA_NAME = '%s'" , parentPath , fileName );
62- List <List <String >> rows = IRODSQuery .executeGenQuery2 (conn .getRcComm (), query );
63- List <String > row = rows .get (0 );
64- attributes [0 ]=toAttributes (row );
65- }else {
66- GenQuery1QueryArgs input = new GenQuery1QueryArgs ();
46+ String query = String .format ("select DATA_MODIFY_TIME, DATA_CREATE_TIME, DATA_SIZE, DATA_CHECKSUM, DATA_OWNER_NAME, DATA_OWNER_ZONE where COLL_NAME = '%s' and DATA_NAME = '%s'" , parentPath , fileName );
47+ List <List <String >> rows = IRODSQuery .executeGenQuery2 (conn .getRcComm (), query );
48+ List <String > row = rows .get (0 );
49+ attributes [0 ] = toAttributes (row );
50+ }
51+ else {
52+ GenQuery1QueryArgs input = new GenQuery1QueryArgs ();
6753
68- // select COLL_NAME, DATA_NAME, DATA_ACCESS_TIME
69- input .addColumnToSelectClause (GenQuery1Columns .COL_D_MODIFY_TIME );
70- input .addColumnToSelectClause (GenQuery1Columns .COL_D_CREATE_TIME );
71- input .addColumnToSelectClause (GenQuery1Columns .COL_DATA_SIZE );
72- input .addColumnToSelectClause (GenQuery1Columns .COL_D_DATA_CHECKSUM );
73- input .addColumnToSelectClause (GenQuery1Columns .COL_D_OWNER_NAME );
74- input .addColumnToSelectClause (GenQuery1Columns .COL_D_OWNER_ZONE );
75-
54+ // select COLL_NAME, DATA_NAME, DATA_ACCESS_TIME
55+ input .addColumnToSelectClause (GenQuery1Columns .COL_D_MODIFY_TIME );
56+ input .addColumnToSelectClause (GenQuery1Columns .COL_D_CREATE_TIME );
57+ input .addColumnToSelectClause (GenQuery1Columns .COL_DATA_SIZE );
58+ input .addColumnToSelectClause (GenQuery1Columns .COL_D_DATA_CHECKSUM );
59+ input .addColumnToSelectClause (GenQuery1Columns .COL_D_OWNER_NAME );
60+ input .addColumnToSelectClause (GenQuery1Columns .COL_D_OWNER_ZONE );
7661
77- // where COLL_NAME like '/tempZone/home/rods and DATA_NAME = 'atime.txt'
78- String collNameCondStr = String .format ("= '%s'" , parentPath );
79- String dataNameCondStr = String .format ("= '%s'" , fileName );
80- input .addConditionToWhereClause (GenQuery1Columns .COL_COLL_NAME , collNameCondStr );
81- input .addConditionToWhereClause (GenQuery1Columns .COL_DATA_NAME , dataNameCondStr );
8262
83- StringBuilder output = new StringBuilder ();
63+ // where COLL_NAME like '/tempZone/home/rods and DATA_NAME = 'atime.txt'
64+ String collNameCondStr = String .format ("= '%s'" , parentPath );
65+ String dataNameCondStr = String .format ("= '%s'" , fileName );
66+ input .addConditionToWhereClause (GenQuery1Columns .COL_COLL_NAME , collNameCondStr );
67+ input .addConditionToWhereClause (GenQuery1Columns .COL_DATA_NAME , dataNameCondStr );
8468
85- IRODSQuery .executeGenQuery1 (conn .getRcComm (), input , row -> {
86- attributes [0 ]=toAttributes (row );
87- return false ;
88- });
89- }
69+ StringBuilder output = new StringBuilder ();
70+
71+ IRODSQuery .executeGenQuery1 (conn .getRcComm (), input , row -> {
72+ attributes [0 ] = toAttributes (row );
73+ return false ;
74+ });
75+ }
9076 return attributes [0 ];
9177 }
9278 catch (IOException | IRODSException e ) {
@@ -96,18 +82,18 @@ public PathAttributes find(final Path file, final ListProgressListener listener)
9682
9783 @ Override
9884 public PathAttributes toAttributes (final List <String > row ) {
99- final IRODSConnection conn = session .getClient ();
85+ final IRODSConnection conn = session .getClient ();
10086 final PathAttributes attributes = new PathAttributes ();
10187 attributes .setModificationDate (Long .parseLong (row .get (0 )) * 1000 ); // seconds to ms
102- attributes .setCreationDate (Long .parseLong (row .get (1 )) * 1000 );
103- attributes .setSize (Long .parseLong (row .get (2 )));
104- String checksum = row .get (3 );
105- if (!StringUtils .isEmpty (checksum )) {
106- attributes .setChecksum (Checksum .parse (checksum ));
107- }
88+ attributes .setCreationDate (Long .parseLong (row .get (1 )) * 1000 );
89+ attributes .setSize (Long .parseLong (row .get (2 )));
90+ String checksum = row .get (3 );
91+ if (!StringUtils .isEmpty (checksum )) {
92+ attributes .setChecksum (Checksum .parse (checksum ));
93+ }
10894
109- attributes .setOwner (conn .getRcComm ().relVersion );
110- attributes .setGroup (row .get (5 ));
95+ attributes .setOwner (conn .getRcComm ().relVersion );
96+ attributes .setGroup (row .get (5 ));
11197 return attributes ;
11298 }
11399}
0 commit comments