Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v3' into v3_FileInfoImprovementA…
Browse files Browse the repository at this point in the history
…ndRequestHandler
  • Loading branch information
marlewe committed Mar 18, 2024
2 parents ae99753 + 95e77b7 commit a532809
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 36 deletions.
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<plugin>
<groupId>com.qmino</groupId>
<artifactId>miredot-plugin</artifactId>
<version>2.4.1-Java11</version>
<version>2.4.4-Java11</version>
<executions>
<execution>
<id>miredot</id>
Expand Down Expand Up @@ -195,6 +195,9 @@
</checks>
</analysis>
<restModel>
<restFramework>
<name>jakarta</name>
</restFramework>
<httpStatusCodes>
<httpStatusCode>
<httpCode>400</httpCode>
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/org/icatproject/ids/IdsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class IdsService {
* datafileIds specified along with a sessionId. If two level storage is not
* in use this has no effect.
*
* @title archive
* @param sessionId A sessionId returned by a call to the icat server.
* @param investigationIds If present, a comma separated list of investigation id values
* @param datasetIds If present, a comma separated list of data set id values or
Expand All @@ -86,7 +87,6 @@ public class IdsService {
* @throws InternalException
* @throws NotFoundException
* @throws DataNotOnlineException
* @summary archive
* @statuscode 200 To indicate success
*/
@POST
Expand All @@ -113,6 +113,7 @@ public void archive(@Context HttpServletRequest request, @FormParam("sessionId")
* Delete data specified by the investigationIds, datasetIds and datafileIds
* specified along with a sessionId.
*
* @title delete
* @param sessionId A sessionId returned by a call to the icat server.
* @param investigationIds If present, a comma separated list of investigation id values
* @param datasetIds If present, a comma separated list of data set id values or
Expand All @@ -124,7 +125,6 @@ public void archive(@Context HttpServletRequest request, @FormParam("sessionId")
* @throws NotFoundException
* @throws InternalException
* @throws DataNotOnlineException
* @summary delete
* @statuscode 200 To indicate success
*/
@DELETE
Expand Down Expand Up @@ -153,8 +153,8 @@ private void exit() {
/**
* Return the version of the server
*
* @title Version
* @return json string of the form: <samp>{"version":"4.4.0"}</samp>
* @summary Version
*/
@GET
@Path("version")
Expand All @@ -173,6 +173,7 @@ public String getVersion() {
* of which may be omitted, along with a sessionId if the preparedId is not
* set. If preparedId is set the compress and zip arguments are not used.
*
* @title getData
* @param preparedId A valid preparedId returned by a call to prepareData
* @param sessionId A sessionId returned by a call to the icat server.
* @param investigationIds A comma separated list of investigation id values.
Expand All @@ -197,7 +198,6 @@ public String getVersion() {
* @throws InsufficientPrivilegesException
* @throws DataNotOnlineException
* @throws NotImplementedException
* @summary getData
* @statuscode 200 To indicate success
*/
@GET
Expand Down Expand Up @@ -232,6 +232,7 @@ public Response getData(@Context HttpServletRequest request, @QueryParam("prepar
* and datafileIds specified along with a sessionId if the preparedId is not
* set.
*
* @title getDatafileIds
* @param preparedId A valid preparedId returned by a call to prepareData
* @param sessionId A sessionId returned by a call to the icat server.
* @param investigationIds A comma separated list of investigation id values.
Expand All @@ -244,7 +245,6 @@ public Response getData(@Context HttpServletRequest request, @QueryParam("prepar
* @throws InsufficientPrivilegesException
* @throws NotImplementedException
* @throws DataNotOnlineException
* @summary getDatafileIds
* @statuscode 200 To indicate success
*/
@GET
Expand Down Expand Up @@ -295,6 +295,7 @@ public String getIcatUrl(@Context HttpServletRequest request) throws InternalExc
* Obtain detailed information about what the ids is doing. You need to be
* privileged to use this call.
*
* @title getServiceStatus
* @param sessionId A valid ICAT session ID of a user in the IDS rootUserNames
* set.
* @return a json string.
Expand All @@ -304,7 +305,6 @@ public String getIcatUrl(@Context HttpServletRequest request) throws InternalExc
* @throws DataNotOnlineException
* @throws NotFoundException
* @throws BadRequestException
* @summary getServiceStatus
* @statuscode 200 To indicate success
*/
@GET
Expand All @@ -324,6 +324,7 @@ public String getServiceStatus(@Context HttpServletRequest request, @QueryParam(
* Return the total size of all the data files specified by the
* investigationIds, datasetIds and datafileIds along with a sessionId.
*
* @title getSize
* @param preparedId A valid preparedId returned by a call to prepareData
* @param sessionId A sessionId returned by a call to the icat server.
* @param investigationIds If present, a comma separated list of investigation id values
Expand All @@ -337,7 +338,6 @@ public String getServiceStatus(@Context HttpServletRequest request, @QueryParam(
* @throws InternalException
* @throws NotImplementedException
* @throws DataNotOnlineException
* @summary getSize
* @statuscode 200 To indicate success
*/
@GET
Expand All @@ -364,6 +364,7 @@ public long getSize(@Context HttpServletRequest request, @QueryParam("preparedId
* Return the archive status of the data files specified by the
* investigationIds, datasetIds and datafileIds along with a sessionId.
*
* @title getStatus
* @param preparedId A valid preparedId returned by a call to prepareData
* @param sessionId A sessionId returned by a call to the icat server. If the
* sessionId is omitted or null the ids reader account will be
Expand All @@ -383,7 +384,6 @@ public long getSize(@Context HttpServletRequest request, @QueryParam("preparedId
* @throws InternalException
* @throws NotImplementedException
* @throws DataNotOnlineException
* @summary getStatus
* @statuscode 200 To indicate success
*/
@GET
Expand Down Expand Up @@ -428,6 +428,7 @@ private void init() {
* the end successfully will then go through all those it did not look at
* because it did not start at the beginning.
*
* @title isPrepared
* @param preparedId A valid preparedId returned by a call to prepareData
* @return true if all the data files are ready to be downloaded else false.
* @throws BadRequestException
Expand All @@ -436,7 +437,6 @@ private void init() {
* @throws NotImplementedException
* @throws DataNotOnlineException
* @throws InsufficientPrivilegesException
* @summary isPrepared
* @statuscode 200 To indicate success
*/
@GET
Expand All @@ -456,14 +456,14 @@ public boolean isPrepared(@Context HttpServletRequest request, @QueryParam("prep
* An ids server can be configured to be read only. This returns thenew DfProcessQueue()
* readOnly status of the server.
*
* @title isReadOnly
* @return true if readonly, else false
* @throws NotImplementedException
* @throws DataNotOnlineException
* @throws NotFoundException
* @throws InsufficientPrivilegesException
* @throws BadRequestException
* @throws InternalException
* @summary isReadOnly
* @statuscode 200 To indicate success
*/
@GET
Expand All @@ -481,14 +481,14 @@ public boolean isReadOnly(@Context HttpServletRequest request) throws InternalEx
* An ids server can be configured to support one or two levels of data
* storage. This returns the twoLevel status of the server.
*
* @title isTwoLevel
* @return true if twoLevel, else false
* @throws NotImplementedException
* @throws DataNotOnlineException
* @throws NotFoundException
* @throws InsufficientPrivilegesException
* @throws BadRequestException
* @throws InternalException
* @summary isTwoLevel
* @statuscode 200 To indicate success
*/
@GET
Expand All @@ -505,8 +505,8 @@ public boolean isTwoLevel(@Context HttpServletRequest request) throws InternalEx
/**
* Should return "IdsOK"
*
* @title ping
* @return "IdsOK"
* @summary ping
* @statuscode 200 To indicate success
*/
@GET
Expand All @@ -524,6 +524,7 @@ public String ping() {
* by the investigationIds, datasetIds and datafileIds, any of which may be
* omitted, along with a sessionId.
*
* @title prepareData
* @param sessionId A sessionId returned by a call to the icat server.
* @param investigationIds A comma separated list of investigation id values.
* @param datasetIds A comma separated list of data set id values.
Expand All @@ -542,7 +543,6 @@ public String ping() {
* @throws InternalException
* @throws NotImplementedException
* @throws DataNotOnlineException
* @summary prepareData
* @statuscode 200 To indicate success
*/
@POST
Expand Down Expand Up @@ -570,6 +570,7 @@ public String prepareData(@Context HttpServletRequest request, @FormParam("sessi
/**
* Stores a data file
*
* @title put
* @param body The contents of the file to be stored
* @param sessionId A sessionId returned by a call to the icat server.
* @param name A name to assign to the data file
Expand All @@ -588,7 +589,6 @@ public String prepareData(@Context HttpServletRequest request, @FormParam("sessi
* @throws InsufficientPrivilegesException
* @throws NotImplementedException
* @throws DataNotOnlineException
* @summary put
* @statuscode 201 When object successfully created
*/
@PUT
Expand Down Expand Up @@ -627,6 +627,7 @@ public Response put(@Context HttpServletRequest request, InputStream body,
* two fields will be removed shortly as they are only required by the old
* (GWT based) topcat.
*
* @title putAsPost
* @param request
* @return a json object with attributes of "id", "checksum", "location" and
* "size";
Expand All @@ -636,7 +637,6 @@ public Response put(@Context HttpServletRequest request, InputStream body,
* @throws InsufficientPrivilegesException
* @throws NotImplementedException
* @throws DataNotOnlineException
* @summary putAsPost
* @statuscode 201 When object successfully created
*/
@POST
Expand Down Expand Up @@ -711,6 +711,7 @@ public Response putAsPost(@Context HttpServletRequest request) throws BadRequest
* You must either specify a preparedId or a sessionId. If preparedId is
* specified then investigationIds, datasetIds and datafileIds are not used.
*
* @title reset
* @param preparedId A valid preparedId returned by a call to prepareData
* @param sessionId A sessionId returned by a call to the icat server.
* @param investigationIds A comma separated list of investigation id values.
Expand All @@ -723,7 +724,6 @@ public Response putAsPost(@Context HttpServletRequest request) throws BadRequest
* @throws InsufficientPrivilegesException
* @throws NotImplementedException
* @throws DataNotOnlineException
* @summary reset
* @statuscode 200 To indicate success
*/
@POST
Expand All @@ -750,6 +750,7 @@ public void reset(@Context HttpServletRequest request, @FormParam("preparedId")
* datafileIds specified along with a sessionId. If two level storage is not
* in use this has no effect.
*
* @title restore
* @param sessionId A sessionId returned by a call to the icat server.
* @param investigationIds If present, a comma separated list of investigation id values
* @param datasetIds If present, a comma separated list of data set id values or
Expand All @@ -761,7 +762,6 @@ public void reset(@Context HttpServletRequest request, @FormParam("preparedId")
* @throws InternalException
* @throws NotFoundException
* @throws DataNotOnlineException
* @summary restore
* @statuscode 200 To indicate success
*/
@POST
Expand Down Expand Up @@ -790,6 +790,7 @@ public void restore(@Context HttpServletRequest request, @FormParam("sessionId")
* storage. If two level storage is not in use this has no
* effect.
*
* @title write
* @param sessionId A sessionId returned by a call to the icat server.
* @param investigationIds If present, a comma separated list of investigation id values
* @param datasetIds If present, a comma separated list of data set id values or
Expand All @@ -800,7 +801,6 @@ public void restore(@Context HttpServletRequest request, @FormParam("sessionId")
* @throws InsufficientPrivilegesException
* @throws InternalException
* @throws NotFoundException
* @summary write
* @statuscode 200 To indicate success
*/
@POST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.OptionalLong;
import java.util.Set;
import java.util.SortedMap;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -39,6 +40,7 @@ public abstract class DataSelectionBase {
protected List<Long> dsids;
protected List<Long> dfids;
protected RequestType requestType;
private long length;


protected static ExecutorService threadPool;
Expand All @@ -53,14 +55,15 @@ class PreparedStatus {

}

protected DataSelectionBase(SortedMap<Long, DataInfoBase> dsInfos, SortedMap<Long, DataInfoBase> dfInfos, Set<Long> emptyDatasets, List<Long> invids2, List<Long> dsids, List<Long> dfids, RequestType requestType) {
protected DataSelectionBase(SortedMap<Long, DataInfoBase> dsInfos, SortedMap<Long, DataInfoBase> dfInfos, Set<Long> emptyDatasets, List<Long> invids2, List<Long> dsids, List<Long> dfids, long length, RequestType requestType) {

this.dsInfos = dsInfos;
this.dfInfos = dfInfos;
this.emptyDatasets = emptyDatasets;
this.invids = invids2;
this.dsids = dsids;
this.dfids = dfids;
this.length = length;
this.requestType = requestType;
}

Expand Down Expand Up @@ -96,7 +99,7 @@ public Map<Long, DataInfoBase> getDfInfo() {
return dfInfos;
}


public boolean mustZip() {
return dfids.size() > 1L || !dsids.isEmpty() || !invids.isEmpty()
|| (dfids.isEmpty() && dsids.isEmpty() && invids.isEmpty());
Expand Down Expand Up @@ -178,6 +181,14 @@ public void restoreDataInfos() {
}


public OptionalLong getFileLength() {
if (this.getDfInfo().isEmpty() || mustZip()) {
return OptionalLong.empty();
}
return OptionalLong.of(length);
}


protected boolean areDataInfosPrepared(String preparedId) throws InternalException {
boolean prepared = true;
var serviceProvider = ServiceProvider.getInstance();
Expand Down
Loading

0 comments on commit a532809

Please sign in to comment.