Skip to content

Commit

Permalink
Update FSF parser for the lastest Jena version
Browse files Browse the repository at this point in the history
  • Loading branch information
goneall committed Dec 16, 2024
1 parent 04b424f commit df14308
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
/pom.xml.releaseBackup
maven-eclipse.xml
dependency-reduced-pom.xml
LICENSE.spdx
LICENSE.spdx

# IntelliJ IDE
.idea
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.spdx.licenselistpublisher.licensegenerator;

import junit.framework.TestCase;
import org.spdx.licenselistpublisher.LicenseGeneratorException;

public class FsfLicenseDataParserTest extends TestCase {

public void setUp() throws Exception {
super.setUp();
}

public void tearDown() throws Exception {
super.tearDown();
}

public void testIsSpdxLicenseFsfLibre() throws LicenseGeneratorException {
assertTrue(FsfLicenseDataParser.getFsfLicenseDataParser().isSpdxLicenseFsfLibre("GPL-2.0-or-later"));
assertFalse(FsfLicenseDataParser.getFsfLicenseDataParser().isSpdxLicenseFsfLibre("CC-BY-NC-2.0"));
assertNull(FsfLicenseDataParser.getFsfLicenseDataParser().isSpdxLicenseFsfLibre("something"));
}
}
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<dependency>
<groupId>org.spdx</groupId>
<artifactId>java-spdx-library</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.0-RC1</version>
</dependency>
<dependency>
<groupId>com.github.spullara.mustache.java</groupId>
Expand All @@ -88,7 +88,7 @@
<dependency>
<groupId>org.spdx</groupId>
<artifactId>spdx-rdf-store</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.0.0-RC1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
Expand All @@ -103,7 +103,7 @@
<dependency>
<groupId>org.spdx</groupId>
<artifactId>spdx-v3jsonld-store</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>1.0.0-RC2</version>
</dependency>
</dependencies>
<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ private FsfLicenseDataParser() throws LicenseGeneratorException {
while (tripleIter.hasNext()) {
Triple t = tripleIter.next();
if (t.getObject().isLiteral()) {
String objectVal = t.getObject().toString(false);
if ("libre".equals(objectVal)) {
String objectVal = t.getObject().toString(model);
if ("\"libre\"".equals(objectVal)) {
Node subject = t.getSubject();
List<String> spdxIds = findSpdxIds(subject, model);
for (String spdxId:spdxIds) {
this.licenseIdToFsfFree.put(spdxId,true);
this.licenseIdToFsfFree.put(spdxId.replaceAll("\"", ""),true);
}
} else if ("non-free".equals(objectVal)) {
} else if ("\"non-free\"".equals(objectVal)) {
Node subject = t.getSubject();
List<String> spdxIds = findSpdxIds(subject, model);
for (String spdxId:spdxIds) {
this.licenseIdToFsfFree.put(spdxId,false);
this.licenseIdToFsfFree.put(spdxId.replaceAll("\"", ""),false);
}
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ private List<String> findSpdxIds(Node subject, Model model, String namespace, St
continue;
}
// Hack - adding all identifiers since we are not able to get the SPDX specific ID's - see https://github.com/spdx/fsf-api/pull/12#issuecomment-376282369
retval.add(identifiersObject.toString(false));
retval.add(identifiersObject.toString(model));
// Node spdxIdProp = model.getProperty(FSF_JSON_NAMESPACE, PROPERTY_SPDXID).asNode();
// Triple spdxIdMatch = Triple.createMatch(identifiersObject, spdxIdProp, null);
// ExtendedIterator<Triple> spdxIdIterator = model.getGraph().find(spdxIdMatch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class LicenseV3JsonLdFormatWriter implements ILicenseFormatWriter {
/**
* @param version License list version
* @param releaseDate release date for the license list
* @param jsonLDFolder Folder to output the license TOC file, the exception TOC file, all license and exception details
* @param jsonLdFolder Folder to output the license TOC file, the exception TOC file, all license and exception details
* @throws InvalidSPDXAnalysisException on error creating TOC stores and/or objects
*/
public LicenseV3JsonLdFormatWriter(String version, String releaseDate, File jsonLdFolder) throws InvalidSPDXAnalysisException {
Expand Down

0 comments on commit df14308

Please sign in to comment.