summaryrefslogtreecommitdiff
path: root/server/core/Image.php
diff options
context:
space:
mode:
Diffstat (limited to 'server/core/Image.php')
-rwxr-xr-xserver/core/Image.php236
1 files changed, 118 insertions, 118 deletions
diff --git a/server/core/Image.php b/server/core/Image.php
index 334fce4..b256d4c 100755
--- a/server/core/Image.php
+++ b/server/core/Image.php
@@ -7,8 +7,8 @@
*
* @author Evan Pisani 'yogg at epsina . com'
*
-* @todo Complete the functions with errors detection and finish the descriptions
*/
+
use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError;
@@ -27,7 +27,7 @@ class image implements Core{
/** @var App $app protected, contains the main app object */
protected $app;
- /** @var OpenStack\Identity $libClass protected, contains the library Identity object */
+ /** @var OpenStack\Image $libClass protected, contains the library Image object */
protected $libClass;
/**
@@ -35,7 +35,7 @@ class image implements Core{
*
* @param App $app the main app object
*
- * @return Image
+ * @return image Object
*/
public function __construct($app){
if(!isset($app)){
@@ -54,7 +54,7 @@ class image implements Core{
* @return void
*/
public function action($action){
- $this->{$action.""}();
+ $this->{$action.""}();
}
/**
@@ -62,7 +62,7 @@ class image implements Core{
*
* @param array $opt Options for the image creation (name is required, others are optionals)
*
- * @return Image
+ * @return void
*/
private function createImage(){
$opt = $this->app->getPostParam("opt");
@@ -78,13 +78,13 @@ class image implements Core{
if(isset($opt['name'])){
$imagesList = $this->listImage();
if(isset($imagesList)){
- foreach($imagesList as $image){
- if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error
- $this->app->setOutput("Error", "Image name already exists");
- }
- }
- }
- $options['name'] = $opt['name'];
+ foreach($imagesList as $image){
+ if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error
+ $this->app->setOutput("Error", "Image name already exists");
+ }
+ }
+ }
+ $options['name'] = $opt['name'];
}
else{
$this->app->setOutput("Error", "Missing parameter 'name' for the new image");
@@ -125,15 +125,15 @@ class image implements Core{
$image = $this->libClass->createImage($options);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
$this->app->setOutput("Images", $image);
}
@@ -141,7 +141,7 @@ class image implements Core{
/**
* List the images of the server
*
- * @return List of Image
+ * @return void
*/
private function listImage(){
try{
@@ -152,15 +152,15 @@ class image implements Core{
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
$this->app->setOutput("Images", $result);
@@ -171,7 +171,7 @@ class image implements Core{
*
* @param String $id Identifier of the image
*
- * @return Image
+ * @return void
*/
private function detailsImage(){
$id = $this->app->getPostParam("id");
@@ -191,16 +191,16 @@ class image implements Core{
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
}
/**
@@ -209,7 +209,7 @@ class image implements Core{
* @param String $id id of the image
* @param array $opt Options for the image creation
*
- * @return Image
+ * @return void
*/
private function updateImage(){
@@ -254,15 +254,15 @@ class image implements Core{
$image->update($options);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
$this->app->setOutput("Images", $image);
}
}
@@ -289,20 +289,20 @@ class image implements Core{
$image->delete();
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
}
/**
- * Resactive an image
+ * Reactive an image
*
* @param String $id Identifier of the image
*
@@ -326,20 +326,20 @@ class image implements Core{
$image->reactivate();
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
}
/**
- * Desactive an image
+ * Desactivaate an image
*
* @param String $id Identifier of the image
*
@@ -362,16 +362,16 @@ class image implements Core{
$image->deactivate();
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
}
/**
@@ -385,9 +385,9 @@ class image implements Core{
private function uploadImage(){
$id = $this->app->getPostParam("id");
$file_name = $this->app->getPostParam("file_name");
- $file = $this->app->getPostParam("file");
+ $file = $this->app->getPostParam("file");
error_log(print_r($file, true), 0);
-
+
if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter");
}
@@ -405,16 +405,16 @@ class image implements Core{
$image->uploadData($stream);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
}
/**
@@ -422,7 +422,7 @@ class image implements Core{
*
* @param String $id Identifier of the image
*
- * @return Stream
+ * @return void
*/
private function downloadImage(){
$id = $this->app->getPostParam("id");
@@ -440,17 +440,17 @@ class image implements Core{
$stream = $image->downloadData();
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- $this->app->setOutput("Images", $stream);
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ $this->app->setOutput("Images", $stream);
+ }
}
/**
@@ -459,7 +459,7 @@ class image implements Core{
* @param String $image_id Identifier of the image
* @param String $member_id Identifier of the member
*
- * @return Member
+ * @return void
*/
private function addMemberImage(){
$image_id = $this->app->getPostParam("image_id");
@@ -483,16 +483,16 @@ class image implements Core{
$this->app->setOutput("Images", $member_id);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
}
@@ -501,7 +501,7 @@ class image implements Core{
*
* @param String $image_id identifier of the image
*
- * @return List of Member
+ * @return void
*/
private function listMemberImage(){
$image_id = $this->app->getPostParam("image_id");
@@ -526,15 +526,15 @@ class image implements Core{
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
$this->app->setOutput("Images", $members);
}
}
@@ -545,7 +545,7 @@ class image implements Core{
* @param String $image_id Identifier of the image
* @param String $member_id Identifier of the member
*
- * @return Member
+ * @return void
*/
private function detailMemberImage(){
$image_id = $this->app->getPostParam("image_id");
@@ -572,15 +572,15 @@ class image implements Core{
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
$this->app->setOutput("Images", $member);
}
}
@@ -618,16 +618,16 @@ class image implements Core{
$member->delete();
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
}
/**
@@ -637,7 +637,7 @@ class image implements Core{
* @param String $member_id Identifier of the member
* @param String $status New status for the member
*
- * @return void
+ * @return void
**/
private function updateMemberImage(){
$image_id = $this->app->getPostParam("image_id");
@@ -665,16 +665,16 @@ class image implements Core{
$member->updateStatus($status);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
}
}