Skip to content

Commit

Permalink
[#441] Add support for library features API.
Browse files Browse the repository at this point in the history
  • Loading branch information
korydraughn committed Aug 9, 2024
1 parent ecbd30b commit 6cfa5e8
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,23 @@ public List<String> 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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
*
Expand Down Expand Up @@ -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<String, Long> features = mapper.readValue(featuresString, new TypeReference<Map<String, Long>>() {});
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"));
}

}

0 comments on commit 6cfa5e8

Please sign in to comment.