use of org.irods.jargon.core.pub.DataTransferOperations in project metalnx-web by irods-contrib.
the class FileOperationServiceImpl method copy.
@Override
public boolean copy(String sourcePath, String dstPath, boolean copyWithMetadata) throws DataGridConnectionRefusedException {
IRODSFileFactory irodsFileFactory = irodsServices.getIRODSFileFactory();
DataTransferOperations dataTransferOperations = irodsServices.getDataTransferOperations();
boolean isCopied = false;
try {
IRODSFile source = irodsFileFactory.instanceIRODSFile(sourcePath);
IRODSFile target = irodsFileFactory.instanceIRODSFile(dstPath);
dataTransferOperations.copy(source, target, null, null);
isCopied = true;
if (copyWithMetadata) {
String objName = sourcePath.substring(sourcePath.lastIndexOf("/") + 1, sourcePath.length());
dstPath = String.format("%s/%s", dstPath, objName);
metadataService.copyMetadata(sourcePath, dstPath);
}
} catch (JargonException e) {
logger.error("Could not copy item from " + sourcePath + " to " + dstPath + ": ", e.getMessage());
}
return isCopied;
}
use of org.irods.jargon.core.pub.DataTransferOperations in project metalnx-web by irods-contrib.
the class FileOperationServiceImpl method move.
@Override
public boolean move(String sourcePath, String targetPath) throws DataGridConnectionRefusedException {
IRODSFileFactory irodsFileFactory = irodsServices.getIRODSFileFactory();
DataTransferOperations dataTransferOperations = irodsServices.getDataTransferOperations();
try {
IRODSFile source = irodsFileFactory.instanceIRODSFile(sourcePath);
if (source.isDirectory()) {
targetPath += "/" + FilenameUtils.getBaseName(sourcePath);
}
IRODSFile target = irodsFileFactory.instanceIRODSFile(targetPath);
dataTransferOperations.move(source, target);
return true;
} catch (JargonException e) {
logger.error("Could not move item from " + sourcePath + " to " + targetPath + ": ", e.getMessage());
}
return false;
}
use of org.irods.jargon.core.pub.DataTransferOperations in project metalnx-web by irods-contrib.
the class SpecQueryServiceImplTest method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper();
testingProperties = testingPropertiesLoader.getTestProperties();
scratchFileUtils = new ScratchFileUtils(testingProperties);
scratchFileUtils.clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH);
irodsTestSetupUtilities = new IRODSTestSetupUtilities();
irodsTestSetupUtilities.initializeIrodsScratchDirectory();
irodsTestSetupUtilities.initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH);
irodsFileSystem = IRODSFileSystem.instance();
// set up test structure
String rootCollection = "SpecQueryServiceImplTestRoot";
String localCollectionAbsolutePath = scratchFileUtils.createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH + '/' + rootCollection);
IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);
String irodsCollectionRootAbsolutePath = (MiscIRODSUtils.computeHomeDirectoryForIRODSAccount(irodsAccount) + '/' + rootCollection);
rootCollPathInIrods = irodsCollectionRootAbsolutePath;
FileGenerator.generateManyFilesAndCollectionsInParentCollectionByAbsolutePath(localCollectionAbsolutePath, "specQueryTset", 1, 2, 3, "testFile", ".txt", 4, 3, 2, 30000);
IRODSFileFactory irodsFileFactory = irodsFileSystem.getIRODSFileFactory(irodsAccount);
IRODSFile destFile = irodsFileFactory.instanceIRODSFile(irodsCollectionRootAbsolutePath);
destFile.deleteWithForceOption();
destFile.mkdirs();
DataTransferOperations dataTransferOperationsAO = irodsFileSystem.getIRODSAccessObjectFactory().getDataTransferOperations(irodsAccount);
DataObjectAO dataObjectAO = irodsFileSystem.getIRODSAccessObjectFactory().getDataObjectAO(irodsAccount);
CollectionAO collectionAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAO(irodsAccount);
File localFile = new File(localCollectionAbsolutePath);
dataTransferOperationsAO.putOperation(localFile, destFile, null, null);
// Decorate with various AVUs to use in tests
decorateChildren(destFile, collectionAO, dataObjectAO);
}
use of org.irods.jargon.core.pub.DataTransferOperations in project metalnx-web by irods-contrib.
the class CollectionServiceImplTest method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper();
testingProperties = testingPropertiesLoader.getTestProperties();
scratchFileUtils = new ScratchFileUtils(testingProperties);
scratchFileUtils.clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH);
irodsTestSetupUtilities = new IRODSTestSetupUtilities();
irodsTestSetupUtilities.initializeIrodsScratchDirectory();
irodsTestSetupUtilities.initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH);
irodsFileSystem = IRODSFileSystem.instance();
// set up test structure
String rootCollection = "CollectionServiceImplTestTestRoot";
String localCollectionAbsolutePath = scratchFileUtils.createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH + '/' + rootCollection);
IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);
String irodsCollectionRootAbsolutePath = (MiscIRODSUtils.computeHomeDirectoryForIRODSAccount(irodsAccount) + '/' + rootCollection);
rootCollPathInIrods = irodsCollectionRootAbsolutePath;
FileGenerator.generateManyFilesAndCollectionsInParentCollectionByAbsolutePath(localCollectionAbsolutePath, "textSearchQueryTest", 1, 2, 3, "textSearchService", ".txt", 4, 3, 2, 30);
IRODSFileFactory irodsFileFactory = irodsFileSystem.getIRODSFileFactory(irodsAccount);
IRODSFile destFile = irodsFileFactory.instanceIRODSFile(irodsCollectionRootAbsolutePath);
destFile.deleteWithForceOption();
destFile.mkdirs();
DataTransferOperations dataTransferOperationsAO = irodsFileSystem.getIRODSAccessObjectFactory().getDataTransferOperations(irodsAccount);
File localFile = new File(localCollectionAbsolutePath);
dataTransferOperationsAO.putOperation(localFile, destFile, null, null);
}
Aggregations