Class RequestBundle

java.lang.Object
co.ecg.alpaca.toolkit.messaging.request.RequestBundle
All Implemented Interfaces:
Supplier<ResponseBundle>

@Component @Scope("prototype") public class RequestBundle extends Object implements Supplier<ResponseBundle>
The Request Bundle object represents a group of Requests sent to the BroadWorks Server. These are bundled into a single XML request and returned as a bundle. The number of requests in a bundle is limited to 15 due to BroadWorks limitation.
Author:
Matthew Keathley
  • Constructor Details

    • RequestBundle

      @Autowired public RequestBundle(LibraryProperties libraryProperties)
  • Method Details

    • addRequest

      public void addRequest(Request<?> request) throws RequestException
      Adds a new request to the bundle
      Parameters:
      request - The Request to be added.
      Throws:
      RequestException - Thrown if the Request is invalid or the bundle is too large.
    • createDocument

      public void createDocument(BroadWorksServer broadWorksServer, Request.Protocol protocol)
      Creates the XML DOM Document for this request bundle. This is typically called during Request object creation.
      Parameters:
      broadWorksServer - The BroadWorksServer for this RequestBundle
      protocol - The Protocol to user for this RequestBundle
    • fire

      public ResponseBundle fire() throws RequestException
      This generates a Response object from a Request. It reads from the cache if available.
      Throws:
      RequestException - Thrown if an error occurs while sending this bundle to BroadWorks.
    • send

      public Future<String> send()
      This generates a Future message from a Request.
    • send

      public String send(OCSClient ocsClient)
      This generates a String message from a Request through the given OCSClient.
      Parameters:
      ocsClient - The OCSClient to send the request through.
    • execute

      public ResponseBundle execute(OCSClient ocsClient, String responseString) throws RequestException
      This generates a Response object from a Request.
      Parameters:
      ocsClient - Specify the OCSClient to send this request bundle. If NULL the OCSSwitchboard is used.
      responseString - The response string if the request has already been sent
      Throws:
      RequestException - Thrown if an error occurs while sending this bundle to BroadWorks.
    • formRequest

      public void formRequest(boolean readFromCache)
      Forms the RequestBundle
      Parameters:
      readFromCache - Enables reading from the JCS cache for retrieving the response. Defaults to 'true'.
    • getBroadWorksServer

      public BroadWorksServer getBroadWorksServer()
    • setBroadWorksServer

      public void setBroadWorksServer(BroadWorksServer bws)
    • getBroadWorksServerForRequest

      public BroadWorksServer getBroadWorksServerForRequest()
    • getRequestBundle

      public List<Request<?>> getRequestBundle()
    • setHandler

      public void setHandler(ResponseBundleHandler handler)
    • getResponseFuture

      public Future<String> getResponseFuture()
    • setResponseFuture

      public void setResponseFuture(Future<String> responseFuture)
    • getOCSProtocol

      public Request.Protocol getOCSProtocol()
      Get the OCS protocol
      Returns:
      The OCS protocol enum
    • isFull

      public boolean isFull()
      Checks if the Request Bundle can hold any more elements
      Returns:
      Returns true if the size of the bundle is greater or equal to 15.
    • isValid

      public boolean isValid()
      Returns True if the Request has no constraint violations
      Returns:
      Return true if there are no validation errors for requests in the bundle.
    • toString

      public String toString()
      The RequestBundle as transformed into the expected XML message
      Overrides:
      toString in class Object
      Returns:
      The XML representation of this Request
    • validate

      public Set<javax.validation.ConstraintViolation<Request<?>>> validate()
      Returns the set of Constraint Violations for the RequestBundle.
      Returns:
      Returns the set of constraint violations for all requests in the bundle.
    • get

      public ResponseBundle get()
      Specified by:
      get in interface Supplier<ResponseBundle>