diff --git a/jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluginApiRequest.java b/jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluggableApiRequest.java similarity index 77% rename from jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluginApiRequest.java rename to jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluggableApiRequest.java index b7fdd5099..eac66aae3 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluginApiRequest.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluggableApiRequest.java @@ -10,16 +10,10 @@ * @author conwaymc * */ -public abstract class PluginApiRequest { +public abstract class PluggableApiRequest { // api number // // AtomicMetadataResponse resp = execApi() - /** - * - */ - public PluginApiRequest() { - } - } diff --git a/jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluginApiResponse.java b/jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluggableApiResponse.java similarity index 62% rename from jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluginApiResponse.java rename to jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluggableApiResponse.java index 8ef7df8f1..4ae21b250 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluginApiResponse.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/apiplugin/PluggableApiResponse.java @@ -9,12 +9,6 @@ * @author conwaymc * */ -public abstract class PluginApiResponse { - - /** - * - */ - public PluginApiResponse() { - } +public abstract class PluggableApiResponse { } diff --git a/jargon-core/src/main/java/org/irods/jargon/core/packinstr/BytesBuff.java b/jargon-core/src/main/java/org/irods/jargon/core/packinstr/BytesBuff.java index b8e1471aa..83450618c 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/packinstr/BytesBuff.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/packinstr/BytesBuff.java @@ -20,16 +20,17 @@ public class BytesBuff extends AbstractIRODSPackingInstruction { private final String buffer; - public static final BytesBuff instance(final String buffer) throws JargonException { - return new BytesBuff(buffer); + public static final BytesBuff instance(final String buffer, final int apiNumber) throws JargonException { + return new BytesBuff(buffer, apiNumber); } - private BytesBuff(final String buffer) throws JargonException { + private BytesBuff(final String buffer, final int apiNumber) throws JargonException { super(); if (buffer == null) { throw new JargonException("buffer is null"); } this.buffer = buffer; + this.setApiNumber(apiNumber); } @Override diff --git a/jargon-core/src/main/java/org/irods/jargon/core/pub/ApiPluginExecutorImpl.java b/jargon-core/src/main/java/org/irods/jargon/core/pub/ApiPluginExecutorImpl.java index a51a43b00..7116e4203 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/pub/ApiPluginExecutorImpl.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/pub/ApiPluginExecutorImpl.java @@ -3,9 +3,14 @@ */ package org.irods.jargon.core.pub; +import org.irods.jargon.core.apiplugin.PluggableApiRequest; +import org.irods.jargon.core.apiplugin.PluggableApiResponse; import org.irods.jargon.core.connection.IRODSAccount; import org.irods.jargon.core.connection.IRODSSession; import org.irods.jargon.core.exception.JargonException; +import org.irods.jargon.core.packinstr.BytesBuff; +import org.irods.jargon.core.packinstr.Tag; +import org.irods.jargon.core.pub.domain.ObjStat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,7 +21,7 @@ * @author conwaymc * */ -class ApiPluginExecutorImpl extends IRODSGenericAO { +class ApiPluginExecutorImpl extends IRODSGenericAO { private static Logger log = LoggerFactory.getLogger(ApiPluginExecutorImpl.class); private ObjectMapper mapper = new ObjectMapper(); @@ -30,22 +35,31 @@ public ApiPluginExecutorImpl(IRODSSession irodsSession, IRODSAccount irodsAccoun super(irodsSession, irodsAccount); } - public OutputType callPluggableApi(int apiNumber, InputType input) throws JargonException { + public O callPluggableApi(int apiNumber, I request) throws JargonException { log.info("callPluggableApi())"); + if (apiNumber <= 0) { throw new IllegalArgumentException("invalid api number"); } - if (input == null) { + + if (request == null) { throw new IllegalArgumentException("null input"); } log.info("apiNumber:{}", apiNumber); - log.info("input:{}", input); + log.info("input:{}", request); try { - String jsonInput = mapper.writeValueAsString(input); + String jsonInput = mapper.writeValueAsString(request); log.debug("jsonInput:{}", jsonInput); - return (OutputType) new Object(); // FIXME: temp shim + BytesBuff bytesBuff = BytesBuff.instance(jsonInput, apiNumber); + Tag response; + ObjStat objStat; + response = this.getIRODSAccessObjectFactory().getIrodsSession().currentConnection(this.getIRODSAccount()) + .irodsFunction(bytesBuff); + + log.debug("response from objStat: {}", response.parseTag()); + return null; } catch (JsonProcessingException e) { log.error("Invalid json", e); diff --git a/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/domain/AtomicMetadataOperation.java b/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/AtomicMetadataOperation.java similarity index 96% rename from jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/domain/AtomicMetadataOperation.java rename to jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/AtomicMetadataOperation.java index de7eba694..6c50af350 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/domain/AtomicMetadataOperation.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/AtomicMetadataOperation.java @@ -1,7 +1,7 @@ /** * */ -package org.irods.jargon.core.pub.apiplugin.domain; +package org.irods.jargon.core.pub.apiplugin.atomicmetadata; import com.fasterxml.jackson.annotation.JsonGetter; diff --git a/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/domain/AtomicMetadataInput.java b/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/AtomicMetadataRequest.java similarity index 80% rename from jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/domain/AtomicMetadataInput.java rename to jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/AtomicMetadataRequest.java index d0899960c..8adbb7255 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/domain/AtomicMetadataInput.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/AtomicMetadataRequest.java @@ -1,11 +1,13 @@ /** * */ -package org.irods.jargon.core.pub.apiplugin.domain; +package org.irods.jargon.core.pub.apiplugin.atomicmetadata; import java.util.ArrayList; import java.util.List; +import org.irods.jargon.core.apiplugin.PluggableApiRequest; + import com.fasterxml.jackson.annotation.JsonGetter; /** @@ -14,7 +16,7 @@ * @author conwaymc * */ -public class AtomicMetadataInput { +public class AtomicMetadataRequest extends PluggableApiRequest { /** * Name of the entity (e.g. path) to be decorated as {@code String} @@ -27,14 +29,14 @@ public class AtomicMetadataInput { /** * Individual metadata operations as - * {@link AtomicMetadataInput.AtomicMetadataOperation} + * {@link AtomicMetadataRequest.AtomicMetadataOperation} */ private List operations = new ArrayList<>(); /** * */ - public AtomicMetadataInput() { + public AtomicMetadataRequest() { } @JsonGetter("entity_name") diff --git a/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/AtomicMetadataResponse.java b/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/AtomicMetadataResponse.java new file mode 100644 index 000000000..10bc6f844 --- /dev/null +++ b/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/AtomicMetadataResponse.java @@ -0,0 +1,7 @@ +package org.irods.jargon.core.pub.apiplugin.atomicmetadata; + +import org.irods.jargon.core.apiplugin.PluggableApiResponse; + +public class AtomicMetadataResponse extends PluggableApiResponse { + +} diff --git a/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/domain/package-info.java b/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/package-info.java similarity index 62% rename from jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/domain/package-info.java rename to jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/package-info.java index be0ac64a8..0d334eed1 100644 --- a/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/domain/package-info.java +++ b/jargon-core/src/main/java/org/irods/jargon/core/pub/apiplugin/atomicmetadata/package-info.java @@ -5,4 +5,4 @@ * @author conwaymc * */ -package org.irods.jargon.core.pub.apiplugin.domain; \ No newline at end of file +package org.irods.jargon.core.pub.apiplugin.atomicmetadata; \ No newline at end of file diff --git a/jargon-core/src/test/java/org/irods/jargon/core/pub/ApiPluginExecutorImplTest.java b/jargon-core/src/test/java/org/irods/jargon/core/pub/ApiPluginExecutorImplTest.java deleted file mode 100644 index a411fde68..000000000 --- a/jargon-core/src/test/java/org/irods/jargon/core/pub/ApiPluginExecutorImplTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.irods.jargon.core.pub; - -import java.util.Properties; - -import org.irods.jargon.core.apiplugin.TestPluggableInput; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.connection.IRODSSession; -import org.irods.jargon.core.connection.JargonProperties; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.testutils.AssertionHelper; -import org.irods.jargon.testutils.IRODSTestSetupUtilities; -import org.irods.jargon.testutils.TestingPropertiesHelper; -import org.irods.jargon.testutils.filemanip.ScratchFileUtils; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; - -public class ApiPluginExecutorImplTest { - - private static Properties testingProperties = new Properties(); - private static TestingPropertiesHelper testingPropertiesHelper = new TestingPropertiesHelper(); - private static ScratchFileUtils scratchFileUtils = null; - public static final String IRODS_TEST_SUBDIR_PATH = "ApiPluginExecutorImplTest"; - private static IRODSTestSetupUtilities irodsTestSetupUtilities = null; - private static AssertionHelper assertionHelper = null; - private static IRODSFileSystem irodsFileSystem; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper(); - testingProperties = testingPropertiesLoader.getTestProperties(); - scratchFileUtils = new ScratchFileUtils(testingProperties); - scratchFileUtils.clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH); - irodsTestSetupUtilities = new IRODSTestSetupUtilities(); - irodsTestSetupUtilities.initializeIrodsScratchDirectory(); - irodsTestSetupUtilities.initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH); - assertionHelper = new AssertionHelper(); - irodsFileSystem = IRODSFileSystem.instance(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - irodsFileSystem.closeAndEatExceptions(); - } - - @After - public void afterEach() throws Exception { - irodsFileSystem.closeAndEatExceptions(); - } - - @Test - public void testCallPluggableApi() throws JargonException { - IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAdminAccountFromTestProperties(testingProperties); - IRODSSession irodsSession = Mockito.mock(IRODSSession.class); - JargonProperties properties = irodsFileSystem.getJargonProperties(); - Mockito.when(irodsSession.getJargonProperties()).thenReturn(properties); - ApiPluginExecutorImpl impl = new ApiPluginExecutorImpl<>(irodsSession, - irodsAccount); - TestPluggableInput input = new TestPluggableInput(); - Object actual = impl.callPluggableApi(1, input); - Assert.assertNotNull("null output", actual); - - } - -} diff --git a/jargon-core/src/test/java/org/irods/jargon/core/pub/apiplugin/domain/AtomicMetadataInputTest.java b/jargon-core/src/test/java/org/irods/jargon/core/pub/apiplugin/domain/AtomicMetadataInputTest.java index 9d7e3d26f..8e1855003 100644 --- a/jargon-core/src/test/java/org/irods/jargon/core/pub/apiplugin/domain/AtomicMetadataInputTest.java +++ b/jargon-core/src/test/java/org/irods/jargon/core/pub/apiplugin/domain/AtomicMetadataInputTest.java @@ -3,6 +3,8 @@ import java.util.Properties; import org.irods.jargon.core.pub.IRODSFileSystem; +import org.irods.jargon.core.pub.apiplugin.atomicmetadata.AtomicMetadataOperation; +import org.irods.jargon.core.pub.apiplugin.atomicmetadata.AtomicMetadataRequest; import org.irods.jargon.testutils.AssertionHelper; import org.irods.jargon.testutils.IRODSTestSetupUtilities; import org.irods.jargon.testutils.TestingPropertiesHelper; @@ -53,7 +55,7 @@ public void afterEach() throws Exception { public void testCreateJsonRequest() throws Exception { String entityName = "entityName"; String entityType = "collection"; - AtomicMetadataInput atomicMetadataInput = new AtomicMetadataInput(); + AtomicMetadataRequest atomicMetadataInput = new AtomicMetadataRequest(); atomicMetadataInput.setEntityName(entityName); atomicMetadataInput.setEntityType(entityType); @@ -67,7 +69,7 @@ public void testCreateJsonRequest() throws Exception { String actual = mapper.writeValueAsString(atomicMetadataInput); Assert.assertNotNull("null atomicMetadataInput", atomicMetadataInput); - AtomicMetadataInput remapped = mapper.readValue(actual, AtomicMetadataInput.class); + AtomicMetadataRequest remapped = mapper.readValue(actual, AtomicMetadataRequest.class); Assert.assertNotNull("did not get remapped object back", remapped); } diff --git a/jargon-core/src/test/java/org/irods/jargon/core/unittest/AOTests.java b/jargon-core/src/test/java/org/irods/jargon/core/unittest/AOTests.java index 877639d4b..4055644a1 100644 --- a/jargon-core/src/test/java/org/irods/jargon/core/unittest/AOTests.java +++ b/jargon-core/src/test/java/org/irods/jargon/core/unittest/AOTests.java @@ -1,6 +1,5 @@ package org.irods.jargon.core.unittest; -import org.irods.jargon.core.pub.ApiPluginExecutorImplTest; import org.irods.jargon.core.pub.BulkFileOperationsAOImplTest; import org.irods.jargon.core.pub.CollectionAOImplForSoftLinkTest; import org.irods.jargon.core.pub.CollectionAOImplTest; @@ -80,7 +79,7 @@ IRODSFileSystemSingletonWrapperTest.class, ResourceAOHelperTest.class, CollectionPagerAOImplTest.class, DataObjectChecksumUtilitiesAOImplTest.class, CollectionListingUtilsTest.class, FederatedDataObjectAOImplTest.class, DataObjectChecksumUtilitiesAOImplTest.class, TrashOperationsTest.class, - TrashOperationsAOImplTest.class, FederatedUserGroupAOTest.class, ApiPluginExecutorImplTest.class }) + TrashOperationsAOImplTest.class, FederatedUserGroupAOTest.class }) /** * Suite to run Access Object tests in org.irods.jargon.pub.*