diff --git a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/ComponentInfoInventoryProcessor.java b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/ComponentInfoInventoryProcessor.java index c174b47d..0368b880 100644 --- a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/ComponentInfoInventoryProcessor.java +++ b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/ComponentInfoInventoryProcessor.java @@ -75,7 +75,8 @@ public void add(Statistics statistics) { * Set the curationDataSelector. * * @param curationDataSelector the curationDataSelector to chose when getting curation data. An empty string will be - * stored as null null which results in the default origin being taken. + * stored as null null which results in the default origin being taken. Use "none" to indicate no + * curation to be applied. */ @Value("${solicitor.curationDataSelector}") public void setCurationDataSelector(String curationDataSelector) { diff --git a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/ComponentInfoCuratorImpl.java b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/ComponentInfoCuratorImpl.java index ada9a5aa..036b4650 100644 --- a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/ComponentInfoCuratorImpl.java +++ b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/ComponentInfoCuratorImpl.java @@ -49,7 +49,8 @@ public ComponentInfoCuratorImpl(CurationProvider curationProvider, * * @param componentInfo the componentInfo to curate * @param curationDataSelector identifies which source should be used for the curation data. null - * indicates that the default should be used. + * indicates that the default should be used. The special value "none" indicates that no curations will be + * applied. * @return the curated component info * @throws ComponentInfoAdapterException if the curation could not be read */ diff --git a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/CuratingComponentInfoAdapter.java b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/CuratingComponentInfoAdapter.java index 4ce22feb..c44c24de 100644 --- a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/CuratingComponentInfoAdapter.java +++ b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/CuratingComponentInfoAdapter.java @@ -50,8 +50,8 @@ public CuratingComponentInfoAdapter(FilteredComponentInfoProvider filteredCompon * data as a {@link ComponentInfo} object. * * @param packageUrl The identifier of the package for which information is requested - * @param curationDataSelector identifies which source should be used for the curation data. null - * indicates that the default should be used. + * @param curationDataSelector Identifies which source should be used for the curation data. null + * indicates that the default should be used. Use "none" to indicate that no curation should be applied. * @return the data derived from the scancode results after applying any defined curation. * @throws ComponentInfoAdapterException if there was an exception when reading the data. In case that there is no * data available no exception will be thrown. Instead null will be return in such a case. diff --git a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/CurationProvider.java b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/CurationProvider.java index be9377ca..8f2d9988 100644 --- a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/CurationProvider.java +++ b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/CurationProvider.java @@ -15,11 +15,13 @@ public interface CurationProvider { * * @param packageUrl identifies the package * @param curationDataSelector identifies which source should be used for the curation data. null - * indicates that the default should be used. - * @return the curation data if it exists or null if no curation exist for the package. + * indicates that the default should be used. The special value "none" indicates that no curations should be + * returned. + * @return the curation data if it exists. null if no curation exist for the package or the + * curationDataSelector was given as "none". * @throws ComponentInfoAdapterException if something unexpected happens - * @throws ComponentInfoAdapterNonExistingCurationDataSelectorException if the specified curationDataSelector could not be - * resolved + * @throws ComponentInfoAdapterNonExistingCurationDataSelectorException if the specified curationDataSelector could + * not be resolved */ ComponentInfoCuration findCurations(String packageUrl, String curationDataSelector) throws ComponentInfoAdapterException, ComponentInfoAdapterNonExistingCurationDataSelectorException; diff --git a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/SingleFileCurationProvider.java b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/SingleFileCurationProvider.java index 169ec7c2..9667a828 100644 --- a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/SingleFileCurationProvider.java +++ b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/curation/SingleFileCurationProvider.java @@ -56,14 +56,20 @@ public SingleFileCurationProvider(AllKindsPackageURLHandler packageURLHandler) { * Return the curation data for a given package. * * @param packageUrl identifies the package - * @param curationDataSelector identifies which source should be used for the curation data. This parameter is ignored - * by this implementation. + * @param curationDataSelector identifies which source should be used for the curation data. The value "none" + * indicates that no curations should be returned. + * @return the curation data if it exists. null if no curation exist for the package or the + * curationDataSelector was given as "none". * @throws ComponentInfoAdapterException if something unexpected happens */ @Override public ComponentInfoCuration findCurations(String packageUrl, String curationDataSelector) throws ComponentInfoAdapterException { + // Return null if curationDataSelector is "none" + if ("none".equalsIgnoreCase(curationDataSelector)) { + return null; + } ComponentInfoCuration foundCuration = null; String packagePathPart = this.packageURLHandler.pathFor(packageUrl); diff --git a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/scancode/FilteredScancodeComponentInfoProvider.java b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/scancode/FilteredScancodeComponentInfoProvider.java index a84ad589..4660d3a4 100644 --- a/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/scancode/FilteredScancodeComponentInfoProvider.java +++ b/core/src/main/java/com/devonfw/tools/solicitor/componentinfo/scancode/FilteredScancodeComponentInfoProvider.java @@ -94,10 +94,10 @@ public void setMinLicensefileNumberOfLines(int minLicensefileNumberOfLines) { * * @param packageUrl The package url of the package * @param curationDataSelector identifies which source should be used for the curation data. null - * indicates that the default should be used. + * indicates that the default should be used. "none" indicates that no curations should be applied. * @return the read scancode information * @throws ComponentInfoAdapterException if there was an exception when reading the data. In case that there is no - * data available no exception will be thrown. Instead null will be return in such a case. + * data available no exception will be thrown. Instead null will be returned in such a case. */ @Override public ComponentInfo getComponentInfo(String packageUrl, String curationDataSelector) @@ -136,10 +136,14 @@ private void addSupplementedData(ScancodeRawComponentInfo rawScancodeData, } /** - * @param packageUrl - * @param rawScancodeData - * @return - * @throws ComponentInfoAdapterException + * Parses and maps scancode JSON to create ScancodeComponentInfo. + * + * @param packageUrl package URL of the package + * @param rawScancodeData raw scancode data + * @param curationDataSelector identifies which source should be used for the curation data. If the value of + * curationdataselector equals "none," no curations will be applied. + * @return the ScancodeComponentInfo + * @throws ComponentInfoAdapterException if there was an issue during parsing */ private ScancodeComponentInfo parseAndMapScancodeJson(String packageUrl, ScancodeRawComponentInfo rawScancodeData, String curationDataSelector) throws ComponentInfoAdapterException { diff --git a/core/src/main/resources/application.properties b/core/src/main/resources/application.properties index 299d6f27..901ec800 100644 --- a/core/src/main/resources/application.properties +++ b/core/src/main/resources/application.properties @@ -67,6 +67,7 @@ solicitor.scancode.issuelistpatterns=.*unknown.* # The curationDataSelector value to use when accessing curation data. # You can change its value to select a specific curation data source (if the implementation supports this). +# Set it to "none" to skip applying curations (no curations will be applied). # Leave it empty to use the default curation data source. solicitor.curationDataSelector= diff --git a/core/src/test/java/com/devonfw/tools/solicitor/componentinfo/curating/SingleFileCurationProviderTest.java b/core/src/test/java/com/devonfw/tools/solicitor/componentinfo/curating/SingleFileCurationProviderTest.java new file mode 100644 index 00000000..de1f8e06 --- /dev/null +++ b/core/src/test/java/com/devonfw/tools/solicitor/componentinfo/curating/SingleFileCurationProviderTest.java @@ -0,0 +1,68 @@ +package com.devonfw.tools.solicitor.componentinfo.curating; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import com.devonfw.tools.solicitor.common.packageurl.AllKindsPackageURLHandler; +import com.devonfw.tools.solicitor.componentinfo.ComponentInfoAdapterException; +import com.devonfw.tools.solicitor.componentinfo.curation.SingleFileCurationProvider; +import com.devonfw.tools.solicitor.componentinfo.curation.model.ComponentInfoCuration; + +/** + * Test for {@link SingleFileCurationProvider}. + * + */ +class SingleFileCurationProviderTest { + + private SingleFileCurationProvider objectUnderTest; + + @BeforeEach + public void setup() { + + AllKindsPackageURLHandler packageUrlHandler = Mockito.mock(AllKindsPackageURLHandler.class); + Mockito.when(packageUrlHandler.pathFor("pkg:maven/somenamespace/somecomponent@2.3.4")) + .thenReturn("pkg/maven/somenamespace/somecomponent/2.3.4"); + Mockito.when(packageUrlHandler.pathFor("pkg:maven/somenamespace/somecomponent@2.3.5")) + .thenReturn("pkg/maven/somenamespace/somecomponent/2.3.5"); + + this.objectUnderTest = new SingleFileCurationProvider(packageUrlHandler); + this.objectUnderTest.setCurationsFileName("src/test/resources/curations/array_of_curations.yaml"); + } + + /** + * Test method for + * {@link com.devonfw.tools.solicitor.componentinfo.curation.SingleFileCurationProvider#findCurations(java.lang.String, java.lang.String)}. + * + * @throws ComponentInfoAdapterException + */ + @Test + void testFindCurationsWithSelectorNull() throws ComponentInfoAdapterException { + + ComponentInfoCuration result; + + result = this.objectUnderTest.findCurations("pkg:maven/somenamespace/somecomponent@2.3.4", null); + assertEquals("https://scancode-licensedb.aboutcode.org/apache-2.0.LICENSE", result.getLicenses().get(0).getUrl()); + result = this.objectUnderTest.findCurations("pkg:maven/somenamespace/somecomponent@2.3.5", null); + assertEquals("https://scancode-licensedb.aboutcode.org/bsd-simplified.LICENSE", + result.getLicenses().get(0).getUrl()); + } + + /** + * Test method for + * {@link com.devonfw.tools.solicitor.componentinfo.curation.SingleFileCurationProvider#findCurations(java.lang.String, java.lang.String)}. + * + * @throws ComponentInfoAdapterException + */ + @Test + void testFindCurationsWithSelectorNone() throws ComponentInfoAdapterException { + + ComponentInfoCuration result; + + result = this.objectUnderTest.findCurations("pkg:maven/somenamespace/somecomponent@2.3.4", "none"); + assertNull(result); + } +} diff --git a/documentation/files/application.properties b/documentation/files/application.properties index 299d6f27..901ec800 100644 --- a/documentation/files/application.properties +++ b/documentation/files/application.properties @@ -67,6 +67,7 @@ solicitor.scancode.issuelistpatterns=.*unknown.* # The curationDataSelector value to use when accessing curation data. # You can change its value to select a specific curation data source (if the implementation supports this). +# Set it to "none" to skip applying curations (no curations will be applied). # Leave it empty to use the default curation data source. solicitor.curationDataSelector= diff --git a/documentation/master-solicitor.asciidoc b/documentation/master-solicitor.asciidoc index 456796e8..9d8f74ab 100644 --- a/documentation/master-solicitor.asciidoc +++ b/documentation/master-solicitor.asciidoc @@ -1670,6 +1670,7 @@ Spring beans implementing this interface will be called at certain points in the Changes in 1.20.0:: * https://github.com/devonfw/solicitor/issues/232: Set a standard for ordering LicenseNameMapping rules. Rules with an 'or-later' suffix are put before '-only' rules. * https://github.com/devonfw/solicitor/issues/234: Correct handling of new data model fields in ModelImporterExporter `dataStatus`,`traceabilityNotes` etc. +* https://github.com/devonfw/solicitor/pull/235: Improvements in Curation Data Handling. When the curationDataSelector parameter is set to "none," no curations will be applied. Changes in 1.19.0:: * https://github.com/devonfw/solicitor/issues/227: Fixed a bug where the `dataStatus` field in the aggregated OSS-Inventory was not filled.