Esempio n. 1
0
 /**
  * Prepare request to be sent
  *
  * @param Command $command
  * @param Node $node
  *
  * @return $this
  */
 public function prepare(Command $command, Node $node)
 {
     // call parent prepare method to setup object members
     parent::prepare($command, $node);
     if ($this->connection === null) {
         $this->openConnection();
     }
     // determine message code and build message content
     $this->prepareMessage();
     return $this;
 }
Esempio n. 2
0
 /**
  * Prepare request to be sent
  *
  * @param Command $command
  * @param Node $node
  *
  * @return $this
  */
 public function prepare(Command $command, Node $node)
 {
     if ($this->connection) {
         $this->resetConnection();
     }
     // call parent prepare method to setup object members
     parent::prepare($command, $node);
     // set the API path to be used
     $this->buildPath();
     // general connection preparation
     $this->prepareConnection();
     // request specific connection preparation
     $this->prepareRequest();
     return $this;
 }
Esempio n. 3
0
 /**
  * @param Command $command
  * @param Api $api
  *
  * @return Command\Response
  * @throws Exception
  */
 public function execute(Command $command, Api $api)
 {
     $success = $api->prepare($command, $this)->send();
     if ($success === FALSE) {
         return false;
     }
     return $api->getResponse();
 }
Esempio n. 4
0
 /**
  * Accessor for the last request issued to the API. For debugging purposes.
  *
  * @return string
  */
 public function getLastRequest()
 {
     return $this->api->getRequest();
 }
Esempio n. 5
0
 /**
  * @param Command $command
  * @param Api $api
  *
  * @return Command\Response
  * @throws Exception
  */
 public function execute(Command $command, Api $api)
 {
     $success = $api->prepare($command, $this)->send();
     if ($success === FALSE) {
         throw new Exception('Command failed to execute against Riak. Error Msg: ' . $api->getError());
     }
     $command->setResponse($api->getStatusCode(), $api->getResponseHeaders(), $api->getResponseBody());
     return $command->getResponse();
 }