ErrorManagement Class Introduction
This commit is contained in:
parent
af451ad442
commit
294fbb4d11
4 changed files with 100 additions and 7 deletions
|
@ -1,13 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
include_once("core/Plugin_Api.php");
|
include_once("core/Plugin_Api.php");
|
||||||
include_once("core/LibOverride/genTokenOptions.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{
|
class App{
|
||||||
|
|
||||||
protected $openstack;
|
protected $openstack;
|
||||||
protected $pluginsApi;
|
protected $pluginsApi;
|
||||||
|
protected $postParams;
|
||||||
protected $tokenClass;
|
protected $tokenClass;
|
||||||
protected $tokenPost;
|
protected $tokenPost;
|
||||||
|
protected $errorClass;
|
||||||
protected $output;
|
protected $output;
|
||||||
|
|
||||||
public function __construct($args){
|
public function __construct($args){
|
||||||
|
@ -16,7 +24,9 @@ class App{
|
||||||
$this->tokenClass = new genTokenOptions($args);
|
$this->tokenClass = new genTokenOptions($args);
|
||||||
$this->openstack = new OpenStack\OpenStack([]);
|
$this->openstack = new OpenStack\OpenStack([]);
|
||||||
$this->pluginsApi = plugin_api::getInstance();
|
$this->pluginsApi = plugin_api::getInstance();
|
||||||
|
$this->errorClass = new errorManagement($this);
|
||||||
$this->output = array();
|
$this->output = array();
|
||||||
|
$this->postParams = $_POST;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,19 +63,37 @@ class App{
|
||||||
$this->tokenClass->genNetworkToken();
|
$this->tokenClass->genNetworkToken();
|
||||||
|
|
||||||
$this->setOutput("token", $this->tokenClass->getBackup());
|
$this->setOutput("token", $this->tokenClass->getBackup());
|
||||||
}catch(Exception $e){
|
}catch(BadResponseError $e){
|
||||||
echo $e;
|
var_dump($e);
|
||||||
|
}catch(UserInputError $e){
|
||||||
|
var_dump($e);
|
||||||
|
}catch(BaseError $e){
|
||||||
|
var_dump($e);
|
||||||
exit();
|
exit();
|
||||||
|
}catch(NotImplementedError $e){
|
||||||
|
var_dump($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPostParam($name){
|
||||||
|
|
||||||
|
return $this->postParams[$name];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function setOutput($key, $out){
|
public function setOutput($key, $out){
|
||||||
|
|
||||||
$this->output[$key] = $out;
|
$this->output[$key] = $out;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getErrorInstance(){
|
||||||
|
|
||||||
|
return $this->errorClass;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function show(){
|
public function show(){
|
||||||
echo json_encode($this->output);
|
echo json_encode($this->output);
|
||||||
}
|
}
|
||||||
|
|
39
server/core/ErrorManagement.php
Executable file
39
server/core/ErrorManagement.php
Executable file
|
@ -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){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* @todo Complete the functions and finish the descriptions
|
* @todo Complete the functions and finish the descriptions
|
||||||
*/
|
*/
|
||||||
|
use OpenStack\Common\Error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identity Class of the back-end application
|
* Identity Class of the back-end application
|
||||||
|
@ -59,6 +59,25 @@ class identity implements Core{
|
||||||
*/
|
*/
|
||||||
$credentials["addCredential"] = function(){
|
$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
|
* @return void
|
||||||
*/
|
*/
|
||||||
$credentials["showCredential"] = function(){
|
$credentials["showCredential"] = function(){
|
||||||
|
$credential = $identity->getCredential('credentialId');
|
||||||
|
$credential->retrieve();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +114,12 @@ class identity implements Core{
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
$credentials["updateCredential"] = function(){
|
$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
|
* @return void
|
||||||
*/
|
*/
|
||||||
$credentials["deleteCredential"] = function(){
|
$credentials["deleteCredential"] = function(){
|
||||||
|
$credential = $identity->getCredential('credentialId');
|
||||||
|
$credential->delete();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
server/vendor/php-opencloud/openstack
vendored
2
server/vendor/php-opencloud/openstack
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 15aca73f423166c7ef8337ba08615c103c66e931
|
Subproject commit 1419eb2e01164bb6b8b837df37724423907352d7
|
Loading…
Add table
Reference in a new issue