All Known Implementing Classes:
DefaultResourceTypeAdapter, ScriptAdapter, SfcTypeAdapter, VisionTemplateAdapter

public interface ResourceTypeAdapter
Project management systems may utilize these adapters when interacting with project resources.
  • Field Details

    • LEGACY_SINGLETON_ERRORED_NAME_PATTERN

      static final Pattern LEGACY_SINGLETON_ERRORED_NAME_PATTERN
      A pattern that matches legacy singletons that had erroneous names like " (2)" or "2)_renamed".
  • Method Details

    • getNewResourceType

      @Nonnull 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 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 Path getResourceDir(@Nullable 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 List<String> getResourcePath(com.google.common.collect.Multimap<String,LegacyProjectResource> resourceTypeMap, Map<UUID,org.apache.commons.lang3.tuple.Pair<String,UUID>> folders, LegacyProjectResource resource, 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.
      Throws:
      IllegalArgumentException - if the resource is orphaned