diff --git a/jargon-core/src/main/java/org/irods/jargon/core/packinstr/MiscApiConstants.java b/jargon-core/src/main/java/org/irods/jargon/core/packinstr/MiscApiConstants.java index c85ecc437..c4c67cb3a 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/packinstr/MiscApiConstants.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/packinstr/MiscApiConstants.java @@ -13,6 +13,7 @@ public class MiscApiConstants { public static final int CLIENT_HINTS_API_NBR = 10215; public static final int IES_CLIENT_HINTS_AN = 10216; + public static final int LIBRARY_FEATURES_AN = 801; public static final int SERVER_REPORT_AN = 10204; public static final int ZONE_REPORT_AN = 10205; diff --git a/jargon-core/src/main/java/org/irods/jargon/core/pub/EnvironmentalInfoAO.java b/jargon-core/src/main/java/org/irods/jargon/core/pub/EnvironmentalInfoAO.java index 62190901a..e77bcbb21 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/pub/EnvironmentalInfoAO.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/pub/EnvironmentalInfoAO.java @@ -98,4 +98,20 @@ public interface EnvironmentalInfoAO extends IRODSAccessObject { */ ClientHints retrieveClientHints(final boolean refresh) throws JargonException; + /** + * Returns a JSON string containing information about the connected server's + * library features. + * + * Each entry contains the name of a feature and an integer representing its + * version. Integer values may increase over time as features are improved. + * + * The information returned is only representative of the "connected" server's + * features. + * + * Developers are encouraged to prefer this over version checking when needing + * to make decisions (at runtime) about whether a particular feature is + * supported. + */ + String getServerLibraryFeatures() throws OperationNotSupportedByThisServerException, JargonException; + } diff --git a/jargon-core/src/main/java/org/irods/jargon/core/pub/EnvironmentalInfoAOImpl.java b/jargon-core/src/main/java/org/irods/jargon/core/pub/EnvironmentalInfoAOImpl.java index 0ff8954da..3df9f6b00 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/pub/EnvironmentalInfoAOImpl.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/pub/EnvironmentalInfoAOImpl.java @@ -246,5 +246,23 @@ public List listAvailableMicroservices() return availableMicroservices; } + + @Override + public String getServerLibraryFeatures() throws OperationNotSupportedByThisServerException, JargonException { + log.info("getServerLibraryFeatures()"); + + if (!getIRODSServerProperties().isAtLeastIrods431()) { + throw new OperationNotSupportedByThisServerException("service not available on servers prior to rods4.3.1"); + } + + Tag tag = getIRODSProtocol().irodsFunction(IRODSConstants.RODS_API_REQ, "", + MiscApiConstants.LIBRARY_FEATURES_AN); + + if (null == tag) { + return null; + } + + return tag.getTag("myStr").getStringValue(); + } } diff --git a/jargon-core/src/test/java/org/irods/jargon/core/pub/EnvironmentalInfoAOTest.java b/jargon-core/src/test/java/org/irods/jargon/core/pub/EnvironmentalInfoAOTest.java index b1bb39fe1..e4232cb7a 100644 --- a/jargon-core/src/test/java/org/irods/jargon/core/pub/EnvironmentalInfoAOTest.java +++ b/jargon-core/src/test/java/org/irods/jargon/core/pub/EnvironmentalInfoAOTest.java @@ -4,6 +4,7 @@ package org.irods.jargon.core.pub; import java.util.List; +import java.util.Map; import java.util.Properties; import org.irods.jargon.core.connection.IRODSAccount; @@ -12,14 +13,21 @@ import org.irods.jargon.core.connection.IRODSSession; import org.irods.jargon.core.connection.IRODSSimpleProtocolManager; import org.irods.jargon.core.exception.DataNotFoundException; +import org.irods.jargon.core.exception.JargonException; import org.irods.jargon.core.pub.domain.ClientHints; import org.irods.jargon.core.pub.domain.RemoteCommandInformation; import org.irods.jargon.testutils.TestingPropertiesHelper; import org.junit.AfterClass; import org.junit.Assert; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + /** * @author Mike Conway - DICE (www.irods.org) * @@ -157,4 +165,27 @@ public void testListAvailableMicroservices() throws Exception { Assert.assertTrue("did not find any microservices", microservices.size() > 0); } + + @Test + public void testGetServerLibraryFeatures() throws JargonException, JsonMappingException, JsonProcessingException { + IRODSFileSystem fs = IRODSFileSystem.instance(); + IRODSAccessObjectFactory aof = fs.getIRODSAccessObjectFactory(); + IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties); + + Assume.assumeTrue("Requires a minimum version of iRODS 4.3.1", + aof.getIRODSServerProperties(irodsAccount).isAtLeastIrods431()); + + EnvironmentalInfoAO eiao = aof.getEnvironmentalInfoAO(irodsAccount); + + String featuresString = eiao.getServerLibraryFeatures(); + Assert.assertNotNull(featuresString); + + ObjectMapper mapper = new ObjectMapper(); + Map features = mapper.readValue(featuresString, new TypeReference>() {}); + Assert.assertFalse(features.isEmpty()); + Assert.assertTrue(features.containsKey("IRODS_HAS_LIBRARY_TICKET_ADMINISTRATION")); + Assert.assertTrue(features.containsKey("IRODS_HAS_API_ENDPOINT_SWITCH_USER")); + Assert.assertTrue(features.containsKey("IRODS_HAS_API_ENDPOINT_CHECK_AUTH_CREDENTIALS")); + } + }