diff --git a/src/main/java/org/spdx/tag/BuildDocument.java b/src/main/java/org/spdx/tag/BuildDocument.java index ddb7ba0..2135d40 100644 --- a/src/main/java/org/spdx/tag/BuildDocument.java +++ b/src/main/java/org/spdx/tag/BuildDocument.java @@ -65,6 +65,7 @@ import org.spdx.library.referencetype.ListedReferenceTypes; import org.spdx.storage.IModelStore; import org.spdx.storage.IModelStore.IdType; +import org.spdx.storage.simple.InMemSpdxStore; /** @@ -295,6 +296,7 @@ public void setProjectUri(String projectUri) throws InvalidSPDXAnalysisException private IModelStore modelStore; private String lastFileId = null; private String lastPackageId = null; + private IModelStore tempModelStore = new InMemSpdxStore(); public BuildDocument(IModelStore modelStore, Properties constants, List warnings) { this.constants = constants; @@ -696,7 +698,7 @@ private void buildDocumentProperties(String tag, String value, int lineNumber) t inSnippetDefinition = false; inExtractedLicenseDefinition = false; addLastPackage(); - this.lastPackage = new SpdxPackage(modelStore, documentNamespace, modelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later + this.lastPackage = new SpdxPackage(tempModelStore, documentNamespace, tempModelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later copyManager, true); this.lastPackage.setName(value); lastPackageLineNumber = lineNumber; @@ -712,7 +714,7 @@ private void buildDocumentProperties(String tag, String value, int lineNumber) t inSnippetDefinition = false; inExtractedLicenseDefinition = false; - this.lastFile = new SpdxFile(modelStore, documentNamespace, modelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later + this.lastFile = new SpdxFile(tempModelStore, documentNamespace, tempModelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later copyManager, true); this.lastFile.setName(value); lastFileLineNumber = lineNumber; @@ -741,8 +743,6 @@ private void addLastPackage() throws InvalidSPDXAnalysisException { } SpdxPackage newPkg = new SpdxPackage(modelStore, documentNamespace, lastPackageId, copyManager, true); newPkg.copyFrom(lastPackage); - modelStore.delete(documentNamespace, lastPackage.getId()); - this.lastPackage = newPkg; elementIdLineNumberMap.put(lastPackageId, lastPackageLineNumber); lastPackageId = null; this.lastPackage = null; @@ -761,10 +761,10 @@ private void addLastFile() throws InvalidSPDXAnalysisException { } SpdxFile newFile = new SpdxFile(modelStore, documentNamespace, lastFileId, copyManager, true); newFile.copyFrom(this.lastFile); - modelStore.delete(documentNamespace, lastFile.getId()); for (String depdendeFileName:lastFileDependencies) { addFileDependency(newFile, depdendeFileName); } + lastFileDependencies.clear(); lastFileId = null; if (lastPackage != null) { @@ -980,7 +980,7 @@ private void buildPackage(SpdxPackage pkg, String tag, String value, int lineNum lastRelationship.setComment(value); } else if (tag.equals(constants.getProperty("PROP_FILE_NAME"))) { addLastFile(); - this.lastFile = new SpdxFile(modelStore, documentNamespace, modelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later + this.lastFile = new SpdxFile(tempModelStore, documentNamespace, tempModelStore.getNextId(IdType.Anonymous, documentNamespace), // We create this as anonymous and copy to the real package with the correct ID later copyManager, true); this.lastFile.setName(value); this.inFileDefinition = true;