Interface ResourceTypeAdapter
-
- All Known Implementing Classes:
DefaultResourceTypeAdapter
,ScriptAdapter
,SfcTypeAdapter
,VisionTemplateAdapter
public interface ResourceTypeAdapter
Project management systems may utilize these adapters when interacting with project resources.
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.Pattern
LEGACY_SINGLETON_ERRORED_NAME_PATTERN
A pattern that matches legacy singletons that had erroneous names like " (2)" or "2)_renamed".
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default byte[]
adaptData(byte[] data)
Adapt the data from the original project resource, if necessary.java.lang.String
getNewResourceType()
Get the desired resource type name, i.e.default java.nio.file.Path
getResourceDir(java.lang.String projectName)
Returns the path to the resource directory for the resource being adapted.default java.lang.String
getResourceFileName()
Get the name of the file that the adapted resource type should use to store its data on disk.default java.util.List<java.lang.String>
getResourcePath(com.google.common.collect.Multimap<java.lang.String,LegacyProjectResource> resourceTypeMap, java.util.Map<java.util.UUID,org.apache.commons.lang3.tuple.Pair<java.lang.String,java.util.UUID>> folders, LegacyProjectResource resource, java.lang.String sanitizedResourceName)
Get the path for a given resource.
-
-
-
Method Detail
-
getNewResourceType
@Nonnull java.lang.String getNewResourceType()
Get the desired resource type name, i.e. that one that will be used when writing resources to the filesystem.- Returns:
- the desired resource type name, i.e. that one that will be used when writing resources to the filesystem.
-
getResourceFileName
default java.lang.String getResourceFileName()
Get the name of the file that the adapted resource type should use to store its data on disk.Defaults to
ProjectResource.DEFAULT_DATA_KEY
.- Returns:
- the name of the file that the adapted resource type should use to store its data on disk.
-
adaptData
default byte[] adaptData(byte[] data)
Adapt the data from the original project resource, if necessary.- Returns:
- the adapted data, if necessary.
-
getResourceDir
default java.nio.file.Path getResourceDir(@Nullable java.lang.String projectName)
Returns the path to the resource directory for the resource being adapted.The default implementation is a simple Path with one component: the value of
getNewResourceType()
.Custom implementations should may provide additional components but must begin with
getNewResourceType()
.Most types won't care about
projectName
, but if this is called during a project import or upgrade from a legacy (<= 7.9),projectName
may be important.- Parameters:
projectName
- the name of the project the resource being adapted belongs to.
-
getResourcePath
default java.util.List<java.lang.String> getResourcePath(com.google.common.collect.Multimap<java.lang.String,LegacyProjectResource> resourceTypeMap, java.util.Map<java.util.UUID,org.apache.commons.lang3.tuple.Pair<java.lang.String,java.util.UUID>> folders, LegacyProjectResource resource, java.lang.String sanitizedResourceName)
Get the path for a given resource.The default implementation can automatically resolve the correct path using the provided
folders
if the resources play into the legacy resource parent UUID convention.- Parameters:
resourceTypeMap
- all the resources, keyed by type, for the project being converted.folders
- all the folders, keyed by their UUID, mapped to their name and parent UUID.resource
- the resource being converted.sanitizedResourceName
- the new, sanitized, name for the resource.- Returns:
- the path for
resource
. This path should not include the resource type folder.
-
-