use of org.eclipse.winery.repository.filebased.MultiRepositoryManager in project winery by eclipse.
the class RepositoryAdminResource method addRepository.
/**
* get Repositories from frontend
*/
@POST
@Path("repositories")
@Consumes(MediaType.APPLICATION_JSON)
public Response addRepository(List<RepositoryProperties> repositoriesList) {
if (repositoriesList == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("Repositories list must be given.").build();
}
MultiRepositoryManager multiRepositoryManager = new MultiRepositoryManager();
multiRepositoryManager.addRepositoryToFile(repositoriesList);
return Response.ok().build();
}
use of org.eclipse.winery.repository.filebased.MultiRepositoryManager in project winery by eclipse.
the class RepositoryAdminResource method deleteRepository.
/**
* Deletes given repository
*
* @param name of repository to delete.
*/
@DELETE
@Path("repositories/{repository}")
public Response deleteRepository(@PathParam("repository") String name) {
String repositoryUrl = "";
if (RepositoryFactory.getRepository() instanceof MultiRepository) {
IRepository gitRepo;
MultiRepositoryManager multiRepositoryManager = new MultiRepositoryManager();
for (RepositoryProperties repo : multiRepositoryManager.getRepositoriesAsList()) {
if (repo.getName().equals(name)) {
repositoryUrl = repo.getUrl();
break;
}
}
for (IRepository repo : ((MultiRepository) RepositoryFactory.getRepository()).getRepositories()) {
gitRepo = repo;
if (gitRepo instanceof GitBasedRepository) {
if (((GitBasedRepository) gitRepo).getRepositoryUrl() != null) {
if (((GitBasedRepository) gitRepo).getRepositoryUrl().equals(repositoryUrl)) {
((GitBasedRepository) gitRepo).forceClear();
((MultiRepository) RepositoryFactory.getRepository()).removeRepository(repositoryUrl);
break;
}
}
}
}
}
return Response.ok().build();
}
Aggregations