All Known Implementing Classes:
AbstractResource, EffectiveResource, ImmutableResource

public interface Resource
  • Field Details

    • PLATFORM_MODULE_ID

      static final String PLATFORM_MODULE_ID
      The id used for moduleId when the resource type belongs to the Ignition platform.
      See Also:
    • DEFAULT_DATA_KEY

      static final String DEFAULT_DATA_KEY
      The default data key (file name) for binary data. Often used by systems coming from the pre-8.0 project system where resources were only able to store one blob of binary data, which then got mapped to this filename upon migration to 8.0.
      See Also:
    • DEFAULT_JSON_KEY

      static final String DEFAULT_JSON_KEY
      The default filename to use for resources which are serialized as JSON: "config.json"
      See Also:
    • DEFAULT_BACKUP_JSON_KEY

      static final String DEFAULT_BACKUP_JSON_KEY
      Resources may optionally store a secondary copy of their configuration to be used on backup nodes. This is the filename (data key) for this copy: "backupConfig.json"
      See Also:
    • UNARY_RESOURCE_NAME

      static final String UNARY_RESOURCE_NAME
      The name of the unary resource. This is a special resource that uses a compact encoding on disk. Useful for resource types that are tree-heavy, with each node of the tree only having a single resource.
      See Also:
  • Method Details

    • getCollectionName

      String getCollectionName()
      Get the name of the ResourceCollection this resource belongs to. Note that if this resource was inherited, this collection name will be the name of the collection that was loaded up, not necessarily the collection that actually holds the definition of this resource.
    • getDefiningCollectionName

      default String getDefiningCollectionName()
      Returns:
      The name of the resource collection that holds the definition of this resource. By comparing this to getCollectionName, you can determine if this resource is inherited or not.
    • getDefiningCollectionNames

      default List<String> getDefiningCollectionNames()
      Returns:
      All collections in the inheritance chain that define this resource.
    • getResourcePath

      ResourcePath getResourcePath()
    • getResourceName

      default String getResourceName()
    • getFolderPath

      default String getFolderPath()
    • getResourceType

      default ResourceType getResourceType()
    • isUnary

      boolean isUnary()
    • getDocumentation

      @Nullable String getDocumentation()
    • getData

      @Nonnull default Optional<ImmutableBytes> getData()
      Returns the data for the legacy "default" file. Equivalent to calling:
           getData("data.bin");
       
    • getData

      @Nonnull Optional<ImmutableBytes> getData(String key)
      Retrieve the data for the given key (filename) as an ImmutableBytes. Consider using getDataStream(String) instead.
    • getDataStream

      Optional<InputStream> getDataStream(String key)
      Retrieve the data for the given key (filename) as an input stream. Depending on the Resource implementation, this may be more memory efficient than getData(String).
    • getDataReader

      Optional<Reader> getDataReader(String key)
      Retrieve the data for the given key (filename) as a reader. Reader will be opened with UTF-8 encoding. This may be more memory efficient than using getData(String), especially for parsing large JSON files, for example.
    • getDataKeys

      @Nonnull com.google.common.collect.ImmutableSet<String> getDataKeys()
      Get an immutable view of the data key set.
      Returns:
      an immutable view of the data key set.
    • getDataDigest

      Optional<String> getDataDigest(String key)
      The "digest" is a unique fingerprint for the data file. Calculated as a sha-256 hash and then encoded to a string as hex. Reference implementation looks like:
           getData(key).map(bytes -> DigestBuilder.sha256().update(bytes).buildHexString());
       
    • getAttributes

      @Nonnull Map<String,com.inductiveautomation.ignition.common.gson.JsonElement> getAttributes()
      Get an immutable view of the attributes map.
      Returns:
      an immutable view of the attributes map.
    • getAttribute

      default Optional<com.inductiveautomation.ignition.common.gson.JsonElement> getAttribute(String key)
    • getApplicationScope

      int getApplicationScope()
      Get the application scope of this resource.
      Returns:
      the application scope of this resource.
      See Also:
    • getVersion

      int getVersion()
      Get the version of this resource.

      The version number is not intended to track mutations to the resource like the legacy edit count, but rather, its interpretation and use is for the entities this resource type belongs to and so it can be used to reason about the contents of the resource, e.g. to distinguish between serialization formats.

      Returns:
      the version of this resource.
    • isFolder

      boolean isFolder()
      Returns:
      true if this resource is a folder.
    • isModuleFolder

      default boolean isModuleFolder()
    • isResourceTypeFolder

      default boolean isResourceTypeFolder()
    • isSingletonResource

      default boolean isSingletonResource()
    • isRestricted

      boolean isRestricted()
      Returns:
      true if this resource is restricted to users of a certain role. Formerly known as "protected".
    • isOverridable

      boolean isOverridable()
      Returns:
      true if this resource can be overridden by child projects.
    • getContentDigest

      ImmutableBytes getContentDigest()
      Get the SHA-256 digest of the content of this resource. This does not include the project name or any part of the path to this resource, but rather, it's a representation of the contents of the folder on disk.

      Any changes to any of the resource contents of that folder shall result in a change to the content digest.

      Returns:
      the SHA-256 digest of the content of this resource.
      See Also:
    • getResourceSignature

      ResourceSignature getResourceSignature()
      Get the ResourceSignature for this resource.
      Returns:
      the ResourceSignature for this resource.
    • getResourceId

      default ResourceId getResourceId()
    • copy

      default Resource copy()
      Create a copy of this Resource.
      Returns:
      a copy of this Resource.
    • copy

      default Resource copy(Consumer<ResourceBuilder> consumer)
      Create a copy of this Resource, allowing for modifications to take place prior via the consumed ResourceBuilder.
      Parameters:
      consumer - the ResourceBuilder consumer.
      Returns:
      a copy of this Resource.
    • copyWithAttribute

      default Resource copyWithAttribute(String key, com.inductiveautomation.ignition.common.gson.JsonElement value)
    • toBuilder

      default ResourceBuilder toBuilder()
      Create a new ResourceBuilder pre-set with all the values from this Resource.
      Returns:
      a new ResourceBuilder pre-set with all the values from this Resource.
    • calculateContentDigest

      static ImmutableBytes calculateContentDigest(Resource resource)
      Calculate the SHA-256 content digest for resource.
      Parameters:
      resource - the Resource.
      Returns:
      the SHA-256 content digest.
      See Also:
    • calculateContentDigest

      static ImmutableBytes calculateContentDigest(Resource resource, Predicate<String> attributeFilter)
    • newBuilder

      static ResourceBuilder newBuilder()
      Create a new ResourceBuilder.
      Returns:
      a new ResourceBuilder.