From a8f40a31ed62a92656c2ae34605539d940d54974 Mon Sep 17 00:00:00 2001
From: Marcus Lewerenz <152180836+LewerenzM@users.noreply.github.com>
Date: Wed, 5 Jun 2024 13:48:24 +0200
Subject: [PATCH 01/19] Added prettier maven plugin
---
pom.xml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/pom.xml b/pom.xml
index 9607b7ad..47d6086d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,6 +13,7 @@
UTF-8
https://repo.icatproject.org/repo
github
+ write
@@ -20,6 +21,10 @@
ICAT Repo
https://repo.icatproject.org/repo
+
+ com.hubspot.maven.plugins Repo
+ https://mvnrepository.com/artifact/com.hubspot.maven.plugins/
+
@@ -129,6 +134,12 @@
test
+
+ com.hubspot.maven.plugins
+ prettier-maven-plugin
+ 0.22
+
+
@@ -415,10 +426,53 @@
+
+ com.hubspot.maven.plugins
+ prettier-maven-plugin
+ 0.22
+
+ 2.0.0
+ 80
+ 4
+ false
+ true
+ true
+
+
+
+ src/main/java/**/*.java
+ src/test/java/**/*.java
+
+
+
+
+ validate
+
+ ${plugin.prettier.goal}
+
+
+
+
+
+
+
+ travis
+
+
+ env.TRAVIS
+
+
+
+
+ check
+
+
+
+
From 6d6461e7d12954c9709aa59b0d1ffd3f45448698 Mon Sep 17 00:00:00 2001
From: Marcus Lewerenz <152180836+LewerenzM@users.noreply.github.com>
Date: Thu, 6 Jun 2024 11:32:38 +0200
Subject: [PATCH 02/19] prettier config file and linting check while build.
---
README.md | 6 ++++++
pom.xml | 28 ++--------------------------
src/.prettierrc.yaml | 4 ++++
3 files changed, 12 insertions(+), 26 deletions(-)
create mode 100644 src/.prettierrc.yaml
diff --git a/README.md b/README.md
index 93da61c5..8066012f 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,11 @@
# ids.server: Server part of ICAT Data Server (IDS)
+## Linting
+The Prettier Maven Plugin is used for linting. it is configured for "check" while build. That's why a build will fail when the files haven't the right format.
+execute `mvn prettier:write` before.
+
+TODO: execute `mvn prettier:wite` while local build but only the `check` while CI build.
+
[](https://github.com/icatproject/ids.server/actions?query=workflow%3A%22CI+Build%22)
General installation instructions are at http://www.icatproject.org/installation/component
diff --git a/pom.xml b/pom.xml
index 47d6086d..c35d3629 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
UTF-8
https://repo.icatproject.org/repo
github
- write
+ check
@@ -432,17 +432,8 @@
0.22
2.0.0
- 80
- 4
- false
- true
+ false
true
-
-
-
- src/main/java/**/*.java
- src/test/java/**/*.java
-
@@ -458,21 +449,6 @@
-
-
- travis
-
-
- env.TRAVIS
-
-
-
-
- check
-
-
-
-
diff --git a/src/.prettierrc.yaml b/src/.prettierrc.yaml
new file mode 100644
index 00000000..314ad51b
--- /dev/null
+++ b/src/.prettierrc.yaml
@@ -0,0 +1,4 @@
+useTabs: false
+tabWidth: 4
+printWidth: 80
+ignoreEditorConfig: true
\ No newline at end of file
From bf8565dfb1e7042eb19ac5af5072a9242f99d324 Mon Sep 17 00:00:00 2001
From: Marcus Lewerenz <152180836+LewerenzM@users.noreply.github.com>
Date: Thu, 6 Jun 2024 12:59:17 +0200
Subject: [PATCH 03/19] WIP: only lint check at CI build
---
README.md | 2 +-
pom.xml | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 8066012f..5c5debcb 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
The Prettier Maven Plugin is used for linting. it is configured for "check" while build. That's why a build will fail when the files haven't the right format.
execute `mvn prettier:write` before.
-TODO: execute `mvn prettier:wite` while local build but only the `check` while CI build.
+TODO: execute `mvn prettier:write` while local build but only the `check` while CI build.
[](https://github.com/icatproject/ids.server/actions?query=workflow%3A%22CI+Build%22)
diff --git a/pom.xml b/pom.xml
index c35d3629..a9264b82 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
UTF-8
https://repo.icatproject.org/repo
github
- check
+ write
@@ -449,6 +449,21 @@
+
+
+ cibuild
+
+
+ env.build_and_test
+
+
+
+
+ check
+
+
+
+
From 9ca3c4bb0b7719366d6a6edca6fcfad7473fd871 Mon Sep 17 00:00:00 2001
From: MLewerenz <152180836+LewerenzM@users.noreply.github.com>
Date: Thu, 6 Jun 2024 13:19:20 +0200
Subject: [PATCH 04/19] added env param to ci-build.yml
---
.github/workflows/ci-build.yml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml
index 48345241..41d75b2a 100644
--- a/.github/workflows/ci-build.yml
+++ b/.github/workflows/ci-build.yml
@@ -1,4 +1,8 @@
name: CI Build
+
+env:
+ CIBUILD: true
+
on:
workflow_dispatch:
pull_request:
From a43120ee9f0fda31d534381f5530338cd6c6c40a Mon Sep 17 00:00:00 2001
From: Marcus Lewerenz <152180836+LewerenzM@users.noreply.github.com>
Date: Thu, 6 Jun 2024 13:23:26 +0200
Subject: [PATCH 05/19] ci env param dependend prettier check
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index a9264b82..0a1b2bd2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -454,7 +454,7 @@
cibuild
- env.build_and_test
+ env.CIBUILD
From 1c2aa8de0650703222641a465f8a60f02e03e210 Mon Sep 17 00:00:00 2001
From: Marcus Lewerenz <152180836+LewerenzM@users.noreply.github.com>
Date: Thu, 6 Jun 2024 13:42:04 +0200
Subject: [PATCH 06/19] linted code to test ci check
---
.../java/org/icatproject/ids/IdsService.java | 631 ++++++++++------
src/main/java/org/icatproject/ids/Tidier.java | 281 +++++--
.../org/icatproject/ids/enums/CallType.java | 6 +-
.../org/icatproject/ids/enums/DeferredOp.java | 5 +-
.../icatproject/ids/enums/RequestIdNames.java | 2 +-
.../icatproject/ids/enums/RequestType.java | 24 +-
.../org/icatproject/ids/enums/Status.java | 4 +-
.../icatproject/ids/enums/StorageUnit.java | 3 +-
.../ids/enums/ValueContainerType.java | 9 +-
.../exceptions/DataNotOnlineException.java | 1 -
.../ids/exceptions/IdsException.java | 2 +-
.../ids/exceptions/IdsExceptionMapper.java | 14 +-
.../InsufficientStorageException.java | 1 +
.../exceptions/NotFoundExceptionMapper.java | 24 +-
.../exceptions/NotImplementedException.java | 1 -
.../exceptions/RuntimeExceptionMapper.java | 30 +-
.../FiniteStateMachine.java | 100 ++-
...niteStateMachineForSingleLevelStorage.java | 22 +-
...iteStateMachineForStorageUnitDatafile.java | 337 +++++++--
...niteStateMachineForStorageUnitDataset.java | 229 ++++--
.../ids/helpers/CORSResponseFilter.java | 10 +-
.../helpers/CheckedWithSizeInputStream.java | 1 +
.../icatproject/ids/helpers/Constants.java | 8 +-
.../ids/helpers/LocationHelper.java | 20 +-
.../ids/helpers/RangeOutputStream.java | 22 +-
.../java/org/icatproject/ids/helpers/SO.java | 91 ++-
.../ids/helpers/ValueContainer.java | 67 +-
.../icatproject/ids/models/DataInfoBase.java | 3 +-
.../icatproject/ids/models/DataSelection.java | 29 +-
.../icatproject/ids/models/DatafileInfo.java | 30 +-
.../icatproject/ids/models/DatasetInfo.java | 68 +-
.../org/icatproject/ids/models/Prepared.java | 132 +++-
.../ids/requestHandlers/ArchiveHandler.java | 24 +-
.../ids/requestHandlers/DeleteHandler.java | 56 +-
.../GetDataFileIdsHandler.java | 45 +-
.../ids/requestHandlers/GetDataHandler.java | 217 ++++--
.../requestHandlers/GetIcatUrlHandler.java | 10 +-
.../GetServiceStatusHandler.java | 27 +-
.../ids/requestHandlers/GetStatusHandler.java | 36 +-
.../requestHandlers/IsPreparedHandler.java | 36 +-
.../requestHandlers/IsReadOnlyHandler.java | 7 +-
.../requestHandlers/IsTwoLevelHandler.java | 4 +-
.../requestHandlers/PrepareDataHandler.java | 61 +-
.../ids/requestHandlers/PutHandler.java | 371 ++++++---
.../ids/requestHandlers/ResetHandler.java | 35 +-
.../ids/requestHandlers/RestoreHandler.java | 27 +-
.../ids/requestHandlers/WriteHandler.java | 47 +-
.../base/DataControllerBase.java | 42 +-
.../base/DataRequestHandler.java | 78 +-
.../base/PreparedDataController.java | 41 +-
.../base/RequestHandlerBase.java | 76 +-
.../base/UnpreparedDataController.java | 76 +-
.../getSizeHandlers/GetSizeHandler.java | 58 +-
.../GetSizeHandlerForFastProcessing.java | 115 ++-
.../icatproject/ids/services/ICATGetter.java | 30 +-
.../icatproject/ids/services/IcatReader.java | 26 +-
.../icatproject/ids/services/LockManager.java | 41 +-
.../ids/services/PropertyHandler.java | 215 ++++--
.../ids/services/ServiceProvider.java | 55 +-
.../icatproject/ids/services/Transmitter.java | 37 +-
.../ids/services/UnfinishedWorkService.java | 102 ++-
.../DataSelectionService.java | 200 +++--
.../DataSelectionServiceFactory.java | 698 +++++++++++++----
...SelectionServiceForSingleLevelStorage.java | 62 +-
...electionServiceForStorageUnitDatafile.java | 52 +-
...SelectionServiceForStorageUnitDataset.java | 62 +-
.../icatproject/ids/thread/DfArchiver.java | 47 +-
.../org/icatproject/ids/thread/DfDeleter.java | 27 +-
.../icatproject/ids/thread/DfRestorer.java | 36 +-
.../org/icatproject/ids/thread/DfWriter.java | 39 +-
.../icatproject/ids/thread/DsArchiver.java | 34 +-
.../icatproject/ids/thread/DsRestorer.java | 105 ++-
.../org/icatproject/ids/thread/DsWriter.java | 86 ++-
.../icatproject/ids/DataSelectionDevTest.java | 79 +-
.../java/org/icatproject/ids/DigestTest.java | 16 +-
.../icatproject/ids/PreparePackingTest.java | 73 +-
.../ids/RangeOutputStreamTest.java | 12 +-
.../org/icatproject/ids/TestICATGetter.java | 17 +-
.../java/org/icatproject/ids/TestUtils.java | 5 +-
.../icatproject/ids/TestValueContainer.java | 19 +-
.../java/org/icatproject/ids/TestZipping.java | 24 +-
.../java/org/icatproject/ids/TidierTest.java | 36 +-
.../org/icatproject/ids/TransmittingTest.java | 289 +++++--
.../org/icatproject/ids/ValidaterTest.java | 5 +-
.../icatproject/ids/integration/BaseTest.java | 617 +++++++++++----
.../ids/integration/one/BaseTests.java | 6 +-
.../integration/one/BogusDatafileTest.java | 96 ++-
.../ids/integration/one/DeleteTest.java | 33 +-
.../integration/one/GetDataExplicitTest.java | 258 +++++--
.../one/GetDataForPreparedIdTest.java | 111 ++-
.../one/GetStatusExplicitTest.java | 47 +-
.../one/GetStatusForPreparedIdTest.java | 49 +-
.../ids/integration/one/MiscTest.java | 42 +-
.../ids/integration/one/PerformanceTest.java | 64 +-
.../ids/integration/one/PrepareDataTest.java | 99 ++-
.../ids/integration/one/PutTest.java | 113 ++-
.../ids/integration/one/WriteTest.java | 12 +-
.../ids/integration/two/ArchiveTest.java | 40 +-
.../ids/integration/two/BaseTests.java | 6 +-
.../integration/two/BogusDatafileTest.java | 143 ++--
.../ids/integration/two/DeleteTest.java | 38 +-
.../integration/two/GetDataExplicitTest.java | 161 +++-
.../two/GetDataForPreparedIdTest.java | 100 ++-
.../two/GetStatusExplicitTest.java | 63 +-
.../two/GetStatusForPreparedIdTest.java | 49 +-
.../ids/integration/two/MiscTest.java | 39 +-
.../ids/integration/two/PrepareDataTest.java | 149 +++-
.../ids/integration/two/PutTest.java | 81 +-
.../integration/two/RestoreErrorsTest.java | 28 +-
.../ids/integration/two/RestoreTest.java | 42 +-
.../ids/integration/two/WriteTest.java | 41 +-
.../ids/integration/twodf/ArchiveTest.java | 40 +-
.../ids/integration/twodf/BaseTests.java | 6 +-
.../integration/twodf/BogusDatafileTest.java | 143 ++--
.../ids/integration/twodf/DeleteTest.java | 38 +-
.../twodf/GetDataExplicitTest.java | 162 +++-
.../twodf/GetDataForPreparedIdTest.java | 100 ++-
.../twodf/GetStatusExplicitTest.java | 66 +-
.../twodf/GetStatusForPreparedIdTest.java | 49 +-
.../ids/integration/twodf/MiscTest.java | 30 +-
.../integration/twodf/PrepareDataTest.java | 149 +++-
.../ids/integration/twodf/PutTest.java | 80 +-
.../ids/integration/twodf/QueueTest.java | 22 +-
.../ids/integration/twodf/RestoreTest.java | 40 +-
.../ids/integration/twodf/WriteTest.java | 41 +-
.../ids/integration/util/Setup.java | 41 +-
.../util/client/BadRequestException.java | 1 -
.../util/client/DataNotOnlineException.java | 1 -
.../util/client/HttpInputStream.java | 8 +-
.../integration/util/client/IdsException.java | 1 -
.../InsufficientPrivilegesException.java | 1 -
.../client/InsufficientStorageException.java | 1 -
.../util/client/InternalException.java | 1 -
.../util/client/NotFoundException.java | 1 -
.../util/client/NotImplementedException.java | 1 -
.../util/client/TestingClient.java | 712 ++++++++++++------
136 files changed, 7478 insertions(+), 3009 deletions(-)
diff --git a/src/main/java/org/icatproject/ids/IdsService.java b/src/main/java/org/icatproject/ids/IdsService.java
index 0d517fa9..218306cb 100644
--- a/src/main/java/org/icatproject/ids/IdsService.java
+++ b/src/main/java/org/icatproject/ids/IdsService.java
@@ -1,12 +1,5 @@
package org.icatproject.ids;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-
-
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.ejb.EJB;
@@ -23,15 +16,17 @@
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
+import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.Path;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import org.icatproject.IcatException_Exception;
import org.icatproject.ids.enums.RequestIdNames;
import org.icatproject.ids.exceptions.BadRequestException;
@@ -66,12 +61,16 @@
import org.icatproject.ids.services.ServiceProvider;
import org.icatproject.ids.services.Transmitter;
import org.icatproject.ids.services.UnfinishedWorkService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Path("/")
@Stateless
public class IdsService {
- private final static Logger logger = LoggerFactory.getLogger(IdsService.class);
+ private static final Logger logger = LoggerFactory.getLogger(
+ IdsService.class
+ );
@EJB
Transmitter transmitter;
@@ -89,24 +88,34 @@ public class IdsService {
private UnfinishedWorkService unfinishedWorkService;
-
@PostConstruct
private void init() {
-
try {
synchronized (lock) {
-
logger.info("creating IdsService");
- FiniteStateMachine.createInstance(reader, lockManager, PropertyHandler.getInstance().getStorageUnit());
+ FiniteStateMachine.createInstance(
+ reader,
+ lockManager,
+ PropertyHandler.getInstance().getStorageUnit()
+ );
this.fsm = FiniteStateMachine.getInstance();
this.fsm.init();
- ServiceProvider.createInstance(transmitter, fsm, lockManager, reader);
-
- var propertyHandler = ServiceProvider.getInstance().getPropertyHandler();
+ ServiceProvider.createInstance(
+ transmitter,
+ fsm,
+ lockManager,
+ reader
+ );
+
+ var propertyHandler = ServiceProvider
+ .getInstance()
+ .getPropertyHandler();
var archiveStorage = propertyHandler.getArchiveStorage();
var twoLevel = archiveStorage != null;
- var preparedDir = propertyHandler.getCacheDir().resolve("prepared");
+ var preparedDir = propertyHandler
+ .getCacheDir()
+ .resolve("prepared");
Files.createDirectories(preparedDir);
this.unfinishedWorkService = new UnfinishedWorkService();
@@ -120,13 +129,21 @@ private void init() {
java.nio.file.Path datasetDir;
if (twoLevel) {
- datasetDir = propertyHandler.getCacheDir().resolve("dataset");
- var markerDir = propertyHandler.getCacheDir().resolve("marker");
+ datasetDir =
+ propertyHandler.getCacheDir().resolve("dataset");
+ var markerDir = propertyHandler
+ .getCacheDir()
+ .resolve("marker");
if (!inited) {
Files.createDirectories(datasetDir);
Files.createDirectories(markerDir);
- this.unfinishedWorkService.restartUnfinishedWork(markerDir, key);
- this.unfinishedWorkService.cleanDatasetCache(datasetDir);
+ this.unfinishedWorkService.restartUnfinishedWork(
+ markerDir,
+ key
+ );
+ this.unfinishedWorkService.cleanDatasetCache(
+ datasetDir
+ );
}
}
@@ -136,18 +153,18 @@ private void init() {
}
} catch (Throwable e) {
logger.error("Won't start ", e);
- throw new RuntimeException("IdsService reports " + e.getClass() + " " + e.getMessage());
+ throw new RuntimeException(
+ "IdsService reports " + e.getClass() + " " + e.getMessage()
+ );
}
}
-
@PreDestroy
private void exit() {
this.fsm.exit();
logger.info("destroyed IdsService");
}
-
/**
* Archive data specified by the investigationIds, datasetIds and
* datafileIds specified along with a sessionId. If two level storage is not
@@ -164,19 +181,27 @@ private void exit() {
* @throws InsufficientPrivilegesException
* @throws InternalException
* @throws NotFoundException
- * @throws DataNotOnlineException
+ * @throws DataNotOnlineException
* @statuscode 200 To indicate success
*/
@POST
@Path("archive")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- public void archive(@Context HttpServletRequest request, @FormParam(RequestIdNames.sessionId) String sessionId,
- @FormParam("investigationIds") String investigationIds, @FormParam("datasetIds") String datasetIds,
- @FormParam("datafileIds") String datafileIds)
- throws NotImplementedException, BadRequestException, InsufficientPrivilegesException, InternalException,
- NotFoundException, DataNotOnlineException {
-
- var handler = new ArchiveHandler(request.getRemoteAddr(), sessionId, investigationIds, datasetIds, datafileIds);
+ public void archive(
+ @Context HttpServletRequest request,
+ @FormParam(RequestIdNames.sessionId) String sessionId,
+ @FormParam("investigationIds") String investigationIds,
+ @FormParam("datasetIds") String datasetIds,
+ @FormParam("datafileIds") String datafileIds
+ )
+ throws NotImplementedException, BadRequestException, InsufficientPrivilegesException, InternalException, NotFoundException, DataNotOnlineException {
+ var handler = new ArchiveHandler(
+ request.getRemoteAddr(),
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds
+ );
handler.handle();
}
@@ -200,16 +225,24 @@ public void archive(@Context HttpServletRequest request, @FormParam(RequestIdNam
*/
@DELETE
@Path("delete")
- public void delete(@Context HttpServletRequest request, @QueryParam(RequestIdNames.sessionId) String sessionId,
- @QueryParam("investigationIds") String investigationIds, @QueryParam("datasetIds") String datasetIds,
- @QueryParam("datafileIds") String datafileIds) throws NotImplementedException, BadRequestException,
- InsufficientPrivilegesException, NotFoundException, InternalException, DataNotOnlineException {
-
- var handler = new DeleteHandler(request.getRemoteAddr(), sessionId, investigationIds, datasetIds, datafileIds);
+ public void delete(
+ @Context HttpServletRequest request,
+ @QueryParam(RequestIdNames.sessionId) String sessionId,
+ @QueryParam("investigationIds") String investigationIds,
+ @QueryParam("datasetIds") String datasetIds,
+ @QueryParam("datafileIds") String datafileIds
+ )
+ throws NotImplementedException, BadRequestException, InsufficientPrivilegesException, NotFoundException, InternalException, DataNotOnlineException {
+ var handler = new DeleteHandler(
+ request.getRemoteAddr(),
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds
+ );
handler.handle();
}
-
/**
* Return the version of the server
*
@@ -222,7 +255,10 @@ public void delete(@Context HttpServletRequest request, @QueryParam(RequestIdNam
public String getVersion() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JsonGenerator gen = Json.createGenerator(baos);
- gen.writeStartObject().write("version", Constants.API_VERSION).writeEnd();
+ gen
+ .writeStartObject()
+ .write("version", Constants.API_VERSION)
+ .writeEnd();
gen.close();
return baos.toString();
}
@@ -257,20 +293,37 @@ public String getVersion() {
* @throws InternalException
* @throws InsufficientPrivilegesException
* @throws DataNotOnlineException
- * @throws NotImplementedException
+ * @throws NotImplementedException
* @statuscode 200 To indicate success
*/
@GET
@Path("getData")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
- public Response getData(@Context HttpServletRequest request, @QueryParam(RequestIdNames.preparedId) String preparedId,
- @QueryParam(RequestIdNames.sessionId) String sessionId, @QueryParam("investigationIds") String investigationIds,
- @QueryParam("datasetIds") String datasetIds, @QueryParam("datafileIds") String datafileIds,
- @QueryParam("compress") boolean compress, @QueryParam("zip") boolean zip,
- @QueryParam("outname") String outname, @HeaderParam("Range") String range) throws BadRequestException,
- NotFoundException, InternalException, InsufficientPrivilegesException, DataNotOnlineException, NotImplementedException {
-
- var handler = new GetDataHandler(request.getRemoteAddr(), preparedId, sessionId, investigationIds, datasetIds, datafileIds, compress, zip, outname, range);
+ public Response getData(
+ @Context HttpServletRequest request,
+ @QueryParam(RequestIdNames.preparedId) String preparedId,
+ @QueryParam(RequestIdNames.sessionId) String sessionId,
+ @QueryParam("investigationIds") String investigationIds,
+ @QueryParam("datasetIds") String datasetIds,
+ @QueryParam("datafileIds") String datafileIds,
+ @QueryParam("compress") boolean compress,
+ @QueryParam("zip") boolean zip,
+ @QueryParam("outname") String outname,
+ @HeaderParam("Range") String range
+ )
+ throws BadRequestException, NotFoundException, InternalException, InsufficientPrivilegesException, DataNotOnlineException, NotImplementedException {
+ var handler = new GetDataHandler(
+ request.getRemoteAddr(),
+ preparedId,
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds,
+ compress,
+ zip,
+ outname,
+ range
+ );
return handler.handle().getResponse();
}
@@ -291,19 +344,30 @@ public Response getData(@Context HttpServletRequest request, @QueryParam(Request
* @throws InternalException
* @throws NotFoundException
* @throws InsufficientPrivilegesException
- * @throws NotImplementedException
- * @throws DataNotOnlineException
+ * @throws NotImplementedException
+ * @throws DataNotOnlineException
* @statuscode 200 To indicate success
*/
@GET
@Path("getDatafileIds")
@Produces(MediaType.APPLICATION_JSON)
- public String getDatafileIds(@Context HttpServletRequest request, @QueryParam(RequestIdNames.preparedId) String preparedId,
- @QueryParam(RequestIdNames.sessionId) String sessionId, @QueryParam("investigationIds") String investigationIds,
- @QueryParam("datasetIds") String datasetIds, @QueryParam("datafileIds") String datafileIds)
- throws BadRequestException, InternalException, NotFoundException, InsufficientPrivilegesException, DataNotOnlineException, NotImplementedException {
-
- var handler = new GetDataFileIdsHandler(request.getRemoteAddr(), preparedId, sessionId, investigationIds, datasetIds, datafileIds);
+ public String getDatafileIds(
+ @Context HttpServletRequest request,
+ @QueryParam(RequestIdNames.preparedId) String preparedId,
+ @QueryParam(RequestIdNames.sessionId) String sessionId,
+ @QueryParam("investigationIds") String investigationIds,
+ @QueryParam("datasetIds") String datasetIds,
+ @QueryParam("datafileIds") String datafileIds
+ )
+ throws BadRequestException, InternalException, NotFoundException, InsufficientPrivilegesException, DataNotOnlineException, NotImplementedException {
+ var handler = new GetDataFileIdsHandler(
+ request.getRemoteAddr(),
+ preparedId,
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds
+ );
return handler.handle().getString();
}
@@ -313,19 +377,19 @@ public String getDatafileIds(@Context HttpServletRequest request, @QueryParam(Re
* obtained.
*
* @return the url of the icat server
- * @throws NotImplementedException
- * @throws DataNotOnlineException
- * @throws NotFoundException
- * @throws InsufficientPrivilegesException
- * @throws BadRequestException
- * @throws InternalException
+ * @throws NotImplementedException
+ * @throws DataNotOnlineException
+ * @throws NotFoundException
+ * @throws InsufficientPrivilegesException
+ * @throws BadRequestException
+ * @throws InternalException
* @statuscode 200 To indicate success
*/
@GET
@Path("getIcatUrl")
@Produces(MediaType.TEXT_PLAIN)
- public String getIcatUrl(@Context HttpServletRequest request) throws InternalException, BadRequestException, InsufficientPrivilegesException, NotFoundException, DataNotOnlineException, NotImplementedException {
-
+ public String getIcatUrl(@Context HttpServletRequest request)
+ throws InternalException, BadRequestException, InsufficientPrivilegesException, NotFoundException, DataNotOnlineException, NotImplementedException {
var handler = new GetIcatUrlHandler(request.getRemoteAddr());
return handler.handle().getString();
}
@@ -340,19 +404,24 @@ public String getIcatUrl(@Context HttpServletRequest request) throws InternalExc
* @return a json string.
* @throws InternalException
* @throws InsufficientPrivilegesException
- * @throws NotImplementedException
- * @throws DataNotOnlineException
- * @throws NotFoundException
- * @throws BadRequestException
+ * @throws NotImplementedException
+ * @throws DataNotOnlineException
+ * @throws NotFoundException
+ * @throws BadRequestException
* @statuscode 200 To indicate success
*/
@GET
@Path("getServiceStatus")
@Produces(MediaType.APPLICATION_JSON)
- public String getServiceStatus(@Context HttpServletRequest request, @QueryParam(RequestIdNames.sessionId) String sessionId)
- throws InternalException, InsufficientPrivilegesException, BadRequestException, NotFoundException, DataNotOnlineException, NotImplementedException {
-
- var handler = new GetServiceStatusHandler(request.getRemoteAddr(), sessionId);
+ public String getServiceStatus(
+ @Context HttpServletRequest request,
+ @QueryParam(RequestIdNames.sessionId) String sessionId
+ )
+ throws InternalException, InsufficientPrivilegesException, BadRequestException, NotFoundException, DataNotOnlineException, NotImplementedException {
+ var handler = new GetServiceStatusHandler(
+ request.getRemoteAddr(),
+ sessionId
+ );
return handler.handle().getString();
}
@@ -372,30 +441,46 @@ public String getServiceStatus(@Context HttpServletRequest request, @QueryParam(
* @throws NotFoundException
* @throws InsufficientPrivilegesException
* @throws InternalException
- * @throws NotImplementedException
- * @throws DataNotOnlineException
+ * @throws NotImplementedException
+ * @throws DataNotOnlineException
* @statuscode 200 To indicate success
*/
@GET
@Path("getSize")
@Produces(MediaType.TEXT_PLAIN)
- public long getSize(@Context HttpServletRequest request, @QueryParam(RequestIdNames.preparedId) String preparedId,
- @QueryParam(RequestIdNames.sessionId) String sessionId, @QueryParam("investigationIds") String investigationIds,
- @QueryParam("datasetIds") String datasetIds, @QueryParam("datafileIds") String datafileIds)
- throws BadRequestException, NotFoundException, InsufficientPrivilegesException, InternalException, DataNotOnlineException, NotImplementedException {
-
-
+ public long getSize(
+ @Context HttpServletRequest request,
+ @QueryParam(RequestIdNames.preparedId) String preparedId,
+ @QueryParam(RequestIdNames.sessionId) String sessionId,
+ @QueryParam("investigationIds") String investigationIds,
+ @QueryParam("datasetIds") String datasetIds,
+ @QueryParam("datafileIds") String datafileIds
+ )
+ throws BadRequestException, NotFoundException, InsufficientPrivilegesException, InternalException, DataNotOnlineException, NotImplementedException {
var result = ValueContainer.getInvalid();
// trying fast computation
- if(sessionId != null) {
- var fastHandler = new GetSizeHandlerForFastProcessing(request.getRemoteAddr(), sessionId, investigationIds, datasetIds, datafileIds);
+ if (sessionId != null) {
+ var fastHandler = new GetSizeHandlerForFastProcessing(
+ request.getRemoteAddr(),
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds
+ );
result = fastHandler.handle();
}
// otherwise normal computation
- if(result.isInvalid()) {
- var handler = new GetSizeHandler(request.getRemoteAddr(), preparedId, sessionId, investigationIds, datasetIds, datafileIds);
+ if (result.isInvalid()) {
+ var handler = new GetSizeHandler(
+ request.getRemoteAddr(),
+ preparedId,
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds
+ );
result = handler.handle();
}
@@ -424,32 +509,48 @@ public long getSize(@Context HttpServletRequest request, @QueryParam(RequestIdNa
* @throws NotFoundException
* @throws InsufficientPrivilegesException
* @throws InternalException
- * @throws NotImplementedException
- * @throws DataNotOnlineException
+ * @throws NotImplementedException
+ * @throws DataNotOnlineException
* @statuscode 200 To indicate success
*/
@GET
@Path("getStatus")
@Produces(MediaType.TEXT_PLAIN)
- public String getStatus(@Context HttpServletRequest request, @QueryParam(RequestIdNames.preparedId) String preparedId,
- @QueryParam(RequestIdNames.sessionId) String sessionId, @QueryParam("investigationIds") String investigationIds,
- @QueryParam("datasetIds") String datasetIds, @QueryParam("datafileIds") String datafileIds)
- throws BadRequestException, NotFoundException, InsufficientPrivilegesException, InternalException, DataNotOnlineException, NotImplementedException {
-
+ public String getStatus(
+ @Context HttpServletRequest request,
+ @QueryParam(RequestIdNames.preparedId) String preparedId,
+ @QueryParam(RequestIdNames.sessionId) String sessionId,
+ @QueryParam("investigationIds") String investigationIds,
+ @QueryParam("datasetIds") String datasetIds,
+ @QueryParam("datafileIds") String datafileIds
+ )
+ throws BadRequestException, NotFoundException, InsufficientPrivilegesException, InternalException, DataNotOnlineException, NotImplementedException {
// special case for getStatus request: getting status is possible without authentification
if (sessionId == null && preparedId == null) {
try {
- sessionId = ServiceProvider.getInstance().getIcatReader().getSessionId();
+ sessionId =
+ ServiceProvider
+ .getInstance()
+ .getIcatReader()
+ .getSessionId();
} catch (IcatException_Exception e) {
- throw new InternalException(e.getFaultInfo().getType() + " " + e.getMessage());
+ throw new InternalException(
+ e.getFaultInfo().getType() + " " + e.getMessage()
+ );
}
}
- var handler = new GetStatusHandler(request.getRemoteAddr(), preparedId, sessionId, investigationIds, datasetIds, datafileIds);
+ var handler = new GetStatusHandler(
+ request.getRemoteAddr(),
+ preparedId,
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds
+ );
return handler.handle().getString();
}
-
/**
* Returns true if all the data files are ready to be downloaded. As a side
* effect, if any data files are archived and no restoration has been
@@ -467,18 +568,23 @@ public String getStatus(@Context HttpServletRequest request, @QueryParam(Request
* @throws BadRequestException
* @throws NotFoundException
* @throws InternalException
- * @throws NotImplementedException
- * @throws DataNotOnlineException
- * @throws InsufficientPrivilegesException
+ * @throws NotImplementedException
+ * @throws DataNotOnlineException
+ * @throws InsufficientPrivilegesException
* @statuscode 200 To indicate success
*/
@GET
@Path("isPrepared")
@Produces(MediaType.TEXT_PLAIN)
- public boolean isPrepared(@Context HttpServletRequest request, @QueryParam(RequestIdNames.preparedId) String preparedId)
- throws BadRequestException, NotFoundException, InternalException, InsufficientPrivilegesException, DataNotOnlineException, NotImplementedException {
-
- var handler = new IsPreparedHandler(request.getRemoteAddr(), preparedId);
+ public boolean isPrepared(
+ @Context HttpServletRequest request,
+ @QueryParam(RequestIdNames.preparedId) String preparedId
+ )
+ throws BadRequestException, NotFoundException, InternalException, InsufficientPrivilegesException, DataNotOnlineException, NotImplementedException {
+ var handler = new IsPreparedHandler(
+ request.getRemoteAddr(),
+ preparedId
+ );
return handler.handle().getBool();
}
@@ -488,19 +594,19 @@ public boolean isPrepared(@Context HttpServletRequest request, @QueryParam(Reque
*
* @title isReadOnly
* @return true if readonly, else false
- * @throws NotImplementedException
- * @throws DataNotOnlineException
- * @throws NotFoundException
- * @throws InsufficientPrivilegesException
- * @throws BadRequestException
- * @throws InternalException
+ * @throws NotImplementedException
+ * @throws DataNotOnlineException
+ * @throws NotFoundException
+ * @throws InsufficientPrivilegesException
+ * @throws BadRequestException
+ * @throws InternalException
* @statuscode 200 To indicate success
*/
@GET
@Path("isReadOnly")
@Produces(MediaType.TEXT_PLAIN)
- public boolean isReadOnly(@Context HttpServletRequest request) throws InternalException, BadRequestException, InsufficientPrivilegesException, NotFoundException, DataNotOnlineException, NotImplementedException {
-
+ public boolean isReadOnly(@Context HttpServletRequest request)
+ throws InternalException, BadRequestException, InsufficientPrivilegesException, NotFoundException, DataNotOnlineException, NotImplementedException {
var handler = new IsReadOnlyHandler(request.getRemoteAddr());
return handler.handle().getBool();
}
@@ -511,19 +617,19 @@ public boolean isReadOnly(@Context HttpServletRequest request) throws InternalEx
*
* @title isTwoLevel
* @return true if twoLevel, else false
- * @throws NotImplementedException
- * @throws DataNotOnlineException
- * @throws NotFoundException
- * @throws InsufficientPrivilegesException
- * @throws BadRequestException
- * @throws InternalException
+ * @throws NotImplementedException
+ * @throws DataNotOnlineException
+ * @throws NotFoundException
+ * @throws InsufficientPrivilegesException
+ * @throws BadRequestException
+ * @throws InternalException
* @statuscode 200 To indicate success
*/
@GET
@Path("isTwoLevel")
@Produces(MediaType.TEXT_PLAIN)
- public boolean isTwoLevel(@Context HttpServletRequest request) throws InternalException, BadRequestException, InsufficientPrivilegesException, NotFoundException, DataNotOnlineException, NotImplementedException {
-
+ public boolean isTwoLevel(@Context HttpServletRequest request)
+ throws InternalException, BadRequestException, InsufficientPrivilegesException, NotFoundException, DataNotOnlineException, NotImplementedException {
var handler = new IsTwoLevelHandler(request.getRemoteAddr());
return handler.handle().getBool();
}
@@ -567,21 +673,33 @@ public String ping() {
* @throws InsufficientPrivilegesException
* @throws NotFoundException
* @throws InternalException
- * @throws NotImplementedException
- * @throws DataNotOnlineException
+ * @throws NotImplementedException
+ * @throws DataNotOnlineException
* @statuscode 200 To indicate success
*/
@POST
@Path("prepareData")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_PLAIN)
- public String prepareData(@Context HttpServletRequest request, @FormParam(RequestIdNames.sessionId) String sessionId,
- @FormParam("investigationIds") String investigationIds, @FormParam("datasetIds") String datasetIds,
- @FormParam("datafileIds") String datafileIds, @FormParam("compress") boolean compress,
- @FormParam("zip") boolean zip)
- throws BadRequestException, InsufficientPrivilegesException, NotFoundException, InternalException, NotImplementedException, DataNotOnlineException {
-
- var handler = new PrepareDataHandler(request.getRemoteAddr(), sessionId, investigationIds, datasetIds, datafileIds, compress, zip);
+ public String prepareData(
+ @Context HttpServletRequest request,
+ @FormParam(RequestIdNames.sessionId) String sessionId,
+ @FormParam("investigationIds") String investigationIds,
+ @FormParam("datasetIds") String datasetIds,
+ @FormParam("datafileIds") String datafileIds,
+ @FormParam("compress") boolean compress,
+ @FormParam("zip") boolean zip
+ )
+ throws BadRequestException, InsufficientPrivilegesException, NotFoundException, InternalException, NotImplementedException, DataNotOnlineException {
+ var handler = new PrepareDataHandler(
+ request.getRemoteAddr(),
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds,
+ compress,
+ zip
+ );
return handler.handle().getString();
}
@@ -613,16 +731,33 @@ public String prepareData(@Context HttpServletRequest request, @FormParam(Reques
@Path("put")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.APPLICATION_JSON)
- public Response put(@Context HttpServletRequest request, InputStream body,
- @QueryParam(RequestIdNames.sessionId) String sessionId, @QueryParam("name") String name,
- @QueryParam("datafileFormatId") String datafileFormatId, @QueryParam("datasetId") String datasetId,
- @QueryParam("description") String description, @QueryParam("doi") String doi,
- @QueryParam("datafileCreateTime") String datafileCreateTime,
- @QueryParam("datafileModTime") String datafileModTime) throws BadRequestException, NotFoundException,
- InternalException, InsufficientPrivilegesException, NotImplementedException, DataNotOnlineException {
-
- var handler = new PutHandler(request.getRemoteAddr(), sessionId, body, name, datafileFormatId, datasetId,
- description, doi, datafileCreateTime, datafileModTime, false, false);
+ public Response put(
+ @Context HttpServletRequest request,
+ InputStream body,
+ @QueryParam(RequestIdNames.sessionId) String sessionId,
+ @QueryParam("name") String name,
+ @QueryParam("datafileFormatId") String datafileFormatId,
+ @QueryParam("datasetId") String datasetId,
+ @QueryParam("description") String description,
+ @QueryParam("doi") String doi,
+ @QueryParam("datafileCreateTime") String datafileCreateTime,
+ @QueryParam("datafileModTime") String datafileModTime
+ )
+ throws BadRequestException, NotFoundException, InternalException, InsufficientPrivilegesException, NotImplementedException, DataNotOnlineException {
+ var handler = new PutHandler(
+ request.getRemoteAddr(),
+ sessionId,
+ body,
+ name,
+ datafileFormatId,
+ datasetId,
+ description,
+ doi,
+ datafileCreateTime,
+ datafileModTime,
+ false,
+ false
+ );
return handler.handle().getResponse();
}
@@ -649,65 +784,90 @@ public Response put(@Context HttpServletRequest request, InputStream body,
@Path("put")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
- public Response putAsPost(@Context HttpServletRequest request) throws BadRequestException, NotFoundException,
- InternalException, InsufficientPrivilegesException, NotImplementedException, DataNotOnlineException {
- try {
- String sessionId = null;
- String name = null;
- String datafileFormatId = null;
- String datasetId = null;
- String description = null;
- String doi = null;
- String datafileCreateTime = null;
- String datafileModTime = null;
- Response result = null;
- boolean wrap = false;
- boolean padding = false;
-
- // Parse the request
- for (Part part : request.getParts()) {
- String fieldName = part.getName();
- InputStream stream = part.getInputStream();
- if (part.getSubmittedFileName() == null) {
- String value = new String(stream.readAllBytes(), StandardCharsets.UTF_8);
- if (fieldName.equals("sessionId")) {
- sessionId = value;
- } else if (fieldName.equals("name")) {
- name = value;
- } else if (fieldName.equals("datafileFormatId")) {
- datafileFormatId = value;
- } else if (fieldName.equals("datasetId")) {
- datasetId = value;
- } else if (fieldName.equals("description")) {
- description = value;
- } else if (fieldName.equals("doi")) {
- doi = value;
- } else if (fieldName.equals("datafileCreateTime")) {
- datafileCreateTime = value;
- } else if (fieldName.equals("datafileModTime")) {
- datafileModTime = value;
- } else if (fieldName.equals("wrap")) {
- wrap = (value != null && value.toUpperCase().equals("TRUE"));
- } else if (fieldName.equals("padding")) {
- padding = (value != null && value.toUpperCase().equals("TRUE"));
- } else {
- throw new BadRequestException("Form field " + fieldName + "is not recognised");
- }
- } else {
- if (name == null) {
- name = part.getSubmittedFileName();
- }
- var handler = new PutHandler(request.getRemoteAddr(), sessionId, stream, name, datafileFormatId, datasetId, description,
- doi, datafileCreateTime, datafileModTime, wrap, padding);
- result = handler.handle().getResponse();
- }
+ public Response putAsPost(@Context HttpServletRequest request)
+ throws BadRequestException, NotFoundException, InternalException, InsufficientPrivilegesException, NotImplementedException, DataNotOnlineException {
+ try {
+ String sessionId = null;
+ String name = null;
+ String datafileFormatId = null;
+ String datasetId = null;
+ String description = null;
+ String doi = null;
+ String datafileCreateTime = null;
+ String datafileModTime = null;
+ Response result = null;
+ boolean wrap = false;
+ boolean padding = false;
+
+ // Parse the request
+ for (Part part : request.getParts()) {
+ String fieldName = part.getName();
+ InputStream stream = part.getInputStream();
+ if (part.getSubmittedFileName() == null) {
+ String value = new String(
+ stream.readAllBytes(),
+ StandardCharsets.UTF_8
+ );
+ if (fieldName.equals("sessionId")) {
+ sessionId = value;
+ } else if (fieldName.equals("name")) {
+ name = value;
+ } else if (fieldName.equals("datafileFormatId")) {
+ datafileFormatId = value;
+ } else if (fieldName.equals("datasetId")) {
+ datasetId = value;
+ } else if (fieldName.equals("description")) {
+ description = value;
+ } else if (fieldName.equals("doi")) {
+ doi = value;
+ } else if (fieldName.equals("datafileCreateTime")) {
+ datafileCreateTime = value;
+ } else if (fieldName.equals("datafileModTime")) {
+ datafileModTime = value;
+ } else if (fieldName.equals("wrap")) {
+ wrap =
+ (
+ value != null &&
+ value.toUpperCase().equals("TRUE")
+ );
+ } else if (fieldName.equals("padding")) {
+ padding =
+ (
+ value != null &&
+ value.toUpperCase().equals("TRUE")
+ );
+ } else {
+ throw new BadRequestException(
+ "Form field " + fieldName + "is not recognised"
+ );
+ }
+ } else {
+ if (name == null) {
+ name = part.getSubmittedFileName();
}
- return result;
- } catch (IOException e) {
- throw new InternalException(e.getClass() + " " + e.getMessage());
- } catch (ServletException e) {
- throw new BadRequestException("Multipart content expected");
+ var handler = new PutHandler(
+ request.getRemoteAddr(),
+ sessionId,
+ stream,
+ name,
+ datafileFormatId,
+ datasetId,
+ description,
+ doi,
+ datafileCreateTime,
+ datafileModTime,
+ wrap,
+ padding
+ );
+ result = handler.handle().getResponse();
}
+ }
+ return result;
+ } catch (IOException e) {
+ throw new InternalException(e.getClass() + " " + e.getMessage());
+ } catch (ServletException e) {
+ throw new BadRequestException("Multipart content expected");
+ }
}
/**
@@ -732,20 +892,30 @@ public Response putAsPost(@Context HttpServletRequest request) throws BadRequest
* @throws NotFoundException
* @throws InternalException
* @throws InsufficientPrivilegesException
- * @throws NotImplementedException
- * @throws DataNotOnlineException
+ * @throws NotImplementedException
+ * @throws DataNotOnlineException
* @statuscode 200 To indicate success
*/
@POST
@Path("reset")
- public void reset(@Context HttpServletRequest request, @FormParam(RequestIdNames.preparedId) String preparedId,
- @FormParam(RequestIdNames.sessionId) String sessionId, @FormParam("investigationIds") String investigationIds,
- @FormParam("datasetIds") String datasetIds, @FormParam("datafileIds") String datafileIds)
- throws BadRequestException, InternalException, NotFoundException, InsufficientPrivilegesException, DataNotOnlineException, NotImplementedException {
-
- var handler = new ResetHandler(request.getRemoteAddr(), preparedId, sessionId, investigationIds, datasetIds, datafileIds);
+ public void reset(
+ @Context HttpServletRequest request,
+ @FormParam(RequestIdNames.preparedId) String preparedId,
+ @FormParam(RequestIdNames.sessionId) String sessionId,
+ @FormParam("investigationIds") String investigationIds,
+ @FormParam("datasetIds") String datasetIds,
+ @FormParam("datafileIds") String datafileIds
+ )
+ throws BadRequestException, InternalException, NotFoundException, InsufficientPrivilegesException, DataNotOnlineException, NotImplementedException {
+ var handler = new ResetHandler(
+ request.getRemoteAddr(),
+ preparedId,
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds
+ );
handler.handle();
-
}
/**
@@ -764,23 +934,30 @@ public void reset(@Context HttpServletRequest request, @FormParam(RequestIdNames
* @throws InsufficientPrivilegesException
* @throws InternalException
* @throws NotFoundException
- * @throws DataNotOnlineException
+ * @throws DataNotOnlineException
* @statuscode 200 To indicate success
*/
@POST
@Path("restore")
@Consumes("application/x-www-form-urlencoded")
- public void restore(@Context HttpServletRequest request, @FormParam(RequestIdNames.sessionId) String sessionId,
- @FormParam("investigationIds") String investigationIds, @FormParam("datasetIds") String datasetIds,
- @FormParam("datafileIds") String datafileIds)
- throws NotImplementedException, BadRequestException, InsufficientPrivilegesException, InternalException,
- NotFoundException, DataNotOnlineException {
-
- var handler = new RestoreHandler(request.getRemoteAddr(), sessionId, investigationIds, datasetIds, datafileIds);
+ public void restore(
+ @Context HttpServletRequest request,
+ @FormParam(RequestIdNames.sessionId) String sessionId,
+ @FormParam("investigationIds") String investigationIds,
+ @FormParam("datasetIds") String datasetIds,
+ @FormParam("datafileIds") String datafileIds
+ )
+ throws NotImplementedException, BadRequestException, InsufficientPrivilegesException, InternalException, NotFoundException, DataNotOnlineException {
+ var handler = new RestoreHandler(
+ request.getRemoteAddr(),
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds
+ );
handler.handle();
}
-
/**
* Write data specified by the investigationIds, datasetIds
* and datafileIds specified along with a sessionId to archive
@@ -803,13 +980,21 @@ public void restore(@Context HttpServletRequest request, @FormParam(RequestIdNam
@POST
@Path("write")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- public void write(@Context HttpServletRequest request, @FormParam(RequestIdNames.sessionId) String sessionId,
- @FormParam("investigationIds") String investigationIds, @FormParam("datasetIds") String datasetIds,
- @FormParam("datafileIds") String datafileIds)
- throws NotImplementedException, BadRequestException, InsufficientPrivilegesException, InternalException,
- NotFoundException, DataNotOnlineException {
-
- var handler = new WriteHandler(request.getRemoteAddr(), sessionId, investigationIds, datasetIds, datafileIds);
+ public void write(
+ @Context HttpServletRequest request,
+ @FormParam(RequestIdNames.sessionId) String sessionId,
+ @FormParam("investigationIds") String investigationIds,
+ @FormParam("datasetIds") String datasetIds,
+ @FormParam("datafileIds") String datafileIds
+ )
+ throws NotImplementedException, BadRequestException, InsufficientPrivilegesException, InternalException, NotFoundException, DataNotOnlineException {
+ var handler = new WriteHandler(
+ request.getRemoteAddr(),
+ sessionId,
+ investigationIds,
+ datasetIds,
+ datafileIds
+ );
handler.handle();
}
}
diff --git a/src/main/java/org/icatproject/ids/Tidier.java b/src/main/java/org/icatproject/ids/Tidier.java
index 9d647de0..43ab0552 100644
--- a/src/main/java/org/icatproject/ids/Tidier.java
+++ b/src/main/java/org/icatproject/ids/Tidier.java
@@ -1,5 +1,10 @@
package org.icatproject.ids;
+import jakarta.annotation.PostConstruct;
+import jakarta.annotation.PreDestroy;
+import jakarta.ejb.EJB;
+import jakarta.ejb.Singleton;
+import jakarta.ejb.Startup;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@@ -11,16 +16,6 @@
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.annotation.PreDestroy;
-import jakarta.ejb.EJB;
-import jakarta.ejb.Singleton;
-import jakarta.ejb.Startup;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.icatproject.Datafile;
import org.icatproject.Dataset;
import org.icatproject.IcatException_Exception;
@@ -38,6 +33,8 @@
import org.icatproject.ids.services.IcatReader;
import org.icatproject.ids.services.LockManager;
import org.icatproject.ids.services.PropertyHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Singleton
@Startup
@@ -55,57 +52,153 @@ public void run() {
if (twoLevel) {
if (storageUnit == StorageUnit.DATASET) {
- List dsInfos = mainStorage.getDatasetsToArchive(stopArchivingLevel,
- startArchivingLevel);
+ List dsInfos = mainStorage.getDatasetsToArchive(
+ stopArchivingLevel,
+ startArchivingLevel
+ );
for (DsInfo dsInfo : dsInfos) {
StringBuilder sb = new StringBuilder(
- "SELECT ds FROM Dataset ds, ds.investigation inv, inv.facility fac WHERE");
+ "SELECT ds FROM Dataset ds, ds.investigation inv, inv.facility fac WHERE"
+ );
boolean andNeeded = false;
- andNeeded = addNumericConstraint(sb, "ds.id", dsInfo.getDsId(), andNeeded);
- andNeeded = addStringConstraint(sb, "ds.location", dsInfo.getDsLocation(), andNeeded);
- andNeeded = addStringConstraint(sb, "ds.name", dsInfo.getDsName(), andNeeded);
-
- andNeeded = addNumericConstraint(sb, "inv.id", dsInfo.getInvId(), andNeeded);
- andNeeded = addStringConstraint(sb, "inv.name", dsInfo.getInvName(), andNeeded);
- andNeeded = addStringConstraint(sb, "inv.visitId", dsInfo.getVisitId(), andNeeded);
-
- andNeeded = addStringConstraint(sb, "fac.name", dsInfo.getFacilityName(), andNeeded);
- andNeeded = addNumericConstraint(sb, "fac.id", dsInfo.getFacilityId(), andNeeded);
+ andNeeded =
+ addNumericConstraint(
+ sb,
+ "ds.id",
+ dsInfo.getDsId(),
+ andNeeded
+ );
+ andNeeded =
+ addStringConstraint(
+ sb,
+ "ds.location",
+ dsInfo.getDsLocation(),
+ andNeeded
+ );
+ andNeeded =
+ addStringConstraint(
+ sb,
+ "ds.name",
+ dsInfo.getDsName(),
+ andNeeded
+ );
+
+ andNeeded =
+ addNumericConstraint(
+ sb,
+ "inv.id",
+ dsInfo.getInvId(),
+ andNeeded
+ );
+ andNeeded =
+ addStringConstraint(
+ sb,
+ "inv.name",
+ dsInfo.getInvName(),
+ andNeeded
+ );
+ andNeeded =
+ addStringConstraint(
+ sb,
+ "inv.visitId",
+ dsInfo.getVisitId(),
+ andNeeded
+ );
+
+ andNeeded =
+ addStringConstraint(
+ sb,
+ "fac.name",
+ dsInfo.getFacilityName(),
+ andNeeded
+ );
+ andNeeded =
+ addNumericConstraint(
+ sb,
+ "fac.id",
+ dsInfo.getFacilityId(),
+ andNeeded
+ );
sb.append(" INCLUDE ds.investigation.facility");
try {
int low = 0;
while (true) {
- String query = sb.toString() + " LIMIT " + low + "," + tidyBlockSize;
+ String query =
+ sb.toString() +
+ " LIMIT " +
+ low +
+ "," +
+ tidyBlockSize;
List