Class BaseStaticSetupResource

java.lang.Object
net.solarnetwork.node.setup.BaseStaticSetupResource
All Implemented Interfaces:
SetupResource
Direct Known Subclasses:
ClasspathSetupResource, ResourceSetupResource

public abstract class BaseStaticSetupResource extends Object implements SetupResource
Abstract base class for static SetupResource implementations.
Version:
1.1
Author:
matt
  • Constructor Details

    • BaseStaticSetupResource

      public BaseStaticSetupResource(String uid, String contentType, Set<String> consumerTypes, Set<String> roles)
      Construct with values. Caching will be disabled and the content length and last modified timestamp will be set to -1.
      Parameters:
      uid - the resourceUID
      contentType - the content type
      consumerTypes - the optional consumer types
      roles - the optional required roles
    • BaseStaticSetupResource

      public BaseStaticSetupResource(String uid, String contentType, Locale locale, int cacheSeconds, Set<String> roles, Set<String> consumerTypes, org.springframework.core.io.Resource resource) throws IOException
      Construct with values. Caching will be disabled and the content length and last modified timestamp will be set to -1.
      Parameters:
      uid - the resourceUID
      contentType - the content type
      locale - the locale
      cacheSeconds - the maximum cache seconds
      consumerTypes - the optional consumer types
      roles - the optional required roles
      resource - A Resource to get contentLength and lastModified values from.
      Throws:
      IOException - if the Resource throws one when accessed
    • BaseStaticSetupResource

      public BaseStaticSetupResource(String uid, String contentType, Locale locale, int cacheSeconds, Set<String> roles, Set<String> consumerTypes, org.springframework.core.io.Resource resource, SetupResourceScope scope) throws IOException
      Construct with values. Caching will be disabled and the content length and last modified timestamp will be set to -1.
      Parameters:
      uid - the resourceUID
      contentType - the content type
      locale - the locale
      cacheSeconds - the maximum cache seconds
      consumerTypes - the optional consumer types
      roles - the optional required roles
      resource - A Resource to get contentLength and lastModified values from.
      scope - the resource scope
      Throws:
      IOException - if the Resource throws one when accessed
      Since:
      1.1
    • BaseStaticSetupResource

      public BaseStaticSetupResource(String uid, String contentType, Locale locale, int cacheSeconds, long contentLength, long lastModified, Set<String> consumerTypes, Set<String> roles)
      Construct with values.
      Parameters:
      uid - the resourceUID
      contentType - the content type
      locale - the locale
      cacheSeconds - the maximum cache seconds
      contentLength - the content length
      lastModified - the last modified date
      consumerTypes - the optional consumer types
      roles - the optional required roles
    • BaseStaticSetupResource

      public BaseStaticSetupResource(String uid, String contentType, Locale locale, int cacheSeconds, long contentLength, long lastModified, Set<String> consumerTypes, Set<String> roles, SetupResourceScope scope)
      Construct with values.
      Parameters:
      uid - the resourceUID
      contentType - the content type
      locale - the locale
      cacheSeconds - the maximum cache seconds
      contentLength - the content length
      lastModified - the last modified date
      consumerTypes - the optional consumer types
      roles - the optional required roles
      scope - the scope
      Since:
      1.1
  • Method Details

    • getResourceUID

      public String getResourceUID()
      Description copied from interface: SetupResource
      Get a globally unique identifier for this resource.
      Specified by:
      getResourceUID in interface SetupResource
      Returns:
      The identifier.
    • getContentType

      public String getContentType()
      Description copied from interface: SetupResource
      Get the content type of this resource.
      Specified by:
      getContentType in interface SetupResource
      Returns:
      The content type.
    • getRequiredRoles

      public Set<String> getRequiredRoles()
      Description copied from interface: SetupResource
      Get a set of required security roles, or null if none required. The set is treated such that any matching role is allowed access, that is the roles are logically OR'ed together.
      Specified by:
      getRequiredRoles in interface SetupResource
      Returns:
      A set of required roles, or null if no role required.
    • getCacheMaximumSeconds

      public int getCacheMaximumSeconds()
      Description copied from interface: SetupResource
      Get a maximum number of seconds this resource may be cached for, or -1 if no caching should be allowed.
      Specified by:
      getCacheMaximumSeconds in interface SetupResource
      Returns:
      The maximum number of seconds the resource may be cached for.
    • contentLength

      public long contentLength() throws IOException
      Description copied from interface: SetupResource
      Determine the content length for this resource.
      Specified by:
      contentLength in interface SetupResource
      Returns:
      the content length, or -1 if not known
      Throws:
      IOException - if the resource cannot be resolved (in the file system or as some other known physical resource type)
    • lastModified

      public long lastModified() throws IOException
      Description copied from interface: SetupResource
      Determine the last-modified timestamp for this resource.
      Specified by:
      lastModified in interface SetupResource
      Returns:
      the last modified timestamp, or -1 if not known
      Throws:
      IOException - if the resource cannot be resolved (in the file system or as some other known physical resource type)
    • getSupportedConsumerTypes

      public Set<String> getSupportedConsumerTypes()
      Description copied from interface: SetupResource
      Get a set of supported consumer types, or null if all types are supported.
      Specified by:
      getSupportedConsumerTypes in interface SetupResource
      Returns:
      A set of supported consumer types, or null if all types are supported.
    • getLocale

      public Locale getLocale()
      Description copied from interface: SetupResource
      The locale of the resource, or null for non-localizable content.
      Specified by:
      getLocale in interface SetupResource
      Returns:
      The locale, or null.
    • getScope

      public SetupResourceScope getScope()
      Description copied from interface: SetupResource
      Get the scope of the resource, or null if undefined.
      Specified by:
      getScope in interface SetupResource
      Returns:
      the resource scope