FOSSology  4.7.1
Open Source License Compliance by Open Source Software
Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController Class Reference

Controller for license compatibility rules. More...

Inheritance diagram for Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController:
Inheritance graph
Collaboration diagram for Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController:
Collaboration graph

Public Member Functions

 __construct ($container)
 
 getRules ($request, $response, $args)
 
 createRule ($request, $response, $args)
 
 updateRule ($request, $response, $args)
 
 deleteRule ($request, $response, $args)
 
 exportRules ($request, $response, $args)
 
- Public Member Functions inherited from Fossology\UI\Api\Controllers\RestController
 isJsonRequest ($request)
 

Public Attributes

const PAGE_PARAM = "page"
 
const LIMIT_PARAM = "limit"
 
const SEARCH_PARAM = "search"
 
const RULE_FETCH_LIMIT = 100
 

Private Member Functions

 parseRule ($body, $isNewRule)
 Validate the rule values sent in the request body. More...
 
 getRuleField ($body, $nameV2, $nameV1)
 Read a rule field from the request body. More...
 
 validateLicenseId ($licenseId, $field)
 Validate a license ID sent in the request body. More...
 
 validateLicenseType ($licenseType, $field)
 Validate a license type sent in the request body. More...
 
 getLicenseTypes ()
 Get the license types configured on the server. More...
 

Private Attributes

 $compatibilityDao
 

Additional Inherited Members

- Protected Member Functions inherited from Fossology\UI\Api\Controllers\RestController
 getParsedBody (ServerRequestInterface $request)
 Parse request body as JSON and return associative PHP array. More...
 
 throwNotAdminException ()
 
 uploadAccessible ($id)
 
 isItemExists (int $uploadId, int $itemId)
 
- Protected Attributes inherited from Fossology\UI\Api\Controllers\RestController
 $container
 
 $restHelper
 
 $dbHelper
 

Detailed Description

Controller for license compatibility rules.

Definition at line 33 of file LicenseCompatibilityRuleController.php.

Constructor & Destructor Documentation

◆ __construct()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::__construct (   $container)
Parameters
ContainerInterface$container

Reimplemented from Fossology\UI\Api\Controllers\RestController.

Definition at line 61 of file LicenseCompatibilityRuleController.php.

Member Function Documentation

◆ createRule()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::createRule (   $request,
  $response,
  $args 
)

Create a new license compatibility rule

Parameters
Request$request
ResponseHelper$response
array$args
Returns
ResponseHelper
Exceptions
HttpErrorException

Definition at line 141 of file LicenseCompatibilityRuleController.php.

◆ deleteRule()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::deleteRule (   $request,
  $response,
  $args 
)

Delete an existing license compatibility rule

Parameters
Request$request
ResponseHelper$response
array$args
Returns
ResponseHelper
Exceptions
HttpErrorException

Definition at line 203 of file LicenseCompatibilityRuleController.php.

◆ exportRules()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::exportRules (   $request,
  $response,
  $args 
)

Export the license compatibility rules as a YAML file

Parameters
Request$request
ResponseHelper$response
array$args
Returns
ResponseHelper
Exceptions
HttpErrorException

Definition at line 259 of file LicenseCompatibilityRuleController.php.

◆ getLicenseTypes()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::getLicenseTypes ( )
private

Get the license types configured on the server.

Returns
array List of the license types

Definition at line 437 of file LicenseCompatibilityRuleController.php.

◆ getRuleField()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::getRuleField (   $body,
  $nameV2,
  $nameV1 
)
private

Read a rule field from the request body.

Both the camelCase (version 2) and the snake_case (version 1) name of the field are accepted.

Parameters
array$bodyParsed request body
string$nameV2Name of the field in version 2
string$nameV1Name of the field in version 1
Returns
array Array with the presence of the field and its value

Definition at line 375 of file LicenseCompatibilityRuleController.php.

◆ getRules()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::getRules (   $request,
  $response,
  $args 
)

Get the list of license compatibility rules, paginated upon request params

Parameters
Request$request
ResponseHelper$response
array$args
Returns
ResponseHelper
Exceptions
HttpErrorException

Definition at line 76 of file LicenseCompatibilityRuleController.php.

◆ parseRule()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::parseRule (   $body,
  $isNewRule 
)
private

Validate the rule values sent in the request body.

Only the fields present in the body are returned, which allows updating a rule partially. For a new rule, the description and the compatibility result are mandatory and at least one license or license type has to be given, otherwise the rule would shadow the default compatibility.

Parameters
array | null$bodyParsed request body
boolean$isNewRuleTrue while creating a rule
Returns
array Rule values as expected by CompatibilityDao
Exceptions
HttpBadRequestException

Definition at line 303 of file LicenseCompatibilityRuleController.php.

◆ updateRule()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::updateRule (   $request,
  $response,
  $args 
)

Update an existing license compatibility rule

Parameters
Request$request
ResponseHelper$response
array$args
Returns
ResponseHelper
Exceptions
HttpErrorException

Definition at line 167 of file LicenseCompatibilityRuleController.php.

◆ validateLicenseId()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::validateLicenseId (   $licenseId,
  $field 
)
private

Validate a license ID sent in the request body.

Parameters
mixed$licenseIdValue to validate, null matches every license
string$fieldName of the field to report in the error message
Returns
int|null Validated license ID
Exceptions
HttpBadRequestException

Definition at line 393 of file LicenseCompatibilityRuleController.php.

◆ validateLicenseType()

Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::validateLicenseType (   $licenseType,
  $field 
)
private

Validate a license type sent in the request body.

Parameters
mixed$licenseTypeValue to validate, null matches every type
string$fieldName of the field to report in the error message
Returns
string|null Validated license type
Exceptions
HttpBadRequestException

Definition at line 416 of file LicenseCompatibilityRuleController.php.

Member Data Documentation

◆ $compatibilityDao

CompatibilityDao Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::$compatibilityDao
private

Compatibility DAO object

Definition at line 56 of file LicenseCompatibilityRuleController.php.

◆ LIMIT_PARAM

const Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::LIMIT_PARAM = "limit"

Query parameter name for limiting listing

Definition at line 42 of file LicenseCompatibilityRuleController.php.

◆ PAGE_PARAM

const Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::PAGE_PARAM = "page"

Query parameter name for page listing

Definition at line 38 of file LicenseCompatibilityRuleController.php.

◆ RULE_FETCH_LIMIT

const Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::RULE_FETCH_LIMIT = 100

Limit of rules in get query

Definition at line 50 of file LicenseCompatibilityRuleController.php.

◆ SEARCH_PARAM

const Fossology\UI\Api\Controllers\LicenseCompatibilityRuleController::SEARCH_PARAM = "search"

Query parameter name to filter the rules on their description

Definition at line 46 of file LicenseCompatibilityRuleController.php.


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