From 471a056694b84fbaa3d8822d8e46de58835679c6 Mon Sep 17 00:00:00 2001 From: michael-conway Date: Fri, 27 May 2016 04:19:47 -0700 Subject: [PATCH] #2 add dummy publish mech --- .../publish/dummy/DummyPublishMechanism.java | 82 +++++++++++++++++++ .../de/publish/dummy/package-info.java | 9 ++ .../publish/mechanism/api/PublishResult.java | 2 + 3 files changed, 93 insertions(+) create mode 100644 dummy-publish/src/main/java/og/iplantc/de/publish/dummy/DummyPublishMechanism.java create mode 100644 dummy-publish/src/main/java/og/iplantc/de/publish/dummy/package-info.java diff --git a/dummy-publish/src/main/java/og/iplantc/de/publish/dummy/DummyPublishMechanism.java b/dummy-publish/src/main/java/og/iplantc/de/publish/dummy/DummyPublishMechanism.java new file mode 100644 index 0000000..0ef63a5 --- /dev/null +++ b/dummy-publish/src/main/java/og/iplantc/de/publish/dummy/DummyPublishMechanism.java @@ -0,0 +1,82 @@ +/** + * + */ +package og.iplantc.de.publish.dummy; + +import org.iplantc.de.publish.mechanism.api.PublishActionDescriptor; +import org.iplantc.de.publish.mechanism.api.PublishContext; +import org.iplantc.de.publish.mechanism.api.PublishMechanism; +import org.iplantc.de.publish.mechanism.api.PublishPhaseEnum; +import org.iplantc.de.publish.mechanism.api.PublishResult; +import org.iplantc.de.publish.mechanism.api.PublishStatusEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Simple noop publish mechanism for testing and demonstration + * + * @author Mike Conway - DICE + * + */ +public class DummyPublishMechanism implements PublishMechanism { + + public static final Logger log = LoggerFactory + .getLogger(DummyPublishMechanism.class); + + /** + * + */ + public DummyPublishMechanism() { + } + + /* + * (non-Javadoc) + * + * @see + * org.iplantc.de.publish.mechanism.api.PublishMechanism#preValidate(org + * .iplantc.de.publish.mechanism.api.PublishActionDescriptor, + * org.iplantc.de.publish.mechanism.api.PublishContext) + */ + @Override + public PublishResult preValidate( + PublishActionDescriptor publishActionDescriptor, + PublishContext publishContext) { + + log.info("preValidate()"); + log.info("publishActionDescriptor:{}", publishActionDescriptor); + log.info("publishContext:{}", publishContext); + PublishResult publishResult = new PublishResult(); + publishResult.setPublishStatus(PublishStatusEnum.SUBMITTED); + publishResult.setResponseCode(PublishResult.PUBLISH_RESULT_NORMAL); + publishResult.setResponseMessage("preValidate successful"); + publishResult.setPublishPhase(PublishPhaseEnum.PRE_VALIDATE); + return publishResult; + + } + + /* + * (non-Javadoc) + * + * @see + * org.iplantc.de.publish.mechanism.api.PublishMechanism#publish(org.iplantc + * .de.publish.mechanism.api.PublishActionDescriptor, + * org.iplantc.de.publish.mechanism.api.PublishContext) + */ + @Override + public PublishResult publish( + PublishActionDescriptor publishActionDescriptor, + PublishContext publishContext) { + + log.info("publish()"); + log.info("publishActionDescriptor:{}", publishActionDescriptor); + log.info("publishContext:{}", publishContext); + PublishResult publishResult = new PublishResult(); + publishResult.setPublishStatus(PublishStatusEnum.SUBMITTED); + publishResult.setResponseCode(PublishResult.PUBLISH_RESULT_NORMAL); + publishResult.setResponseMessage("publish successful"); + publishResult.setPublishPhase(PublishPhaseEnum.PUBLISH); + return publishResult; + + } + +} diff --git a/dummy-publish/src/main/java/og/iplantc/de/publish/dummy/package-info.java b/dummy-publish/src/main/java/og/iplantc/de/publish/dummy/package-info.java new file mode 100644 index 0000000..e3d8819 --- /dev/null +++ b/dummy-publish/src/main/java/og/iplantc/de/publish/dummy/package-info.java @@ -0,0 +1,9 @@ +/** + * + */ +/** + * Base dummy publisher for testing and demonstration + * @author Mike Conway - DICE + * + */ +package og.iplantc.de.publish.dummy; \ No newline at end of file diff --git a/publisher-api/src/main/java/org/iplantc/de/publish/mechanism/api/PublishResult.java b/publisher-api/src/main/java/org/iplantc/de/publish/mechanism/api/PublishResult.java index b359388..bfbb8ca 100644 --- a/publisher-api/src/main/java/org/iplantc/de/publish/mechanism/api/PublishResult.java +++ b/publisher-api/src/main/java/org/iplantc/de/publish/mechanism/api/PublishResult.java @@ -16,6 +16,8 @@ */ public class PublishResult { + public static final int PUBLISH_RESULT_NORMAL = 0; + /** * Represents the phase of the publishing cycle that this response pertains * to