Skip to content

Commit ae14e24

Browse files
authored
Merge pull request #200 from spdx/issue199
Fix URL referenced in exceptions TOC
2 parents b9902aa + 758f018 commit ae14e24

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/main/java/org/spdx/storage/listedlicense/ExceptionJsonTOC.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ public void addException(ListedLicenseException exception, String exceptionHTMLR
195195
ExceptionJson ej = new ExceptionJson();
196196
ej.setLicenseExceptionId(exception.getId());
197197
ej.setDeprecatedLicenseId(deprecated);
198-
ej.setDetailsUrl(exceptionHTMLReference);
198+
ej.setDetailsUrl(LicenseJsonTOC.toAbsoluteURL(exceptionJSONReference));
199199
ej.setName(exception.getName());
200-
ej.setReference(exceptionJSONReference);
200+
ej.setReference(LicenseJsonTOC.toAbsoluteURL(exceptionHTMLReference));
201201
int referenceNumber = 0;
202202
for (ExceptionJson existing:this.exceptions) {
203203
if (existing.getReferenceNumber() > referenceNumber) {

src/main/java/org/spdx/storage/listedlicense/LicenseJsonTOC.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public void setReleaseDate(String releaseDate) {
256256
this.releaseDate = releaseDate;
257257
}
258258

259-
private static String toAbsoluteURL(String relURL) {
259+
protected static String toAbsoluteURL(String relURL) {
260260
String retval = relURL.startsWith("./") ? relURL.substring(2) : relURL;
261261
return SpdxConstants.LISTED_LICENSE_URL + retval;
262262
}

src/test/java/org/spdx/storage/listedlicense/ExceptionJsonTOCTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,44 +85,44 @@ public void testAddException() throws Exception {
8585
ExceptionJsonTOC ejt = new ExceptionJsonTOC();
8686
InMemSpdxStore store = new InMemSpdxStore();
8787
String docUri = "http://temp.doc.uri";
88-
String detailsUrl1 = "http://details1";
88+
String detailsUrl1 = "./details1";
8989
String exceptionId1 = "id1";
9090
boolean deprecated1 = true;
9191
String name1 = "name1";
92-
String reference1 = "http://reference1";
92+
String reference1 = "./reference1";
9393
List<String> seeAlso1 = Arrays.asList(new String[]{"http://seeAlso1", "http://seeAlso2", "http://seeAlso3"});
94-
String detailsUrl2 = "http://details2";
94+
String detailsUrl2 = "./details2";
9595
boolean deprecated2 = false;
9696
String exceptionId2 = "id2";
9797
String name2 = "name2";
98-
String reference2 = "http://reference2";
98+
String reference2 = "./reference2";
9999
List<String> seeAlso2 = Arrays.asList(new String[]{"http://seeAlso4"});
100100

101101
ListedLicenseException ex1 = new ListedLicenseException(store, docUri, exceptionId1, null, true);
102102
ex1.setName(name1);
103103
ex1.setSeeAlso(seeAlso1);
104-
ejt.addException(ex1, detailsUrl1, reference1, deprecated1);
104+
ejt.addException(ex1, reference1, detailsUrl1, deprecated1);
105105

106106
ListedLicenseException ex2 = new ListedLicenseException(store, docUri, exceptionId2, null, true);
107107
ex2.setName(name2);
108108
ex2.setSeeAlso(seeAlso2);
109-
ejt.addException(ex2, detailsUrl2, reference2, deprecated2);
109+
ejt.addException(ex2, reference2, detailsUrl2, deprecated2);
110110

111111
List<ExceptionJsonTOC.ExceptionJson> result = ejt.getExceptions();
112112
assertEquals(2, result.size());
113113
assertEquals(deprecated1, result.get(0).isDeprecatedLicenseId());
114-
assertEquals(detailsUrl1, result.get(0).getDetailsUrl());
114+
assertEquals(detailsUrl1.substring(2), result.get(0).getDetailsUrl().substring(result.get(0).getDetailsUrl().lastIndexOf('/') + 1));
115115
assertEquals(exceptionId1, result.get(0).getLicenseExceptionId());
116116
assertEquals(name1, result.get(0).getName());
117-
assertEquals(reference1, result.get(0).getReference());
117+
assertEquals(reference1.substring(2), result.get(0).getReference().substring(result.get(0).getReference().lastIndexOf('/') + 1));
118118
assertEquals(1, result.get(0).getReferenceNumber());
119119
assertTrue(UnitTestHelper.isListsEqual(seeAlso1, result.get(0).getSeeAlso()));
120120

121121
assertEquals(deprecated2, result.get(1).isDeprecatedLicenseId());
122-
assertEquals(detailsUrl2, result.get(1).getDetailsUrl());
122+
assertEquals(detailsUrl2.substring(2), result.get(1).getDetailsUrl().substring(result.get(1).getDetailsUrl().lastIndexOf('/') + 1));
123123
assertEquals(exceptionId2, result.get(1).getLicenseExceptionId());
124124
assertEquals(name2, result.get(1).getName());
125-
assertEquals(reference2, result.get(1).getReference());
125+
assertEquals(reference2.substring(2), result.get(1).getReference().substring(result.get(1).getReference().lastIndexOf('/') + 1));
126126
assertEquals(2, result.get(1).getReferenceNumber());
127127
assertTrue(UnitTestHelper.isListsEqual(seeAlso2, result.get(1).getSeeAlso()));
128128

0 commit comments

Comments
 (0)