Skip to content

Commit

Permalink
Merge branch 'deprecations'
Browse files Browse the repository at this point in the history
  • Loading branch information
RKrahl committed Aug 14, 2023
2 parents cb45bad + 5df326c commit 189062e
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 99 deletions.
19 changes: 10 additions & 9 deletions miredot.htmlintro.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<h1>IDS Restful API</h1>

<h2>authorization</h2>
<p>Most operations require a sessionId from making a login call to
<p>
Most operations require a sessionId from making a login call to
ICAT. The sessionId is then used to check that the operation on the
data is permitted by following the general rule that if you are allowed
that access to the metadata then you are allowed the same access to the
data.
</p>

<h2>Error handling</h2>
<p>In the case of an error the returned json will be of the form:
<p>
In the case of an error the returned json will be of the form:
{"code":"NotFoundException", "message":"One of the data files requested
has been deleted"}. Clients should always check the status code and if
status/100 is not 2 then an error has occurred.</p>
status/100 is not 2 then an error has occurred.
</p>

<h2>Testing</h2>
<p>
The @GET calls can be tried on a web browser and curl can be used to
make any of the calls. For example a url of the form:
<kbd> https://example.com:443/ids/getApiVersion</kbd>
will return some text such as
<samp>1.5.0</samp>
<kbd>https://example.com/ids/version</kbd> will return some text such
as <samp>{"version":"2.0.0"}</samp>
</p>



2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.icatproject</groupId>
<artifactId>ids.server</artifactId>
<packaging>war</packaging>
<version>1.12.2-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<name>IDS Server</name>

<properties>
Expand Down
16 changes: 8 additions & 8 deletions src/main/config/run.properties.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ storageUnit = dataset
tidyBlockSize = 500
!enableWrite = true

# File checking properties
filesCheck.parallelCount = 5
filesCheck.gapSeconds = 5
filesCheck.lastIdFile = ${HOME}/ids/lastIdFile
filesCheck.errorLog = ${HOME}/ids/errorLog
# File checking properties. Deprecated
!filesCheck.parallelCount = 5
!filesCheck.gapSeconds = 5
!filesCheck.lastIdFile = ${HOME}/ids/lastIdFile
!filesCheck.errorLog = ${HOME}/ids/errorLog

# Link properties
linkLifetimeSeconds = 3600
# Link properties. Deprecated
!linkLifetimeSeconds = 3600

# JMS Logging
log.list = READ WRITE INFO LINK MIGRATE PREPARE

# JMS - uncomment and edit if needed
!jms.topicConnectionFactory = java:comp/DefaultJMSConnectionFactory
!jms.topicConnectionFactory = java:comp/DefaultJMSConnectionFactory
1 change: 1 addition & 0 deletions src/main/java/org/icatproject/ids/FileChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ public void init() {
StorageUnit storageUnit = propertyHandler.getStorageUnit();
filesCheckParallelCount = propertyHandler.getFilesCheckParallelCount();
if (filesCheckParallelCount > 0) {
logger.warn("The FileChecker is deprecated and slated for removal in ids.server 3.0");
if (storageUnit == null || storageUnit == StorageUnit.DATASET) {
filesCheckGapMillis = propertyHandler.getFilesCheckGapMillis();
filesCheckLastIdFile = propertyHandler.getFilesCheckLastIdFile();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/icatproject/ids/IdsBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,8 @@ public String getLink(String sessionId, long datafileId, String username, String

if (!linkEnabled) {
throw new NotImplementedException("Sorry getLink is not available on this IDS installation");
} else {
logger.warn("The getLink API call is deprecated and slated for removal in ids.server 3.0");
}

validateUUID("sessionId", sessionId);
Expand Down
20 changes: 2 additions & 18 deletions src/main/java/org/icatproject/ids/IdsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,6 @@ private void exit() {
logger.info("destroyed IdsService");
}

/**
* Return the version of the server
*
* @summary getApiVersion
*
* @return the version of the ids server
*
* @statuscode 200 To indicate success
*/
@GET
@Path("getApiVersion")
@Produces(MediaType.TEXT_PLAIN)
@Deprecated
public String getApiVersion() {
return Constants.API_VERSION;
}

/**
* Return the version of the server
*
Expand Down Expand Up @@ -328,6 +311,7 @@ public String getIcatUrl(@Context HttpServletRequest request) {
@Path("getLink")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_PLAIN)
@Deprecated
public String getLink(@Context HttpServletRequest request, @FormParam("sessionId") String sessionId,
@FormParam("datafileId") long datafileId, @FormParam("username") String username)
throws BadRequestException, InsufficientPrivilegesException, NotImplementedException, InternalException,
Expand Down Expand Up @@ -849,4 +833,4 @@ public void write(@Context HttpServletRequest request, @FormParam("sessionId") S
NotFoundException, DataNotOnlineException {
idsBean.write(sessionId, investigationIds, datasetIds, datafileIds, request.getRemoteAddr());
}
}
}
29 changes: 12 additions & 17 deletions src/main/java/org/icatproject/ids/PropertyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,9 @@ private PropertyHandler() {
abort("storageUnit value " + props.getString("storageUnit") + " must be taken from " + vs);
}
if (storageUnit == StorageUnit.DATASET) {
if (!props.has("delayDatasetWritesSeconds") && props.has("writeDelaySeconds")) {
// compatibility mode
logger.warn("writeDelaySeconds is deprecated, please use delayDatasetWritesSeconds instead");
delayDatasetWrites = props.getPositiveLong("writeDelaySeconds");
} else {
delayDatasetWrites = props.getPositiveLong("delayDatasetWritesSeconds");
}
delayDatasetWrites = props.getPositiveLong("delayDatasetWritesSeconds");
} else if (storageUnit == StorageUnit.DATAFILE) {
if (!props.has("delayDatafileOperationsSeconds") && props.has("writeDelaySeconds")) {
// compatibility mode
logger.warn("writeDelaySeconds is deprecated, please use delayDatafileOperationsSeconds instead");
delayDatafileOperations = props.getPositiveLong("writeDelaySeconds");
} else {
delayDatafileOperations = props.getPositiveLong("delayDatafileOperationsSeconds");
}
delayDatafileOperations = props.getPositiveLong("delayDatafileOperationsSeconds");
}
tidyBlockSize = props.getPositiveInt("tidyBlockSize");
}
Expand All @@ -209,7 +197,11 @@ private PropertyHandler() {
abort(cacheDir + " must be an existing directory");
}

filesCheckParallelCount = props.getNonNegativeInt("filesCheck.parallelCount");
if (props.has("filesCheck.parallelCount")) {
filesCheckParallelCount = props.getNonNegativeInt("filesCheck.parallelCount");
} else {
filesCheckParallelCount = 0;
}
if (filesCheckParallelCount > 0) {
filesCheckGapMillis = props.getPositiveInt("filesCheck.gapSeconds") * 1000;
filesCheckLastIdFile = props.getFile("filesCheck.lastIdFile").toPath();
Expand All @@ -222,8 +214,11 @@ private PropertyHandler() {
}
}

linkLifetimeMillis = props.getNonNegativeLong("linkLifetimeSeconds") * 1000L;

if (props.has("linkLifetimeSeconds")) {
linkLifetimeMillis = props.getNonNegativeLong("linkLifetimeSeconds") * 1000L;
} else {
linkLifetimeMillis = 0;
}
maxIdsInQuery = props.getPositiveInt("maxIdsInQuery");

/* JMS stuff */
Expand Down
11 changes: 7 additions & 4 deletions src/main/scripts/setup
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from setup_utils import *
import os
import warnings

# ids.server

Expand Down Expand Up @@ -33,15 +34,14 @@ if arg == "INSTALL":
if not idsProperties.get("tidyBlockSize"): abort("tidyBlockSize is not set in ids.properties")
if not idsProperties.get("storageUnit"): abort("storageUnit is not set in run.properties")
if idsProperties["storageUnit"].lower == "dataset":
if not (idsProperties.get("delayDatasetWritesSeconds") or
idsProperties.get("writeDelaySeconds")):
if not (idsProperties.get("delayDatasetWritesSeconds")):
abort("delayDatasetWritesSeconds is not set in run.properties")
if idsProperties["storageUnit"].lower == "datafile":
if not (idsProperties.get("delayDatafileOperationsSeconds") or
idsProperties.get("writeDelaySeconds")):
if not (idsProperties.get("delayDatafileOperationsSeconds")):
abort("delayDatafileOperationsSeconds is not set in run.properties")

if int(idsProperties["filesCheck.parallelCount"]):
warnings.warn("The FileChecker is deprecated and slated for removal in ids.server 3.0")
if not idsProperties.get("filesCheck.gapSeconds"): abort("filesCheck.gapSeconds is not set in run.properties")
if not idsProperties.get("filesCheck.lastIdFile"): abort("filesCheck.lastIdFile is not set in run.properties")
parent = os.path.dirname(os.path.expandvars(idsProperties["filesCheck.lastIdFile"]))
Expand All @@ -53,6 +53,9 @@ if arg == "INSTALL":
abort("Please create directory " + parent + " for filesCheck.errorLog specified in run.properties")
if not idsProperties.get("reader"): abort("reader is not set in run.properties")

if int(idsProperties["linkLifetimeSeconds"]):
warnings.warn("The getLink API call is deprecated and slated for removal in ids.server 3.0")

try:
uninstall()
actions.createJMSResource("javax.jms.Topic", "jms/IDS/log")
Expand Down
16 changes: 12 additions & 4 deletions src/site/xhtml/installation.xhtml.vm
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,13 @@
<dd>If true disables write operations (put and delete).</dd>

<dt>linkLifetimeSeconds</dt>
<dd>The length of time in seconds to keep the links established
by the getLink call. If this is set to zero then the getLink call
will return a NotImplementedException.</dd>
<dd>Optional, default zero. The length of time in seconds to keep the links
established by the getLink call. If this is set to zero then the getLink
call is disabled.
<p><strong>Deprecated:</strong> the getLink call is deprecated
and slated for removal along with this property in
ids.server 3.0.</p>
</dd>

<dt>reader</dt>
<dd>
Expand Down Expand Up @@ -230,10 +234,12 @@
computed and stored in ICAT. File checking, if enabled, cycles through
all the stored data making sure that they can be read and that files
have the expected size and checksum.</p>
<p><strong>Deprecated:</strong> the FileChecker is deprecated and slated for removal
along with the properties in this section in ids.server 3.0.</p>
<dl>
<dt>filesCheck.parallelCount</dt>
<dd>
This must always be set, and if non zero then the readability of the
Optional, default zero. If non zero then the readability of the
data will be checked. The behaviour is dependent upon whether or not
archive storage has a been requested. In the case of single level
storage this is done in groups of files where the group size is
Expand All @@ -247,6 +253,8 @@
<p>If the archive storage has a long latency then it is useful to
have a "large" value, however a thread is started for each stored
file so the value of this parameter should not be too large.</p>
<p>If this is set to zero then the FileChecker is disabled and all other
properties in this section will be ignored.</p>
</dd>
<dt>filesCheck.gapSeconds</dt>
<dd>the number of seconds to wait before launching a check of the
Expand Down
7 changes: 7 additions & 0 deletions src/site/xhtml/release-notes.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

<h1>IDS Server Release Notes</h1>

<h2>2.0.0</h2>
<ul>
<li>#139: Remove getApiVersion call, deprecated in 1.8.0.
Remove runtime property writeDelaySeconds, deprecated in 1.10.0.
Deprecate FileChecker and getLink call</li>
</ul>

<h2>1.12.1</h2>
<ul>
<li>#122: Bump dependency on logback-classic to version 1.2.0.</li>
Expand Down
4 changes: 0 additions & 4 deletions src/test/java/org/icatproject/ids/integration/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,6 @@ protected void getIcatUrlTest() throws Exception {
System.out.println(testingClient.getIcatUrl(200));
}

protected void apiVersionTest() throws Exception {
assertTrue(testingClient.getApiVersion(200).startsWith("1.8."));
}

protected void raceTest() throws Exception {
logTime("Starting");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ public void getIcatUrlTest() throws Exception {
super.getIcatUrlTest();
}

@Test
public void apiVersionTest() throws Exception {
super.apiVersionTest();
}

@Test
public void getDatafileIdsTest() throws Exception {
super.getDatafileIdsTest();
Expand All @@ -43,4 +38,4 @@ public void cloningTest() throws Exception {
super.cloningTest();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public void getIcatUrlTest() throws Exception {
super.getIcatUrlTest();
}

@Test
public void apiVersionTest() throws Exception {
super.apiVersionTest();
}

@Test
public void getDatafileIdsTest() throws Exception {
super.getDatafileIdsTest();
Expand Down Expand Up @@ -65,4 +60,4 @@ public void isPreparedTest() throws Exception {
super.isPreparedTest();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public void getIcatUrlTest() throws Exception {
super.getIcatUrlTest();
}

@Test
public void apiVersionTest() throws Exception {
super.apiVersionTest();
}

@Test
public void getDatafileIdsTest() throws Exception {
super.getDatafileIdsTest();
Expand Down Expand Up @@ -65,4 +60,4 @@ public void isPreparedTest() throws Exception {
super.isPreparedTest();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,21 +248,6 @@ private void expectNothing(CloseableHttpResponse response, Integer sc) throws In
}
}

public String getApiVersion(int sc) throws InternalException, ParseException, NotImplementedException {
URI uri = getUri(getUriBuilder("getApiVersion"));
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet(uri);
try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
return getString(response, sc);
} catch (IOException | InsufficientStorageException | DataNotOnlineException | BadRequestException
| InsufficientPrivilegesException | NotFoundException e) {
throw new InternalException(e.getClass() + " " + e.getMessage());
}
} catch (IOException e) {
throw new InternalException(e.getClass() + " " + e.getMessage());
}
}

public URL getIcatUrl(int sc) throws InternalException, ParseException, NotImplementedException {
URI uri = getUri(getUriBuilder("getIcatUrl"));
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
Expand Down Expand Up @@ -927,4 +912,4 @@ public void write(String sessionId, DataSelection data, Integer sc) throws NotIm
}
}

}
}

0 comments on commit 189062e

Please sign in to comment.