Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/main/config/run.properties.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ tidyBlockSize = 500
!filesCheck.lastIdFile = ${HOME}/ids/lastIdFile
!filesCheck.errorLog = ${HOME}/ids/errorLog

# Link properties. Deprecated
!linkLifetimeSeconds = 3600

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

Expand Down
95 changes: 0 additions & 95 deletions src/main/java/org/icatproject/ids/IdsBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -1027,101 +1027,6 @@ public String getIcatUrl(String ip) {
return propertyHandler.getIcatUrl();
}

public String getLink(String sessionId, long datafileId, String username, String ip)
throws BadRequestException, InsufficientPrivilegesException, InternalException, NotFoundException,
DataNotOnlineException, NotImplementedException {

long start = System.currentTimeMillis();

// Log and validate
logger.info("New webservice request: getLink datafileId=" + datafileId + " username='" + username + "'");

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);

Datafile datafile = null;
try {
datafile = (Datafile) icat.get(sessionId, "Datafile INCLUDE Dataset, Investigation, Facility", datafileId);
} catch (IcatException_Exception e) {
IcatExceptionType type = e.getFaultInfo().getType();
if (type == IcatExceptionType.BAD_PARAMETER) {
throw new BadRequestException(e.getMessage());
} else if (type == IcatExceptionType.INSUFFICIENT_PRIVILEGES) {
throw new InsufficientPrivilegesException(e.getMessage());
} else if (type == IcatExceptionType.INTERNAL) {
throw new InternalException(e.getMessage());
} else if (type == IcatExceptionType.NO_SUCH_OBJECT_FOUND) {
throw new NotFoundException(e.getMessage());
} else if (type == IcatExceptionType.OBJECT_ALREADY_EXISTS) {
throw new InternalException(e.getClass() + " " + e.getMessage());
} else if (type == IcatExceptionType.SESSION) {
throw new InsufficientPrivilegesException(e.getMessage());
} else if (type == IcatExceptionType.VALIDATION) {
throw new BadRequestException(e.getMessage());
}
}
if (datafile.getLocation() == null) {
throw new NotFoundException("Datafile not found");
}

String location = getLocation(datafile.getId(), datafile.getLocation());
DsInfo dsInfo = new DsInfoImpl(datafile.getDataset());

try (Lock lock = lockManager.lock(dsInfo, LockType.SHARED)) {
if (storageUnit == StorageUnit.DATASET) {
Set<Long> mt = Collections.emptySet();
if (restoreIfOffline(dsInfo, mt)) {
throw new DataNotOnlineException(
"Before linking a datafile, its dataset has to be restored, restoration requested automatically");
}
} else if (storageUnit == StorageUnit.DATAFILE) {
DfInfoImpl dfInfo = new DfInfoImpl(datafileId, datafile.getName(), location, datafile.getCreateId(),
datafile.getModId(), datafile.getDataset().getId());
if (restoreIfOffline(dfInfo)) {
throw new DataNotOnlineException(
"Before linking a datafile, it has to be restored, restoration requested automatically");
}
}

Path target = mainStorage.getPath(location, datafile.getCreateId(), datafile.getModId());
ShellCommand sc = new ShellCommand("setfacl", "-m", "user:" + username + ":r", target.toString());
if (sc.getExitValue() != 0) {
throw new BadRequestException(sc.getMessage() + ". Check that user '" + username + "' exists");
}
Path link = linkDir.resolve(UUID.randomUUID().toString());
Files.createLink(link, target);

if (logSet.contains(CallType.LINK)) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (JsonGenerator gen = Json.createGenerator(baos).writeStartObject()) {
gen.write("userName", icat.getUserName(sessionId));
gen.write("datafileId", datafileId);
gen.writeEnd();
}
String body = baos.toString();
transmitter.processMessage("getLink", ip, body, start);
} catch (IcatException_Exception e) {
logger.error("Failed to prepare jms message " + e.getClass() + " " + e.getMessage());
}
}

return link.toString();
} catch (AlreadyLockedException e) {
logger.debug("Could not acquire lock, getLink failed");
throw new DataNotOnlineException("Data is busy");
} catch (IOException e) {
logger.error("I/O error " + e.getMessage() + " linking " + location + " from MainStorage");
throw new InternalException(e.getClass() + " " + e.getMessage());
}

}

public String getServiceStatus(String sessionId, String ip)
throws InternalException, InsufficientPrivilegesException {

Expand Down
41 changes: 0 additions & 41 deletions src/main/java/org/icatproject/ids/IdsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,47 +276,6 @@ public String getIcatUrl(@Context HttpServletRequest request) {
return idsBean.getIcatUrl(request.getRemoteAddr());
}

/**
* Return a hard link to a data file.
*
* This is only useful in those cases where the user has direct access to
* the file system where the IDS is storing data. Only read access to the
* file is granted.
*
* @summary getLink
*
* @param sessionId
* A valid ICAT session ID
* @param datafileId
* the id of a data file
* @param username
* the name of the user who will will be granted access to the
* linked file.
*
* @return the path of the created link.
*
* @throws BadRequestException
* @throws InsufficientPrivilegesException
* @throws NotImplementedException
* @throws InternalException
* @throws NotFoundException
* @throws DataNotOnlineException
*
* @statuscode 200 To indicate success
*
*/
@POST
@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,
NotFoundException, DataNotOnlineException {
return idsBean.getLink(sessionId, datafileId, username, request.getRemoteAddr());
}

/**
* Obtain detailed information about what the ids is doing. You need to be
* privileged to use this call.
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/org/icatproject/ids/PropertyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@ private PropertyHandler() {
}
}

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

/* JMS stuff */
Expand Down
3 changes: 0 additions & 3 deletions src/main/scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ 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.get("linkLifetimeSeconds", 0)) > 0:
warnings.warn("The getLink API call is deprecated and slated for removal in ids.server 3.0")

try:
uninstall()
actions.createJMSResource("jakarta.jms.Topic", "jms/IDS/log")
Expand Down
9 changes: 0 additions & 9 deletions src/site/xhtml/installation.xhtml.vm
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@
<dt>readOnly</dt>
<dd>If true disables write operations (put and delete).</dd>

<dt>linkLifetimeSeconds</dt>
<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>
Space separated icat plugin name and credentials for a user permitted
Expand Down
35 changes: 0 additions & 35 deletions src/test/java/org/icatproject/ids/integration/one/LinkTest.java

This file was deleted.

42 changes: 0 additions & 42 deletions src/test/java/org/icatproject/ids/integration/two/LinkTest.java

This file was deleted.

42 changes: 0 additions & 42 deletions src/test/java/org/icatproject/ids/integration/twodf/LinkTest.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -355,28 +355,6 @@ public InputStream getData(String preparedId, long offset, Integer sc)
}
}

public Path getLink(String sessionId, long datafileId, String username, int sc)
throws BadRequestException, InsufficientPrivilegesException, InternalException, NotFoundException,
DataNotOnlineException, NotImplementedException {
URI uri = getUri(getUriBuilder("getLink"));
List<NameValuePair> formparams = new ArrayList<>();
formparams.add(new BasicNameValuePair("sessionId", sessionId));
formparams.add(new BasicNameValuePair("datafileId", Long.toString(datafileId)));
formparams.add(new BasicNameValuePair("username", username));

try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(uri);
httpPost.setEntity(new UrlEncodedFormEntity(formparams));
try (CloseableHttpResponse response = httpclient.execute(httpPost)) {
return Paths.get(getString(response, sc));
} catch (InsufficientStorageException e) {
throw new InternalException(e.getClass() + " " + e.getMessage());
}
} catch (IOException e) {
throw new InternalException(e.getClass() + " " + e.getMessage());
}
}

public ServiceStatus getServiceStatus(String sessionId, Integer sc)
throws InternalException, InsufficientPrivilegesException, NotImplementedException {

Expand Down
2 changes: 0 additions & 2 deletions src/test/resources/one.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ filesCheck.gapSeconds = 3
filesCheck.lastIdFile = ${HOME}/data/ids/lastIdFile
filesCheck.errorLog = ${HOME}/data/ids/errorLog

linkLifetimeSeconds = 3600

log.list = READ WRITE INFO LINK MIGRATE PREPARE
2 changes: 0 additions & 2 deletions src/test/resources/two.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ filesCheck.gapSeconds = 3
filesCheck.lastIdFile = ${HOME}/data/ids/lastIdFile
filesCheck.errorLog = ${HOME}/data/ids/errorLog

linkLifetimeSeconds = 3600

log.list = READ WRITE INFO LINK MIGRATE PREPARE
2 changes: 0 additions & 2 deletions src/test/resources/twodf.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ filesCheck.gapSeconds = 3
filesCheck.lastIdFile = ${HOME}/data/ids/lastIdFile
filesCheck.errorLog = ${HOME}/data/ids/errorLog

linkLifetimeSeconds = 3600

log.list = READ WRITE INFO LINK MIGRATE PREPARE