ProcessMaker-BE "Role and User (Endpoints)"
- Se han implementado los siguientes Endpoints:
GET /api/1.0/{workspace}/role/{rol_uid}/users?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/role/{rol_uid}/available-users?filter={filter}&start={start}&limit={limit}
POST /api/1.0/{workspace}/role/{rol_uid}/user
DELETE /api/1.0/{workspace}/role/{rol_uid}/user/{usr_uid}
This commit is contained in:
@@ -62,7 +62,7 @@ class Role
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function setArrayFieldNameForException($arrayData)
|
||||
public function setArrayFieldNameForException(array $arrayData)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayData as $key => $value) {
|
||||
@@ -191,9 +191,9 @@ class Role
|
||||
public function throwExceptionIfNotExistsRole($roleUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$role = \RolesPeer::retrieveByPK($roleUid);
|
||||
$obj = \RolesPeer::retrieveByPK($roleUid);
|
||||
|
||||
if (is_null($role)) {
|
||||
if (is_null($obj)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ROLE_DOES_NOT_EXIST", array($fieldNameForException, $roleUid)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -251,7 +251,7 @@ class Role
|
||||
*
|
||||
* return void Throw exception if data has an invalid value
|
||||
*/
|
||||
public function throwExceptionIfDataIsInvalid($roleUid, $arrayData)
|
||||
public function throwExceptionIfDataIsInvalid($roleUid, array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Set variables
|
||||
@@ -289,7 +289,7 @@ class Role
|
||||
*
|
||||
* return array Return data of the new Role created
|
||||
*/
|
||||
public function create($arrayData)
|
||||
public function create(array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
@@ -335,7 +335,7 @@ class Role
|
||||
*
|
||||
* return array Return data of the Role updated
|
||||
*/
|
||||
public function update($roleUid, $arrayData)
|
||||
public function update($roleUid, array $arrayData)
|
||||
{
|
||||
try {
|
||||
$arrayDataBackup = $arrayData;
|
||||
@@ -445,7 +445,7 @@ class Role
|
||||
*
|
||||
* return array Return an array with data Role
|
||||
*/
|
||||
public function getRoleDataFromRecord($record)
|
||||
public function getRoleDataFromRecord(array $record)
|
||||
{
|
||||
try {
|
||||
$conf = new \Configurations();
|
||||
@@ -487,7 +487,7 @@ class Role
|
||||
*
|
||||
* return array Return an array with all Roles
|
||||
*/
|
||||
public function getRoles($arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
|
||||
public function getRoles(array $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$arrayRole = array();
|
||||
|
||||
408
workflow/engine/src/ProcessMaker/BusinessModel/Role/User.php
Normal file
408
workflow/engine/src/ProcessMaker/BusinessModel/Role/User.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -67,7 +67,7 @@ class WebEntry
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function setArrayFieldNameForException($arrayData)
|
||||
public function setArrayFieldNameForException(array $arrayData)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayData as $key => $value) {
|
||||
@@ -175,9 +175,9 @@ class WebEntry
|
||||
public function throwExceptionIfNotExistsWebEntry($webEntryUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$webEntry = \WebEntryPeer::retrieveByPK($webEntryUid);
|
||||
$obj = \WebEntryPeer::retrieveByPK($webEntryUid);
|
||||
|
||||
if (is_null($webEntry)) {
|
||||
if (is_null($obj)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_WEB_ENTRY_DOES_NOT_EXIST", array($fieldNameForException, $webEntryUid)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -215,7 +215,7 @@ class WebEntry
|
||||
*
|
||||
* return void Throw exception if data has an invalid value
|
||||
*/
|
||||
public function throwExceptionIfDataIsInvalid($webEntryUid, $processUid, $arrayData)
|
||||
public function throwExceptionIfDataIsInvalid($webEntryUid, $processUid, array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Set variables
|
||||
@@ -537,7 +537,7 @@ class WebEntry
|
||||
*
|
||||
* return array Return data of the new Web Entry created
|
||||
*/
|
||||
public function create($processUid, $userUidCreator, $arrayData)
|
||||
public function create($processUid, $userUidCreator, array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
@@ -622,7 +622,7 @@ class WebEntry
|
||||
*
|
||||
* return array Return data of the Web Entry updated
|
||||
*/
|
||||
public function update($webEntryUid, $userUidUpdater, $arrayData)
|
||||
public function update($webEntryUid, $userUidUpdater, array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
@@ -797,7 +797,7 @@ class WebEntry
|
||||
*
|
||||
* return array Return an array with data Web Entry
|
||||
*/
|
||||
public function getWebEntryDataFromRecord($record)
|
||||
public function getWebEntryDataFromRecord(array $record)
|
||||
{
|
||||
try {
|
||||
if ($record["WE_METHOD"] == "WS") {
|
||||
|
||||
@@ -71,7 +71,7 @@ class WebEntry extends Api
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostWebEntry($prj_uid, $request_data)
|
||||
public function doPostWebEntry($prj_uid, array $request_data)
|
||||
{
|
||||
try {
|
||||
$arrayData = $this->webEntry->create($prj_uid, $this->getUserId(), $request_data);
|
||||
@@ -91,7 +91,7 @@ class WebEntry extends Api
|
||||
* @param string $we_uid {@min 32}{@max 32}
|
||||
* @param array $request_data
|
||||
*/
|
||||
public function doPutWebEntry($prj_uid, $we_uid, $request_data)
|
||||
public function doPutWebEntry($prj_uid, $we_uid, array $request_data)
|
||||
{
|
||||
try {
|
||||
$arrayData = $this->webEntry->update($we_uid, $this->getUserId(), $request_data);
|
||||
|
||||
@@ -66,7 +66,7 @@ class Role extends Api
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPost($request_data)
|
||||
public function doPost(array $request_data)
|
||||
{
|
||||
try {
|
||||
$arrayData = $this->role->create($request_data);
|
||||
@@ -85,7 +85,7 @@ class Role extends Api
|
||||
* @param string $rol_uid {@min 32}{@max 32}
|
||||
* @param array $request_data
|
||||
*/
|
||||
public function doPut($rol_uid, $request_data)
|
||||
public function doPut($rol_uid, array $request_data)
|
||||
{
|
||||
try {
|
||||
$arrayData = $this->role->update($rol_uid, $request_data);
|
||||
|
||||
81
workflow/engine/src/ProcessMaker/Services/Api/Role/User.php
Normal file
81
workflow/engine/src/ProcessMaker/Services/Api/Role/User.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Services\Api\Role;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Role\User Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class User extends Api
|
||||
{
|
||||
private $roleUser;
|
||||
|
||||
/**
|
||||
* Constructor of the class
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$this->roleUser = new \ProcessMaker\BusinessModel\Role\User();
|
||||
|
||||
$this->roleUser->setFormatFieldNameInUppercase(false);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:rol_uid/users
|
||||
* @url GET /:rol_uid/available-users
|
||||
*
|
||||
* @param string $rol_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetUsers($rol_uid, $filter = null, $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$response = $this->roleUser->getUsers($rol_uid, (preg_match("/^.*\/users$/", $this->restler->url))? "USERS" : "AVAILABLE-USERS", array("filter" => $filter), null, null, $start, $limit);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /:rol_uid/user
|
||||
*
|
||||
* @param string $rol_uid {@min 32}{@max 32}
|
||||
* @param array $request_data
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostUser($rol_uid, array $request_data)
|
||||
{
|
||||
try {
|
||||
$arrayData = $this->roleUser->create($rol_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url DELETE /:rol_uid/user/:usr_uid
|
||||
*
|
||||
* @param string $rol_uid {@min 32}{@max 32}
|
||||
* @param string $usr_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doDeleteUser($rol_uid, $usr_uid)
|
||||
{
|
||||
try {
|
||||
$this->roleUser->delete($rol_uid, $usr_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user