Class Spdx2to3Converter

  • All Implemented Interfaces:
    ISpdxConverter

    public class Spdx2to3Converter
    extends Object
    implements ISpdxConverter
    Author:
    Gary O'Neall Converts SPDX spec version 2.X objects to SPDX spec version 3.X and stores the result in the toModelStore
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Map<org.spdx.library.model.v2.enumerations.AnnotationType,​org.spdx.library.model.v3_0_1.core.AnnotationType> ANNOTATION_TYPE_MAP  
      static Map<String,​org.spdx.library.model.v3_0_1.software.ContentIdentifierType> CONTENT_IDENTIFIER_TYPE_MAP  
      static Map<String,​org.spdx.library.model.v3_0_1.core.ExternalIdentifierType> EXTERNAL_IDENTIFIER_TYPE_MAP  
      static Map<String,​org.spdx.library.model.v3_0_1.core.ExternalRefType> EXTERNAL_REF_TYPE_MAP  
      static Map<org.spdx.library.model.v2.enumerations.ChecksumAlgorithm,​org.spdx.library.model.v3_0_1.core.HashAlgorithm> HASH_ALGORITH_MAP  
      static Map<org.spdx.library.model.v2.enumerations.RelationshipType,​org.spdx.library.model.v3_0_1.core.LifecycleScopeType> LIFECYCLE_SCOPE_MAP  
      static Map<org.spdx.library.model.v2.enumerations.Purpose,​org.spdx.library.model.v3_0_1.software.SoftwarePurpose> PURPOSE_MAP  
      static Map<org.spdx.library.model.v2.enumerations.RelationshipType,​org.spdx.library.model.v3_0_1.core.RelationshipType> RELATIONSHIP_TYPE_MAP  
      static Set<org.spdx.library.model.v2.enumerations.RelationshipType> SWAP_TO_FROM_REL_TYPES  
    • Constructor Summary

      Constructors 
      Constructor Description
      Spdx2to3Converter​(org.spdx.storage.IModelStore toModelStore, org.spdx.core.IModelCopyManager copyManager, org.spdx.library.model.v3_0_1.core.CreationInfo defaultCreationInfo, String toSpecVersion, String defaultUriPrefix)  
      Spdx2to3Converter​(org.spdx.storage.IModelStore toModelStore, org.spdx.core.IModelCopyManager copyManager, org.spdx.library.model.v3_0_1.core.CreationInfo defaultCreationInfo, String toSpecVersion, String defaultUriPrefix, boolean complexLicenses)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void addExternalRefToArtifact​(org.spdx.library.model.v2.enumerations.ReferenceCategory referenceCategory, org.spdx.library.model.v2.ReferenceType referenceType, String referenceLocator, String comment, org.spdx.library.model.v3_0_1.software.SoftwareArtifact artifact, org.spdx.storage.IModelStore modelStore)  
      static void addExternalRefToArtifact​(org.spdx.library.model.v2.ExternalRef externalRef, org.spdx.library.model.v3_0_1.software.SoftwareArtifact artifact, org.spdx.storage.IModelStore modelStore)  
      boolean alreadyCopied​(String fromObjectUri)  
      org.spdx.library.model.v3_0_1.core.Annotation convertAndStore​(org.spdx.library.model.v2.Annotation fromAnnotation, org.spdx.library.model.v3_0_1.core.Element toElement)
      Converts an SPDX spec version 2 annotation to an SPDX spec version 3 annotation
      org.spdx.library.model.v3_0_1.core.Hash convertAndStore​(org.spdx.library.model.v2.Checksum checksum)
      Converts the SPDX spec version 2 Checksum to an SPDX spec version 3 Hash and store the result
      org.spdx.library.model.v3_0_1.core.NamespaceMap convertAndStore​(org.spdx.library.model.v2.ExternalDocumentRef externalDocRef, Collection<org.spdx.library.model.v3_0_1.core.ExternalMap> docImports)
      Converts the externalDocRef to a NamespaceMap and store the NamespaceMap.
      org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo convertAndStore​(org.spdx.library.model.v2.license.AnyLicenseInfo fromLicense)
      Converts an SPDX spec version 2 SPDX AnyLicenseIfno to an SPDX spec version 3 SPDX AnyLicenseIfno and store the result
      org.spdx.library.model.v3_0_1.expandedlicensing.ConjunctiveLicenseSet convertAndStore​(org.spdx.library.model.v2.license.ConjunctiveLicenseSet fromConjunctiveLicenseSet)
      Converts an SPDX spec version 2 SPDX ConjunctiveLicenseSet to an SPDX spec version 3 SPDX ConjunctiveLicenseSet and store the result in the toStore
      org.spdx.library.model.v3_0_1.expandedlicensing.DisjunctiveLicenseSet convertAndStore​(org.spdx.library.model.v2.license.DisjunctiveLicenseSet fromDisjunctiveLicenseSet)
      Converts an SPDX spec version 2 SPDX DisjunctiveLicenseSet to an SPDX spec version 3 SPDX DisjunctiveLicenseSet and store the result in the toStore
      org.spdx.library.model.v3_0_1.expandedlicensing.CustomLicense convertAndStore​(org.spdx.library.model.v2.license.ExtractedLicenseInfo fromExtractedLicenseInfo)
      Converts an SPDX spec version 2 SPDX ExtractedLicenseInfo to an SPDX spec version 3 SPDX CustomLicense and store the result in the toStore
      org.spdx.library.model.v3_0_1.expandedlicensing.LicenseAddition convertAndStore​(org.spdx.library.model.v2.license.LicenseException fromException)
      Converts an SPDX spec version 2 SPDX LicenseException to an SPDX spec version 3 LicenseAddition and store the result in the toStore
      org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException convertAndStore​(org.spdx.library.model.v2.license.ListedLicenseException fromException)
      Converts an SPDX spec version 2 SPDX ListedLicenseException to an SPDX spec version 3 ListedLicenseAddition and store the result in the toStore
      org.spdx.library.model.v3_0_1.expandedlicensing.OrLaterOperator convertAndStore​(org.spdx.library.model.v2.license.OrLaterOperator fromOrLaterOperator)
      Converts an SPDX spec version 2 SPDX OrLaterOperator to an SPDX spec version 3 SPDX OrLaterOperator and store the result in the toStore
      org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicense convertAndStore​(org.spdx.library.model.v2.license.SpdxListedLicense fromSpdxListedLicense)
      Converts an SPDX spec version 2 SPDX SpdxListedLicense to an SPDX spec version 3 SPDX ListedLicense and store the result in the toStore
      org.spdx.library.model.v3_0_1.expandedlicensing.WithAdditionOperator convertAndStore​(org.spdx.library.model.v2.license.WithExceptionOperator fromWithExceptionOperator)
      Converts an SPDX spec version 2 SPDX WithExceptionOperator to an SPDX spec version 3 SPDX WithAdditionOperator and store the result in the toStore
      org.spdx.library.model.v3_0_1.core.Relationship convertAndStore​(org.spdx.library.model.v2.Relationship fromRelationship, org.spdx.library.model.v3_0_1.core.Element containingElement)
      Converts an SPDX spec version 2 relationship to an SPDX spec version 3 relationship
      org.spdx.library.model.v3_0_1.core.SpdxDocument convertAndStore​(org.spdx.library.model.v2.SpdxDocument fromDoc)
      Converts an SPDX spec version 2 SPDX document to an SPDX spec version 3 SPDX document and store the result in the toStore
      org.spdx.library.model.v3_0_1.core.Element convertAndStore​(org.spdx.library.model.v2.SpdxElement fromElement)
      Converts the Element and stores all properties in the toStore
      org.spdx.library.model.v3_0_1.software.SpdxFile convertAndStore​(org.spdx.library.model.v2.SpdxFile spdxFile)
      Converts the SPDX 2 SpdxFile to an SPDX 3 SpdxFile and returns the converted file
      org.spdx.library.model.v3_0_1.software.SpdxPackage convertAndStore​(org.spdx.library.model.v2.SpdxPackage spdxPackage)
      Converts the SPDX 2 SpdxPackage to an SPDX 3 SpdxPackage and returns the converted package
      org.spdx.library.model.v3_0_1.core.IntegrityMethod convertAndStore​(org.spdx.library.model.v2.SpdxPackageVerificationCode spdxPackageVerificationCode)
      Converts the spdxPackageVerificationCode to an IntegrityMethod and store the result in the toModelStore
      org.spdx.library.model.v3_0_1.software.Snippet convertAndStore​(org.spdx.library.model.v2.SpdxSnippet fromSnippet)
      Converts the SPDX 2 SpdxSnippet to an SPDX 3 Snippet and returns the converted snippet
      static org.spdx.library.model.v3_0_1.core.CreationInfo convertCreationInfo​(org.spdx.library.model.v2.SpdxCreatorInformation creationInfoV2, org.spdx.storage.IModelStore modelStore, String uriPrefix)  
      org.spdx.library.model.v3_0_1.simplelicensing.LicenseExpression convertToLicenseExpression​(org.spdx.library.model.v2.license.AnyLicenseInfo fromLicense)
      Converts an SPDX spec version 2 SPDX AnyLicenseIfno to an SPDX spec version 3 LicenseExpression
      protected Optional<org.spdx.library.model.v3_0_1.ModelObjectV3> getExistingObject​(String fromObjectUri, String toType)  
      static org.spdx.library.model.v3_0_1.core.Agent stringToAgent​(String spdx2personOrgString, org.spdx.library.model.v3_0_1.core.CreationInfo creationInfo)  
    • Field Detail

      • RELATIONSHIP_TYPE_MAP

        public static final Map<org.spdx.library.model.v2.enumerations.RelationshipType,​org.spdx.library.model.v3_0_1.core.RelationshipType> RELATIONSHIP_TYPE_MAP
      • LIFECYCLE_SCOPE_MAP

        public static final Map<org.spdx.library.model.v2.enumerations.RelationshipType,​org.spdx.library.model.v3_0_1.core.LifecycleScopeType> LIFECYCLE_SCOPE_MAP
      • SWAP_TO_FROM_REL_TYPES

        public static final Set<org.spdx.library.model.v2.enumerations.RelationshipType> SWAP_TO_FROM_REL_TYPES
      • ANNOTATION_TYPE_MAP

        public static final Map<org.spdx.library.model.v2.enumerations.AnnotationType,​org.spdx.library.model.v3_0_1.core.AnnotationType> ANNOTATION_TYPE_MAP
      • HASH_ALGORITH_MAP

        public static final Map<org.spdx.library.model.v2.enumerations.ChecksumAlgorithm,​org.spdx.library.model.v3_0_1.core.HashAlgorithm> HASH_ALGORITH_MAP
      • CONTENT_IDENTIFIER_TYPE_MAP

        public static final Map<String,​org.spdx.library.model.v3_0_1.software.ContentIdentifierType> CONTENT_IDENTIFIER_TYPE_MAP
      • EXTERNAL_IDENTIFIER_TYPE_MAP

        public static final Map<String,​org.spdx.library.model.v3_0_1.core.ExternalIdentifierType> EXTERNAL_IDENTIFIER_TYPE_MAP
      • EXTERNAL_REF_TYPE_MAP

        public static final Map<String,​org.spdx.library.model.v3_0_1.core.ExternalRefType> EXTERNAL_REF_TYPE_MAP
      • PURPOSE_MAP

        public static final Map<org.spdx.library.model.v2.enumerations.Purpose,​org.spdx.library.model.v3_0_1.software.SoftwarePurpose> PURPOSE_MAP
    • Constructor Detail

      • Spdx2to3Converter

        public Spdx2to3Converter​(org.spdx.storage.IModelStore toModelStore,
                                 org.spdx.core.IModelCopyManager copyManager,
                                 org.spdx.library.model.v3_0_1.core.CreationInfo defaultCreationInfo,
                                 String toSpecVersion,
                                 String defaultUriPrefix)
        Parameters:
        toModelStore - modelStore to store any converted elements to
        copyManager - Copy manager to use for the conversion
        defaultCreationInfo - creationInfo to use for created SPDX elements
        toSpecVersion - specific spec version to convert to
        defaultUriPrefix - URI prefix to use when creating new elements
      • Spdx2to3Converter

        public Spdx2to3Converter​(org.spdx.storage.IModelStore toModelStore,
                                 org.spdx.core.IModelCopyManager copyManager,
                                 org.spdx.library.model.v3_0_1.core.CreationInfo defaultCreationInfo,
                                 String toSpecVersion,
                                 String defaultUriPrefix,
                                 boolean complexLicenses)
        Parameters:
        toModelStore - modelStore to store any converted elements to
        copyManager - Copy manager to use for the conversion
        defaultCreationInfo - creationInfo to use for created SPDX elements
        toSpecVersion - specific spec version to convert to
        defaultUriPrefix - URI prefix to use when creating new elements
        complexLicenses - if true, copy listed license information into the toModelStore and use the ExpandedLicenses otherwise use license expression strings
    • Method Detail

      • convertCreationInfo

        public static org.spdx.library.model.v3_0_1.core.CreationInfo convertCreationInfo​(org.spdx.library.model.v2.SpdxCreatorInformation creationInfoV2,
                                                                                          org.spdx.storage.IModelStore modelStore,
                                                                                          String uriPrefix)
                                                                                   throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        creationInfoV2 - SPDX Spec version 2 creation info
        modelStore - modelStore to store the CreationInfo
        uriPrefix - Prefix to use for the created Agents and Tools
        Returns:
        SPDX spec version 3 CreationInfo
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on error converting
      • stringToAgent

        public static org.spdx.library.model.v3_0_1.core.Agent stringToAgent​(String spdx2personOrgString,
                                                                             org.spdx.library.model.v3_0_1.core.CreationInfo creationInfo)
                                                                      throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        spdx2personOrgString - String formatted in the SPDX 2 typical format for person/org/tool
        creationInfo - creationInfo to add to the Agent
        Returns:
        Agent based on parsing the spdx2personOrgString - if NONE or NOASSERTION is the string value, the null is returned
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion
      • alreadyCopied

        public boolean alreadyCopied​(String fromObjectUri)
        Parameters:
        fromObjectUri - object URI of the SPDX object copied from
        Returns:
        true if the SPDX object has already been copied
      • getExistingObject

        protected Optional<org.spdx.library.model.v3_0_1.ModelObjectV3> getExistingObject​(String fromObjectUri,
                                                                                          String toType)
                                                                                   throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        fromObjectUri - Object URI of the SPDX spec version 2 object being converted from
        toType - SPDX spec version 3 type
        Returns:
        optional of the existing object - if it exists
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - if there is an error creating the existing model object
      • convertAndStore

        public org.spdx.library.model.v3_0_1.core.Relationship convertAndStore​(org.spdx.library.model.v2.Relationship fromRelationship,
                                                                               org.spdx.library.model.v3_0_1.core.Element containingElement)
                                                                        throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 relationship to an SPDX spec version 3 relationship
        Parameters:
        fromRelationship - relationship to convert from
        containingElement - Element which contains the property referring to the fromRelationship
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion
      • convertAndStore

        public org.spdx.library.model.v3_0_1.core.Annotation convertAndStore​(org.spdx.library.model.v2.Annotation fromAnnotation,
                                                                             org.spdx.library.model.v3_0_1.core.Element toElement)
                                                                      throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 annotation to an SPDX spec version 3 annotation
        Parameters:
        fromAnnotation - annotation to convert from
        toElement - Element which contains the property referring to the fromAnnotation
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion
      • convertAndStore

        public org.spdx.library.model.v3_0_1.core.SpdxDocument convertAndStore​(org.spdx.library.model.v2.SpdxDocument fromDoc)
                                                                        throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX document to an SPDX spec version 3 SPDX document and store the result in the toStore
        Parameters:
        fromDoc - SPDX spec version 2 document to convert from
        Returns:
        SPDX spec version 3 document converted from the version 2 document
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting the SPDX document
      • convertAndStore

        public org.spdx.library.model.v3_0_1.core.NamespaceMap convertAndStore​(org.spdx.library.model.v2.ExternalDocumentRef externalDocRef,
                                                                               Collection<org.spdx.library.model.v3_0_1.core.ExternalMap> docImports)
                                                                        throws org.spdx.core.InvalidSPDXAnalysisException
        Converts the externalDocRef to a NamespaceMap and store the NamespaceMap. The document information is also retained in the externalDocRefMap such that any subsequent references to the external documents can be captured in the ExternalMap for the document
        Parameters:
        externalDocRef - SPDX Model V2 external document reference
        docImports - SPDX document imports to track any added external references
        Returns:
        the namespace map correlating the documentRef ID to the document URI
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertAndStore

        public org.spdx.library.model.v3_0_1.expandedlicensing.ConjunctiveLicenseSet convertAndStore​(org.spdx.library.model.v2.license.ConjunctiveLicenseSet fromConjunctiveLicenseSet)
                                                                                              throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX ConjunctiveLicenseSet to an SPDX spec version 3 SPDX ConjunctiveLicenseSet and store the result in the toStore
        Parameters:
        fromConjunctiveLicenseSet - an SPDX spec version 2 ConjunctiveLicenseSet to convert from
        Returns:
        an SPDX spec version 3 ConjunctiveLicenseSet
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertAndStore

        public org.spdx.library.model.v3_0_1.expandedlicensing.DisjunctiveLicenseSet convertAndStore​(org.spdx.library.model.v2.license.DisjunctiveLicenseSet fromDisjunctiveLicenseSet)
                                                                                              throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX DisjunctiveLicenseSet to an SPDX spec version 3 SPDX DisjunctiveLicenseSet and store the result in the toStore
        Parameters:
        fromDisjunctiveLicenseSet - an SPDX spec version 2 DisjunctiveLicenseSet to convert from
        Returns:
        an SPDX spec version 3 DisjunctiveLicenseSet
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertAndStore

        public org.spdx.library.model.v3_0_1.expandedlicensing.CustomLicense convertAndStore​(org.spdx.library.model.v2.license.ExtractedLicenseInfo fromExtractedLicenseInfo)
                                                                                      throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX ExtractedLicenseInfo to an SPDX spec version 3 SPDX CustomLicense and store the result in the toStore
        Parameters:
        fromExtractedLicenseInfo - an SPDX spec version 2 ExtractedLicenseInfo to convert from
        Returns:
        an SPDX spec version 3 CustomLicense
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertAndStore

        public org.spdx.library.model.v3_0_1.expandedlicensing.OrLaterOperator convertAndStore​(org.spdx.library.model.v2.license.OrLaterOperator fromOrLaterOperator)
                                                                                        throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX OrLaterOperator to an SPDX spec version 3 SPDX OrLaterOperator and store the result in the toStore
        Parameters:
        fromOrLaterOperator - an SPDX spec version 2 OrLaterOperator to convert from
        Returns:
        an SPDX spec version 3 OrLaterOperator
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertAndStore

        public org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicense convertAndStore​(org.spdx.library.model.v2.license.SpdxListedLicense fromSpdxListedLicense)
                                                                                      throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX SpdxListedLicense to an SPDX spec version 3 SPDX ListedLicense and store the result in the toStore
        Parameters:
        fromSpdxListedLicense - an SPDX spec version 2 SpdxListedLicense to convert from
        Returns:
        an SPDX spec version 3 ListedLicense
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertAndStore

        public org.spdx.library.model.v3_0_1.expandedlicensing.WithAdditionOperator convertAndStore​(org.spdx.library.model.v2.license.WithExceptionOperator fromWithExceptionOperator)
                                                                                             throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX WithExceptionOperator to an SPDX spec version 3 SPDX WithAdditionOperator and store the result in the toStore
        Parameters:
        fromWithExceptionOperator - an SPDX spec version 2 WithExceptionOperator to convert from
        Returns:
        an SPDX spec version 3 WithAdditionOperator
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertAndStore

        public org.spdx.library.model.v3_0_1.expandedlicensing.LicenseAddition convertAndStore​(org.spdx.library.model.v2.license.LicenseException fromException)
                                                                                        throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX LicenseException to an SPDX spec version 3 LicenseAddition and store the result in the toStore
        Parameters:
        fromException - an SPDX spec version 2 LicenseException to convert from
        Returns:
        an SPDX spec version 3 LicenseAddition
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertAndStore

        public org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException convertAndStore​(org.spdx.library.model.v2.license.ListedLicenseException fromException)
                                                                                               throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX ListedLicenseException to an SPDX spec version 3 ListedLicenseAddition and store the result in the toStore
        Parameters:
        fromException - an SPDX spec version 2 ListedLicenseException to convert from
        Returns:
        an SPDX spec version 3 ListedLicenseException
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertToLicenseExpression

        public org.spdx.library.model.v3_0_1.simplelicensing.LicenseExpression convertToLicenseExpression​(org.spdx.library.model.v2.license.AnyLicenseInfo fromLicense)
                                                                                                   throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX AnyLicenseIfno to an SPDX spec version 3 LicenseExpression
        Parameters:
        fromLicense - an SPDX spec version 2 AnyLicenseInfo
        Returns:
        an SPDX spec version 3 LicenseExpression
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertAndStore

        public org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo convertAndStore​(org.spdx.library.model.v2.license.AnyLicenseInfo fromLicense)
                                                                                     throws org.spdx.core.InvalidSPDXAnalysisException
        Converts an SPDX spec version 2 SPDX AnyLicenseIfno to an SPDX spec version 3 SPDX AnyLicenseIfno and store the result
        Parameters:
        fromLicense - an SPDX spec version 2 AnyLicenseInfo
        Returns:
        an SPDX spec version 3 AnyLicenseIfno
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any errors converting
      • convertAndStore

        public org.spdx.library.model.v3_0_1.core.Element convertAndStore​(org.spdx.library.model.v2.SpdxElement fromElement)
                                                                   throws org.spdx.core.InvalidSPDXAnalysisException
        Converts the Element and stores all properties in the toStore
        Parameters:
        fromElement - element to convert from
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion
      • convertAndStore

        public org.spdx.library.model.v3_0_1.software.SpdxFile convertAndStore​(org.spdx.library.model.v2.SpdxFile spdxFile)
                                                                        throws org.spdx.core.InvalidSPDXAnalysisException
        Converts the SPDX 2 SpdxFile to an SPDX 3 SpdxFile and returns the converted file
        Parameters:
        spdxFile - SPDX file to convert from
        Returns:
        SPDX 3 SpdxFile
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion
      • convertAndStore

        public org.spdx.library.model.v3_0_1.core.Hash convertAndStore​(org.spdx.library.model.v2.Checksum checksum)
                                                                throws org.spdx.core.InvalidSPDXAnalysisException
        Converts the SPDX spec version 2 Checksum to an SPDX spec version 3 Hash and store the result
        Parameters:
        checksum - SPDX spec version 2 Checksum
        Returns:
        SPDX spec version 3 Hash
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion
      • convertAndStore

        public org.spdx.library.model.v3_0_1.software.SpdxPackage convertAndStore​(org.spdx.library.model.v2.SpdxPackage spdxPackage)
                                                                           throws org.spdx.core.InvalidSPDXAnalysisException
        Converts the SPDX 2 SpdxPackage to an SPDX 3 SpdxPackage and returns the converted package
        Parameters:
        spdxPackage - SPDX package to convert from
        Returns:
        SPDX 3 SpdxPackage
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion
      • convertAndStore

        public org.spdx.library.model.v3_0_1.core.IntegrityMethod convertAndStore​(org.spdx.library.model.v2.SpdxPackageVerificationCode spdxPackageVerificationCode)
                                                                           throws org.spdx.core.InvalidSPDXAnalysisException
        Converts the spdxPackageVerificationCode to an IntegrityMethod and store the result in the toModelStore
        Parameters:
        spdxPackageVerificationCode - SPDX Spec version 2 package verification code
        Returns:
        the package verification code integrity method
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion
      • addExternalRefToArtifact

        public static void addExternalRefToArtifact​(org.spdx.library.model.v2.ExternalRef externalRef,
                                                    org.spdx.library.model.v3_0_1.software.SoftwareArtifact artifact,
                                                    org.spdx.storage.IModelStore modelStore)
                                             throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        externalRef - SPDX Spec version 2 External Ref to add to the package
        artifact - SPDX Spec version 3 Artifact to add either an ExternalRef or ExternalId depending on the externalRef type
        modelStore - modelStore to use for creating any SPDX objects
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion
      • addExternalRefToArtifact

        public static void addExternalRefToArtifact​(org.spdx.library.model.v2.enumerations.ReferenceCategory referenceCategory,
                                                    org.spdx.library.model.v2.ReferenceType referenceType,
                                                    String referenceLocator,
                                                    @Nullable
                                                    String comment,
                                                    org.spdx.library.model.v3_0_1.software.SoftwareArtifact artifact,
                                                    org.spdx.storage.IModelStore modelStore)
                                             throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        referenceCategory - Reference category for external ref
        referenceType - Reference type for external ref
        referenceLocator - Locator for external ref
        comment - External reference comment
        artifact - Artifact which contains the external ref
        modelStore - modelStore to use for creating any SPDX objects
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion
      • convertAndStore

        public org.spdx.library.model.v3_0_1.software.Snippet convertAndStore​(org.spdx.library.model.v2.SpdxSnippet fromSnippet)
                                                                       throws org.spdx.core.InvalidSPDXAnalysisException
        Converts the SPDX 2 SpdxSnippet to an SPDX 3 Snippet and returns the converted snippet
        Parameters:
        fromSnippet - SPDX 2 snippet to convert from
        Returns:
        SPDX 3 Snippet
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on any error in conversion