package co.codewizards.cloudstore.rest.server.service; import java.net.URL; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import co.codewizards.cloudstore.core.dto.RepositoryDto; import co.codewizards.cloudstore.core.repo.local.LocalRepoRegistryImpl; import co.codewizards.cloudstore.core.repo.transport.RepoTransport; import co.codewizards.cloudstore.core.repo.transport.RepoTransportFactory; import co.codewizards.cloudstore.core.repo.transport.RepoTransportFactoryRegistry; @Path("_RepositoryDto/{repositoryName}") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) public class RepositoryDtoService { private static final Logger logger = LoggerFactory.getLogger(RepositoryDtoService.class); { logger.debug("<init>: created new instance"); } private @PathParam("repositoryName") String repositoryName; @GET public RepositoryDto getRepositoryDto() { URL localRootURL = LocalRepoRegistryImpl.getInstance().getLocalRootURLForRepositoryNameOrFail(repositoryName); RepoTransportFactoryRegistry repoTransportRegistry = RepoTransportFactoryRegistry.getInstance(); RepoTransportFactory repoTransportFactory = repoTransportRegistry.getRepoTransportFactory(localRootURL); try (final RepoTransport repoTransport = repoTransportFactory.createRepoTransport(localRootURL, null);) { RepositoryDto repositoryDto = repoTransport.getRepositoryDto(); return repositoryDto; } } }