Skip to content

Commit 8319660

Browse files
authored
Merge pull request #125 from spdx/issue124
Add warning if a LicenseRef is not present
2 parents b8f709d + f84dc07 commit 8319660

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/org/spdx/library/model/license/ExtractedLicenseInfo.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,13 @@ protected List<String> _verify(List<String> verifiedIds, String specVersion) {
134134
}
135135
}
136136
try {
137-
String licenseText = this.getExtractedText();
137+
String licenseText = this.getExtractedText();
138138
if (licenseText == null || licenseText.isEmpty()) {
139139
retval.add("Missing required license text for " + id);
140140
}
141+
if (LicenseExpressionParser.UNINITIALIZED_LICENSE_TEXT.equals(licenseText)) {
142+
retval.add("License not found for " + id);
143+
}
141144
} catch (InvalidSPDXAnalysisException ex) {
142145
retval.add("Unable to fetch license text: "+ex.getMessage());
143146
}

src/main/java/org/spdx/library/model/license/LicenseExpressionParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ enum Operator {
5252
static final String LEFT_PAREN = "(";
5353
static final String RIGHT_PAREN = ")";
5454
static final Map<String, Operator> OPERATOR_MAP = new HashMap<>();
55+
public static final String UNINITIALIZED_LICENSE_TEXT = "[Initialized with license Parser. The actual license text is not available]";
5556

5657
static {
5758
OPERATOR_MAP.put("+", Operator.OR_LATER);
@@ -293,7 +294,7 @@ private static AnyLicenseInfo parseSimpleLicenseToken(String token, IModelStore
293294
} else {
294295
localLicense = (ExtractedLicenseInfo) SpdxModelFactory.createModelObject(
295296
store, documentUri, token, SpdxConstants.CLASS_SPDX_EXTRACTED_LICENSING_INFO, copyManager);
296-
localLicense.setExtractedText("[Initialized with license Parser. The actual license text is not available]");
297+
localLicense.setExtractedText(UNINITIALIZED_LICENSE_TEXT);
297298
}
298299
return localLicense;
299300
}

0 commit comments

Comments
 (0)