Class AbstractResourceFinder
java.lang.Object
org.eclipse.lemminx.customservice.synapse.resourceFinder.AbstractResourceFinder
- Direct Known Subclasses:
NewProjectResourceFinder,OldProjectResourceFinder
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ResourceCreates a Resource object from the given registry file.createResources(List<File> files, String type, String from) protected voidfindAllLocalEntryResources(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.protected voidfindAllRegistryResources(Path registryPath, Map<String, ResourceResponse> allResources) Scans the given registry directory and populates the provided map with all registry resources found.abstract Map<String,ResourceResponse> findAllResources(String projectPath) Finds and returns all resources for the given project path, grouped by resource type.findResourceInArtifacts(Path artifactsPath, List<RequestedResource> types) findResourceInLocalEntry(Path localEntryPath, List<RequestedResource> types) findResourceInRegistry(Path registryPath, List<RequestedResource> requestedResources) protected abstract ResourceResponsefindResources(String projectPath, List<RequestedResource> type) protected abstract StringgetArtifactFolder(String type) getAvailableResources(String uri, org.eclipse.lsp4j.jsonrpc.messages.Either<String, List<RequestedResource>> resourceTypes) loadDependentResources(String projectPath) Loads dependent resources for the given project path.protected voidmergeResourceResponses(ResourceResponse response1, ResourceResponse response2) Merges the resources and registry resources from twoResourceResponseobjects.
-
Field Details
-
ARTIFACTS
- See Also:
-
REGISTRY
- See Also:
-
LOCAL_ENTRY
- See Also:
-
resourceFromRegistryOnly
-
dependentResourcesMap
-
-
Constructor Details
-
AbstractResourceFinder
public AbstractResourceFinder()
-
-
Method Details
-
loadDependentResources
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
-
mergeResourceResponses
Merges the resources and registry resources from twoResourceResponseobjects.If both responses are non-null, their resource lists and registry resource lists are combined to
response1. Ifresponse1is null, a newResourceResponseis created and populated with the resources fromresponse2.- Parameters:
response1- the targetResourceResponseto merge into (may be null)response2- the sourceResourceResponseto 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 scanallResources- the map to populate with found resources, keyed by resource type
-
findResources
-
findAllResources
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
-
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 directoryallResources- the map to populate with found resources, keyed by resource type
-
getArtifactFolder
-
findResourceInRegistry
protected List<Resource> findResourceInRegistry(Path registryPath, List<RequestedResource> requestedResources) -
createResources
-
createRegistryResourceFromFile
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
-