Interface Resource
- All Known Implementing Classes:
AbstractResource
,EffectiveResource
,ImmutableResource
public interface Resource
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Resources may optionally store a secondary copy of their configuration to be used on backup nodes.static final String
The default data key (file name) for binary data.static final String
The default filename to use for resources which are serialized as JSON: "config.json"static final String
The id used for moduleId when the resource type belongs to the Ignition platform.static final String
The name of the unary resource. -
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableBytes
calculateContentDigest
(Resource resource) Calculate the SHA-256 content digest forresource
.static ImmutableBytes
calculateContentDigest
(Resource resource, Predicate<String> attributeFilter) default Resource
copy()
Create a copy of thisResource
.default Resource
copy
(Consumer<ResourceBuilder> consumer) Create a copy of thisResource
, allowing for modifications to take place prior via the consumedResourceBuilder
.default Resource
copyWithAttribute
(String key, com.inductiveautomation.ignition.common.gson.JsonElement value) int
Get the application scope of this resource.default Optional<com.inductiveautomation.ignition.common.gson.JsonElement>
getAttribute
(String key) Get an immutable view of the attributes map.Get the name of theResourceCollection
this resource belongs to.Get the SHA-256 digest of the content of this resource.default Optional<ImmutableBytes>
getData()
Returns the data for the legacy "default" file.Retrieve the data for the given key (filename) as anImmutableBytes
.getDataDigest
(String key) The "digest" is a unique fingerprint for the data file.com.google.common.collect.ImmutableSet<String>
Get an immutable view of the data key set.getDataReader
(String key) Retrieve the data for the given key (filename) as a reader.getDataStream
(String key) Retrieve the data for the given key (filename) as an input stream.default String
default String
default ResourceId
default String
Get theResourceSignature
for this resource.default ResourceType
int
Get the version of this resource.boolean
isFolder()
default boolean
boolean
default boolean
boolean
default boolean
boolean
isUnary()
static ResourceBuilder
Create a newResourceBuilder
.default ResourceBuilder
Create a newResourceBuilder
pre-set with all the values from thisResource
.
-
Field Details
-
PLATFORM_MODULE_ID
The id used for moduleId when the resource type belongs to the Ignition platform.- See Also:
-
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
The default filename to use for resources which are serialized as JSON: "config.json"- See Also:
-
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
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 theResourceCollection
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
- 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
- Returns:
- All collections in the inheritance chain that define this resource.
-
getResourcePath
ResourcePath getResourcePath() -
getResourceName
-
getFolderPath
-
getResourceType
-
isUnary
boolean isUnary() -
getDocumentation
-
getData
Returns the data for the legacy "default" file. Equivalent to calling:getData("data.bin");
-
getData
Retrieve the data for the given key (filename) as anImmutableBytes
. Consider usinggetDataStream(String)
instead. -
getDataStream
Retrieve the data for the given key (filename) as an input stream. Depending on the Resource implementation, this may be more memory efficient thangetData(String)
. -
getDataReader
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 usinggetData(String)
, especially for parsing large JSON files, for example. -
getDataKeys
Get an immutable view of the data key set.- Returns:
- an immutable view of the data key set.
-
getDataDigest
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
Get an immutable view of the attributes map.- Returns:
- an immutable view of the attributes map.
-
getAttribute
-
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 theResourceSignature
for this resource.- Returns:
- the
ResourceSignature
for this resource.
-
getResourceId
-
copy
Create a copy of thisResource
.- Returns:
- a copy of this
Resource
.
-
copy
Create a copy of thisResource
, allowing for modifications to take place prior via the consumedResourceBuilder
.- Parameters:
consumer
- theResourceBuilder
consumer.- Returns:
- a copy of this
Resource
.
-
copyWithAttribute
-
toBuilder
Create a newResourceBuilder
pre-set with all the values from thisResource
.- Returns:
- a new
ResourceBuilder
pre-set with all the values from thisResource
.
-
calculateContentDigest
Calculate the SHA-256 content digest forresource
.- Parameters:
resource
- theResource
.- Returns:
- the SHA-256 content digest.
- See Also:
-
calculateContentDigest
-
newBuilder
Create a newResourceBuilder
.- Returns:
- a new
ResourceBuilder
.
-