Class SpdxListedLicenseModelStore

java.lang.Object
org.spdx.storage.listedlicense.SpdxListedLicenseModelStore
All Implemented Interfaces:
AutoCloseable, org.spdx.storage.IModelStore, IListedLicenseStore
Direct Known Subclasses:
SpdxListedLicenseLocalStore, SpdxListedLicenseWebStore

public abstract class SpdxListedLicenseModelStore extends Object implements IListedLicenseStore
Read-only model store for the SPDX listed licenses

License and exception ID's can be case-insensitive

License information is stored in a LicenseJson file with the ID being Listed License ID License Exception information is stored in an ExceptionJson file with the ID being the Listed Exception ID CrossRef information is stored within the LicenseJson file. Id's are anonymous and generated.

Author:
Gary O'Neall
  • Field Details

  • Constructor Details

    • SpdxListedLicenseModelStore

      public SpdxListedLicenseModelStore() throws org.spdx.core.InvalidSPDXAnalysisException
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - on error loading ids
  • Method Details

    • objectUriToLicenseOrExceptionId

      public static String objectUriToLicenseOrExceptionId(String objectUri)
    • licenseOrExceptionIdToObjectUri

      public static String licenseOrExceptionIdToObjectUri(String id)
    • getTocInputStream

      public abstract InputStream getTocInputStream() throws IOException
      Returns:
      InputStream for the Table of Contents of the licenses formatted in JSON SPDX
      Throws:
      IOException - on IO errors
    • getExceptionTocInputStream

      public abstract InputStream getExceptionTocInputStream() throws IOException
      Returns:
      InputStream for the Table of Contents of the exceptions formatted in JSON SPDX
      Throws:
      IOException - on IO errors
    • getLicenseInputStream

      public abstract InputStream getLicenseInputStream(String licenseId) throws IOException
      Returns:
      InputStream for a license formatted in SPDX JSON
      Throws:
      IOException - on IO errors
    • getExceptionInputStream

      public abstract InputStream getExceptionInputStream(String exceptionId) throws IOException
      Returns:
      InputStream for an exception formatted in SPDX JSON
      Throws:
      IOException - on IO errors
    • exists

      public boolean exists(String objectUri)
      Specified by:
      exists in interface org.spdx.storage.IModelStore
    • create

      public void create(org.spdx.core.TypedValue typedValue) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      create in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • getPropertyValueDescriptors

      public List<org.spdx.storage.PropertyDescriptor> getPropertyValueDescriptors(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      getPropertyValueDescriptors in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • setValue

      public void setValue(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      setValue in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • clearValueCollection

      public void clearValueCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      clearValueCollection in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • addValueToCollection

      public boolean addValueToCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      addValueToCollection in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • removeValueFromCollection

      public boolean removeValueFromCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      removeValueFromCollection in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • listValues

      public Iterator<Object> listValues(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      listValues in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • getValue

      public Optional<Object> getValue(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      getValue in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • getNextId

      public String getNextId(org.spdx.storage.IModelStore.IdType idType) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      getNextId in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • getSpdxListedLicenseIds

      public List<String> getSpdxListedLicenseIds()
      Specified by:
      getSpdxListedLicenseIds in interface IListedLicenseStore
      Returns:
      List of all SPDX listed license IDs
    • getLicenseListVersion

      public String getLicenseListVersion()
      Specified by:
      getLicenseListVersion in interface IListedLicenseStore
      Returns:
      The version of the loaded license list in the form M.N, where M is the major release and N is the minor release.
    • getLicenseListReleaseDate

      public String getLicenseListReleaseDate()
      Returns:
      the release date for the license list
    • getSpdxListedExceptionIds

      public List<String> getSpdxListedExceptionIds()
      Specified by:
      getSpdxListedExceptionIds in interface IListedLicenseStore
      Returns:
      list of SPDX exception IDs
    • isSpdxListedLicenseId

      public boolean isSpdxListedLicenseId(String listedLicenseDocumentUri, String licenseId)
      Specified by:
      isSpdxListedLicenseId in interface IListedLicenseStore
      Parameters:
      listedLicenseDocumentUri - Prefix URL for the listed license
      licenseId - license ID
      Returns:
      true if the licenseId belongs to an SPDX listed license
    • isSpdxListedExceptionId

      public boolean isSpdxListedExceptionId(String listedLicenseDocumentUri, String exceptionId)
      Specified by:
      isSpdxListedExceptionId in interface IListedLicenseStore
      Parameters:
      listedLicenseDocumentUri - prefix URL for the listed license
      exceptionId - exception ID maintained by the SPDX legal team
      Returns:
      true if the exceptionId belongs to an SPDX listed exception
    • getTypedValue

      public Optional<org.spdx.core.TypedValue> getTypedValue(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      getTypedValue in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • removeProperty

      public void removeProperty(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      removeProperty in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • getAllItems

      public Stream<org.spdx.core.TypedValue> getAllItems(@Nullable String documentUri, @Nullable String typeFilter) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      getAllItems in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • collectionSize

      public int collectionSize(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      collectionSize in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • collectionContains

      public boolean collectionContains(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      collectionContains in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • isCollectionMembersAssignableTo

      public boolean isCollectionMembersAssignableTo(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      isCollectionMembersAssignableTo in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • isPropertyValueAssignableTo

      public boolean isPropertyValueAssignableTo(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz, String specVersion) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      isPropertyValueAssignableTo in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • isCollectionProperty

      public boolean isCollectionProperty(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      isCollectionProperty in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • getIdType

      public org.spdx.storage.IModelStore.IdType getIdType(String objectUri)
      Specified by:
      getIdType in interface org.spdx.storage.IModelStore
    • isAnon

      public boolean isAnon(String objectUri)
      Specified by:
      isAnon in interface org.spdx.storage.IModelStore
    • enterCriticalSection

      public org.spdx.storage.IModelStore.IModelStoreLock enterCriticalSection(boolean readLockRequested)
      Specified by:
      enterCriticalSection in interface org.spdx.storage.IModelStore
    • leaveCriticalSection

      public void leaveCriticalSection(org.spdx.storage.IModelStore.IModelStoreLock lock)
      Specified by:
      leaveCriticalSection in interface org.spdx.storage.IModelStore
    • listedLicenseIdCaseSensitive

      public Optional<String> listedLicenseIdCaseSensitive(String licenseId)
      Specified by:
      listedLicenseIdCaseSensitive in interface IListedLicenseStore
      Parameters:
      licenseId - case insensitive license ID
      Returns:
      the case-sensitive license ID
    • listedExceptionIdCaseSensitive

      public Optional<String> listedExceptionIdCaseSensitive(String exceptionId)
      Specified by:
      listedExceptionIdCaseSensitive in interface IListedLicenseStore
      Parameters:
      exceptionId - case-insensitive exception ID
      Returns:
      case sensitive ID
    • getCaseSensitiveId

      public Optional<String> getCaseSensitiveId(String documentUri, String caseInsensitiveId)
      Specified by:
      getCaseSensitiveId in interface org.spdx.storage.IModelStore
    • delete

      public void delete(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      delete in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • getListedLicenseCreationInfo

      public org.spdx.library.model.v3_0_1.core.CreationInfo getListedLicenseCreationInfo() throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      getListedLicenseCreationInfo in interface IListedLicenseStore
      Returns:
      the CreationInfo used for all SPDX listed licenses and listed exceptions
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - on error inflating the CreationInfo
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception