001package co.codewizards.cloudstore.rest.server.service; 002 003import static co.codewizards.cloudstore.core.util.Util.*; 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.dto.DateTime; 017import co.codewizards.cloudstore.core.repo.transport.RepoTransport; 018 019@Path("_makeDirectory/{repositoryName}") 020@Consumes(MediaType.APPLICATION_XML) 021@Produces(MediaType.APPLICATION_XML) 022public class MakeDirectoryService extends AbstractServiceWithRepoToRepoAuth 023{ 024 private static final Logger logger = LoggerFactory.getLogger(MakeDirectoryService.class); 025 026 { 027 logger.debug("<init>: created new instance"); 028 } 029 030 private @QueryParam("lastModified") DateTime lastModified; 031 032 @POST 033 public void makeDirectory() 034 { 035 makeDirectory(""); 036 } 037 038 @POST 039 @Path("{path:.*}") 040 public void makeDirectory(@PathParam("path") String path) 041 { 042 assertNotNull("path", path); 043 RepoTransport repoTransport = authenticateAndCreateLocalRepoTransport(); 044 try { 045 path = repoTransport.unprefixPath(path); 046 repoTransport.makeDirectory(path, lastModified == null ? null : lastModified.toDate()); 047 } finally { 048 repoTransport.close(); 049 } 050 } 051}