Search in sources :

Example 1 with DataTransferOperations

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;
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) DataTransferOperations(org.irods.jargon.core.pub.DataTransferOperations) JargonException(org.irods.jargon.core.exception.JargonException) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile)

Example 2 with DataTransferOperations

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;
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) DataTransferOperations(org.irods.jargon.core.pub.DataTransferOperations) JargonException(org.irods.jargon.core.exception.JargonException) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile)

Example 3 with DataTransferOperations

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);
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) IRODSTestSetupUtilities(org.irods.jargon.testutils.IRODSTestSetupUtilities) CollectionAO(org.irods.jargon.core.pub.CollectionAO) DataTransferOperations(org.irods.jargon.core.pub.DataTransferOperations) IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile) File(java.io.File) TestingPropertiesHelper(org.irods.jargon.testutils.TestingPropertiesHelper) ScratchFileUtils(org.irods.jargon.testutils.filemanip.ScratchFileUtils) BeforeClass(org.junit.BeforeClass)

Example 4 with DataTransferOperations

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);
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) IRODSTestSetupUtilities(org.irods.jargon.testutils.IRODSTestSetupUtilities) DataTransferOperations(org.irods.jargon.core.pub.DataTransferOperations) IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile) File(java.io.File) TestingPropertiesHelper(org.irods.jargon.testutils.TestingPropertiesHelper) ScratchFileUtils(org.irods.jargon.testutils.filemanip.ScratchFileUtils) BeforeClass(org.junit.BeforeClass)

Aggregations

DataTransferOperations (org.irods.jargon.core.pub.DataTransferOperations)4 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)4 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)4 File (java.io.File)2 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)2 JargonException (org.irods.jargon.core.exception.JargonException)2 IRODSTestSetupUtilities (org.irods.jargon.testutils.IRODSTestSetupUtilities)2 TestingPropertiesHelper (org.irods.jargon.testutils.TestingPropertiesHelper)2 ScratchFileUtils (org.irods.jargon.testutils.filemanip.ScratchFileUtils)2 BeforeClass (org.junit.BeforeClass)2 CollectionAO (org.irods.jargon.core.pub.CollectionAO)1 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)1