001package co.codewizards.cloudstore.rest.server.service; 002 003import static co.codewizards.cloudstore.core.util.Util.assertNotNull; 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") String toPath) 031 { 032 move("", toPath); 033 } 034 035 @POST 036 @Path("{path:.*}") 037 public void move(@PathParam("path") String path, @QueryParam("to") String toPath) 038 { 039 assertNotNull("path", path); 040 RepoTransport repoTransport = authenticateAndCreateLocalRepoTransport(); 041 try { 042 path = repoTransport.unprefixPath(path); 043 repoTransport.move(path, toPath); 044 } finally { 045 repoTransport.close(); 046 } 047 } 048}