FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
Fossology\UI\Api\Helper\DbHelper Class Reference

Provides helper methods to access database for REST api. More...

Collaboration diagram for Fossology\UI\Api\Helper\DbHelper:
Collaboration graph

Public Member Functions

 __construct (DbManager $dbManager)
 
 getDbManager ()
 
 getUploads ($userId, $uploadId=null)
 
 getFilenameFromUploadTree ($uploadTreePk)
 
 doesIdExist ($tableName, $idRowName, $id)
 
 deleteUser ($id)
 
 getUsers ($id=null)
 
 getJobs ($id=null, $limit=0, $page=1, $uploadId=null)
 Get the recent jobs. More...
 
 getTokenKey ($tokenId)
 
 invalidateToken ($tokenId)
 
 insertNewTokenKey ($userId, $expire, $scope, $name, $key)
 
 getMaxTokenValidity ()
 

Private Member Functions

 checkTokenNameUnique ($userId, $tokenName)
 
 checkTokenKeyUnique ($userId, $tokenKey)
 

Private Attributes

 $dbManager
 

Detailed Description

Provides helper methods to access database for REST api.

Definition at line 43 of file DbHelper.php.

Constructor & Destructor Documentation

Fossology\UI\Api\Helper\DbHelper::__construct ( DbManager  $dbManager)

DbHelper constructor.

Parameters
DbManager$dbManagerDB manager in use

Definition at line 56 of file DbHelper.php.

Member Function Documentation

Fossology\UI\Api\Helper\DbHelper::checkTokenKeyUnique (   $userId,
  $tokenKey 
)
private

Checks if the personal_access_tokens_token_key_ukey constraint is followed by this token.

Parameters
int$userIdUser id
string$tokenKeyToken secret key
Returns
boolean True if the constraint is followed, false otherwise.

Definition at line 361 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::checkTokenNameUnique (   $userId,
  $tokenName 
)
private

Checks if the personal_access_tokens_token_name_ukey constraint is followed by this token.

Parameters
int$userIdUser id
string$tokenNameName of the token
Returns
boolean True if the constraint is followed, false otherwise.

Definition at line 340 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::deleteUser (   $id)

Delete the given user id

Parameters
integer$idUser id to be deleted

Definition at line 151 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::doesIdExist (   $tableName,
  $idRowName,
  $id 
)

Check if a given id exists under given table.

Parameters
string$tableNameTable name
string$idRowNameID column name
string$idID to check
Returns
boolean True if id exists, false otherwise

Definition at line 140 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::getDbManager ( )

Get the DB manager

Returns
ModernDbManager

Definition at line 66 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::getFilenameFromUploadTree (   $uploadTreePk)

Get first upload name under a given upload tree id

Parameters
integer$uploadTreePkUpload tree id to check.
Returns
string

Definition at line 125 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::getJobs (   $id = null,
  $limit = 0,
  $page = 1,
  $uploadId = null 
)

Get the recent jobs.

If a limit is passed, the results are trimmed. If an ID is passed, the information for the given id is only retrieved.

Parameters
integer$idSet to get information of only given job id
integer$limitSet to limit the result length
integer$pagePage number required
integer$uploadIdUpload ID to be filtered
Returns
array[] List of jobs at first index and total number of pages at second.

Definition at line 215 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::getMaxTokenValidity ( )

Get the value for maximum API token validity from sysconfig table.

Returns
integer The value stored in DB or 30 (default).

Definition at line 379 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::getTokenKey (   $tokenId)

Get the required information to validate a token based on token id.

Parameters
int$tokenIdToken id (primary key of the table).
Returns
array Returns the token_key, created_on,expire_onand user_fk` for the given token id.

Definition at line 280 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::getUploads (   $userId,
  $uploadId = null 
)

Get the uploads under the given user id if not upload id is provided.

Get a single upload information under the given user and upload id.

Parameters
integer$userIdUser to check
integer$uploadIdPass the upload id to check for single upload.
Returns
Upload[][] Uploads as an associative array

Definition at line 80 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::getUsers (   $id = null)

Get the user under the given user id or every user from the database.

Parameters
integer$idUser id of the required user, or NULL to fetch all users.
Returns
User[][] Users as an associative array

Definition at line 164 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::insertNewTokenKey (   $userId,
  $expire,
  $scope,
  $name,
  $key 
)

Insert a new token in the DB.

Parameters
int$userIdUser of the new token
string$expireWhen the token will expire
string$scopeScope of the token
string$nameName of the token
string$keySecret key of the token
Returns
array|Fossology::UI::Api::Models::Info New token id and created_on or Info on error.
Exceptions
DuplicateTokenNameExceptionIf user already have a token with same name.
DuplicateTokenKeyExceptionIf user already have a token with same key.

Definition at line 314 of file DbHelper.php.

Fossology\UI\Api\Helper\DbHelper::invalidateToken (   $tokenId)

Mark a token as invalid/inactive.

Parameters
int$tokenIdThe token to be marked as invalid

Definition at line 293 of file DbHelper.php.

Member Data Documentation

ModernDbManager Fossology\UI\Api\Helper\DbHelper::$dbManager
private

DB manager in use

Definition at line 49 of file DbHelper.php.


The documentation for this class was generated from the following file: