Class IRExtractionService

java.lang.Object
edu.university.ecs.lab.intermediate.create.services.IRExtractionService

public class IRExtractionService extends Object
Top-level service for extracting intermediate representation from remote repositories. Methods are allowed to exit the program with an error code if an error occurs.
  • Field Details

    • gitService

      private final GitService gitService
      Service to handle cloning from git
    • config

      private final Config config
      Configuration object
    • commitID

      private final String commitID
      CommitID of IR Extraction
  • Constructor Details

    • IRExtractionService

      public IRExtractionService(String configPath, Optional<String> commitID)
      This constructor initializes a new IRExtractionService and instantiates a GitService object for repository manipulation
      Parameters:
      configPath - path to configuration file
      commitID - optional commitID for extraction, if empty resolves to HEAD
      See Also:
  • Method Details

    • generateIR

      public void generateIR(String fileName)
      Intermediate extraction runner, generates IR from remote repository and writes to file.
      Parameters:
      fileName - name of output file for IR extraction
    • cloneAndScanServices

      public Set<Microservice> cloneAndScanServices()
      Clone remote repositories and scan through each local repo and extract endpoints/calls
      Returns:
      a map of services and their endpoints
    • findRootDirectories

      private List<String> findRootDirectories(String directory)
      Recursively search for directories containing a microservice (pom.xml file)
      Parameters:
      directory - the directory to start the search from
      Returns:
      a list of directory paths containing pom.xml
    • writeToFile

      private void writeToFile(Set<Microservice> microservices, String fileName)
      Write each service and endpoints to intermediate representation
      Parameters:
      microservices - a list of microservices extracted from repository
      fileName - the name of the output file for IR
    • recursivelyScanFiles

      public Microservice recursivelyScanFiles(String rootMicroservicePath)
      Recursively scan the files in the given repository path and extract the endpoints and dependencies for a single microservice.
      Returns:
      model of a single service containing the extracted endpoints and dependencies
    • scanDirectory

      public void scanDirectory(File directory, Microservice microservice)
      Recursively scan the given directory for files and extract the endpoints and dependencies.
      Parameters:
      directory - the directory to scan