Package dd2480.group4.storage
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.
-
Constructor Details
-
Repository
public Repository()
-
-
Method Details
-
createDirectory
public java.nio.file.Path createDirectory() throws java.io.IOExceptionCreates a temporary directory and returns the path to it.- Specified by:
createDirectory
in interfaceRepositoryHandler
- 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.InterruptedExceptionClones a repository to the given path.- Specified by:
cloneGit
in interfaceRepositoryHandler
- 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.InterruptedExceptionClones a repository to the given path.- Specified by:
cloneGit
in interfaceRepositoryHandler
- 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.IOExceptionDeletes the directory at the given path.- Specified by:
deleteDirectory
in interfaceRepositoryHandler
- 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.
-