2016-01-30 11:41:45 +01:00
|
|
|
|
<?php
|
2016-02-07 22:42:33 +01:00
|
|
|
|
/**
|
|
|
|
|
* File containing the identity Class.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Import the Error of the Library
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-03-09 15:21:46 +01:00
|
|
|
|
use OpenCloud\Common\Error;
|
2016-04-26 20:42:31 +02:00
|
|
|
|
|
2016-05-05 19:16:10 +02:00
|
|
|
|
require_once("CoreInterface.php");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
/**
|
|
|
|
|
* Identity Class of the back-end application
|
|
|
|
|
*
|
2016-04-26 20:42:31 +02:00
|
|
|
|
* This class implements the management for the identity request
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @version 1.0 Initialisation of this file
|
|
|
|
|
* @since 1.0 Core application's file
|
|
|
|
|
*
|
|
|
|
|
* @author Eole 'eoledev at outlook . fr'
|
|
|
|
|
*
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-05 00:07:31 +01:00
|
|
|
|
class identity implements Core{
|
2016-01-30 11:41:45 +01:00
|
|
|
|
|
2016-02-07 22:42:33 +01:00
|
|
|
|
/** @var App $app protected, contains the main app object */
|
2016-02-05 00:07:31 +01:00
|
|
|
|
protected $app;
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
|
|
|
|
/** @var OpenStack\Identity $libClass protected, contains the library Identity object */
|
2016-02-05 00:07:31 +01:00
|
|
|
|
protected $libClass;
|
2016-01-30 11:41:45 +01:00
|
|
|
|
|
2016-02-07 22:42:33 +01:00
|
|
|
|
/**
|
|
|
|
|
* identity constructor
|
|
|
|
|
*
|
|
|
|
|
* @param App $app the main app object
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return identity Object
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-05 00:07:31 +01:00
|
|
|
|
public function __construct($app){
|
2016-01-30 11:41:45 +01:00
|
|
|
|
|
2016-02-05 00:07:31 +01:00
|
|
|
|
$this->app = $app;
|
|
|
|
|
$this->libClass = $app->getLibClass("Identity");
|
2016-01-30 11:41:45 +01:00
|
|
|
|
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 17:20:38 +01:00
|
|
|
|
/**
|
|
|
|
|
* Execute an action
|
|
|
|
|
*
|
|
|
|
|
* @param String $action name of another function of this class
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-17 17:20:38 +01:00
|
|
|
|
*/
|
|
|
|
|
public function action($action){
|
|
|
|
|
|
2016-04-26 20:42:31 +02:00
|
|
|
|
$this->{$action.""}();
|
2016-02-17 17:20:38 +01:00
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
/**
|
|
|
|
|
* Add a credential for the given user/project.
|
|
|
|
|
*
|
|
|
|
|
* Create a secret/access pair for use with ec2 style auth.
|
|
|
|
|
* This operation will generates a new set of credentials that map the user/project pair.
|
|
|
|
|
*
|
2016-02-12 18:01:18 +01:00
|
|
|
|
* @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}"
|
|
|
|
|
* @param String $projectId Required project's UUID
|
|
|
|
|
* @param String $type Required Type of credential : ec2, cert...
|
|
|
|
|
* @param String $userId Required Id of the user which own the credential
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function addCredential(){
|
2016-02-05 00:07:31 +01:00
|
|
|
|
|
2016-02-12 12:45:00 +01:00
|
|
|
|
$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");
|
2016-02-12 18:01:18 +01:00
|
|
|
|
return;
|
2016-02-12 12:45:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$opt = array('blob' => $blob, 'projectId' => $projectId, 'type' => $type, 'userId' => $userId);
|
|
|
|
|
$res = $this->libClass->createCredential($opt);
|
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
2016-02-12 15:45:25 +01:00
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-05 00:07:31 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-07 22:42:33 +01:00
|
|
|
|
/**
|
|
|
|
|
* List the credentials for a given user.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listCredentials(){
|
2016-02-12 15:45:25 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$this->libClass->listCredentials()
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve a user’s access/secret pair by the access key.
|
|
|
|
|
*
|
2016-02-12 18:01:18 +01:00
|
|
|
|
* @param String $credentialId Required credential id for which it retrieve the details
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function showCredential(){
|
2016-02-12 15:45:25 +01:00
|
|
|
|
$credentId = $this->app->getPostParam("credentialId");
|
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
if(!isset($credentId)){
|
|
|
|
|
$this->app->setOutput("Error", "Parameters Incorrect");
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 15:45:25 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$cred = $this->libClass->getCredential($credentId);
|
|
|
|
|
$cred->retrieve();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update a user’s access/secret pair.
|
|
|
|
|
*
|
2016-02-12 18:01:18 +01:00
|
|
|
|
* @param String $credentialId Required credential id to update
|
|
|
|
|
* @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}"
|
|
|
|
|
* @param String $type Required Type of credential : ec2, cert...
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function updateCredential(){
|
2016-02-12 18:01:18 +01:00
|
|
|
|
|
|
|
|
|
$credentId = $this->app->getPostParam("credentialId");
|
|
|
|
|
$blob = $this->app->getPostParam("blob");
|
|
|
|
|
$type = $this->app->getPostParam("type");
|
|
|
|
|
|
|
|
|
|
if(!isset($blob) || !isset($credentId) || !isset($type)){
|
|
|
|
|
$this->app->setOutput("Error", "Parameters Incorrect");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$credential = $this->libClass->getCredential($credentId);
|
2016-02-12 12:45:00 +01:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
$credential->type = $type;
|
|
|
|
|
$credential->blob = $blob;
|
2016-02-12 12:45:00 +01:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
$credential->update();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a user’s access/secret pair.
|
|
|
|
|
*
|
2016-02-12 18:01:18 +01:00
|
|
|
|
* @param String $credentialId Required credential id to delete
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function deleteCredential(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
$credentId = $this->app->getPostParam("credentialId");
|
|
|
|
|
|
|
|
|
|
if(!isset($credentId)){
|
|
|
|
|
$this->app->setOutput("Error", "Parameters Incorrect");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$credential = $this->libClass->getCredential($credentId);
|
|
|
|
|
$credential->delete();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
}-
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a domain to an OpenStack instance.
|
|
|
|
|
*
|
2016-02-12 18:01:18 +01:00
|
|
|
|
* @param String $desc Optional Domain Description
|
|
|
|
|
* @param String $enabled Optional Domain enabled or not : value true or false
|
|
|
|
|
* @param String $name Required Domain Name
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function addDomain(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
$description = $this->app->getPostParam("desc");
|
|
|
|
|
$enabled = $this->app->getPostParam("enabled");
|
|
|
|
|
$name = $this->app->getPostParam("name");
|
|
|
|
|
|
|
|
|
|
if(!isset($name)){
|
|
|
|
|
$this->app->setOutput("Error", "Parameters Incorrect");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(isset($enabled) && isset($description))
|
2016-04-26 20:42:31 +02:00
|
|
|
|
$opt = array('description' => $description, 'enabled' => $enabled, 'name' => $name);
|
2016-02-12 18:01:18 +01:00
|
|
|
|
elseif(isset($enabled))
|
2016-04-26 20:42:31 +02:00
|
|
|
|
$opt = array('enabled' => $enabled, 'name' => $name);
|
2016-02-12 18:01:18 +01:00
|
|
|
|
elseif(isset($description))
|
2016-04-26 20:42:31 +02:00
|
|
|
|
$opt = array('description' => $description, 'name' => $name);
|
2016-02-12 18:01:18 +01:00
|
|
|
|
else
|
2016-04-26 20:42:31 +02:00
|
|
|
|
$opt = array('name' => $name);
|
2016-02-12 18:01:18 +01:00
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$res = $this->libClass->createCredential($opt);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the different domain's list.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listDomains(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$this->libClass->listDomains()
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the details of a given domain.
|
|
|
|
|
*
|
2016-02-12 18:01:18 +01:00
|
|
|
|
* @param String $domainId Required Domain id for which it retrieve the details
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function showDomain(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
|
|
|
|
|
if(!isset($domId)){
|
|
|
|
|
$this->app->setOutput("Error", "Parameters Incorrect");
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($domId);
|
|
|
|
|
$domain->retrieve();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update the given domain.
|
|
|
|
|
*
|
2016-02-12 18:01:18 +01:00
|
|
|
|
* @param String $domainId Required domain id to update
|
|
|
|
|
* @param String $desc Optional Domain Description
|
|
|
|
|
* @param String $enabled Optional Domain enabled or not : value true or false
|
|
|
|
|
* @param String $name Required Domain Name
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function updateDomain(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
$description = $this->app->getPostParam("desc");
|
|
|
|
|
$enabled = $this->app->getPostParam("enabled");
|
|
|
|
|
$name = $this->app->getPostParam("name");
|
|
|
|
|
|
|
|
|
|
if(!isset($domId)){
|
|
|
|
|
$this->app->setOutput("Error", "Parameters Incorrect");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-04-26 20:42:31 +02:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($domId);
|
|
|
|
|
|
|
|
|
|
if(isset($name))
|
2016-04-26 20:42:31 +02:00
|
|
|
|
$domain->name = $name;
|
2016-02-12 18:01:18 +01:00
|
|
|
|
if(isset($enabled))
|
2016-04-26 20:42:31 +02:00
|
|
|
|
$domain->enabled = $enabled;
|
2016-02-12 18:01:18 +01:00
|
|
|
|
if(isset($description))
|
2016-04-26 20:42:31 +02:00
|
|
|
|
$domain->description = $description;
|
2016-02-12 18:01:18 +01:00
|
|
|
|
|
|
|
|
|
$domain->update();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete the given domain.
|
|
|
|
|
*
|
2016-02-12 18:01:18 +01:00
|
|
|
|
* @param String $domainId Required Domain id to delete
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function deleteDomain(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 18:01:18 +01:00
|
|
|
|
if(!isset($domId)){
|
|
|
|
|
$this->app->setOutput("Error", "Parameters Incorrect");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($domId);
|
|
|
|
|
$domain->delete();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the different roles of a given user in a domain.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listRolesDomainUser(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
|
|
|
|
|
if(!isset($domId) || !isset($userId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($domId);
|
|
|
|
|
|
|
|
|
|
$domain->listUserRoles(['userId' => $userId]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Grant a role to a given user in a domain.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function grantRoleDomainUser(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($domId) || !isset($roleId) || !isset($userId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($domId);
|
|
|
|
|
|
|
|
|
|
$domain->grantUserRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'userId' => $userId,
|
|
|
|
|
'roleId' => $roleId,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify that a user has a given role in a domain.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function checkRoleDomainUser(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($domId) || !isset($roleId) || !isset($userId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($domId);
|
|
|
|
|
|
|
|
|
|
$result = $domain->checkUserRole(['userId' => $userId, 'roleId' => $roleId]);
|
|
|
|
|
|
|
|
|
|
/*if (true === $result) {
|
|
|
|
|
// It exists!
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a role for a given user in a domain.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function revokeRoleDomainUser(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($domId) || !isset($roleId) || !isset($userId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($domId);
|
|
|
|
|
|
|
|
|
|
$domain->revokeUserRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'userId' => $userId,
|
|
|
|
|
'roleId' => $roleId,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the roles of a given group in a domain.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listRolesDomainGroup(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($domId) || !isset($groupId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($domId);
|
|
|
|
|
|
|
|
|
|
$domain->listGroupRoles(['groupId' => $groupId]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a role to a given group in a domain.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function grantRoleDomainGroup(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($domId) || !isset($groupId) || !isset($roleId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($domId);
|
|
|
|
|
|
|
|
|
|
$domain->grantGroupRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'groupId' => $groupId,
|
|
|
|
|
'roleId' => $roleId,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify that a role is associated with a given group in a domain.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function checkRoleDomainGroup(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($domId) || !isset($groupId) || !isset($roleId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($domId);
|
|
|
|
|
|
|
|
|
|
$result = $domain->checkGroupRole(['groupId' => $groupId, 'roleId' => $roleId]);
|
|
|
|
|
|
|
|
|
|
/*if (true === $result) {
|
|
|
|
|
// It exists!
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a role for a given group in a domain.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function revokeRoleDomainGroup(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($domId) || !isset($groupId) || !isset($roleId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$domain = $this->libClass->getDomain($roleId);
|
|
|
|
|
|
|
|
|
|
$domain->revokeGroupRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'groupId' => $groupId,
|
|
|
|
|
'roleId' => $roleId,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add an endpoint to the Openstack instance
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function addEndpoint(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$servId = $this->app->getPostParam("serviceId");
|
|
|
|
|
$name = $this->app->getPostParam("name");
|
|
|
|
|
$region = $this->app->getPostParam("region");
|
|
|
|
|
$url = $this->app->getPostParam("url");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($servId) || !isset($name) || !isset($region) || !isset($url)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$endpoint = $this->libClass->createEndpoint([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'interface' => \OpenStack\Identity\v3\Enum::INTERFACE_INTERNAL,
|
|
|
|
|
'name' => $name,
|
|
|
|
|
'region' => $region,
|
|
|
|
|
'url' => $url,
|
|
|
|
|
'serviceId' => $servId
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the endpoint for the given id
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function getEndpoint(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$endId = $this->app->getPostParam("endpointId");
|
|
|
|
|
|
|
|
|
|
if(!isset($endId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$endpoint = $this->libClass->getEndpoint($endId);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the list of the different endpoints
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listEndpoints(){
|
2016-04-26 20:42:31 +02:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$res = $this->libClass->listEndpoints();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update a given endpoint
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function updateEndpoint(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Not Implemented Yet
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a given endpoint
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function deleteEndpoint(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$endId = $this->app->getPostParam("endpointId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($endId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$endpoint = $this->libClass->getEndpoint($endId);
|
|
|
|
|
$endpoint->delete();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a group.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function addGroup(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Not Implemented Yet
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-07 22:42:33 +01:00
|
|
|
|
/**
|
|
|
|
|
* Retrieve the group's list.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listGroups(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Not Implemented Yet
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the details of a given group.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function showGroup(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Not Implemented Yet
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update a given group.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function updateGroup(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Todo Argument Optional
|
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
|
|
|
|
$description = $this->app->getPostParam("description");
|
|
|
|
|
$name = $this->app->getPostParam("name");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($groupId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$group = $this->libClass->getGroup($groupId);
|
|
|
|
|
|
|
|
|
|
if(isset($description))
|
2016-04-26 20:42:31 +02:00
|
|
|
|
$group->description = 'foo';
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(isset($name))
|
2016-04-26 20:42:31 +02:00
|
|
|
|
$group->name = 'bar';
|
2016-02-12 20:03:21 +01:00
|
|
|
|
|
|
|
|
|
$group->update();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete the given group.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function deleteGroup(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
|
|
|
|
|
|
|
|
|
if(!isset($groupId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$group = $this->libClass->getGroup($groupId);
|
|
|
|
|
|
|
|
|
|
$group->delete();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the users of a given group.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listGroupUsers(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($groupId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$group = $this->libClass->getGroup($groupId);
|
|
|
|
|
|
|
|
|
|
$users = $group->listUsers();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a user to a group.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function addGroupUser(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($userId) || !isset($groupId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$group = $this->libClass->getGroup($groupId);
|
|
|
|
|
|
|
|
|
|
$group->addUser(['userId' => $userId]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove a user from a given group.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function removeGroupUser(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
|
|
|
|
|
|
|
|
|
if(!isset($userId) || !isset($groupId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$group = $this->libClass->getGroup($groupId);
|
|
|
|
|
|
|
|
|
|
$group->removeUser(['userId' => $userId]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if a group contains a given user.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function checkGroupUser(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
|
|
|
|
|
|
|
|
|
if(!isset($userId) || !isset($groupId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$group = $this->libClass->getGroup($groupId);
|
|
|
|
|
|
|
|
|
|
$result = $group->checkMembership(['userId' => $userId]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function addPolicies(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Not Implemented Yet
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listPolicies(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Not Implemented Yet
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function showPolicie(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Not Implemented Yet
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function updatePolicies(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Not Implemented Yet
|
2016-02-05 00:07:31 +01:00
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function deletePolicies(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Not Implemented Yet
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function addProject(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Todo Parameters Optional
|
|
|
|
|
$description = $this->app->getPostParam("description");
|
|
|
|
|
$name = $this->app->getPostParam("name");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($name) || !isset($description)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->createProject([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'description' => $description,
|
|
|
|
|
'enabled' => true,
|
|
|
|
|
'name' => $name
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the different projects.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listProjects(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$projects = $this->libClass->listProjects();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the details of a given project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function showProject(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$projId = $this->app->getPostParam("projetId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($projId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
$project->retrieve();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update a given project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function updateProject(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Todo Parameters Optionnal
|
|
|
|
|
$description = $this->app->getPostParam("description");
|
|
|
|
|
$name = $this->app->getPostParam("name");
|
|
|
|
|
$projId = $this->app->getPostParam("projetId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($projId) || !isset($name) || !isset($description)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
|
|
|
|
|
$project->enabled = false;
|
|
|
|
|
$project->description = $description;
|
|
|
|
|
$project->name = $name;
|
|
|
|
|
|
|
|
|
|
$project->update();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a given project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function deleteProject(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$projId = $this->app->getPostParam("projId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($projId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
|
|
|
|
|
$project->delete();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* List the roles of a given user in a project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listRolesProjectUser(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$projId = $this->app->getPostParam("projetId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($projId) || !isset($userId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
|
|
|
|
|
$project->listUserRoles(['userId' => $userId]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Grant a role to an user in a project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function grantRoleProjectUser(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$projId = $this->app->getPostParam("projId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($projId) || !isset($userId) || !isset($roleId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
|
|
|
|
|
$project->grantUserRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'userId' => $userId,
|
|
|
|
|
'roleId' => $roleId,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if a given user has a role in a project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function checkRoleProjectUser(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$projId = $this->app->getPostParam("projetId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($projId) || !isset($userId) || !isset($roleId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
|
|
|
|
|
$result = $project->checkUserRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'userId' => $userId,
|
|
|
|
|
'roleId' => $roleId,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
/*if (true === $result) {
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a role for a given user in a project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function revokeRoleProjectUser(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$projId = $this->app->getPostParam("projetId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
|
|
|
|
|
|
|
|
|
if(!isset($projId) || !isset($userId) || !isset($roleId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
|
|
|
|
|
$project->revokeUserRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'userId' => $userId,
|
|
|
|
|
'roleId' => $roleId,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* List the roles of a group in a project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listRolesProjectGroup(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
|
|
|
|
|
$projId = $this->app->getPostParam("projetId");
|
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!isset($projId) || !isset($groupId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-04-26 20:42:31 +02:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
|
|
|
|
|
$project->listGroupRoles(['groupId' => $groupId]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a role to a group in a project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function grantRoleProjectGroup(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
|
|
|
|
|
$projId = $this->app->getPostParam("projetId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
|
|
|
|
|
|
|
|
|
if(!isset($projId) || !isset($userId) || !isset($roleId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-04-26 20:42:31 +02:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
|
|
|
|
|
$project->grantUserRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'userId' => $userId,
|
|
|
|
|
'roleId' => $roleId,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if a group has a given role in a project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function checkRoleProjectGroup(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$projId = $this->app->getPostParam("projetId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($projId) || !isset($userId) || !isset($roleId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
|
|
|
|
|
$result = $project->checkGroupRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'groupId' => $groupId,
|
|
|
|
|
'roleId' => $roleId,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
/*if (true === $result) {
|
|
|
|
|
}*/
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a role for a group in a project.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function revokeRoleProjectGroup(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$projId = $this->app->getPostParam("projetId");
|
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$roleId = $this->app->getPostParam("roleId");
|
|
|
|
|
|
|
|
|
|
if(!isset($projId) || !isset($userId) || !isset($roleId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$project = $this->libClass->getProject($projId);
|
|
|
|
|
|
|
|
|
|
$project->revokeGroupRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'groupId' => $groupId,
|
|
|
|
|
'roleId' => $roleId,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a role.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function addRole(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$name = $this->app->getPostParam("name");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($name)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$role = $this->libClass->createRole([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'name' => $name,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* List the different roles
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listRoles(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$roles = $this->libClass->listRoles();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-04-26 20:42:31 +02:00
|
|
|
|
* List the different assignments for a given role
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listRoleAssignements(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$assignements = $this->libClass->listRoleAssignments();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a service.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function addService(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$name = $this->app->getPostParam("name");
|
|
|
|
|
$type = $this->app->getPostParam("type");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($name) || !isset($type)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$service = $this->libClass->createService([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'name' => $name,
|
|
|
|
|
'type' => $type,
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the different services.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listServices(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$services = $this->libClass->listServices();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the details for a given service.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function showService(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$servId = $this->app->getPostParam("serviceId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($servId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$service = $this->libClass->getService($servId);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a given service.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function deleteService(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$servId = $this->app->getPostParam("serviceId");
|
|
|
|
|
$groupId = $this->app->getPostParam("groupId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($servId) || !isset($groupId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$service = $this->libClass->getService($servId);
|
|
|
|
|
$service->delete();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a new token for a given user id.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function genTokenUserID(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$userPass = $this->app->getPostParam("userPassword");
|
|
|
|
|
|
|
|
|
|
if(!isset($userId) || !isset($userPass)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$token = $this->libClass->generateToken([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'user' => [
|
|
|
|
|
'id' => $userId,
|
|
|
|
|
'password' => $userPass
|
|
|
|
|
]
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a new token for a given user name.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function genTokenUserName(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$username = $this->app->getPostParam("username");
|
|
|
|
|
$userPass = $this->app->getPostParam("userPassword");
|
|
|
|
|
$domId = $this->app->getPostParam("domainId");
|
|
|
|
|
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($userId) || !isset($userPass) || !isset($domId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$token = $this->libClass->generateToken([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'user' => [
|
|
|
|
|
'name' => $username,
|
|
|
|
|
'password' => $userPass,
|
|
|
|
|
'domain' => [
|
|
|
|
|
'id' => $domId
|
|
|
|
|
]
|
|
|
|
|
]
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a new token from another token ID.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function genTokenID(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$tokenId = $this->app->getPostParam("tokenId");
|
|
|
|
|
$projectId = $this->app->getPostParam("projectId");
|
|
|
|
|
|
|
|
|
|
if(!isset($tokenId) || !isset($projectId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$token = $this->libClass->generateToken([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'tokenId' => $tokenId,
|
|
|
|
|
'scope' => ['project' => ['id' => $projectId]]
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a new token scoped by a project ID.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function genTokenScopedProjectID(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$userPass = $this->app->getPostParam("userPass");
|
|
|
|
|
$projId = $this->app->getPostParam("projetId");
|
|
|
|
|
|
|
|
|
|
if(!isset($userId) || !isset($projId) || !isset($userPass)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$token = $this->libClass->generateToken([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'user' => [
|
|
|
|
|
'id' => $userId,
|
|
|
|
|
'password' => $userPass
|
|
|
|
|
],
|
|
|
|
|
'scope' => [
|
|
|
|
|
'project' => ['id' => $projId]
|
|
|
|
|
]
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a new token scoped by a project name.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function genTokenScopedProjectName(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$userPass = $this->app->getPostParam("userPass");
|
|
|
|
|
$projName = $this->app->getPostParam("projetName");
|
|
|
|
|
$domId = $this->app->getPostParam("domId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($userId) || !isset($projName) || !isset($userPass) || !isset($domId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$token = $this->libClass->generateToken([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'user' => [
|
|
|
|
|
'id' => $userId,
|
|
|
|
|
'password' => $userPass
|
|
|
|
|
],
|
|
|
|
|
'scope' => [
|
|
|
|
|
'project' => [
|
|
|
|
|
'name' => $projName,
|
|
|
|
|
'domain' => [
|
|
|
|
|
'id' => $domId
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
]
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if a token is validate.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function validateToken(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$tokenId = $this->app->getPostParam("tokenId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($tokenId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$result = $this->libClass->validateToken($tokenId);
|
|
|
|
|
|
|
|
|
|
/*if (true === $result) {
|
|
|
|
|
// It's valid!
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a given token.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function revokeToken(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$tokenId = $this->app->getPostParam("tokenId");
|
|
|
|
|
|
|
|
|
|
if(!isset($tokenId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$this->libClass->revokeToken($tokenId);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a new user.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function addUser(){
|
2016-02-12 20:03:21 +01:00
|
|
|
|
//Todo Optionnal Parameter
|
|
|
|
|
$projId = $this->app->getPostParam("projId");
|
|
|
|
|
$desc = $this->app->getPostParam("description");
|
|
|
|
|
$email = $this->app->getPostParam("email");
|
|
|
|
|
$name = $this->app->getPostParam("name");
|
|
|
|
|
$pass = $this->app->getPostParam("pass");
|
|
|
|
|
$domId = $this->app->getPostParam("domId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($domId) || !isset($groupId)){
|
2016-04-26 20:42:31 +02:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$user = $this->libClass->createUser([
|
2016-04-26 20:42:31 +02:00
|
|
|
|
'defaultProjectId' => $projId,
|
|
|
|
|
'description' => $desc,
|
|
|
|
|
'domainId' => $domId,
|
|
|
|
|
'email' => $email,
|
|
|
|
|
'enabled' => true,
|
|
|
|
|
'name' => $name,
|
|
|
|
|
'password' => $pass
|
2016-02-12 20:03:21 +01:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the different users.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listUsers(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$users = $this->libClass->listUsers();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the details of a given user.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function showUser(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
|
|
|
|
|
if(!isset($userId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$user = $this->libClass->getUser($userId);
|
|
|
|
|
$user->retrieve();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update a given user.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function updateUser(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
$desc = $this->app->getPostParam("description");
|
|
|
|
|
$name = $this->app->getPostParam("name");
|
|
|
|
|
|
|
|
|
|
if(!isset($userId) || !isset($desc) || !isset($name)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$user = $this->libClass->getUser($userId);
|
|
|
|
|
|
|
|
|
|
$user->description = $desc;
|
|
|
|
|
$user->name = $name;
|
|
|
|
|
|
|
|
|
|
$user->update();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a given user.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function deleteUser(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
|
|
|
|
|
if(!isset($userId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$user = $this->libClass->getUser($userId);
|
|
|
|
|
$user->delete();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the groups which contains a given user.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listUserGroups(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
if(!isset($userId)){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$user = $this->libClass->getUser($userId);
|
|
|
|
|
|
|
|
|
|
$groups = $user->listGroups();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieve the projects which contains a given user.
|
|
|
|
|
*
|
2016-04-27 14:22:59 +02:00
|
|
|
|
* @return void
|
2016-02-07 22:42:33 +01:00
|
|
|
|
*/
|
2016-02-17 17:20:38 +01:00
|
|
|
|
private function listUserProjects(){
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
$userId = $this->app->getPostParam("userId");
|
|
|
|
|
|
|
|
|
|
if(!isset($userId)){
|
|
|
|
|
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
|
2016-02-12 20:03:21 +01:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$user = $this->libClass->getUser($userId);
|
|
|
|
|
|
|
|
|
|
$projects = $user->listProjects();
|
|
|
|
|
|
|
|
|
|
//TODO parse answer
|
|
|
|
|
|
|
|
|
|
}catch(BadResponseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(UserInputError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(BaseError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(NotImplementedError $e){
|
2016-03-20 10:41:58 +01:00
|
|
|
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
2016-04-26 20:42:31 +02:00
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$this->app->getErrorInstance()->OtherException($e);
|
|
|
|
|
}
|
2016-02-07 22:42:33 +01:00
|
|
|
|
}
|
2016-01-30 11:41:45 +01:00
|
|
|
|
}
|