Skip to content

Commit

Permalink
#37 add checks for trailing slashes in collection paths
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Nov 9, 2015
1 parent 0d4c95f commit 64d026d
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 79 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ Fixed open flags on WRITE and WRITE_TRUNCATE in output stream code to fire postP

Added check of empty CA since the default value of the certificateAuthority in GSIIRODSAccount is blank versus null. User submitted patch.

### Trailing slash on path to CollectionAO.getPermissionForCollection() throws FileNotFoundException #37

Enhanced collection-related methods to tolerate trailing slashes on collections in various operations

### Misc

Lots of small fixes, pull requests, iRODS compatability tests and fixes through work with consortium
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ public List<MetaDataAndDomainData> findMetadataValuesByMetadataQueryForCollectio
}
}

MiscIRODSUtils.checkPathSizeForMax(collectionAbsolutePath);
String myPath = MiscIRODSUtils
.checkPathSizeForMax(collectionAbsolutePath);

log.info("absPath for querying iCAT:{}", collectionAbsolutePath);

Expand All @@ -347,10 +348,10 @@ public List<MetaDataAndDomainData> findMetadataValuesByMetadataQueryForCollectio
try {
addSelectsForMetadataAndDomainDataToBuilder(builder);

if (!collectionAbsolutePath.isEmpty()) {
if (!myPath.isEmpty()) {
builder.addConditionAsGenQueryField(
RodsGenQueryEnum.COL_COLL_NAME,
QueryConditionOperators.EQUAL, collectionAbsolutePath);
QueryConditionOperators.EQUAL, myPath);
}

for (AVUQueryElement queryElement : avuQuery) {
Expand All @@ -362,7 +363,7 @@ public List<MetaDataAndDomainData> findMetadataValuesByMetadataQueryForCollectio
.exportIRODSQueryFromBuilder(getJargonProperties()
.getMaxFilesAndDirsQueryMax());

if (collectionAbsolutePath.isEmpty()) {
if (myPath.isEmpty()) {

resultSet = irodsGenQueryExecutor
.executeIRODSQueryAndCloseResult(irodsQuery,
Expand All @@ -371,8 +372,8 @@ public List<MetaDataAndDomainData> findMetadataValuesByMetadataQueryForCollectio

resultSet = irodsGenQueryExecutor
.executeIRODSQueryAndCloseResultInZone(irodsQuery,
partialStartIndex, MiscIRODSUtils
.getZoneInPath(collectionAbsolutePath));
partialStartIndex,
MiscIRODSUtils.getZoneInPath(myPath));
}
} catch (GenQueryBuilderException e) {
log.error("error building query", e);
Expand Down Expand Up @@ -507,10 +508,10 @@ public void addAVUMetadata(final String absolutePath, final AvuData avuData)
log.info("adding avu metadata to collection: {}", avuData);
log.info("absolute path: {}", absolutePath);

MiscIRODSUtils.checkPathSizeForMax(absolutePath);
String myPath = MiscIRODSUtils.checkPathSizeForMax(absolutePath);

final ModAvuMetadataInp modifyAvuMetadataInp = ModAvuMetadataInp
.instanceForAddCollectionMetadata(absolutePath, avuData);
.instanceForAddCollectionMetadata(myPath, avuData);

log.debug("sending avu request");

Expand Down Expand Up @@ -558,10 +559,10 @@ public void deleteAVUMetadata(final String absolutePath,
log.info("deleting avu metadata from collection: {}", avuData);
log.info("absolute path: {}", absolutePath);

MiscIRODSUtils.checkPathSizeForMax(absolutePath);
String myPath = MiscIRODSUtils.checkPathSizeForMax(absolutePath);

final ModAvuMetadataInp modifyAvuMetadataInp = ModAvuMetadataInp
.instanceForDeleteCollectionMetadata(absolutePath, avuData);
.instanceForDeleteCollectionMetadata(myPath, avuData);

log.debug("sending avu request");

Expand Down Expand Up @@ -598,9 +599,6 @@ public void deleteAllAVUMetadata(final String absolutePath)
throw new IllegalArgumentException("null or empty absolutePath");
}

log.info("absolute path: {}", absolutePath);
MiscIRODSUtils.checkPathSizeForMax(absolutePath);

log.info("absolute path: {}", absolutePath);

ObjStat objStat = this.retrieveObjStat(absolutePath);
Expand All @@ -626,7 +624,8 @@ public void deleteAllAVUMetadata(final String absolutePath)
metadata.getAvuValue(), metadata.getAvuUnit()));
}

deleteBulkAVUMetadataFromCollection(absolutePath, avusToDelete);
deleteBulkAVUMetadataFromCollection(objStat.getAbsolutePath(),
avusToDelete);
log.debug("metadata removed");
}

Expand Down Expand Up @@ -654,7 +653,7 @@ public void modifyAvuValueBasedOnGivenAttributeAndUnit(
log.info("with avu metadata:{}", avuData);
log.info("absolute path: {}", absolutePath);

MiscIRODSUtils.checkPathSizeForMax(absolutePath);
String myPath = MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// avu is distinct based on attrib and value, so do an attrib/unit
// query, can only be one result
Expand All @@ -669,7 +668,7 @@ public void modifyAvuValueBasedOnGivenAttributeAndUnit(
AVUQueryElement.AVUQueryPart.UNITS,
AVUQueryOperatorEnum.EQUAL, avuData.getUnit()));
result = this.findMetadataValuesByMetadataQueryForCollection(
queryElements, absolutePath);
queryElements, myPath);
} catch (JargonQueryException e) {
log.error("error querying data for avu", e);
throw new JargonException("error querying data for AVU");
Expand All @@ -687,7 +686,7 @@ public void modifyAvuValueBasedOnGivenAttributeAndUnit(

AvuData modAvuData = new AvuData(result.get(0).getAvuAttribute(),
avuData.getValue(), result.get(0).getAvuUnit());
modifyAVUMetadata(absolutePath, currentAvuData, modAvuData);
modifyAVUMetadata(myPath, currentAvuData, modAvuData);
log.info("metadata modified to:{}", modAvuData);
}

Expand Down Expand Up @@ -720,11 +719,11 @@ public void modifyAVUMetadata(final String absolutePath,
log.info("with new avu metadata:{}", newAvuData);
log.info("absolute path: {}", absolutePath);

MiscIRODSUtils.checkPathSizeForMax(absolutePath);
String myPath = MiscIRODSUtils.checkPathSizeForMax(absolutePath);

final ModAvuMetadataInp modifyAvuMetadataInp = ModAvuMetadataInp
.instanceForModifyCollectionMetadata(absolutePath,
currentAvuData, newAvuData);
.instanceForModifyCollectionMetadata(myPath, currentAvuData,
newAvuData);

log.debug("sending avu request");

Expand Down Expand Up @@ -772,8 +771,6 @@ public List<MetaDataAndDomainData> findMetadataValuesForCollection(
collectionAbsolutePath);
log.info("with partial start of:{}", partialStartIndex);

MiscIRODSUtils.checkPathSizeForMax(collectionAbsolutePath);

ObjStat objStat = getObjectStatForAbsolutePath(collectionAbsolutePath);
return findMetadataValuesForCollection(objStat, partialStartIndex);

Expand Down Expand Up @@ -806,8 +803,6 @@ public MetaDataAndDomainData findMetadataValueForCollectionByMetadataId(
collectionAbsolutePath);
log.info("with id:{}", id);

MiscIRODSUtils.checkPathSizeForMax(collectionAbsolutePath);

ObjStat objStat = getObjectStatForAbsolutePath(collectionAbsolutePath);
return findMetadataValueForCollectionById(objStat, id);

Expand Down Expand Up @@ -1125,7 +1120,6 @@ public int countAllFilesUnderneathTheGivenCollection(
"irodsCollectionAbsolutePath is null");
}

MiscIRODSUtils.checkPathSizeForMax(irodsCollectionAbsolutePath);
ObjStat objStat = collectionAndDataObjectListAndSearchAO
.retrieveObjectStatForPath(irodsCollectionAbsolutePath);

Expand Down Expand Up @@ -1215,8 +1209,6 @@ public void setAccessPermissionInherit(final String zone,
throw new IllegalArgumentException("null or empty absolutePath");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// pi tests parameters
log.info("setAccessPermissionInherit on absPath:{}", absolutePath);

Expand Down Expand Up @@ -1251,8 +1243,6 @@ public void setAccessPermissionInheritAsAdmin(final String zone,
throw new IllegalArgumentException("null or empty absolutePath");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// pi tests parameters
log.info("setAccessPermissionInherit on absPath:{}", absolutePath);

Expand Down Expand Up @@ -1287,8 +1277,6 @@ public void setAccessPermissionToNotInherit(final String zone,
throw new IllegalArgumentException("null or empty absolutePath");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// pi tests parameters
log.info("setAccessPermissionToNotInherit on absPath:{}", absolutePath);

Expand Down Expand Up @@ -1324,8 +1312,6 @@ public void setAccessPermissionToNotInheritInAdminMode(final String zone,
throw new IllegalArgumentException("null or empty absolutePath");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// pi tests parameters
log.info("setAccessPermissionToNotInherit on absPath:{}", absolutePath);

Expand Down Expand Up @@ -1362,8 +1348,6 @@ public void setAccessPermissionRead(final String zone,
throw new IllegalArgumentException("null or empty absolutePath");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// pi tests parameters
log.info("setAccessPermissionRead on absPath:{}", absolutePath);

Expand Down Expand Up @@ -1404,8 +1388,6 @@ public void setAccessPermissionReadAsAdmin(final String zone,
throw new IllegalArgumentException("null or empty userName");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// pi tests parameters
log.info("setAccessPermissionReadAsAdmin on absPath:{}", absolutePath);

Expand Down Expand Up @@ -1486,8 +1468,6 @@ public void setAccessPermissionWrite(final String zone,
throw new IllegalArgumentException("null or empty userName");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// pi tests parameters
log.info("setAccessPermissionWrite on absPath:{}", absolutePath);
// overhead iRODS behavior, if you set perm with recursive when no
Expand Down Expand Up @@ -1530,8 +1510,6 @@ public void setAccessPermissionWriteAsAdmin(final String zone,
throw new IllegalArgumentException("null or empty userName");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// pi tests parameters
log.info("setAccessPermissionWriteAsAdmin on absPath:{}", absolutePath);
String effectiveAbsPath = resolveAbsolutePathViaObjStat(absolutePath);
Expand Down Expand Up @@ -1573,8 +1551,6 @@ public void setAccessPermissionOwn(final String zone,
throw new IllegalArgumentException("null or empty userName");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// pi tests parameters
log.info("setAccessPermissionOwn on absPath:{}", absolutePath);

Expand Down Expand Up @@ -1617,8 +1593,6 @@ public void setAccessPermissionOwnAsAdmin(final String zone,
throw new IllegalArgumentException("null or empty userName");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

// pi tests parameters
log.info("setAccessPermissionOwnAsAdmin on absPath:{}", absolutePath);
// overhead iRODS behavior, if you set perm with recursive when no
Expand Down Expand Up @@ -1660,7 +1634,6 @@ public void removeAccessPermissionForUser(final String zone,
throw new IllegalArgumentException("null or empty userName");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);
// pi tests parameters
log.info("removeAccessPermission on absPath:{}", absolutePath);
log.info("for user:{}", userName);
Expand Down Expand Up @@ -1703,7 +1676,6 @@ public void removeAccessPermissionForUserAsAdmin(final String zone,
throw new IllegalArgumentException("null or empty userName");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);
// pi tests parameters
log.info("removeAccessPermissionAsAdmin on absPath:{}", absolutePath);
log.info("for user:{}", userName);
Expand Down Expand Up @@ -1738,8 +1710,6 @@ public boolean isCollectionSetForPermissionInheritance(
"null or empty absolutePathToCollection");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);

ObjStat objStat = getObjectStatForAbsolutePath(absolutePath);
String absPath = resolveAbsolutePathGivenObjStat(objStat);

Expand Down Expand Up @@ -1801,13 +1771,13 @@ public FilePermissionEnum getPermissionForCollection(
throw new IllegalArgumentException("null zone");
}

MiscIRODSUtils.checkPathSizeForMax(irodsAbsolutePath);
String myPath = MiscIRODSUtils.checkPathSizeForMax(irodsAbsolutePath);

log.info("getPermissionForCollection for absPath:{}", irodsAbsolutePath);
log.info("userName:{}", userName);

UserFilePermission permission = getPermissionForUserName(
irodsAbsolutePath, userName);
UserFilePermission permission = getPermissionForUserName(myPath,
userName);
if (permission == null) {
log.info("no permission found, return 'none'");
return FilePermissionEnum.NONE;
Expand Down Expand Up @@ -1837,10 +1807,9 @@ private boolean adjustRecursiveOption(final String absolutePath,
throw new IllegalArgumentException("null or empty absolutePath");
}

MiscIRODSUtils.checkPathSizeForMax(absolutePath);
String myPath = MiscIRODSUtils.checkPathSizeForMax(absolutePath);

IRODSFile collFile = getIRODSFileFactory().instanceIRODSFile(
absolutePath);
IRODSFile collFile = getIRODSFileFactory().instanceIRODSFile(myPath);

if (!collFile.exists()) {
throw new JargonException(
Expand All @@ -1852,7 +1821,7 @@ private boolean adjustRecursiveOption(final String absolutePath,
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = getIRODSAccessObjectFactory()
.getCollectionAndDataObjectListAndSearchAO(getIRODSAccount());
int countFilesUnderParent = collectionAndDataObjectListAndSearchAO
.countDataObjectsAndCollectionsUnderPath(absolutePath);
.countDataObjectsAndCollectionsUnderPath(myPath);

if (recursive) {
if (countFilesUnderParent == 0) {
Expand Down Expand Up @@ -1886,8 +1855,6 @@ public UserFilePermission getPermissionForUserName(
throw new IllegalArgumentException("null or empty userName");
}

MiscIRODSUtils.checkPathSizeForMax(irodsCollectionAbsolutePath);

log.info(
"getPermissionForUserName with irodsCollectionAbsolutePath: {}",
irodsCollectionAbsolutePath);
Expand Down Expand Up @@ -2100,8 +2067,6 @@ public List<UserFilePermission> listPermissionsForCollection(
"null or empty collectionAbsolutePath");
}

MiscIRODSUtils.checkPathSizeForMax(irodsCollectionAbsolutePath);

log.info("listPermissionsForCollection: {}",
irodsCollectionAbsolutePath);

Expand Down Expand Up @@ -2187,13 +2152,13 @@ public boolean isUserHasAccess(final String irodsAbsolutePath,
throw new IllegalArgumentException("null or empty userName");
}

MiscIRODSUtils.checkPathSizeForMax(irodsAbsolutePath);
String myPath = MiscIRODSUtils.checkPathSizeForMax(irodsAbsolutePath);

log.info("irodsAbsolutePath:{}", irodsAbsolutePath);
log.info("userName:{}", userName);

UserFilePermission derivedPermission = getPermissionForUserName(
irodsAbsolutePath, userName);
UserFilePermission derivedPermission = getPermissionForUserName(myPath,
userName);
boolean hasPermission = false;
if (derivedPermission != null) {
hasPermission = true;
Expand Down
Loading

0 comments on commit 64d026d

Please sign in to comment.