Class AbstractResourceFinder

java.lang.Object
org.eclipse.lemminx.customservice.synapse.resourceFinder.AbstractResourceFinder
Direct Known Subclasses:
NewProjectResourceFinder, OldProjectResourceFinder

public abstract class AbstractResourceFinder extends Object
  • Field Details

  • Constructor Details

    • AbstractResourceFinder

      public AbstractResourceFinder()
  • Method Details

    • loadDependentResources

      public String loadDependentResources(String projectPath)
      Loads dependent resources for the given project path.

      This method initializes the dependent resources map and attempts to locate the dependencies directory for the specified project. If found, it iterates through each dependent project, finds resources of each type, and merges them into the dependent resources map.

      Parameters:
      projectPath - the absolute path to the project whose dependencies are to be loaded
      Throws:
      RuntimeException - if an I/O error occurs while accessing the dependencies
    • getDependentResourcesMap

      public Map<String,ResourceResponse> getDependentResourcesMap()
    • mergeResourceResponses

      protected void mergeResourceResponses(ResourceResponse response1, ResourceResponse response2)
      Merges the resources and registry resources from two ResourceResponse objects.

      If both responses are non-null, their resource lists and registry resource lists are combined to response1. If response1 is null, a new ResourceResponse is created and populated with the resources from response2.

      Parameters:
      response1 - the target ResourceResponse to merge into (may be null)
      response2 - the source ResourceResponse to merge from (may be null)
    • getAvailableResources

      public ResourceResponse getAvailableResources(String uri, org.eclipse.lsp4j.jsonrpc.messages.Either<String,List<RequestedResource>> resourceTypes)
    • findAllRegistryResources

      protected void findAllRegistryResources(Path registryPath, Map<String,ResourceResponse> allResources)
      Scans the given registry directory and populates the provided map with all registry resources found.
      Parameters:
      registryPath - the path to the registry directory to scan
      allResources - the map to populate with found resources, keyed by resource type
    • findResources

      protected abstract ResourceResponse findResources(String projectPath, List<RequestedResource> type)
    • findAllResources

      public abstract Map<String,ResourceResponse> findAllResources(String projectPath)
      Finds and returns all resources for the given project path, grouped by resource type.
      Parameters:
      projectPath - the absolute path to the project
      Returns:
      a map where the key is the resource type and the value is the corresponding ResourceResponse
    • findResourceInArtifacts

      protected List<Resource> findResourceInArtifacts(Path artifactsPath, List<RequestedResource> types)
    • findResourceInLocalEntry

      protected List<Resource> findResourceInLocalEntry(Path localEntryPath, List<RequestedResource> types)
    • findAllLocalEntryResources

      protected void findAllLocalEntryResources(Path localEntryPath, Map<String,ResourceResponse> allResources)
      Scans the specified local entry directory and adds all valid local entry resources to the provided map of all resources, grouped by their type.
      Parameters:
      localEntryPath - the path to the local entry directory
      allResources - the map to populate with found resources, keyed by resource type
    • getArtifactFolder

      protected abstract String getArtifactFolder(String type)
    • findResourceInRegistry

      protected List<Resource> findResourceInRegistry(Path registryPath, List<RequestedResource> requestedResources)
    • createResources

      protected List<Resource> createResources(List<File> files, String type, String from)
    • createRegistryResourceFromFile

      protected Resource createRegistryResourceFromFile(File file)
      Creates a Resource object from the given registry file.

      If the file is an XML file, it parses the file, detects the resource type from the root element, and creates a registry resource. If the file is not XML, it uses the file extension as the type and creates a non-XML registry resource.

      Parameters:
      file - the registry file to process
      Returns:
      a Resource representing the registry file, or null if the file is invalid or cannot be parsed