From e9c7477ff0acedf9b49e508e1543395bbcbf7533 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 27 Mar 2016 19:24:03 +0200 Subject: Modifications in error management and correct error in Image.php --- server/core/Image.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server/core/Image.php') diff --git a/server/core/Image.php b/server/core/Image.php index 71e19ce..e9736a2 100755 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -76,7 +76,7 @@ class image implements Core{ // Check the image name if(isset($opt['name'])){ - $imagesList = listImage(); + $imagesList = $this->listImage(); if(isset($imagesList)){ foreach($imagesList as $image){ if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error @@ -84,7 +84,7 @@ class image implements Core{ } } } - + $options['name'] = $opt['name']; } else{ $this->app->setOutput("Error", "Missing parameter 'name' for the new image"); @@ -118,7 +118,7 @@ class image implements Core{ if(isset($opt['protected'])){ // boolean $options['protected'] = $opt['protected']; } - if(isset($opt['properties'])){ // type dict ? + if(isset($opt['properties'])){ // type dict $options['properties'] = $opt['properties']; } @@ -187,7 +187,6 @@ class image implements Core{ $this->app->setOutput("Error", "Image doesn't exist"); } else{ - echo 'toto'; $this->app->setOutput("Images", $image); } }catch(BadResponseError $e){ @@ -326,6 +325,7 @@ class image implements Core{ if($image == null){ // if the image don't exists -> error $this->app->setOutput("Error", "Image doesn't exist"); } + $image->reactivate(); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); -- cgit v1.2.3 From 19d84e2ae4c6710aac2236df4f135409ef519fc8 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 27 Mar 2016 19:40:36 +0200 Subject: Update commentaries --- server/core/Automating.php | 15 +++++++---- server/core/ErrorManagement.php | 55 ++++++++++++++++++++++++++++++++++++++--- server/core/Image.php | 4 +-- 3 files changed, 64 insertions(+), 10 deletions(-) (limited to 'server/core/Image.php') diff --git a/server/core/Automating.php b/server/core/Automating.php index 2665541..065cf5e 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -1,11 +1,11 @@ {$action.""}(); } - + /** + * Create a new image on a new server + * + * @param $error the error triggered + * + * @return Image the new image created + */ private function createImageOnNewServer(){ try{ $image = new Image($this->app); @@ -87,9 +93,8 @@ class automating implements Core{ }catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } + $this->app->setOutput("Auto", $res); } - - } ?> \ No newline at end of file diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php index e7cb83e..be7080b 100755 --- a/server/core/ErrorManagement.php +++ b/server/core/ErrorManagement.php @@ -1,4 +1,13 @@ app = $args; } + /** + * Put an error message corresponding to a base error in the output + * + * @param $error the error triggered + * + * @return String BaseError message + */ public function BaseErrorHandler($error){ $this->app->setOutput("Error", "BaseError"); } + /** + * Put an error message corresponding to a bad response in function of the status code in the output + * + * @param $error the error triggered + * + * @return String Error message + */ public function BadResponseHandler($error){ $statusCode = $error->getResponse()->getStatusCode(); switch ($statusCode) { @@ -54,19 +83,39 @@ Class errorManagement{ } } + /** + * Put an error message corresponding to a not implemented yet error in the output + * + * @param $error the error triggered + * + * @return String internal error message + */ public function NotImplementedHandler($error){ $this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator"); } + /** + * Put an error message corresponding to a user input error in the output + * + * @param $error the error triggered + * + * @return String User input error message + */ public function UserInputHandler($error){ $this->app->setOutput("Error", "UserInputError"); } + /** + * Put an error message corresponding to an other error in the output + * + * @param $error the error triggered + * + * @return String error message + */ public function OtherException($error){ $this->app->setOutput("Error", $error->getMessage()); } - } ?> diff --git a/server/core/Image.php b/server/core/Image.php index e9736a2..c595135 100755 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -5,7 +5,7 @@ * @version 1.0 Initialisation of this file * @since 1.0 Core application's file * -* @author Yogg 'yogg at epsina . com' +* @author Evan Pisani 'yogg at epsina . com' * * @todo Complete the functions with errors detection and finish the descriptions */ @@ -19,7 +19,7 @@ include("CoreInterface.php"); /** * Image Class of the back-end application * -* ADD CLASS DESCRIPTION +* Management of images * */ class image implements Core{ -- cgit v1.2.3