Search in sources :

Example 1 with MultiRepositoryManager

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();
}
Also used : MultiRepositoryManager(org.eclipse.winery.repository.filebased.MultiRepositoryManager) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 2 with MultiRepositoryManager

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();
}
Also used : MultiRepositoryManager(org.eclipse.winery.repository.filebased.MultiRepositoryManager) MultiRepository(org.eclipse.winery.repository.filebased.MultiRepository) IRepository(org.eclipse.winery.repository.backend.IRepository) RepositoryProperties(org.eclipse.winery.repository.backend.filebased.RepositoryProperties) GitBasedRepository(org.eclipse.winery.repository.backend.filebased.GitBasedRepository) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Aggregations

Path (javax.ws.rs.Path)2 MultiRepositoryManager (org.eclipse.winery.repository.filebased.MultiRepositoryManager)2 Consumes (javax.ws.rs.Consumes)1 DELETE (javax.ws.rs.DELETE)1 POST (javax.ws.rs.POST)1 IRepository (org.eclipse.winery.repository.backend.IRepository)1 GitBasedRepository (org.eclipse.winery.repository.backend.filebased.GitBasedRepository)1 RepositoryProperties (org.eclipse.winery.repository.backend.filebased.RepositoryProperties)1 MultiRepository (org.eclipse.winery.repository.filebased.MultiRepository)1