diff --git a/components/blitz/resources/omero/Repositories.ice b/components/blitz/resources/omero/Repositories.ice index 0829e7b086d..72f7d3f2528 100644 --- a/components/blitz/resources/omero/Repositories.ice +++ b/components/blitz/resources/omero/Repositories.ice @@ -296,13 +296,13 @@ module omero { /** * [ImportSettings] which are provided by the - * client on the call to [ManagedRepository::prepareImport]. + * client on the call to [ManagedRepository::importFileset]. **/ ImportSettings settings; /** * [ImportLocation] which is calculated during - * the call to [ManagedRepository::prepareImport]. + * the call to [ManagedRepository::importFileset]. **/ ImportLocation location; @@ -342,7 +342,17 @@ module omero { * overwritten or interfering with one another, a new directory * may be created for the current session. **/ - ImportProcess* prepareImport(omero::model::Fileset fs, ImportSettings settings) throws ServerError; + ImportProcess* importFileset(omero::model::Fileset fs, ImportSettings settings) throws ServerError; + + /** + * For clients without access to Bio-Formats, the simplified + * []importPaths] method allows passing solely the absolute + * path of the files to be uploaded (no directories) and all + * configuration happens server-side. Much of the functionality + * provided via [omero::model::Fileset] and [omero::grid::ImportSettings] + * is of course lost. + **/ + ImportProcess* importPaths(omero::api::StringSet filePaths) throws ServerError; /** * List imports that are currently running in this importer. diff --git a/components/blitz/src/ome/formats/importer/ImportContainer.java b/components/blitz/src/ome/formats/importer/ImportContainer.java index 82445be0614..85956443454 100644 --- a/components/blitz/src/ome/formats/importer/ImportContainer.java +++ b/components/blitz/src/ome/formats/importer/ImportContainer.java @@ -55,8 +55,8 @@ public class ImportContainer private IObject target; public ImportContainer(File file, - IObject target, - Double[] userPixels, String reader, String[] usedFiles, Boolean isSPW) + IObject target, + Double[] userPixels, String reader, String[] usedFiles, Boolean isSPW) { this.file = file; this.target = target; diff --git a/components/blitz/src/ome/formats/importer/ImportLibrary.java b/components/blitz/src/ome/formats/importer/ImportLibrary.java index 83b8bf01c76..38e6146bbed 100644 --- a/components/blitz/src/ome/formats/importer/ImportLibrary.java +++ b/components/blitz/src/ome/formats/importer/ImportLibrary.java @@ -80,10 +80,10 @@ public class ImportLibrary implements IObservable /** The class used to identify the dataset target.*/ private static final String DATASET_CLASS = "omero.model.Dataset"; - + /** The class used to identify the screen target.*/ private static final String SCREEN_CLASS = "omero.model.Screen"; - + private final ArrayList observers = new ArrayList(); private final OMEROMetadataStoreClient store; @@ -140,7 +140,7 @@ public void notifyObservers(ImportEvent event) /** * Primary user method for importing a number - * + * * @param config The configuration information. * @param candidates Hosts information about the files to import. */ @@ -213,7 +213,7 @@ public ImportProcessPrx createImport(final ImportContainer container) final ImportSettings settings = new ImportSettings(); final Fileset fs = new FilesetI(); container.fillData(new ImportConfig(), settings, fs); - return repo.prepareImport(fs, settings); + return repo.importFileset(fs, settings); } diff --git a/components/blitz/src/ome/services/blitz/repo/ManagedImportProcessI.java b/components/blitz/src/ome/services/blitz/repo/ManagedImportProcessI.java index 0e8ad26d950..f4b2c3ac288 100644 --- a/components/blitz/src/ome/services/blitz/repo/ManagedImportProcessI.java +++ b/components/blitz/src/ome/services/blitz/repo/ManagedImportProcessI.java @@ -121,7 +121,7 @@ public void ice_exception(Exception ex) { /** * The import location as defined by the managed repository during - * prepareImport. Never null. + * importFileset. Never null. */ private final ImportLocation location; diff --git a/components/blitz/src/ome/services/blitz/repo/ManagedRepositoryI.java b/components/blitz/src/ome/services/blitz/repo/ManagedRepositoryI.java index 020f80929f2..1ac48c00f58 100644 --- a/components/blitz/src/ome/services/blitz/repo/ManagedRepositoryI.java +++ b/components/blitz/src/ome/services/blitz/repo/ManagedRepositoryI.java @@ -41,6 +41,7 @@ import Ice.Current; import ome.formats.importer.ImportConfig; +import ome.formats.importer.ImportContainer; import ome.services.blitz.impl.ServiceFactoryI; import omero.ServerError; @@ -51,9 +52,11 @@ import omero.grid._ManagedRepositoryTie; import omero.model.Fileset; import omero.model.FilesetEntry; +import omero.model.FilesetI; import omero.model.FilesetJobLink; import omero.model.FilesetVersionInfo; import omero.model.FilesetVersionInfoI; +import omero.model.IObject; import omero.model.IndexingJobI; import omero.model.Job; import omero.model.MetadataImportJob; @@ -126,7 +129,7 @@ public Ice.Object tie() { * * @FIXME For the moment only the top-level directory is being incremented. */ - public ImportProcessPrx prepareImport(Fileset fs, ImportSettings settings, + public ImportProcessPrx importFileset(Fileset fs, ImportSettings settings, Ice.Current __current) throws omero.ServerError { if (fs == null || fs.sizeOfUsedFiles() < 1) { @@ -161,6 +164,25 @@ public ImportProcessPrx prepareImport(Fileset fs, ImportSettings settings, return createImportProcess(fs, location, settings, __current); } + public ImportProcessPrx importPaths(List paths, + Ice.Current __current) throws ServerError { + + if (paths == null || paths.size() < 1) { + throw new omero.ApiUsageException(null, null, "No paths provided"); + } + + final ImportContainer container = new ImportContainer( + null /*file*/, null /*target*/, null /*userPixels*/, + "Unknown" /*reader*/, paths.toArray(new String[0]), + false /*spw*/); + + final ImportSettings settings = new ImportSettings(); + final Fileset fs = new FilesetI(); + container.fillData(new ImportConfig(), settings, fs); + + return importFileset(fs, settings, __current); + } + public List listImports(Ice.Current __current) throws omero.ServerError { final List filesetIds = new ArrayList(); diff --git a/components/blitz/test/ome/services/blitz/test/ManagedRepositoryITest.java b/components/blitz/test/ome/services/blitz/test/ManagedRepositoryITest.java index e30e130db93..af80a47b72b 100644 --- a/components/blitz/test/ome/services/blitz/test/ManagedRepositoryITest.java +++ b/components/blitz/test/ome/services/blitz/test/ManagedRepositoryITest.java @@ -136,7 +136,7 @@ public void testBasicImportExample() throws Exception { Fileset fs = new FilesetI(); ic.fillData(new ImportConfig(), settings, fs); - ImportProcessPrx i = repo.prepareImport(fs, settings, curr()); + ImportProcessPrx i = repo.importFileset(fs, settings, curr()); assertNotNull(i); upload(i.getUploader(0)); diff --git a/components/tools/OmeroJava/test/integration/ManagedRepositoryTest.java b/components/tools/OmeroJava/test/integration/ManagedRepositoryTest.java index 16f567f0c61..97d612b2ef7 100644 --- a/components/tools/OmeroJava/test/integration/ManagedRepositoryTest.java +++ b/components/tools/OmeroJava/test/integration/ManagedRepositoryTest.java @@ -26,14 +26,14 @@ import omero.model.OriginalFile; import omero.sys.EventContext; -/** +/** * Collections of tests for the ManagedRepository service. * * @author Colin Blackburn      * c.blackburn@dundee.ac.uk */ @Test(groups = {"integration", "fs"}) -public class ManagedRepositoryTest +public class ManagedRepositoryTest extends AbstractServerTest { @@ -67,7 +67,7 @@ public void setRepo() throws Exception { */ void assertFileExists(String message, String path) throws ServerError - { + { assertTrue(message + path, repo.fileExists(path)); } @@ -77,9 +77,9 @@ void assertFileExists(String message, String path) */ void assertFileDoesNotExist(String message, String path) throws ServerError - { + { assertFalse(message + path, repo.fileExists(path)); - } + } /** * Construct a path from its elements @@ -96,7 +96,7 @@ String buildPath(String[] pathElements) } // Primarily to get code compiling during the major refactoring - ImportLocation prepareImport(List srcPaths) { + ImportLocation importFileset(List srcPaths) { fail("NYI"); return null; } @@ -128,30 +128,30 @@ public void testGetCurrentRepoDirSimple() srcPaths.add(buildPath(src)); String[] dest = {uniquePath, file1}; destPath = buildPath(dest); - ImportLocation data = prepareImport(srcPaths); + ImportLocation data = importFileset(srcPaths); assertContains(data.usedFiles.get(0), destPath); touch(uploadUsedFile(data, data.usedFiles.get(0))); - + // Different file that should go in existing directory src[1] = file2; srcPaths.set(0, buildPath(src)); dest[1] = file2; destPath = buildPath(dest); - data = prepareImport(srcPaths); + data = importFileset(srcPaths); assertContains(data.usedFiles.get(0), destPath); touch(uploadUsedFile(data, data.usedFiles.get(0))); // Same file that should go in new directory dest[0] = uniquePath + "-1"; destPath = buildPath(dest); - data = prepareImport(srcPaths); + data = importFileset(srcPaths); assertContains(data.usedFiles.get(0), destPath); touch(uploadUsedFile(data, data.usedFiles.get(0))); // Same file again that should go in new directory dest[0] = uniquePath + "-2"; destPath = buildPath(dest); - data = prepareImport(srcPaths); + data = importFileset(srcPaths); assertContains(data.usedFiles.get(0), destPath); } @@ -162,9 +162,9 @@ public void testGetCurrentRepoDirSimple() * @throws Exception Thrown if an error occurred. */ @Test - public void testGetCurrentRepoDirMultipleFiles() + public void testGetCurrentRepoDirMultipleFiles() throws Exception - { + { List srcPaths = new ArrayList(); List destPaths = new ArrayList(); @@ -183,7 +183,7 @@ public void testGetCurrentRepoDirMultipleFiles() destPaths.add(buildPath(dest)); dest[1] = file2; destPaths.add(buildPath(dest)); - ImportLocation data = prepareImport(srcPaths); + ImportLocation data = importFileset(srcPaths); assertTrue(data.usedFiles.size()==destPaths.size()); for (int i=0; i