Skip to content

Commit

Permalink
#151 merge
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Nov 2, 2015
2 parents f6260dd + 1477d19 commit b22cb2a
Show file tree
Hide file tree
Showing 10 changed files with 369 additions and 44 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Work for milestone https://github.com/DICE-UNC/jargon/milestones/4.0.3.1%20secon
## News



https://github.com/DICE-UNC/jargon/issues?q=is%3Aopen+is%3Aissue+milestone%3A%22features+branch+4.0.3%22

Please go to [[https://github.com/DICE-UNC/jargon]] for the latest news and info.
Expand Down Expand Up @@ -48,7 +49,14 @@ Updated semantics of move collection to avoid 'collection already exists errors'

### Rename operation in DTO #147

Added a rename() operation to DataTransferOperations to clarify difference between a rename and a move
### across federation browsing under strict acls doesn't interpolate home/ and find subdirs viewable #39

More gracefully handle path guessing heuristics cross-federation browsing when drilling down and stict ACLs is on.

### CI integration with iRODS 4 #18

Changes in build automation and testing to integrate Jargon testing into iRODS Consortium Continuous integration


### CollectionPager not navigating strict acl dirs with heuristics #148

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ void buildSelects(final IRODSGenQueryBuilder builder)
.addSelectAsGenQueryValue(
RodsGenQueryEnum.COL_DATA_TYPE_NAME)
.addSelectAsGenQueryValue(RodsGenQueryEnum.COL_DATA_SIZE)
.addSelectAsGenQueryValue(
RodsGenQueryEnum.COL_D_RESC_GROUP_NAME)
.addSelectAsGenQueryValue(RodsGenQueryEnum.COL_D_RESC_NAME)
.addSelectAsGenQueryValue(RodsGenQueryEnum.COL_D_DATA_PATH)
.addSelectAsGenQueryValue(RodsGenQueryEnum.COL_D_OWNER_NAME)
Expand Down Expand Up @@ -167,21 +165,20 @@ public static DataObject buildDomainFromResultSetRow(
.getIntOrZeroFromIRODSValue(row.getColumn(5)));
dataObject.setDataTypeName(row.getColumn(6));
dataObject.setDataSize(Long.parseLong(row.getColumn(7)));
dataObject.setResourceGroupName(row.getColumn(8));
dataObject.setResourceName(row.getColumn(9));
dataObject.setDataPath(row.getColumn(10));
dataObject.setDataOwnerName(row.getColumn(11));
dataObject.setDataOwnerZone(row.getColumn(12));
dataObject.setReplicationStatus(row.getColumn(13));
dataObject.setDataStatus(row.getColumn(14));
dataObject.setChecksum(row.getColumn(15));
dataObject.setExpiry(row.getColumn(16));
dataObject.setDataMapId(Integer.parseInt(row.getColumn(17)));
dataObject.setComments(row.getColumn(18));
dataObject.setResourceName(row.getColumn(8));
dataObject.setDataPath(row.getColumn(9));
dataObject.setDataOwnerName(row.getColumn(10));
dataObject.setDataOwnerZone(row.getColumn(11));
dataObject.setReplicationStatus(row.getColumn(12));
dataObject.setDataStatus(row.getColumn(13));
dataObject.setChecksum(row.getColumn(14));
dataObject.setExpiry(row.getColumn(15));
dataObject.setDataMapId(Integer.parseInt(row.getColumn(16)));
dataObject.setComments(row.getColumn(17));
dataObject.setCreatedAt(IRODSDataConversionUtil
.getDateFromIRODSValue(row.getColumn(19)));
.getDateFromIRODSValue(row.getColumn(18)));
dataObject.setUpdatedAt(IRODSDataConversionUtil
.getDateFromIRODSValue(row.getColumn(20)));
.getDateFromIRODSValue(row.getColumn(19)));

// add info to track position in records for possible requery
dataObject.setLastResult(row.isLastResult());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,14 +627,12 @@ private void putCommonProcessing(final File localFile,
targetFile, getIRODSProtocol(), transferControlBlock,
transferStatusCallbackListener);
} catch (FileNotFoundException e) {
log.error(
"File not found for local file I was trying to put:{}",
localFile.getAbsolutePath());
throw new DataNotFoundException(
"localFile not found to put to irods", e);
log.error("iRODS file missing in put operation:{}",
targetFile.getAbsolutePath());
throw new DataNotFoundException("irodsFile not found", e);
} catch (java.io.FileNotFoundException e) {
throw new DataNotFoundException(
"irods destination not found in put to irods", e);
"local file not found in put to irods", e);
}
} else {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ private void processCopyWhenSourceIsDir(
operativeTransferControlBlock);

/*
* Don't copy to self
* Don't copy to self or parent
*/
if (targetFile.getAbsolutePath().equals(sourceFile.getParent())) {
log.error("source file is being copied to own parent:{}",
Expand All @@ -1782,6 +1782,13 @@ private void processCopyWhenSourceIsDir(
"attempt to copy source file to its parent");
}

if (targetFile.getAbsolutePath().equals(sourceFile.getAbsolutePath())) {
log.error("source file is being copied to self:{}",
sourceFile.getAbsolutePath());
throw new DuplicateDataException(
"attempt to copy source file to itself");
}

// if the target is a file throw an exception
if (targetFile.exists() && targetFile.isFile()) {
targetFile = (IRODSFile) targetFile.getParentFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,44 @@ public String buildIRODSCollectionAbsolutePathFromFederatedZoneReadTestPropertie
return pathBuilder.toString();
}

/**
* Handy method to give, from the root IRODS collection, a full path to a
* given user home collection in the federated zone. So if user1 in zone1
* wants to see his home collection in federated zone zone2, the path
* returned would be /zone2/home/user1#zone1 plus the extra path info
*
* @param testingProperties
* <code>Properties</code> that define test behavior
* @param collectionPathBelowScratch
* <code>String</code> with no leading '/' that defines the
* desired path underneath the IRODS scratch directory
* @return <code>String</code> with trailing '/' that gives the absolute
* path for an IRODS collection
* @throws TestingUtilsException
* @throws URISyntaxException
*/
public String buildIRODSCollectionAbsolutePathFromFederatedZoneHomeDirTestProperties(
final Properties testingProperties,
final String collectionPathBelowScratch)
throws TestingUtilsException {

if (testingProperties.get(IRODS_SCRATCH_DIR_KEY) == null) {
throw new TestingUtilsException(
"scratch path not provided in testing.properties");
}

StringBuilder pathBuilder = new StringBuilder();
pathBuilder.append('/');
pathBuilder.append(testingProperties.get(IRODS_FEDERATED_ZONE_KEY));
pathBuilder.append("/home/");
pathBuilder.append(testingProperties.get(IRODS_USER_KEY));
pathBuilder.append("#");
pathBuilder.append(testingProperties.get(IRODS_ZONE_KEY));
pathBuilder.append('/');
pathBuilder.append(collectionPathBelowScratch);
return pathBuilder.toString();
}

/**
* Handy method to give, from the root IRODS collection, a full path to a
* given collection in the IRODS test scratch area on IRODS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3552,7 +3552,7 @@ public void testCopyCollectionToTarget() throws Exception {
}

/**
* Normal test of consilidated 'copy()' method, this time with a collection,
* Normal test of consolidated 'copy()' method, this time with a collection,
* using the string path sigs
*
* @throws Exception
Expand Down Expand Up @@ -3611,6 +3611,66 @@ public void testCopyCollectionToTargetCollection() throws Exception {

}

/**
* Bug https://github.com/DICE-UNC/jargon/issues/151
*
* @throws Exception
*/
@Test(expected = DuplicateDataException.class)
public void testCopyCollectionToTargetCollectionSelfBug151()
throws Exception {

// generate a local scratch file
String testOrigDirectory = "testCopyCollectionToTargetCollectionSelfBug151";
String testTargetDirectory = "testCopyCollectionToTargetCollectionSelfBug151";

String localCollectionAbsolutePath = scratchFileUtils
.createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH
+ '/' + testOrigDirectory);

String irodsCollectionRootAbsolutePath = testingPropertiesHelper
.buildIRODSCollectionAbsolutePathFromTestProperties(
testingProperties, IRODS_TEST_SUBDIR_PATH);

String irodsOriginalAbsolutePath = testingPropertiesHelper
.buildIRODSCollectionAbsolutePathFromTestProperties(
testingProperties, IRODS_TEST_SUBDIR_PATH + "/"
+ testOrigDirectory);

String irodsTargetAbsolutePath = testingPropertiesHelper
.buildIRODSCollectionAbsolutePathFromTestProperties(
testingProperties, IRODS_TEST_SUBDIR_PATH + "/"
+ testTargetDirectory);

FileGenerator
.generateManyFilesAndCollectionsInParentCollectionByAbsolutePath(
localCollectionAbsolutePath, "prefixForColl", 2, 3, 2,
"testFile", ".txt", 2, 2, 1, 2);

IRODSAccount irodsAccount = testingPropertiesHelper
.buildIRODSAccountFromTestProperties(testingProperties);

DataTransferOperations dataTransferOperations = irodsFileSystem
.getIRODSAccessObjectFactory().getDataTransferOperations(
irodsAccount);

dataTransferOperations.putOperation(localCollectionAbsolutePath,
irodsCollectionRootAbsolutePath, "", null, null);

dataTransferOperations.copy(irodsOriginalAbsolutePath, "",
irodsTargetAbsolutePath, null, null);

File localFile = new File(localCollectionAbsolutePath);
IRODSFile targetFile = irodsFileSystem
.getIRODSFileFactory(irodsAccount).instanceIRODSFile(
irodsTargetAbsolutePath, testOrigDirectory);

// compare the local source to the copied-to target
assertionHelper.assertTwoFilesAreEqualByRecursiveTreeComparison(
localFile, (File) targetFile);

}

@Test
public void testCopyCollectionToTargetCollectionWithResource()
throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.irods.jargon.core.exception.FileNotFoundException;
import org.irods.jargon.core.protovalues.FilePermissionEnum;
import org.irods.jargon.core.pub.domain.Collection;
import org.irods.jargon.core.pub.domain.ObjStat;
import org.irods.jargon.core.pub.domain.UserFilePermission;
import org.irods.jargon.core.pub.io.IRODSFile;
import org.irods.jargon.core.pub.io.IRODSFileFactory;
Expand Down Expand Up @@ -127,6 +128,62 @@ public void testListCollectionWithOneDataObject() throws Exception {

}

@Test
public void testRetrieveObjStatInFederatedZone() throws Exception {

if (!testingPropertiesHelper.isTestFederatedZone(testingProperties)) {
return;
}

String fileName = "testRetrieveObjStatInFederatedZone.txt";
String testSubdir = "testRetrieveObjStatInFederatedZone";

IRODSAccount irodsAccount = testingPropertiesHelper
.buildIRODSAccountForFederatedZoneFromTestProperties(testingProperties);

String targetIrodsPath = testingPropertiesHelper
.buildIRODSCollectionAbsolutePathFromFederatedZoneReadTestProperties(
testingProperties, IRODS_TEST_SUBDIR_PATH + "/"
+ testSubdir);

String absPath = scratchFileUtils
.createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH);
String localFilePath = FileGenerator
.generateFileOfFixedLengthGivenName(absPath, fileName, 3);
File localFile = new File(localFilePath);

IRODSFileFactory irodsFileFactory = irodsFileSystem
.getIRODSFileFactory(irodsAccount);
IRODSFile destFile = irodsFileFactory
.instanceIRODSFile(targetIrodsPath);

// delete to clean up
destFile.deleteWithForceOption();
destFile.mkdirs();

DataTransferOperations dataTransferOperationsAO = irodsFileSystem
.getIRODSAccessObjectFactory().getDataTransferOperations(
irodsAccount);

dataTransferOperationsAO.putOperation(localFile, destFile, null, null);

/*
* setup done, now connect from the first zone and try to list the coll
* with the data object
*/

IRODSAccount fedAccount = testingPropertiesHelper
.buildIRODSAccountFromTestProperties(testingProperties);

CollectionAndDataObjectListAndSearchAO collectionListAndSearchAO = irodsFileSystem
.getIRODSAccessObjectFactory()
.getCollectionAndDataObjectListAndSearchAO(fedAccount);
ObjStat objStat = collectionListAndSearchAO
.retrieveObjectStatForPath(targetIrodsPath + "/" + fileName);
Assert.assertNotNull("null objstat", objStat);

}

@Test
public void testListDataObjectsUnderPathInAnotherZone() throws Exception {

Expand Down
Loading

0 comments on commit b22cb2a

Please sign in to comment.