From 5263cf00a253891396c442fe5be29762fb8be50d Mon Sep 17 00:00:00 2001 From: EoleDev Date: Tue, 26 Apr 2016 20:42:31 +0200 Subject: Refactoring of comments beginning --- server/core/App.php | 164 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 128 insertions(+), 36 deletions(-) (limited to 'server/core/App.php') diff --git a/server/core/App.php b/server/core/App.php index 114d945..3a027d7 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -1,21 +1,53 @@ tokenPost = NULL; @@ -27,6 +59,13 @@ class App{ } + /** + * Set the class var $tokenPost and load the token + * into the genTokenOptions Class + * + * @param String $token token to be set + * + */ public function setToken($token){ $this->tokenPost = $token; @@ -34,42 +73,59 @@ class App{ } + /** + * Check the expiration of the token + * + * @return Boolean if the token is not expired + */ public function checkToken(){ return $this->tokenClass->checkToken(); } + /** + * Get the service Class given the name in parameter + * + * @param String $service Name of the service + * + * @return Core object + */ public function getLibClass($service){ switch($service){ - case "Identity": - if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken(); - $opt = $this->tokenClass->getOptions($service); - return $this->openstack->identityV3($opt); - break; - case "Image": - if($this->tokenPost == NULL) $this->tokenClass->genImageToken(); - $opt = $this->tokenClass->getOptions($service); - return $this->openstack->imagesV2($opt); - break; - case "Network": - if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); - $opt = $this->tokenClass->getOptions($service); - return $this->openstack->networkingV2($opt); - break; - case "Compute": - if($this->tokenPost == NULL) $this->tokenClass->genComputeToken(); - $opt = $this->tokenClass->getOptions($service); - return $this->openstack->computeV2($opt); - break; - case "NetworkLayer3": - if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); - $opt = $this->tokenClass->getOptions('Network'); - return $this->openstack->networkingV2ExtLayer3($opt); - break; + case "Identity": + if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->identityV3($opt); + break; + case "Image": + if($this->tokenPost == NULL) $this->tokenClass->genImageToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->imagesV2($opt); + break; + case "Network": + if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->networkingV2($opt); + break; + case "Compute": + if($this->tokenPost == NULL) $this->tokenClass->genComputeToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->computeV2($opt); + break; + case "NetworkLayer3": + if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); + $opt = $this->tokenClass->getOptions('Network'); + return $this->openstack->networkingV2ExtLayer3($opt); + break; } } + /** + * Generate the token for the different services in OpenStack + * + * @return NULL + */ public function authenticate(){ try{ @@ -81,16 +137,21 @@ class App{ $this->setOutput("token", $this->tokenClass->getBackup()); }catch(BadResponseError $e){ $this->errorClass->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->errorClass->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->errorClass->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->errorClass->NotImplementedHandler($e); - } + } } + /** + * Revoke the openstack services' token + * + * @return NULL + */ public function deauthenticate(){ try{ @@ -103,16 +164,23 @@ class App{ $this->setOutput("deauthenticate", "Ok"); }catch(BadResponseError $e){ $this->errorClass->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->errorClass->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->errorClass->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->errorClass->NotImplementedHandler($e); - } + } } + /** + * Retrieve a post parameter given its name + * + * @param String $name Expected post parameter's name + * + * @return Object Post value + */ public function getPostParam($name){ if(isset($this->postParams[$name])){ @@ -123,28 +191,52 @@ class App{ } - + /** + * Set a post parameter for automating task + * + * @param String $param Name for the Post entry + * @param Object $value Value for the Post entry + * + * @return NULL + */ public function setPostParam($param, $value){ $this->postParams[$param] = $value; - + } + /** + * Set a new output message + * + * @param String $key Array key for the message + * @param Array $out Message's value + * + * @return NULL + */ public function setOutput($key, $out){ $this->output[$key] = $out; } + /** + * Retrieve the errorManagement instance Object + * + * @return errorManagement object + */ public function getErrorInstance(){ return $this->errorClass; } + /** + * Output the messages to be send to the client + * + * @return NULl + */ public function show(){ echo json_encode($this->output); - //error_log(var_dump(json_encode($this->output), true), 0); } } -- cgit v1.2.3