diff --git a/src/main/config/run.properties.example b/src/main/config/run.properties.example index 2dadc9bd..1155abed 100644 --- a/src/main/config/run.properties.example +++ b/src/main/config/run.properties.example @@ -36,11 +36,8 @@ 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 +log.list = READ WRITE INFO MIGRATE PREPARE # JMS - uncomment and edit if needed !jms.topicConnectionFactory = java:comp/DefaultJMSConnectionFactory diff --git a/src/main/java/org/icatproject/ids/IdsBean.java b/src/main/java/org/icatproject/ids/IdsBean.java index e5c371a4..529c79aa 100644 --- a/src/main/java/org/icatproject/ids/IdsBean.java +++ b/src/main/java/org/icatproject/ids/IdsBean.java @@ -126,7 +126,7 @@ public Void call() throws Exception { } enum CallType { - INFO, PREPARE, READ, WRITE, MIGRATE, LINK + INFO, PREPARE, READ, WRITE, MIGRATE } public class RestoreDfTask implements Callable { @@ -475,10 +475,6 @@ public static void validateUUID(String thing, String id) throws BadRequestExcept private ICAT icat; - private Path linkDir; - - private boolean linkEnabled; - private MainStorageInterface mainStorage; private Path markerDir; @@ -1030,101 +1026,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 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 { @@ -1530,8 +1431,6 @@ private void init() { datatypeFactory = DatatypeFactory.newInstance(); preparedDir = propertyHandler.getCacheDir().resolve("prepared"); Files.createDirectories(preparedDir); - linkDir = propertyHandler.getCacheDir().resolve("link"); - Files.createDirectories(linkDir); rootUserNames = propertyHandler.getRootUserNames(); readOnly = propertyHandler.getReadOnly(); @@ -1562,8 +1461,6 @@ private void init() { } } - linkEnabled = propertyHandler.getLinkLifetimeMillis() > 0; - maxIdsInQuery = propertyHandler.getMaxIdsInQuery(); threadPool = Executors.newCachedThreadPool(); diff --git a/src/main/java/org/icatproject/ids/IdsService.java b/src/main/java/org/icatproject/ids/IdsService.java index b5590fe1..17564a1f 100644 --- a/src/main/java/org/icatproject/ids/IdsService.java +++ b/src/main/java/org/icatproject/ids/IdsService.java @@ -241,39 +241,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. - * - * @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 - * @summary getLink - * @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. diff --git a/src/main/java/org/icatproject/ids/PropertyHandler.java b/src/main/java/org/icatproject/ids/PropertyHandler.java index 72cc617f..021467f2 100644 --- a/src/main/java/org/icatproject/ids/PropertyHandler.java +++ b/src/main/java/org/icatproject/ids/PropertyHandler.java @@ -56,7 +56,6 @@ public static Logger getLogger() { private Path filesCheckLastIdFile; private int filesCheckParallelCount; private ICAT icatService; - private long linkLifetimeMillis; private MainStorageInterface mainStorage; @@ -215,11 +214,6 @@ private PropertyHandler() { } } - if (props.has("linkLifetimeSeconds")) { - linkLifetimeMillis = props.getNonNegativeLong("linkLifetimeSeconds") * 1000L; - } else { - linkLifetimeMillis = 0; - } maxIdsInQuery = props.getPositiveInt("maxIdsInQuery"); /* JMS stuff */ @@ -314,10 +308,6 @@ public String getKey() { return key; } - public long getLinkLifetimeMillis() { - return linkLifetimeMillis; - } - public Set getLogSet() { return logSet; } diff --git a/src/main/java/org/icatproject/ids/Tidier.java b/src/main/java/org/icatproject/ids/Tidier.java index ea86beb0..7f1bd626 100644 --- a/src/main/java/org/icatproject/ids/Tidier.java +++ b/src/main/java/org/icatproject/ids/Tidier.java @@ -44,25 +44,6 @@ public void run() { try { cleanPreparedDir(preparedDir, preparedCount); - if (linkLifetimeMillis > 0) { - long deleteMillis = System.currentTimeMillis() - linkLifetimeMillis; - int n = 0; - for (File f : linkDir.toFile().listFiles()) { - Path p = f.toPath(); - - if (Files.getLastModifiedTime(p).toMillis() < deleteMillis) { - try { - Files.delete(p); - n++; - } catch (Exception e) { - logger.error(e.getClass() + " " + e.getMessage()); - } - } - } - if (n > 0) { - logger.debug("Deleted " + n + " links from " + linkDir); - } - } if (twoLevel) { if (storageUnit == StorageUnit.DATASET) { List dsInfos = mainStorage.getDatasetsToArchive(stopArchivingLevel, @@ -228,8 +209,6 @@ static void cleanPreparedDir(Path preparedDir, int preparedCount) throws IOExcep @EJB private FiniteStateMachine fsm; - private Path linkDir; - private long linkLifetimeMillis; private MainStorageInterface mainStorage; private Path preparedDir; @@ -264,9 +243,6 @@ public void init() { preparedCount = propertyHandler.getPreparedCount(); preparedDir = propertyHandler.getCacheDir().resolve("prepared"); Files.createDirectories(preparedDir); - linkDir = propertyHandler.getCacheDir().resolve("link"); - Files.createDirectories(linkDir); - linkLifetimeMillis = propertyHandler.getLinkLifetimeMillis(); mainStorage = propertyHandler.getMainStorage(); twoLevel = propertyHandler.getArchiveStorage() != null; key = propertyHandler.getKey(); diff --git a/src/main/scripts/setup b/src/main/scripts/setup index e0594813..dc5655a3 100755 --- a/src/main/scripts/setup +++ b/src/main/scripts/setup @@ -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") diff --git a/src/site/xhtml/installation.xhtml.vm b/src/site/xhtml/installation.xhtml.vm index 2f4ec985..195f5259 100644 --- a/src/site/xhtml/installation.xhtml.vm +++ b/src/site/xhtml/installation.xhtml.vm @@ -136,15 +136,6 @@ please consult the documentation for your plugin(s).

readOnly
If true disables write operations (put and delete).
-
linkLifetimeSeconds
-
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. -

Deprecated: the getLink call is deprecated - and slated for removal along with this property in - ids.server 3.0.

-
-
reader
Space separated icat plugin name and credentials for a user permitted @@ -168,7 +159,7 @@ please consult the documentation for your plugin(s).
log.list
Optional. If present it specifies a set of call types to log via JMS calls. The types are specified by a space separated list of - values taken from READ, WRITE, LINK, MIGRATE, PREPARE and INFO. + values taken from READ, WRITE, MIGRATE, PREPARE and INFO.
jms.topicConnectionFactory
diff --git a/src/site/xhtml/release-notes.xhtml b/src/site/xhtml/release-notes.xhtml index 1e3bff32..512a965c 100644 --- a/src/site/xhtml/release-notes.xhtml +++ b/src/site/xhtml/release-notes.xhtml @@ -6,6 +6,11 @@

IDS Server Release Notes

+

3.0.0 (not yet released)

+ +

2.0.0

Make the transition to Payara 6