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