Package com.lpvs.service
Class LPVSLicenseService
java.lang.Object
com.lpvs.service.LPVSLicenseService
Service class for managing licenses and license conflicts.
It provides methods to retrieve licenses from a database, check for license conflicts,
and handle license-related operations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents a license conflict between two licenses.static class
The OsoriConnection class provides methods for creating a connection to the OSORI database. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLPVSLicenseService
(String licenseConflictsSource, LPVSExitHandler exitHandler) Constructs an instance of LPVSLicenseService with the specified license conflicts source and exit handler. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLicenseConflict
(String license1, String license2) Adds a license conflict to the list of conflicts.protected void
addLicenseToList
(LPVSLicense license) Adds a license to the list of licenses.findConflicts
(LPVSQueue webhookConfig, List<LPVSFile> scanResults) Finds license conflicts based on the provided scan results and repository information.findLicense
(String licenseSpdxId, String licenseName) Search for a license using the given SPDX identifier and license name.protected LPVSLicense
findLicenseByName
(String name) Finds a license by its name.protected LPVSLicense
findLicenseBySPDX
(String name) Finds a license by SPDX identifier.findLicenseInOsoriDB
(String licenseSpdxId) Search for a license with the given SPDX identifier in the OSORI database.getLicenseBySpdxIdAndName
(String licenseSpdxId, Optional<String> licenseName) Gets a license object from the database using the specified license SPDX ID and license name.void
This method reloads licenses and license conflicts from database tables if the licenses list in case of single scan triggered and used in memory database.
-
Field Details
-
licenseConflictsSource
Source of license conflicts.
-
-
Constructor Details
-
LPVSLicenseService
@Autowired public LPVSLicenseService(@Value("${license_conflict:db}") String licenseConflictsSource, LPVSExitHandler exitHandler) Constructs an instance of LPVSLicenseService with the specified license conflicts source and exit handler.- Parameters:
licenseConflictsSource
- Source of license conflicts.exitHandler
- Handler for exiting the application.
-
-
Method Details
-
reloadFromTables
public void reloadFromTables()This method reloads licenses and license conflicts from database tables if the licenses list in case of single scan triggered and used in memory database. -
findLicenseBySPDX
Finds a license by SPDX identifier.- Parameters:
name
- SPDX identifier of the license.- Returns:
- LPVSLicense object if found, otherwise null.
-
addLicenseToList
Adds a license to the list of licenses.- Parameters:
license
- The license to add.
-
findLicenseByName
Finds a license by its name.- Parameters:
name
- The name of the license.- Returns:
- LPVSLicense object if found, otherwise null.
-
getLicenseBySpdxIdAndName
Gets a license object from the database using the specified license SPDX ID and license name.- Parameters:
licenseSpdxId
- The license SPDX ID to search forlicenseName
- The license name to use if the license is not found in the database- Returns:
- The license object that was found or created
-
findLicenseInOsoriDB
Search for a license with the given SPDX identifier in the OSORI database.- Parameters:
licenseSpdxId
- The SPDX identifier of the license to search for.- Returns:
- The LPVSLicense object if the license is found in the OSORI database, otherwise null.
-
findLicense
Search for a license using the given SPDX identifier and license name. It first tries to find the license by its SPDX identifier, and if that fails, it checks by the license name and alternative names.- Parameters:
licenseSpdxId
- The SPDX identifier of the license to search for.licenseName
- The name or alternative name of the license to search for.- Returns:
- The LPVSLicense object if the license is found, otherwise null.
-
addLicenseConflict
Adds a license conflict to the list of conflicts.- Parameters:
license1
- The first license in conflict.license2
- The second license in conflict.
-
findConflicts
public List<LPVSLicenseService.Conflict<String,String>> findConflicts(LPVSQueue webhookConfig, List<LPVSFile> scanResults) Finds license conflicts based on the provided scan results and repository information.- Parameters:
webhookConfig
- Configuration related to the repository and webhook.scanResults
- List of scanned files.- Returns:
- List of license conflicts found.
-