Class AbstractEventPublisher

java.lang.Object
org.gcube.event.publisher.AbstractEventPublisher
All Implemented Interfaces:
EventPublisher

public abstract class AbstractEventPublisher extends Object implements EventPublisher
  • Field Details

    • logger

      protected static final org.slf4j.Logger logger
  • Constructor Details

    • AbstractEventPublisher

      public AbstractEventPublisher()
  • Method Details

    • publish

      public void publish(Event event)
      Description copied from interface: EventPublisher
      Publish a new event and nothing more. The sender is not interested to the success/failure of the send. The results on the workflow engine, is the start of an instance of the workflow identified by the Event.getName() string.
      Specified by:
      publish in interface EventPublisher
      Parameters:
      event - the event to be published
    • publish

      public String publish(Event event, boolean waitForResult)
      Description copied from interface: EventPublisher
      Publishes a new event and optionally wait for the result. If waitForResult parameter is false the behavior is the same of the EventPublisher.publish(Event) method, if true, the workflow id is returned as string if the publish had success.
      Specified by:
      publish in interface EventPublisher
      Parameters:
      event - the vent to be published
      waitForResult - if the sender is interested or not to the resulting workflow id
      Returns:
      the resulting workflow id
    • isLastPublishOK

      public boolean isLastPublishOK()
      Description copied from interface: EventPublisher
      Tells if the last publish was a success or not.
      Specified by:
      isLastPublishOK in interface EventPublisher
      Returns:
      true if the publish was OK, false otherwise
    • getLastPublishEventHTTPResponseCode

      public int getLastPublishEventHTTPResponseCode()
      Description copied from interface: EventPublisher
      Returns the last returned HTTP response code of a publish. E.g. 200 if the send was OK or 404 if the event doesn't have a corresponding workflow definition.
      Specified by:
      getLastPublishEventHTTPResponseCode in interface EventPublisher
      Returns:
      the HTTP response code of the last publish or -1 if an error occurred before the call (e.g. during the authorization or connection)
    • publishAndCheck

      public EventStatus publishAndCheck(Event event)
      Description copied from interface: EventPublisher
      Publish an event and immediately checks for the results status. The behavior is the same of the EventPublisher.publishAndCheck(Event, int) with delayMS argument less or equal to 0.
      Specified by:
      publishAndCheck in interface EventPublisher
      Parameters:
      event - the event to be published
      Returns:
      an object with info about the event's running status
    • publishAndCheck

      public EventStatus publishAndCheck(Event event, int delayMS)
      Description copied from interface: EventPublisher
      Publish an event and checks for the results status after a delay. The behavior is the same of the EventPublisher.publishAndCheck(Event) if delayMS argument is less or equal to 0.
      Specified by:
      publishAndCheck in interface EventPublisher
      Parameters:
      event - the event to be published
      delayMS - the delay betwen the publish and the query calls
      Returns:
      an object with info about the event's running status
    • check

      public EventStatus check(String instanceId)
      Description copied from interface: EventPublisher
      Checks for the workflow results status.
      Specified by:
      check in interface EventPublisher
      Parameters:
      instanceId - the workflow instance id, resulting of the EventPublisher.publish(Event, boolean) with waitForResult as true.
      Returns:
      an object with info about the event's running status
    • refresh

      public EventStatus refresh(EventStatus eventStatus)
      Description copied from interface: EventPublisher
      Refreshes an event status by checking for the status of the workflow execution represented by the EventStatus.getInstanceId() string.
      Specified by:
      refresh in interface EventPublisher
      Parameters:
      eventStatus - a previously obtained event status.
      Returns:
      an object with new info about the event's running status
    • isLastCheckOK

      public boolean isLastCheckOK()
      Description copied from interface: EventPublisher
      Tells if the last check was a success or not.
      Specified by:
      isLastCheckOK in interface EventPublisher
      Returns:
      true if the publish was OK, false otherwise
    • getLastCheckHTTPResponseCode

      public int getLastCheckHTTPResponseCode()
      Description copied from interface: EventPublisher
      Returns the last returned HTTP response code of a check. E.g. 200 if the send was OK or 404 if the event doesn't have a corresponding workflow instance.
      Specified by:
      getLastCheckHTTPResponseCode in interface EventPublisher
      Returns:
      the HTTP response code of the last publish or -1 if an error occurred before the call (e.g. during the authorization or connection)
    • createEventSender

      protected abstract EventSender createEventSender()
    • createResultsParser

      protected ResultsParser createResultsParser()
    • getEventSender

      public EventSender getEventSender()
    • setEventSender

      public void setEventSender(EventSender eventSender)
    • getResultsParser

      public ResultsParser getResultsParser()
    • setResultsParser

      public void setResultsParser(ResultsParser resultsParser)