From 5eddebb09d0d8db946167f3f9aff0f6f9479c44a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 5 Jul 2011 14:26:45 +0200 Subject: [PATCH] Review of code for Zend\Service\Rackspace --- library/Zend/Service/Rackspace/Files.php | 179 ++++++++-------- .../Service/Rackspace/Files/Container.php | 199 +++++++++--------- .../Service/Rackspace/Files/ContainerList.php | 28 +-- .../Zend/Service/Rackspace/Files/Object.php | 132 +++++++----- .../Service/Rackspace/Files/ObjectList.php | 34 +-- library/Zend/Service/Rackspace/Rackspace.php | 40 ++-- library/Zend/Service/Rackspace/Servers.php | 56 ++--- .../Zend/Service/Rackspace/Servers/Server.php | 3 +- tests/TestConfiguration.php.dist | 2 +- tests/Zend/Service/Rackspace/OfflineTest.php | 2 +- 10 files changed, 353 insertions(+), 322 deletions(-) diff --git a/library/Zend/Service/Rackspace/Files.php b/library/Zend/Service/Rackspace/Files.php index a4a47b5dd60..e7c368db419 100644 --- a/library/Zend/Service/Rackspace/Files.php +++ b/library/Zend/Service/Rackspace/Files.php @@ -22,12 +22,7 @@ namespace Zend\Service\Rackspace; use Zend\Service\Rackspace\Rackspace as RackspaceAbstract, - Zend\Service\Rackspace\Files\Container, - Zend\Service\Rackspace\Files\ContainerList, - Zend\Service\Rackspace\Files\Object, - Zend\Service\Rackspace\Files\ObjectList, - Zend\Http\Client as HttpClient, - Zend\Service\Rackspace\Exception\InvalidArgumentException; + Zend\Http\Client as HttpClient; class Files extends RackspaceAbstract { @@ -72,15 +67,15 @@ class Files extends RackspaceAbstract /** * @var integer */ - protected $_countContainers; + protected $countContainers; /** * @var integer */ - protected $_sizeContainers; + protected $sizeContainers; /** * @var integer */ - protected $_countObjects; + protected $countObjects; /** * Return the total count of containers * @@ -88,10 +83,10 @@ class Files extends RackspaceAbstract */ public function getCountContainers() { - if (!isset($this->_countContainers)) { + if (!isset($this->countContainers)) { $this->getInfoContainers(); } - return $this->_countContainers; + return $this->countContainers; } /** * Return the size in bytes of all the containers @@ -100,10 +95,10 @@ public function getCountContainers() */ public function getSizeContainers() { - if (!isset($this->_sizeContainers)) { + if (!isset($this->sizeContainers)) { $this->getInfoContainers(); } - return $this->_sizeContainers; + return $this->sizeContainers; } /** * Return the count of objects contained in all the containers @@ -112,10 +107,10 @@ public function getSizeContainers() */ public function getCountObjects() { - if (!isset($this->_countObjects)) { + if (!isset($this->countObjects)) { $this->getInfoContainers(); } - return $this->_countObjects; + return $this->countObjects; } /** * Get all the containers @@ -127,10 +122,10 @@ public function getContainers($options=array()) { $result= $this->httpCall($this->getStorageUrl(),HttpClient::GET,null,$options); if ($result->isSuccessful()) { - $this->_countContainers= $result->getHeader(self::ACCOUNT_CONTAINER_COUNT); - $this->_sizeContainers= $result->getHeader(self::ACCOUNT_BYTES_USED); - $this->_countObjects= $result->getHeader(self::ACCOUNT_OBJ_COUNT); - return new ContainerList($this,json_decode($result->getBody(),true)); + $this->countContainers= $result->getHeader(self::ACCOUNT_CONTAINER_COUNT); + $this->sizeContainers= $result->getHeader(self::ACCOUNT_BYTES_USED); + $this->countObjects= $result->getHeader(self::ACCOUNT_OBJ_COUNT); + return new Files\ContainerList($this,json_decode($result->getBody(),true)); } return false; } @@ -145,7 +140,7 @@ public function getCdnContainers($options=array()) $options['enabled_only']= true; $result= $this->httpCall($this->getCdnUrl(),HttpClient::GET,null,$options); if ($result->isSuccessful()) { - return new ContainerList($this,json_decode($result->getBody(),true)); + return new Files\ContainerList($this,json_decode($result->getBody(),true)); } return false; } @@ -161,13 +156,13 @@ public function getInfoContainers() { $result= $this->httpCall($this->getStorageUrl(),HttpClient::HEAD); if ($result->isSuccessful()) { - $this->_countContainers= $result->getHeader(self::ACCOUNT_CONTAINER_COUNT); - $this->_sizeContainers= $result->getHeader(self::ACCOUNT_BYTES_USED); - $this->_countObjects= $result->getHeader(self::ACCOUNT_OBJ_COUNT); + $this->countContainers= $result->getHeader(self::ACCOUNT_CONTAINER_COUNT); + $this->sizeContainers= $result->getHeader(self::ACCOUNT_BYTES_USED); + $this->countObjects= $result->getHeader(self::ACCOUNT_OBJ_COUNT); $output= array( - 'tot_containers' => $this->_countContainers, - 'size_containers' => $this->_sizeContainers, - 'tot_objects' => $this->_countObjects + 'tot_containers' => $this->countContainers, + 'size_containers' => $this->sizeContainers, + 'tot_objects' => $this->countObjects ); return $output; } @@ -183,11 +178,11 @@ public function getInfoContainers() public function getObjects($container,$options=array()) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } $result= $this->httpCall($this->getStorageUrl().'/'.rawurlencode($container),HttpClient::GET,null,$options); if ($result->isSuccessful()) { - return new ObjectList($this,json_decode($result->getBody(),true),$container); + return new Files\ObjectList($this,json_decode($result->getBody(),true),$container); } return false; } @@ -201,7 +196,7 @@ public function getObjects($container,$options=array()) public function createContainer($container,$metadata=array()) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } $headers=array(); if (!empty($metadata)) { @@ -219,15 +214,15 @@ public function createContainer($container,$metadata=array()) 'bytes' => 0, 'metadata' => $metadata ); - return new Container($this,$data); + return new Files\Container($this,$data); case '202': - $this->_errorMsg= self::ERROR_CONTAINER_EXIST; + $this->errorMsg= self::ERROR_CONTAINER_EXIST; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -239,7 +234,7 @@ public function createContainer($container,$metadata=array()) public function deleteContainer($container) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } $result= $this->httpCall($this->getStorageUrl().'/'.rawurlencode($container),HttpClient::DELETE); $status= $result->getStatus(); @@ -247,16 +242,16 @@ public function deleteContainer($container) case '204': // break intentionally omitted return true; case '409': - $this->_errorMsg= self::ERROR_CONTAINER_NOT_EMPTY; + $this->errorMsg= self::ERROR_CONTAINER_NOT_EMPTY; break; case '404': - $this->_errorMsg= self::ERROR_CONTAINER_NOT_FOUND; + $this->errorMsg= self::ERROR_CONTAINER_NOT_FOUND; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -268,7 +263,7 @@ public function deleteContainer($container) public function getMetadataContainer($container) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } $result= $this->httpCall($this->getStorageUrl().'/'.rawurlencode($container),HttpClient::HEAD); $status= $result->getStatus(); @@ -290,13 +285,13 @@ public function getMetadataContainer($container) ); return $data; case '404': - $this->_errorMsg= self::ERROR_CONTAINER_NOT_FOUND; + $this->errorMsg= self::ERROR_CONTAINER_NOT_FOUND; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -308,7 +303,7 @@ public function getMetadataContainer($container) public function getContainer($container) { $result= $this->getMetadataContainer($container); if (!empty($result)) { - return new Container($this,$result); + return new Files\Container($this,$result); } return false; } @@ -323,10 +318,10 @@ public function getContainer($container) { public function getObject($container,$object,$headers=array()) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } if (empty($object)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_OBJECT); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_OBJECT); } $result= $this->httpCall($this->getStorageUrl().'/'.rawurlencode($container).'/'.rawurlencode($object),HttpClient::GET); $status= $result->getStatus(); @@ -341,15 +336,15 @@ public function getObject($container,$object,$headers=array()) 'content_type' => $result->getHeader(self::HEADER_CONTENT_TYPE), 'file' => $result->getBody() ); - return new Object($this,$data); + return new Files\Object($this,$data); case '404': - $this->_errorMsg= self::ERROR_OBJECT_NOT_FOUND; + $this->errorMsg= self::ERROR_OBJECT_NOT_FOUND; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -363,13 +358,13 @@ public function getObject($container,$object,$headers=array()) */ public function storeObject($container,$object,$file,$metadata=array()) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } if (empty($object)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_OBJECT); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_OBJECT); } if (empty($file)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_FILE); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_FILE); } if (!empty($metadata) && is_array($metadata)) { foreach ($metadata as $key => $value) { @@ -384,16 +379,16 @@ public function storeObject($container,$object,$file,$metadata=array()) { case '201': // break intentionally omitted return true; case '412': - $this->_errorMsg= self::ERROR_OBJECT_MISSING_PARAM; + $this->errorMsg= self::ERROR_OBJECT_MISSING_PARAM; break; case '422': - $this->_errorMsg= self::ERROR_OBJECT_CHECKSUM; + $this->errorMsg= self::ERROR_OBJECT_CHECKSUM; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -405,10 +400,10 @@ public function storeObject($container,$object,$file,$metadata=array()) { */ public function deleteObject($container,$object) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } if (empty($object)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_OBJECT); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_OBJECT); } $result= $this->httpCall($this->getStorageUrl().'/'.rawurlencode($container).'/'.rawurlencode($object),HttpClient::DELETE); $status= $result->getStatus(); @@ -416,13 +411,13 @@ public function deleteObject($container,$object) { case '204': // break intentionally omitted return true; case '404': - $this->_errorMsg= self::ERROR_OBJECT_NOT_FOUND; + $this->errorMsg= self::ERROR_OBJECT_NOT_FOUND; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -438,16 +433,16 @@ public function deleteObject($container,$object) { */ public function copyObject($container_source,$obj_source,$container_dest,$obj_dest,$metadata=array(),$content_type=null) { if (empty($container_source)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_SOURCE_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_SOURCE_CONTAINER); } if (empty($obj_source)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_SOURCE_OBJECT); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_SOURCE_OBJECT); } if (empty($container_dest)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_DEST_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_DEST_CONTAINER); } if (empty($obj_dest)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_DEST_OBJECT); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_DEST_OBJECT); } $headers= array( self::HEADER_COPY_FROM => '/'.rawurlencode($container_source).'/'.rawurlencode($obj_source), @@ -468,10 +463,10 @@ public function copyObject($container_source,$obj_source,$container_dest,$obj_de case '201': // break intentionally omitted return true; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -483,10 +478,10 @@ public function copyObject($container_source,$obj_source,$container_dest,$obj_de */ public function getMetadataObject($container,$object) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } if (empty($object)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_OBJECT); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_OBJECT); } $result= $this->httpCall($this->getStorageUrl().'/'.rawurlencode($container).'/'.rawurlencode($object),HttpClient::HEAD); $status= $result->getStatus(); @@ -511,13 +506,13 @@ public function getMetadataObject($container,$object) { ); return $data; case '404': - $this->_errorMsg= self::ERROR_OBJECT_NOT_FOUND; + $this->errorMsg= self::ERROR_OBJECT_NOT_FOUND; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -532,10 +527,10 @@ public function getMetadataObject($container,$object) { public function setMetadataObject($container,$object,$metadata=array()) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } if (empty($object)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_OBJECT); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_OBJECT); } $headers=array(); if (!empty($metadata) && is_array($metadata)) { @@ -549,13 +544,13 @@ public function setMetadataObject($container,$object,$metadata=array()) case '202': // break intentionally omitted return true; case '404': - $this->_errorMsg= self::ERROR_OBJECT_NOT_FOUND; + $this->errorMsg= self::ERROR_OBJECT_NOT_FOUND; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -567,13 +562,13 @@ public function setMetadataObject($container,$object,$metadata=array()) */ public function enableCdnContainer ($container,$ttl=self::CDN_TTL_MIN) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } $headers=array(); if (is_numeric($ttl) && ($ttl>=self::CDN_TTL_MIN) && ($ttl<=self::CDN_TTL_MAX)) { $headers[self::CDN_TTL]= $ttl; } else { - throw new InvalidArgumentException(self::ERROR_CDN_TTL_OUT_OF_RANGE); + throw new Exception\InvalidArgumentException(self::ERROR_CDN_TTL_OUT_OF_RANGE); } $result= $this->httpCall($this->getCdnUrl().'/'.rawurlencode($container),HttpClient::PUT,$headers); $status= $result->getStatus(); @@ -585,13 +580,13 @@ public function enableCdnContainer ($container,$ttl=self::CDN_TTL_MIN) { ); return $data; case '404': - $this->_errorMsg= self::ERROR_CONTAINER_NOT_FOUND; + $this->errorMsg= self::ERROR_CONTAINER_NOT_FOUND; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -606,17 +601,17 @@ public function enableCdnContainer ($container,$ttl=self::CDN_TTL_MIN) { public function updateCdnContainer($container,$ttl=null,$cdn_enabled=null,$log=null) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } if (empty($ttl) && (!isset($cdn_enabled)) && (!isset($log))) { - throw new InvalidArgumentException(self::ERROR_PARAM_UPDATE_CDN); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_UPDATE_CDN); } $headers=array(); if (isset($ttl)) { if (is_numeric($ttl) && ($ttl>=self::CDN_TTL_MIN) && ($ttl<=self::CDN_TTL_MAX)) { $headers[self::CDN_TTL]= $ttl; } else { - throw new InvalidArgumentException(self::ERROR_CDN_TTL_OUT_OF_RANGE); + throw new Exception\InvalidArgumentException(self::ERROR_CDN_TTL_OUT_OF_RANGE); } } if (isset($cdn_enabled)) { @@ -643,13 +638,13 @@ public function updateCdnContainer($container,$ttl=null,$cdn_enabled=null,$log=n ); return $data; case '404': - $this->_errorMsg= self::ERROR_CONTAINER_NOT_FOUND; + $this->errorMsg= self::ERROR_CONTAINER_NOT_FOUND; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } /** @@ -660,7 +655,7 @@ public function updateCdnContainer($container,$ttl=null,$cdn_enabled=null,$log=n */ public function getInfoCdn($container) { if (empty($container)) { - throw new InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); + throw new Exception\InvalidArgumentException(self::ERROR_PARAM_NO_NAME_CONTAINER); } $result= $this->httpCall($this->getCdnUrl().'/'.rawurlencode($container),HttpClient::HEAD); $status= $result->getStatus(); @@ -675,13 +670,13 @@ public function getInfoCdn($container) { $data['log_retention']= (strtolower($result->getHeader(self::CDN_LOG_RETENTION))!=='false'); return $data; case '404': - $this->_errorMsg= self::ERROR_CONTAINER_NOT_FOUND; + $this->errorMsg= self::ERROR_CONTAINER_NOT_FOUND; break; default: - $this->_errorMsg= $result->getBody(); + $this->errorMsg= $result->getBody(); break; } - $this->_errorStatus= $status; + $this->errorCode= $status; return false; } } \ No newline at end of file diff --git a/library/Zend/Service/Rackspace/Files/Container.php b/library/Zend/Service/Rackspace/Files/Container.php index 8f301653dd0..1c7064747b3 100644 --- a/library/Zend/Service/Rackspace/Files/Container.php +++ b/library/Zend/Service/Rackspace/Files/Container.php @@ -23,79 +23,79 @@ namespace Zend\Service\Rackspace\Files; use Zend\Service\Rackspace\Files as RackspaceFiles, - Zend\Service\Rackspace\Exception\InvalidArgumentException; + Zend\Service\Rackspace\Exception; class Container { - const ERROR_PARAM_CONSTRUCT= 'You must pass a RackspaceFiles and an array'; - const ERROR_PARAM_NO_NAME= 'You must pass the container name in the array (name)'; - const ERROR_PARAM_NO_TTL= 'You must pass the CDN ttl of the container in the array (ttl)'; - const ERROR_PARAM_NO_LOG_RETENTION= 'You must pass the CDN log retention of the container in the array (log_retention)'; - const ERROR_PARAM_NO_CDN_URI= 'You must pass the CDN uri of the container in the array (cdn_uri)'; - const ERROR_PARAM_NO_COUNT= 'You must pass the object count of the container in the array (count)'; - const ERROR_PARAM_NO_BYTES= 'You must pass the byte size of the container in the array (bytes)'; + const ERROR_PARAM_CONSTRUCT = 'You must pass a RackspaceFiles and an array'; + const ERROR_PARAM_NO_NAME = 'You must pass the container name in the array (name)'; + const ERROR_PARAM_NO_TTL = 'You must pass the CDN ttl of the container in the array (ttl)'; + const ERROR_PARAM_NO_LOG_RETENTION = 'You must pass the CDN log retention of the container in the array (log_retention)'; + const ERROR_PARAM_NO_CDN_URI = 'You must pass the CDN uri of the container in the array (cdn_uri)'; + const ERROR_PARAM_NO_COUNT = 'You must pass the object count of the container in the array (count)'; + const ERROR_PARAM_NO_BYTES = 'You must pass the byte size of the container in the array (bytes)'; /** * @var string */ - protected $_name; + protected $name; /** * Count total of object in the container * * @var integer */ - protected $_objectCount; + protected $objectCount; /** * Size in byte of the container * * @var integer */ - protected $_size; + protected $size; /** * @var array */ - protected $_metadata = array(); + protected $metadata = array(); /** * If it's true means we called the getMetadata API * * @var boolean */ - private $_getMetadata = false; + protected $getMetadata = false; /** * The service that has created the container object * - * @var RackspaceFile + * @var Zend\Service\Rackspace\Files */ - protected $_service; + protected $service; /** * CDN enabled * * @var boolean */ - protected $_cdn; + protected $cdn; /** * CDN URI * * @var string */ - protected $_cdnUri; + protected $cdnUri; /** * CDN URI SSL * * @var string */ - protected $_cdnUriSsl; + protected $cdnUriSsl; /** * TTL of the CDN container * * @var integer */ - protected $_ttl; + protected $ttl; /** * Log retention enabled for the CDN * * @var boolean */ - protected $_logRetention; + protected $logRetention; /** * __construct() * @@ -134,22 +134,22 @@ public function __construct(RackspaceFiles $service, $data) throw new InvalidArgumentException(self::ERROR_PARAM_NO_BYTES); } } - $this->_service = $service; - $this->_name = $data['name']; + $this->service = $service; + $this->name = $data['name']; if (!empty($data['cdn_enabled'])) { - $this->_cdn= (strtolower($data['cdn_enabled'])!=='false'); - $this->_ttl= $data['ttl']; - $this->_logRetention= (strtolower($data['log_retention'])!=='false'); - $this->_cdnUri= $data['cdn_uri']; + $this->cdn= (strtolower($data['cdn_enabled'])!=='false'); + $this->ttl= $data['ttl']; + $this->logRetention= (strtolower($data['log_retention'])!=='false'); + $this->cdnUri= $data['cdn_uri']; if (!empty($data['cdn_uri_ssl'])) { - $this->_cdnUriSsl= $data['cdn_uri_ssl']; + $this->cdnUriSsl= $data['cdn_uri_ssl']; } } else { - $this->_objectCount = $data['count']; - $this->_size = $data['bytes']; + $this->objectCount = $data['count']; + $this->size = $data['bytes']; if (!empty($data['metadata']) && is_array($data['metadata'])) { - $this->_metadata = $data['metadata']; - $this->_getMetadata = true; + $this->metadata = $data['metadata']; + $this->getMetadata = true; } } } @@ -160,7 +160,7 @@ public function __construct(RackspaceFiles $service, $data) */ public function getName() { - return $this->_name; + return $this->name; } /** * Get the size in bytes of the container @@ -169,10 +169,10 @@ public function getName() */ public function getSize() { - if (!isset($this->_size)) { + if (!isset($this->size)) { $null= $this->getMetadata(); } - return $this->_size; + return $this->size; } /** * Get the total count of objects in the container @@ -181,10 +181,10 @@ public function getSize() */ public function getObjectCount() { - if (!isset($this->_size)) { + if (!isset($this->size)) { $null= $this->getMetadata(); } - return $this->_objectCount; + return $this->objectCount; } /** * Return true if the container is CDN enabled @@ -193,21 +193,22 @@ public function getObjectCount() */ public function isCdnEnabled() { - if (!isset($this->_cdn)) { + if (!isset($this->cdn)) { $this->updateCdnInfo(); } - return $this->_cdn; + return $this->cdn; } /** * Get the TTL of the CDN * * @return integer */ - public function getCdnTtl() { - if (!isset($this->_ttl)) { + public function getCdnTtl() + { + if (!isset($this->ttl)) { $this->updateCdnInfo(); } - return $this->_ttl; + return $this->ttl; } /** * Return true if the log retention is enabled for the CDN @@ -216,10 +217,10 @@ public function getCdnTtl() { */ public function isCdnLogEnabled() { - if (!isset($this->_logRetention)) { + if (!isset($this->logRetention)) { $this->updateCdnInfo(); } - return $this->_logRetention; + return $this->logRetention; } /** * Get the CDN URI @@ -228,10 +229,10 @@ public function isCdnLogEnabled() */ public function getCdnUri() { - if (!isset($this->_cdnUri)) { + if (!isset($this->cdnUri)) { $this->updateCdnInfo(); } - return $this->_cdnUri; + return $this->cdnUri; } /** * Get the CDN URI SSL @@ -240,10 +241,10 @@ public function getCdnUri() */ public function getCdnUriSsl() { - if (!isset($this->_cdnUriSsl)) { + if (!isset($this->cdnUriSsl)) { $this->updateCdnInfo(); } - return $this->_cdnUriSsl; + return $this->cdnUriSsl; } /** * Get the metadata of the container @@ -255,21 +256,21 @@ public function getCdnUriSsl() */ public function getMetadata($key=null) { - if (empty($this->_metadata) && (!$this->_getMetadata)) { - $result = $this->_service->getMetadataContainer($this->getName()); + if (empty($this->metadata) && (!$this->getMetadata)) { + $result = $this->service->getMetadataContainer($this->getName()); if (!empty($result)) { - $this->_objectCount = $result['tot_objects']; - $this->_size = $result['size']; + $this->objectCount = $result['tot_objects']; + $this->size = $result['size']; if (!empty($result['metadata']) && is_array($result['metadata'])) { - $this->_metadata = $result['metadata']; + $this->metadata = $result['metadata']; } } - $this->_getMetadata = true; + $this->getMetadata = true; } - if (!empty($this->_metadata[$key])) { - return $this->_metadata[$key]; + if (!empty($this->metadata[$key])) { + return $this->metadata[$key]; } - return $this->_metadata; + return $this->metadata; } /** * Get all the object of the container @@ -278,7 +279,7 @@ public function getMetadata($key=null) */ public function getObjects() { - return $this->_service->getObjects($this->getName()); + return $this->service->getObjects($this->getName()); } /** * Get an object of the container @@ -289,7 +290,7 @@ public function getObjects() */ public function getObject($name, $headers=array()) { - return $this->_service->getObject($this->getName(), $name, $headers); + return $this->service->getObject($this->getName(), $name, $headers); } /** * Add an object in the container @@ -301,7 +302,7 @@ public function getObject($name, $headers=array()) */ public function addObject($name, $file, $metadata=array()) { - return $this->_service->storeObject($this->getName(), $name, $file, $metadata); + return $this->service->storeObject($this->getName(), $name, $file, $metadata); } /** * Delete an object in the container @@ -311,7 +312,7 @@ public function addObject($name, $file, $metadata=array()) */ public function deleteObject($obj) { - return $this->_service->deleteObject($this->getName(), $obj); + return $this->service->deleteObject($this->getName(), $obj); } /** * Copy an object to another container @@ -325,7 +326,7 @@ public function deleteObject($obj) */ public function copyObject($obj_source, $container_dest, $obj_dest, $metadata=array(), $content_type=null) { - return $this->_service->copyObject($this->getName(), $obj_source, $container_dest, $obj_dest, $metadata, $content_type); + return $this->service->copyObject($this->getName(), $obj_source, $container_dest, $obj_dest, $metadata, $content_type); } /** * Get the metadata of an object in the container @@ -335,7 +336,7 @@ public function copyObject($obj_source, $container_dest, $obj_dest, $metadata=ar */ public function getMetadataObject($object) { - return $this->_service->getMetadataObject($this->getName(),$object); + return $this->service->getMetadataObject($this->getName(),$object); } /** * Set the metadata of an object in the container @@ -344,8 +345,9 @@ public function getMetadataObject($object) * @param array $metadata * @return boolean */ - public function setMetadataObject($object,$metadata=array()) { - return $this->_service->setMetadataObject($this->getName(),$object,$metadata); + public function setMetadataObject($object,$metadata=array()) + { + return $this->service->setMetadataObject($this->getName(),$object,$metadata); } /** * Enable the CDN for the container @@ -353,14 +355,15 @@ public function setMetadataObject($object,$metadata=array()) { * @param integer $ttl * @return boolean */ - public function enableCdn($ttl=RackspaceFiles::CDN_TTL_MIN) { - $result= $this->_service->enableCdnContainer($this->getName(),$ttl); + public function enableCdn($ttl=RackspaceFiles::CDN_TTL_MIN) + { + $result= $this->service->enableCdnContainer($this->getName(),$ttl); if ($result!==false) { - $this->_cdn= true; - $this->_ttl= $ttl; - $this->_logRetention= true; - $this->_cdnUri= $result['cdn_uri']; - $this->_cdnUriSsl= $result['cdn_uri_ssl']; + $this->cdn= true; + $this->ttl= $ttl; + $this->logRetention= true; + $this->cdnUri= $result['cdn_uri']; + $this->cdnUriSsl= $result['cdn_uri_ssl']; return true; } return false; @@ -370,10 +373,11 @@ public function enableCdn($ttl=RackspaceFiles::CDN_TTL_MIN) { * * @return boolean */ - public function disableCdn() { - $result= $this->_service->updateCdnContainer($this->getName(),null,false); + public function disableCdn() + { + $result= $this->service->updateCdnContainer($this->getName(),null,false); if ($result!==false) { - $this->_cdn= false; + $this->cdn= false; $this->_resetParamsCdn(); return true; } @@ -385,10 +389,11 @@ public function disableCdn() { * @param integer $ttl * @return boolean */ - public function changeTtlCdn($ttl) { - $result= $this->_service->updateCdnContainer($this->getName(),$ttl); + public function changeTtlCdn($ttl) + { + $result= $this->service->updateCdnContainer($this->getName(),$ttl); if ($result!==false) { - $this->_ttl= $ttl; + $this->ttl= $ttl; return true; } return false; @@ -398,10 +403,11 @@ public function changeTtlCdn($ttl) { * * @return boolean */ - public function enableLogCdn() { - $result= $this->_service->updateCdnContainer($this->getName(),null,null,true); + public function enableLogCdn() + { + $result= $this->service->updateCdnContainer($this->getName(),null,null,true); if ($result!==false) { - $this->_logRetention= true; + $this->logRetention= true; return true; } return false; @@ -411,10 +417,11 @@ public function enableLogCdn() { * * @return boolean */ - public function disableLogCdn() { - $result= $this->_service->updateCdnContainer($this->getName(),null,null,false); + public function disableLogCdn() + { + $result= $this->service->updateCdnContainer($this->getName(),null,null,false); if ($result!==false) { - $this->_logRetention= false; + $this->logRetention= false; return true; } return false; @@ -424,14 +431,15 @@ public function disableLogCdn() { * * @return boolean */ - public function updateCdnInfo() { - $result= $this->_service->getInfoCdn($this->getName()); + public function updateCdnInfo() + { + $result= $this->service->getInfoCdn($this->getName()); if ($result!==false) { - $this->_cdn= (strtolower($result['cdn_enabled'])!=='false'); - $this->_ttl= $result['ttl']; - $this->_logRetention= (strtolower($result['log_retention'])!=='false'); - $this->_cdnUri= $result['cdn_uri']; - $this->_cdnUriSsl= $result['cdn_uri_ssl']; + $this->cdn= (strtolower($result['cdn_enabled'])!=='false'); + $this->ttl= $result['ttl']; + $this->logRetention= (strtolower($result['log_retention'])!=='false'); + $this->cdnUri= $result['cdn_uri']; + $this->cdnUriSsl= $result['cdn_uri_ssl']; return true; } return false; @@ -439,10 +447,11 @@ public function updateCdnInfo() { /** * Reset all the parameters related to the CDN container */ - private function _resetParamsCdn() { - $this->_ttl= null; - $this->_logRetention= null; - $this->_cdnUri= null; - $this->_cdnUriSsl= null; + private function _resetParamsCdn() + { + $this->ttl= null; + $this->logRetention= null; + $this->cdnUri= null; + $this->cdnUriSsl= null; } } \ No newline at end of file diff --git a/library/Zend/Service/Rackspace/Files/ContainerList.php b/library/Zend/Service/Rackspace/Files/ContainerList.php index a12834e23f4..15a44c46d24 100644 --- a/library/Zend/Service/Rackspace/Files/ContainerList.php +++ b/library/Zend/Service/Rackspace/Files/ContainerList.php @@ -49,17 +49,17 @@ class ContainerList implements \Countable, \Iterator, \ArrayAccess /** * @var array Array of Zend\Service\GoGrid\Object */ - protected $_objects = array(); + protected $objects = array(); /** * @var int Iterator key */ - protected $_iteratorKey = 0; + protected $iteratorKey = 0; /** * @var RackspaceFiles */ - protected $_service; + protected $service; /** - * __construct() + * Constructor * * @param array $list * @return boolean @@ -69,7 +69,7 @@ public function __construct(RackspaceFiles $service,$list = array()) if (!($service instanceof RackspaceFiles) || !is_array($list)) { throw new InvalidArgumentException("You must pass a RackspaceFiles object and an array"); } - $this->_service= $service; + $this->service= $service; $this->_constructFromArray($list); } /** @@ -81,7 +81,7 @@ public function __construct(RackspaceFiles $service,$list = array()) private function _constructFromArray(array $list) { foreach ($list as $container) { - $this->_addObject(new Container($this->_service,$container)); + $this->_addObject(new Container($this->service,$container)); } } /** @@ -92,7 +92,7 @@ private function _constructFromArray(array $list) */ protected function _addObject (Container $obj) { - $this->_objects[] = $obj; + $this->objects[] = $obj; return $this; } /** @@ -104,7 +104,7 @@ protected function _addObject (Container $obj) */ public function count() { - return count($this->_objects); + return count($this->objects); } /** * Return the current element @@ -115,7 +115,7 @@ public function count() */ public function current() { - return $this->_objects[$this->_iteratorKey]; + return $this->objects[$this->iteratorKey]; } /** * Return the key of the current element @@ -126,7 +126,7 @@ public function current() */ public function key() { - return $this->_iteratorKey; + return $this->iteratorKey; } /** * Move forward to next element @@ -137,7 +137,7 @@ public function key() */ public function next() { - $this->_iteratorKey += 1; + $this->iteratorKey += 1; } /** * Rewind the Iterator to the first element @@ -148,7 +148,7 @@ public function next() */ public function rewind() { - $this->_iteratorKey = 0; + $this->iteratorKey = 0; } /** * Check if there is a current element after calls to rewind() or next() @@ -160,7 +160,7 @@ public function rewind() public function valid() { $numItems = $this->count(); - if ($numItems > 0 && $this->_iteratorKey < $numItems) { + if ($numItems > 0 && $this->iteratorKey < $numItems) { return true; } else { return false; @@ -190,7 +190,7 @@ public function offsetExists($offset) public function offsetGet($offset) { if ($this->offsetExists($offset)) { - return $this->_objects[$offset]; + return $this->objects[$offset]; } else { throw new OutOfBoundsException('Illegal index'); } diff --git a/library/Zend/Service/Rackspace/Files/Object.php b/library/Zend/Service/Rackspace/Files/Object.php index 156197a85cf..8a7675d5e7d 100644 --- a/library/Zend/Service/Rackspace/Files/Object.php +++ b/library/Zend/Service/Rackspace/Files/Object.php @@ -26,56 +26,68 @@ class Object { + /** + * The service that has created the object + * + * @var Zend\Service\Rackspace\Files + */ + protected $service; /** * Name of the object * * @var string */ - protected $_name; + protected $name; /** * MD5 value of the object's content * * @var string */ - protected $_hash; + protected $hash; /** * Size in bytes of the object's content * * @var integer */ - protected $_size; + protected $size; /** * Content type of the object's content * - * @var + * @var string */ - protected $_contentType; + protected $contentType; /** * Date of the last modified of the object * * @var string */ - protected $_lastModified; + protected $lastModified; /** * Object content * * @var string */ - protected $_file; + protected $file; /** * Name of the container where the object is stored * * @var string */ - protected $_container; + protected $container; /** * If it's true means we called the getMetadata API * * @var boolean */ - private $_getMetadata = false; + protected $getMetadata = false; + /** + * Metadata + * + * @var array + */ + protected $metadata= array(); /** - * __construct() + * Constructor * * You must pass the RackspaceFiles object of the caller and an associative * array with the keys "name", "container", "hash", "bytes", "content_type", @@ -114,72 +126,79 @@ public function __construct(RackspaceFiles $service,$data) if (!array_key_exists('last_modified', $data)) { throw new InvalidArgumentException("You must pass the last modified data of the object in the array (last_modified)"); } - $this->_name= $data['name']; - $this->_container= $data['container']; - $this->_hash= $data['hash']; - $this->_size= $data['bytes']; - $this->_contentType= $data['content_type']; - $this->_lastModified= $data['last_modified']; + $this->name= $data['name']; + $this->container= $data['container']; + $this->hash= $data['hash']; + $this->size= $data['bytes']; + $this->contentType= $data['content_type']; + $this->lastModified= $data['last_modified']; if (!empty($data['file'])) { - $this->_file= $data['file']; + $this->file= $data['file']; } - $this->_service= $service; + $this->service= $service; } /** * Get name * * @return string */ - public function getName() { - return $this->_name; + public function getName() + { + return $this->name; } /** * Get the name of the container * * @return string */ - public function getContainer() { - return $this->_container; + public function getContainer() + { + return $this->container; } /** * Get the MD5 of the object's content * * @return string */ - public function getHash() { - return $this->_hash; + public function getHash() + { + return $this->hash; } /** * Get the size of the object's content * * @return integer */ - public function getSize() { - return $this->_size; + public function getSize() + { + return $this->size; } /** * Get the content type of the object's content * * @return string */ - public function getContentType() { - return $this->_contentType; + public function getContentType() + { + return $this->contentType; } /** * Get the data of the last modified of the object * * @return string */ - public function getLastModified() { - return $this->_lastModified; + public function getLastModified() + { + return $this->lastModified; } /** * Get the content of the object * * @return string */ - public function getFile() { - return $this->_file; + public function getFile() + { + return $this->file; } /** * Get the metadata of the object @@ -188,24 +207,25 @@ public function getFile() { * @param string $key * @return string|array */ - public function getMetadata($key=null) { - if (empty($this->_metadata) && (!$this->_getMetadata)) { - $result= $this->_service->getMetadataObject($this->_container,$this->_name); + public function getMetadata($key=null) + { + if (empty($this->metadata) && (!$this->getMetadata)) { + $result= $this->service->getMetadataObject($this->container,$this->name); if (!empty($result)) { - $this->_hash= $data['hash']; - $this->_size= $data['bytes']; - $this->_contentType= $data['content_type']; - $this->_lastModified= $data['last_modified']; + $this->hash= $data['hash']; + $this->size= $data['bytes']; + $this->contentType= $data['content_type']; + $this->lastModified= $data['last_modified']; if (!empty($result['metadata'])) { - $this->_metadata= $result['metadata']; + $this->metadata= $result['metadata']; } } - $this->_getMetadata= true; + $this->getMetadata= true; } - if (!empty($this->_metadata[$key])) { - return $this->_metadata[$key]; + if (!empty($this->metadata[$key])) { + return $this->metadata[$key]; } - return $this->_metadata; + return $this->metadata; } /** * Set the metadata value @@ -214,8 +234,9 @@ public function getMetadata($key=null) { * @param array $metadata * @return boolean */ - public function setMetadata($metadata) { - return $this->_service->setMetadataObject($this->_container,$this->_name,$metadata); + public function setMetadata($metadata) + { + return $this->service->setMetadataObject($this->container,$this->name,$metadata); } /** * Copy the object to another container @@ -228,19 +249,21 @@ public function setMetadata($metadata) { * @param string $content_type * @return boolean */ - public function copyTo($container_dest,$name_dest,$metadata=array(),$content_type=null) { - return $this->_service->copyObject($this->_container,$this->_name,$container_dest,$name_dest,$metadata,$content_type); + public function copyTo($container_dest,$name_dest,$metadata=array(),$content_type=null) + { + return $this->service->copyObject($this->container,$this->name,$container_dest,$name_dest,$metadata,$content_type); } /** * Get the CDN URL of the object * * @return string */ - public function getCdnUrl() { - $result= $this->_service->getInfoCdn($this->_container); + public function getCdnUrl() + { + $result= $this->service->getInfoCdn($this->container); if ($result!==false) { if ($result['cdn_enabled']) { - return $result['cdn_uri'].'/'.$this->_name; + return $result['cdn_uri'].'/'.$this->name; } } return false; @@ -250,11 +273,12 @@ public function getCdnUrl() { * * @return string */ - public function getCdnUrlSsl() { - $result= $this->_service->getInfoCdn($this->_container); + public function getCdnUrlSsl() + { + $result= $this->service->getInfoCdn($this->container); if ($result!==false) { if ($result['cdn_enabled']) { - return $result['cdn_uri_ssl'].'/'.$this->_name; + return $result['cdn_uri_ssl'].'/'.$this->name; } } return false; diff --git a/library/Zend/Service/Rackspace/Files/ObjectList.php b/library/Zend/Service/Rackspace/Files/ObjectList.php index 867746265b0..902ffa6b090 100644 --- a/library/Zend/Service/Rackspace/Files/ObjectList.php +++ b/library/Zend/Service/Rackspace/Files/ObjectList.php @@ -47,23 +47,23 @@ class ObjectList implements \Countable, \Iterator, \ArrayAccess { /** - * @var array Array of Zend\Service\GoGrid\Object + * @var array of Zend\Service\GoGrid\Object */ - protected $_objects = array(); + protected $objects = array(); /** * @var int Iterator key */ - protected $_iteratorKey = 0; + protected $iteratorKey = 0; /** * @var RackspaceFiles */ - protected $_service; + protected $service; /** * The container name of the object list * * @var string */ - protected $_container; + protected $container; /** * __construct() * @@ -81,8 +81,8 @@ public function __construct(RackspaceFiles $service,$list,$container) if (empty($container)) { throw new InvalidArgumentException("You must pass the container of the object list"); } - $this->_service= $service; - $this->_container= $container; + $this->service= $service; + $this->container= $container; $this->_constructFromArray($list); } /** @@ -94,8 +94,8 @@ public function __construct(RackspaceFiles $service,$list,$container) private function _constructFromArray(array $list) { foreach ($list as $obj) { - $obj['container']= $this->_container; - $this->_addObject(new Object($this->_service,$obj)); + $obj['container']= $this->container; + $this->_addObject(new Object($this->service,$obj)); } } /** @@ -106,7 +106,7 @@ private function _constructFromArray(array $list) */ protected function _addObject (Object $obj) { - $this->_objects[] = $obj; + $this->objects[] = $obj; return $this; } /** @@ -118,7 +118,7 @@ protected function _addObject (Object $obj) */ public function count() { - return count($this->_objects); + return count($this->objects); } /** * Return the current element @@ -129,7 +129,7 @@ public function count() */ public function current() { - return $this->_objects[$this->_iteratorKey]; + return $this->objects[$this->iteratorKey]; } /** * Return the key of the current element @@ -140,7 +140,7 @@ public function current() */ public function key() { - return $this->_iteratorKey; + return $this->iteratorKey; } /** * Move forward to next element @@ -151,7 +151,7 @@ public function key() */ public function next() { - $this->_iteratorKey += 1; + $this->iteratorKey += 1; } /** * Rewind the Iterator to the first element @@ -162,7 +162,7 @@ public function next() */ public function rewind() { - $this->_iteratorKey = 0; + $this->iteratorKey = 0; } /** * Check if there is a current element after calls to rewind() or next() @@ -174,7 +174,7 @@ public function rewind() public function valid() { $numItems = $this->count(); - if ($numItems > 0 && $this->_iteratorKey < $numItems) { + if ($numItems > 0 && $this->iteratorKey < $numItems) { return true; } else { return false; @@ -204,7 +204,7 @@ public function offsetExists($offset) public function offsetGet($offset) { if ($this->offsetExists($offset)) { - return $this->_objects[$offset]; + return $this->objects[$offset]; } else { throw new OutOfBoundsException('Illegal index'); } diff --git a/library/Zend/Service/Rackspace/Rackspace.php b/library/Zend/Service/Rackspace/Rackspace.php index fb33e178b98..51bcae1234a 100644 --- a/library/Zend/Service/Rackspace/Rackspace.php +++ b/library/Zend/Service/Rackspace/Rackspace.php @@ -32,12 +32,12 @@ abstract class Rackspace const API_FORMAT = 'json'; const USER_AGENT = 'Zend\Service\Rackspace'; const STORAGE_URL = "X-Storage-Url"; - const AUTHtoken = "X-Auth-Token"; - const AUTHuser_HEADER = "X-Auth-User"; - const AUTHkey_HEADER = "X-Auth-Key"; - const AUTHuser_HEADER_LEGACY = "X-Storage-User"; - const AUTHkey_HEADER_LEGACY = "X-Storage-Pass"; - const AUTHtoken_LEGACY = "X-Storage-Token"; + const AUTHTOKEN = "X-Auth-Token"; + const AUTHUSER_HEADER = "X-Auth-User"; + const AUTHKEY_HEADER = "X-Auth-Key"; + const AUTHUSER_HEADER_LEGACY = "X-Storage-User"; + const AUTHKEY_HEADER_LEGACY = "X-Storage-Pass"; + const AUTHTOKEN_LEGACY = "X-Storage-Token"; const CDNM_URL = "X-CDN-Management-Url"; const MANAGEMENT_URL = "X-Server-Management-Url"; /** @@ -99,7 +99,7 @@ abstract class Rackspace */ protected $managementUrl; /** - * __construct() + * Constructor * * You must pass the account and the Rackspace authentication key. * Optional: the authentication url (default is US) @@ -155,7 +155,8 @@ public function getAuthUrl() * * @return string|boolean */ - public function getStorageUrl() { + public function getStorageUrl() + { if (empty($this->storageUrl)) { if (!$this->authenticate()) { return false; @@ -168,7 +169,8 @@ public function getStorageUrl() { * * @return string|boolean */ - public function getCdnUrl() { + public function getCdnUrl() + { if (empty($this->cdnUrl)) { if (!$this->authenticate()) { return false; @@ -243,19 +245,21 @@ public function getToken() return $this->token; } /** - * Get the error msg of the last REST call + * Get the error msg of the last HTTP call * * @return string */ - public function getErrorMsg() { + public function getErrorMsg() + { return $this->errorMsg; } /** - * Get the error code of the last REST call + * Get the error code of the last HTTP call * * @return strig */ - public function getErrorCode() { + public function getErrorCode() + { return $this->errorCode; } /** @@ -293,8 +297,8 @@ protected function httpCall($url,$method,$headers=array(),$data=array(),$body=nu { $client = $this->getHttpClient(); $client->resetParameters(true); - if (empty($headers[self::AUTHuser_HEADER])) { - $headers[self::AUTHtoken]= $this->getToken(); + if (empty($headers[self::AUTHUSER_HEADER])) { + $headers[self::AUTHTOKEN]= $this->getToken(); } $client->setMethod($method); if (empty($get['format'])) { @@ -321,12 +325,12 @@ protected function httpCall($url,$method,$headers=array(),$data=array(),$body=nu public function authenticate() { $headers= array ( - self::AUTHuser_HEADER => $this->user, - self::AUTHkey_HEADER => $this->key + self::AUTHUSER_HEADER => $this->user, + self::AUTHKEY_HEADER => $this->key ); $result= $this->httpCall($this->authUrl.'/'.self::VERSION,HttpClient::GET, $headers); if ($result->getStatus()==204) { - $this->token= $result->getHeader(self::AUTHtoken); + $this->token= $result->getHeader(self::AUTHTOKEN); $this->storageUrl= $result->getHeader(self::STORAGE_URL); $this->cdnUrl= $result->getHeader(self::CDNM_URL); $this->managementUrl= $result->getHeader(self::MANAGEMENT_URL); diff --git a/library/Zend/Service/Rackspace/Servers.php b/library/Zend/Service/Rackspace/Servers.php index 330ab557240..b1ad4945dbb 100644 --- a/library/Zend/Service/Rackspace/Servers.php +++ b/library/Zend/Service/Rackspace/Servers.php @@ -50,7 +50,7 @@ class Servers extends Rackspace * Get the list of the servers * If $details is true returns detail info * - * @param boolean $details + * @param boolean $details * @return Zend\Service\Rackspace\Servers\ServerList|boolean */ public function listServers($details=false) @@ -85,7 +85,7 @@ public function listServers($details=false) /** * Get the specified server * - * @param string $id + * @param string $id * @return Zend\Service\Rackspace\Servers\Server */ public function getServer($id) @@ -122,7 +122,7 @@ public function getServer($id) /** * Get the server info as an array * - * @param string $id + * @param string $id * @return array|boolean */ public function getServerInfo($id) @@ -162,9 +162,9 @@ public function getServerInfo($id) * The required parameters are specified in $data (name, imageId, falvorId) * The $files is an associative array with 'serverPath' => 'localPath' * - * @param array $data - * @param array $metadata - * @param array $files + * @param array $data + * @param array $metadata + * @param array $files * @return Zend\Service\Rackspace\Servers\Server|boolean */ public function createServer(array $data, $metadata=array(),$files=array()) @@ -287,8 +287,8 @@ protected function updateServer($id,$name=null,$password=null) /** * Change the server's name * - * @param string $id - * @param string $name + * @param string $id + * @param string $name * @return boolean */ public function changeServerName($id,$name) @@ -304,8 +304,8 @@ public function changeServerName($id,$name) /** * Change the admin password of the server * - * @param string $id - * @param string $password + * @param string $id + * @param string $password * @return boolean */ public function changeServerPassword($id,$password) @@ -321,7 +321,7 @@ public function changeServerPassword($id,$password) /** * Delete a server * - * @param string $id + * @param string $id * @return boolean */ public function deleteServer($id) @@ -359,7 +359,7 @@ public function deleteServer($id) /** * Get the server's IPs (public and private) * - * @param string $id + * @param string $id * @return array|boolean */ public function getServerIp($id) @@ -393,7 +393,7 @@ public function getServerIp($id) /** * Get the Public IPs of a server * - * @param string $id + * @param string $id * @return array|boolean */ public function getServerPublicIp($id) @@ -407,7 +407,7 @@ public function getServerPublicIp($id) /** * Get the Private IPs of a server * - * @param string $id + * @param string $id * @return array|boolean */ public function getServerPrivateIp($id) @@ -684,7 +684,7 @@ public function resizeServer($id,$flavorId) * the original server is removed and cannot be rolled back to. All resizes are automatically * confirmed after 24 hours if they are not explicitly confirmed or reverted. * - * @param type $id + * @param string $id * @return boolean */ public function confirmResizeServer($id) @@ -735,7 +735,7 @@ public function confirmResizeServer($id) * automatically confirmed after 24 hours if they have not already been confirmed explicitly or * reverted. * - * @param type $id + * @param string $id * @return boolean */ public function revertResizeServer($id) @@ -782,7 +782,7 @@ public function revertResizeServer($id) * * If $details is true returns detail info * - * @param boolean $details + * @param boolean $details * @return array|boolean */ public function listFlavors($details=false) @@ -817,7 +817,7 @@ public function listFlavors($details=false) /** * Get the detail of a flavor * - * @param string $flavorId + * @param string $flavorId * @return array|boolean */ public function getFlavor($flavorId) @@ -851,7 +851,7 @@ public function getFlavor($flavorId) /** * Get the list of the images * - * @param boolean $details + * @param boolean $details * @return Zend\Service\Rackspace\Servers\ImageList|boolean */ public function listImages($details=false) @@ -886,7 +886,7 @@ public function listImages($details=false) /** * Get detail about an image * - * @param string $id + * @param string $id * @return Zend\Service\Rackspace\Servers\Image|boolean */ public function getImage($id) @@ -920,7 +920,7 @@ public function getImage($id) /** * Get the info of an image as an array * - * @param string $id + * @param string $id * @return array|boolean */ public function getImageInfo($id) @@ -957,8 +957,8 @@ public function getImageInfo($id) /** * Create an image for a serverId * - * @param string $serverId - * @param string $name + * @param string $serverId + * @param string $name * @return Zend\Service\Rackspace\Servers\Image */ public function createImage($serverId,$name) @@ -1010,7 +1010,7 @@ public function createImage($serverId,$name) /** * Delete an image * - * @param string $id + * @param string $id * @return boolean */ public function deleteImage($id) @@ -1045,7 +1045,7 @@ public function deleteImage($id) /** * Get the backup schedule of a server * - * @param string $id server's Id + * @param string $id server's Id * @return array|boolean */ public function getBackupSchedule($id) @@ -1211,7 +1211,7 @@ public function listSharedIpGroups($details=false) /** * Get the shared IP group * - * @param integer $id + * @param integer $id * @return Zend\Service\Rackspace\Servers\SharedIpGroup|boolean */ public function getSharedIpGroup($id) @@ -1248,7 +1248,7 @@ public function getSharedIpGroup($id) /** * Get the shared IP group info as an array * - * @param integer $id + * @param integer $id * @return array|boolean */ public function getSharedIpGroupInfo($id) @@ -1329,7 +1329,7 @@ public function createSharedIpGroup($name,$serverId) /** * Delete a Shared Ip Group * - * @param integer $id + * @param integer $id * @return boolean */ public function deleteSharedIpGroup($id) diff --git a/library/Zend/Service/Rackspace/Servers/Server.php b/library/Zend/Service/Rackspace/Servers/Server.php index 01e77f033dc..1499748ab66 100644 --- a/library/Zend/Service/Rackspace/Servers/Server.php +++ b/library/Zend/Service/Rackspace/Servers/Server.php @@ -94,9 +94,8 @@ class Server * @var Zend\Service\Rackspace\Servers */ protected $service; - /** - * Construct + * Constructor * * @param RackspaceServers $service * @param array $data diff --git a/tests/TestConfiguration.php.dist b/tests/TestConfiguration.php.dist index b5d1fdac901..4ed7f2987bc 100755 --- a/tests/TestConfiguration.php.dist +++ b/tests/TestConfiguration.php.dist @@ -605,7 +605,7 @@ define('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL', false); /** * Zend_Service_Rackspace tests */ -define ('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED', fals); +define ('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED', false); define ('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER','insertUserName'); define ('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY','insertKey'); define ('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_NAME','test-zf-rackspace'); diff --git a/tests/Zend/Service/Rackspace/OfflineTest.php b/tests/Zend/Service/Rackspace/OfflineTest.php index 2b428017a4b..ffe8b4b21b1 100644 --- a/tests/Zend/Service/Rackspace/OfflineTest.php +++ b/tests/Zend/Service/Rackspace/OfflineTest.php @@ -184,7 +184,7 @@ public function testAuthenticateError() $this->assertFalse($this->_files->authenticate()); $this->assertFalse($this->_files->isSuccessful()); - $this->assertEquals($this->_files->getErrorStatus(),'401'); + $this->assertEquals($this->_files->getErrorCode(),'401'); $this->assertEquals($this->_files->getErrorMsg(),'Bad username or password'); }