Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 1 addition & 4 deletions src/main/config/run.properties.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
105 changes: 1 addition & 104 deletions src/main/java/org/icatproject/ids/IdsBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<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 Expand Up @@ -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();
Expand Down Expand Up @@ -1562,8 +1461,6 @@ private void init() {
}
}

linkEnabled = propertyHandler.getLinkLifetimeMillis() > 0;

maxIdsInQuery = propertyHandler.getMaxIdsInQuery();

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

/**
* Return a hard link to a data file.
* <p>
* 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.
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/icatproject/ids/PropertyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public static Logger getLogger() {
private Path filesCheckLastIdFile;
private int filesCheckParallelCount;
private ICAT icatService;
private long linkLifetimeMillis;

private MainStorageInterface mainStorage;

Expand Down Expand Up @@ -215,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 Expand Up @@ -314,10 +308,6 @@ public String getKey() {
return key;
}

public long getLinkLifetimeMillis() {
return linkLifetimeMillis;
}

public Set<CallType> getLogSet() {
return logSet;
}
Expand Down
24 changes: 0 additions & 24 deletions src/main/java/org/icatproject/ids/Tidier.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<DsInfo> dsInfos = mainStorage.getDatasetsToArchive(stopArchivingLevel,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
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
11 changes: 1 addition & 10 deletions src/site/xhtml/installation.xhtml.vm
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,6 @@ please consult the documentation for your plugin(s).
<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 All @@ -168,7 +159,7 @@ please consult the documentation for your plugin(s).
<dt>log.list</dt>
<dd>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.
</dd>

<dt>jms.topicConnectionFactory</dt>
Expand Down
5 changes: 5 additions & 0 deletions src/site/xhtml/release-notes.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

<h1>IDS Server Release Notes</h1>

<h2>3.0.0 (not yet released)</h2>
<ul>
<li>#148: Drop getLink API call, deprecated in 2.0.0.</li>
</ul>

<h2>2.0.0</h2>
<p>Make the transition to Payara 6</p>
<ul>
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.

Loading