summaryrefslogtreecommitdiff
path: root/server/core
diff options
context:
space:
mode:
authorEoleDev <EoleDev@outlook.fr>2016-02-12 12:45:00 +0100
committerEoleDev <EoleDev@outlook.fr>2016-02-12 12:45:00 +0100
commit294fbb4d11b9399be231bd999447f2a214e11a1f (patch)
treecc5c257b725fcf068280cc1de5b826a7f76737ee /server/core
parentaf451ad44290f6cf8373b3672da1ada64f91ecfc (diff)
ErrorManagement Class Introduction
Diffstat (limited to 'server/core')
-rwxr-xr-xserver/core/App.php32
-rwxr-xr-xserver/core/ErrorManagement.php39
-rwxr-xr-xserver/core/Identity.php34
3 files changed, 99 insertions, 6 deletions
diff --git a/server/core/App.php b/server/core/App.php
index bba99b4..ff2e1af 100755
--- a/server/core/App.php
+++ b/server/core/App.php
@@ -1,13 +1,21 @@
<?php
include_once("core/Plugin_Api.php");
include_once("core/LibOverride/genTokenOptions.php");
+include_once("core/ErrorManagement.php");
+
+use OpenStack\Common\Error\BadResponseError;
+use OpenStack\Common\Error\BaseError;
+use OpenStack\Common\Error\NotImplementedError;
+use OpenStack\Common\Error\UserInputError;
class App{
protected $openstack;
protected $pluginsApi;
+ protected $postParams;
protected $tokenClass;
protected $tokenPost;
+ protected $errorClass;
protected $output;
public function __construct($args){
@@ -16,7 +24,9 @@ class App{
$this->tokenClass = new genTokenOptions($args);
$this->openstack = new OpenStack\OpenStack([]);
$this->pluginsApi = plugin_api::getInstance();
+ $this->errorClass = new errorManagement($this);
$this->output = array();
+ $this->postParams = $_POST;
}
@@ -53,19 +63,37 @@ class App{
$this->tokenClass->genNetworkToken();
$this->setOutput("token", $this->tokenClass->getBackup());
- }catch(Exception $e){
- echo $e;
+ }catch(BadResponseError $e){
+ var_dump($e);
+ }catch(UserInputError $e){
+ var_dump($e);
+ }catch(BaseError $e){
+ var_dump($e);
exit();
+ }catch(NotImplementedError $e){
+ var_dump($e);
}
}
+ public function getPostParam($name){
+
+ return $this->postParams[$name];
+
+ }
+
public function setOutput($key, $out){
$this->output[$key] = $out;
}
+ public function getErrorInstance(){
+
+ return $this->errorClass;
+
+ }
+
public function show(){
echo json_encode($this->output);
}
diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php
new file mode 100755
index 0000000..ebd5abe
--- /dev/null
+++ b/server/core/ErrorManagement.php
@@ -0,0 +1,39 @@
+<?php
+
+use OpenStack\Common\Error\BadResponseError;
+use OpenStack\Common\Error\BaseError;
+use OpenStack\Common\Error\NotImplementedError;
+use OpenStack\Common\Error\UserInputError;
+
+
+Class errorManagement{
+
+ protected $app;
+
+
+ public function __construct($args){
+
+ $this->app = $args;
+
+ }
+
+ public function BaseErrorHandler($error){
+
+ }
+
+ public function BadResponseHandler($error){
+
+ }
+
+ public function NotImplementedHandler($error){
+
+ }
+
+ public function UserInputHandler($error){
+
+ }
+
+
+}
+
+?> \ No newline at end of file
diff --git a/server/core/Identity.php b/server/core/Identity.php
index 7b6293c..1dc8373 100755
--- a/server/core/Identity.php
+++ b/server/core/Identity.php
@@ -9,7 +9,7 @@
*
* @todo Complete the functions and finish the descriptions
*/
-
+use OpenStack\Common\Error;
/**
* Identity Class of the back-end application
@@ -59,6 +59,25 @@ class identity implements Core{
*/
$credentials["addCredential"] = function(){
+ $blob = $this->app->getPostParam("blob");
+ $projectId = $this->app->getPostParam("projectId");
+ $type = $this->app->getPostParam("type");
+ $userId = $this->app->getPostParam("userId");
+
+ if(!isset($blob) || !isset($projectId) || !isset($type) || !isset($userId)){
+ $this->app->setOutput("Error", "Parameters Incorrect");
+ }
+
+ try{
+
+ $opt = array('blob' => $blob, 'projectId' => $projectId, 'type' => $type, 'userId' => $userId);
+ $res = $this->libClass->createCredential($opt);
+
+ }catch(Exception $e){
+
+ }
+
+ ]
}
@@ -82,7 +101,8 @@ class identity implements Core{
* @return void
*/
$credentials["showCredential"] = function(){
-
+ $credential = $identity->getCredential('credentialId');
+$credential->retrieve();
}
@@ -94,7 +114,12 @@ class identity implements Core{
* @return void
*/
$credentials["updateCredential"] = function(){
-
+ $credential = $identity->getCredential('credentialId');
+
+$credential->type = 'foo';
+$credential->blob = 'bar';
+
+$credential->update();
}
@@ -106,7 +131,8 @@ class identity implements Core{
* @return void
*/
$credentials["deleteCredential"] = function(){
-
+ $credential = $identity->getCredential('credentialId');
+$credential->delete();
}