protected function buildPath()
{
$bucket = null;
$key = '';
$bucket = $this->command->getBucket();
$location = $this->command->getLocation();
if (!empty($location) && $location instanceof Location) {
$key = $location->getKey();
}
switch (get_class($this->command)) {
case 'Basho\\Riak\\Command\\Bucket\\List':
$this->path = sprintf('/types/%s/buckets/%s', $bucket->getType(), $bucket->getName());
break;
/** @noinspection PhpMissingBreakStatementInspection */
/** @noinspection PhpMissingBreakStatementInspection */
case 'Basho\\Riak\\Command\\Bucket\\Store':
$this->headers[static::CONTENT_TYPE_KEY] = static::CONTENT_TYPE_JSON;
case 'Basho\\Riak\\Command\\Bucket\\Fetch':
case 'Basho\\Riak\\Command\\Bucket\\Delete':
$this->path = sprintf('/types/%s/buckets/%s/props', $bucket->getType(), $bucket->getName());
break;
case 'Basho\\Riak\\Command\\Bucket\\Keys':
$this->path = sprintf('/types/%s/buckets/%s/keys', $bucket->getType(), $bucket->getName());
break;
/** @noinspection PhpMissingBreakStatementInspection */
/** @noinspection PhpMissingBreakStatementInspection */
case 'Basho\\Riak\\Command\\Object\\Fetch':
$this->headers['Accept'] = '*/*, multipart/mixed';
case 'Basho\\Riak\\Command\\Object\\Store':
case 'Basho\\Riak\\Command\\Object\\Delete':
$this->path = sprintf('/types/%s/buckets/%s/keys/%s', $bucket->getType(), $bucket->getName(), $key);
break;
case 'Basho\\Riak\\Command\\DataType\\Counter\\Store':
case 'Basho\\Riak\\Command\\DataType\\Set\\Store':
/** @noinspection PhpMissingBreakStatementInspection */
/** @noinspection PhpMissingBreakStatementInspection */
case 'Basho\\Riak\\Command\\DataType\\Map\\Store':
case 'Basho\\Riak\\Command\\DataType\\Hll\\Store':
$this->headers[static::CONTENT_TYPE_KEY] = static::CONTENT_TYPE_JSON;
case 'Basho\\Riak\\Command\\DataType\\Counter\\Fetch':
case 'Basho\\Riak\\Command\\DataType\\Set\\Fetch':
case 'Basho\\Riak\\Command\\DataType\\Map\\Fetch':
case 'Basho\\Riak\\Command\\DataType\\Hll\\Fetch':
$this->path = sprintf('/types/%s/buckets/%s/datatypes/%s', $bucket->getType(), $bucket->getName(), $key);
break;
/** @noinspection PhpMissingBreakStatementInspection */
/** @noinspection PhpMissingBreakStatementInspection */
case 'Basho\\Riak\\Command\\Search\\Index\\Store':
$this->headers[static::CONTENT_TYPE_KEY] = static::CONTENT_TYPE_JSON;
case 'Basho\\Riak\\Command\\Search\\Index\\Fetch':
case 'Basho\\Riak\\Command\\Search\\Index\\Delete':
$this->path = sprintf('/search/index/%s', $this->command);
break;
/** @noinspection PhpMissingBreakStatementInspection */
/** @noinspection PhpMissingBreakStatementInspection */
case 'Basho\\Riak\\Command\\Search\\Schema\\Store':
$this->headers[static::CONTENT_TYPE_KEY] = static::CONTENT_TYPE_XML;
case 'Basho\\Riak\\Command\\Search\\Schema\\Fetch':
$this->path = sprintf('/search/schema/%s', $this->command);
break;
case 'Basho\\Riak\\Command\\Search\\Fetch':
$this->path = sprintf('/search/query/%s', $this->command);
break;
case 'Basho\\Riak\\Command\\MapReduce\\Fetch':
$this->headers[static::CONTENT_TYPE_KEY] = static::CONTENT_TYPE_JSON;
$this->path = sprintf('/%s', $this->config['mapred_prefix']);
break;
case 'Basho\\Riak\\Command\\Indexes\\Query':
$this->path = $this->createIndexQueryPath($bucket);
break;
case 'Basho\\Riak\\Command\\Ping':
$this->path = '/ping';
break;
case 'Basho\\Riak\\Command\\Stats':
$this->path = '/stats';
break;
case 'Basho\\Riak\\Command\\Object\\FetchPreflist':
$this->path = sprintf('/types/%s/buckets/%s/keys/%s/preflist', $bucket->getType(), $bucket->getName(), $key);
break;
case 'Basho\\Riak\\Command\\TimeSeries\\Fetch':
case 'Basho\\Riak\\Command\\TimeSeries\\Delete':
/** @var $command Command\TimeSeries\Fetch */
$command = $this->command;
$this->path = sprintf('%s/tables/%s/keys/%s', static::TS_API_PREFIX, $command->getTable(), implode("/", $command->getData()));
break;
case 'Basho\\Riak\\Command\\TimeSeries\\Store':
/** @var $command Command\TimeSeries\Store */
$command = $this->command;
$this->path = sprintf('%s/tables/%s/keys', static::TS_API_PREFIX, $command->getTable());
break;
case 'Basho\\Riak\\Command\\TimeSeries\\Query\\Fetch':
$this->path = sprintf('%s/query', static::TS_API_PREFIX);
break;
default:
$this->path = '';
}
return $this;
}