Class Repository

java.lang.Object
dd2480.group4.storage.Repository
All Implemented Interfaces:
RepositoryHandler

public class Repository
extends java.lang.Object
implements RepositoryHandler
A class for handling cloning of repositories.
  • Constructor Summary

    Constructors 
    Constructor Description
    Repository()  
  • Method Summary

    Modifier and Type Method Description
    void cloneGit​(java.nio.file.Path path, java.lang.String repo)
    Clones a repository to the given path.
    void cloneGit​(java.nio.file.Path path, java.lang.String repo, java.lang.String hashId)
    Clones a repository to the given path.
    java.nio.file.Path createDirectory()
    Creates a temporary directory and returns the path to it.
    void deleteDirectory​(java.nio.file.Path path)
    Deletes the directory at the given path.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • createDirectory

      public java.nio.file.Path createDirectory() throws java.io.IOException
      Creates a temporary directory and returns the path to it.
      Specified by:
      createDirectory in interface RepositoryHandler
      Returns:
      the path to the directory
      Throws:
      java.io.IOException - if it fails to create the repository
    • cloneGit

      public void cloneGit​(java.nio.file.Path path, java.lang.String repo) throws java.io.IOException, java.lang.InterruptedException
      Clones a repository to the given path.
      Specified by:
      cloneGit in interface RepositoryHandler
      Parameters:
      path - the location where the repositories is cloned to.
      repo - the http-address to the repo to be cloned.
      Throws:
      java.io.IOException - if it fails to write to the location.
      java.lang.InterruptedException - if it fails to sleep.
    • cloneGit

      public void cloneGit​(java.nio.file.Path path, java.lang.String repo, java.lang.String hashId) throws java.io.IOException, java.lang.InterruptedException
      Clones a repository to the given path.
      Specified by:
      cloneGit in interface RepositoryHandler
      Parameters:
      path - the location where the repositories is cloned to.
      repo - the http-address to the repo to be cloned.
      hashId - the commit hash to checkout
      Throws:
      java.io.IOException - if it fails to write to the location.
      java.lang.InterruptedException - if it fails to sleep.
    • deleteDirectory

      public void deleteDirectory​(java.nio.file.Path path) throws java.io.IOException
      Deletes the directory at the given path.
      Specified by:
      deleteDirectory in interface RepositoryHandler
      Parameters:
      path - the path to the directory which is to be deleted.
      Throws:
      java.io.IOException - if if is not allowed to delete teh directory.