Comments (5)
but get LicenseRef-gnrtd0 everywhere else in the output document when using licenseRef1.
Can you add an example document and a minimal full code example?
from spdx-java-library.
public static void buildDocument() throws InvalidSPDXAnalysisException, IOException {
var modelStore = new MultiFormatStore(new InMemSpdxStore(), MultiFormatStore.Format.XML, MultiFormatStore.Verbose.COMPACT);
var documentUri = "https://some.namespace";
var copyManager = new ModelCopyManager();
var document = SpdxModelFactory.createSpdxDocument(modelStore, documentUri, copyManager);
document.setName("document name");
var extractedLicenseInfo1 = new ExtractedLicenseInfo(modelStore, documentUri, "LicenseRef-1", copyManager, true);
var licenseRef1 = LicenseInfoFactory.parseSPDXLicenseString("LicenseRef-1");
var sha1Checksum = Checksum.create(modelStore, documentUri, ChecksumAlgorithm.SHA1, "d6a770ba38583ed4bb4525bd96e50461655d2758");
var file = document.createSpdxFile("SPDXRef-somefile", "./foo.txt", licenseRef1, List.of(), null, sha1Checksum).build();
document.addExtractedLicenseInfos(extractedLicenseInfo1);
document.getDocumentDescribes().add(file);
modelStore.serialize(documentUri, new FileOutputStream("temp.xml"));
}
yields
<?xml version='1.0' encoding='UTF-8'?>
<Document>
<SPDXID>SPDXRef-DOCUMENT</SPDXID>
<spdxVersion>SPDX-2.3</spdxVersion>
<creationInfo>
<created>2022-10-13T11:08:12Z</created>
<creators>Tool: SPDX Tools</creators>
<licenseListVersion>3.18</licenseListVersion>
</creationInfo>
<name>document name</name>
<dataLicense>CC0-1.0</dataLicense>
<hasExtractedLicensingInfos>
<licenseId>LicenseRef-1</licenseId>
</hasExtractedLicensingInfos>
<documentDescribes>SPDXRef-somefile</documentDescribes>
<documentNamespace>https://some.namespace</documentNamespace>
<files>
<SPDXID>SPDXRef-somefile</SPDXID>
<checksums>
<algorithm>SHA1</algorithm>
<checksumValue>d6a770ba38583ed4bb4525bd96e50461655d2758</checksumValue>
</checksums>
<fileName>./foo.txt</fileName>
<licenseConcluded>LicenseRef-gnrtd0</licenseConcluded>
</files>
</Document>
from spdx-java-library.
This is not the intended behavior. I'll take a look and see what's going on in the code.
from spdx-java-library.
In looking a bit closer - the library is working correctly.
The issue is you are using the default model store for the license parser.
In your above example, change:
var licenseRef1 = LicenseInfoFactory.parseSPDXLicenseString("LicenseRef-1");
to:
var licenseRef1 = LicenseInfoFactory.parseSPDXLicenseString("LicenseRef-1", modelStore, documentUri, copyManager);
A bit more background and context. Anytime you create a ModelObject
it is stored in a ModelStore
. This includes ExtractedLicenseInfo
. When you created your ExtractedLicenseInfo
, you specified a specific model store. When you called the parseSPDXLicenseString
, you did not specify a model store so it used the default. Since the default model store didn't have the LicenseRef-1
, it created a new and different ExtractedLicenseInfo
. When you added as a concluded license, the library recognized it wasn't present in the model store for the File and copied what it had from the default model store to the specified modelStore. Since there already existed a "LicenseRef-1", it generated a new ID so that it would not conflict.
from spdx-java-library.
Oh yeah, that makes sense!
Thanks for the comprehensive advice, Gary! :)
from spdx-java-library.
Related Issues (20)
- Update POM file to use release plugin HOT 1
- Enhancement: caching version of org.spdx.storage.listedlicense.SpdxListedLicenseWebStore and associated classes HOT 27
- tools-java should issue an error for absolute FileName HOT 5
- Need to update optional fields handling for cases with filesAnalyzed=true HOT 2
- Do we have a release schedule? HOT 4
- Performance enhancement: only download and parse license & exception JSON files once
- Exceptions aren't always passed on, making troubleshooting difficult
- Update CI to flag any new quality issues
- LicenseCompareHelper: EPL-2.0 license text published by Eclipse Foundation not recognised HOT 3
- LicenseCompareHelper: BSD-2-Clause license text not recognised HOT 2
- In need of a canonical way to add license texts for licenseRefs / Maybe bugged? HOT 4
- LicenseCompareHelper: GPL-2.0 license text not recognised HOT 2
- Question HOT 2
- Refactor nonOptionalTextToPatterns HOT 2
- Verify error when license exceptions are used in an expression in LicenseConcluded but not in LicenseInfoInFile HOT 2
- Official Apache-1.1 license text is not being matched correctly by LicenseCompareHelper.matchingStandardLicenseIdsWithinText() HOT 1
- Official GPL-1.0 license text is not being matched correctly by LicenseCompareHelper.isTextStandardLicense() HOT 1
- Potential enhancement: LicenseCompareHelper.isTextStandardLicense().getDifferenceMessage() should sort by line then column
- Official CC-BY-4.0 license text is not being matched correctly by LicenseCompareHelper.isTextStandardLicense() HOT 3
- Inconsistent behaviour between LicenseCompareHelper methods when called with official MIT license text HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spdx-java-library.