You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#338
Dependes on updates to the SPDX Models versions 2 and 3 which add
a new class "InvalidLicenseExpression" which is used to produce the
errors.
This changes the behavior of the license parser from throwing an
exception to returning an InvalidLicenseExpression where the verify
routine will return the error message.
* Factory for creating SPDXLicenseInfo objects from a Jena model
@@ -90,8 +91,7 @@ public static SpdxListedLicense getListedLicenseByIdCompatV2(String licenseId)th
90
91
* @param documentUri Document URI for the document containing any extractedLicenseInfos - if any extractedLicenseInfos by ID already exist, they will be used. If
91
92
* none exist for an ID, they will be added. If null, the default model document URI will be used.
92
93
* @param copyManager allows for copying of any properties set which use other model stores or document URI's. If null, the default will be used.
93
-
* @return an SPDXLicenseInfo created from the string
94
-
* @throws InvalidLicenseStringException if the license string is not valid
94
+
* @return an SPDXLicenseInfo created from the string. If the license expression is not parseable, a <code>InvalidLicenseExpression</code> is returned.
95
95
* @throws DefaultStoreNotInitializedException if the default model store is not initialized
thrownewLicenseParserException("NONE is currently not allowed in a complex license expression");
507
511
} else {
508
512
thrownewLicenseParserException(String.format("Unknown license %s. Must be a listed license or have the syntax %s", token, SpdxConstantsCompatV2.LICENSE_ID_PATTERN));
thrownewLicenseParserException("NONE is currently not allowed in a complex license expression");
593
601
} else {
594
602
thrownewLicenseParserException(String.format("Unknown license %s. Must be a listed license or have the syntax %s", token, SpdxConstantsCompatV2.LICENSE_ID_PATTERN));
AnyLicenseInfoorder1 = LicenseInfoFactory.parseSPDXLicenseString("(LicenseRef-14 AND LicenseRef-5 AND LicenseRef-6 AND LicenseRef-15 AND LicenseRef-3 AND LicenseRef-12 AND LicenseRef-4 AND LicenseRef-13 AND LicenseRef-10 AND LicenseRef-9 AND LicenseRef-11 AND LicenseRef-7 AND LicenseRef-8 AND LGPL-2.1+ AND LicenseRef-1 AND LicenseRef-2 AND LicenseRef-0 AND GPL-2.0+ AND GPL-2.0 AND LicenseRef-17 AND LicenseRef-16 AND BSD-3-Clause-Clear)");
163
164
AnyLicenseInfoorder2 = LicenseInfoFactory.parseSPDXLicenseString("(LicenseRef-14 AND LicenseRef-5 AND LicenseRef-6 AND LicenseRef-15 AND LicenseRef-12 AND LicenseRef-3 AND LicenseRef-13 AND LicenseRef-4 AND LicenseRef-10 AND LicenseRef-9 AND LicenseRef-11 AND LicenseRef-7 AND LicenseRef-8 AND LGPL-2.1+ AND LicenseRef-1 AND LicenseRef-2 AND LicenseRef-0 AND GPL-2.0+ AND GPL-2.0 AND LicenseRef-17 AND BSD-3-Clause-Clear AND LicenseRef-16)");
164
-
assertTrue(order1.equals(order2));
165
+
assertEquals(order1, order2);
165
166
assertTrue(order1.equivalent(order2));
166
167
}
167
168
@@ -171,4 +172,14 @@ public void testParseSPDXLicenseStringMixedCase() throws InvalidSPDXAnalysisExce
0 commit comments