001package co.codewizards.cloudstore.rest.server.service; 002 003import static java.util.Objects.*; 004 005import javax.ws.rs.Consumes; 006import javax.ws.rs.POST; 007import javax.ws.rs.Path; 008import javax.ws.rs.PathParam; 009import javax.ws.rs.Produces; 010import javax.ws.rs.QueryParam; 011import javax.ws.rs.core.MediaType; 012 013import org.slf4j.Logger; 014import org.slf4j.LoggerFactory; 015 016import co.codewizards.cloudstore.core.repo.transport.RepoTransport; 017 018@Path("_move/{repositoryName}") 019@Consumes(MediaType.APPLICATION_XML) 020@Produces(MediaType.APPLICATION_XML) 021public class MoveService extends AbstractServiceWithRepoToRepoAuth 022{ 023 private static final Logger logger = LoggerFactory.getLogger(MoveService.class); 024 025 { 026 logger.debug("<init>: created new instance"); 027 } 028 029 @POST 030 public void move(@QueryParam("to") final String toPath) 031 { 032 move("", toPath); 033 } 034 035 @POST 036 @Path("{path:.*}") 037 public void move(@PathParam("path") String path, @QueryParam("to") final String toPath) 038 { 039 requireNonNull(path, "path"); 040 try (final RepoTransport repoTransport = authenticateAndCreateLocalRepoTransport();) { 041 path = repoTransport.unprefixPath(path); 042 repoTransport.move(path, toPath); 043 } 044 } 045}