Skip to content
Snippets Groups Projects
Commit 35404a82 authored by Fabio Vandewaeter's avatar Fabio Vandewaeter
Browse files

save

parent 913b9285
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ public class FTPResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response listFTPServers() {
System.out.println("listFTPServers()");
List<FTPServerConfig> servers = FTPServerRepository.getInstance().getAllServers();
return Response.ok(servers).build();
}
......@@ -31,6 +32,7 @@ public class FTPResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response addFTPServer(FTPServerConfig config, @Context UriInfo uriInfo) {
System.out.println("addFTPServer()");
boolean created = FTPServerRepository.getInstance().addServer(config);
if (!created) {
return Response.status(Response.Status.CONFLICT)
......@@ -51,6 +53,7 @@ public class FTPResource {
@PathParam("path") String path,
@HeaderParam("X-FTP-User") String ftpUser,
@HeaderParam("X-FTP-Pass") String ftpPass) {
System.out.println("getFTPContent()");
FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias);
if (config == null) {
return Response.status(Response.Status.NOT_FOUND)
......@@ -80,6 +83,7 @@ public class FTPResource {
@DELETE
@Path("/{alias}")
public Response removeFTPServer(@PathParam("alias") String alias) {
System.out.println("removeFTPServer()");
boolean removed = FTPServerRepository.getInstance().removeServer(alias);
return removed ? Response.noContent().build() : Response.status(Response.Status.NOT_FOUND).build();
}
......@@ -88,12 +92,13 @@ public class FTPResource {
@Path("/{alias}")
@Consumes(MediaType.APPLICATION_JSON)
public Response updateFTPServer(@PathParam("alias") String alias, FTPServerConfig newConfig) {
System.out.println("updateFTPServer()");
boolean updated = FTPServerRepository.getInstance().updateServer(alias, newConfig);
return updated ? Response.ok(newConfig).build() : Response.status(Response.Status.NOT_FOUND).build();
}
@GET
@Path("/{alias}/{path: .+}/download")
@Path("/{alias}/{path: .+}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response downloadFile(
@PathParam("alias") String alias,
......@@ -101,6 +106,7 @@ public class FTPResource {
@HeaderParam("X-FTP-User") String user,
@HeaderParam("X-FTP-Pass") String pass) {
System.out.println("downloadFile()");
FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias);
if (config == null) {
return Response.status(Response.Status.NOT_FOUND)
......@@ -175,7 +181,7 @@ public class FTPResource {
}
@PUT
@Path("/{alias}/{path: .+}/upload")
@Path("/{alias}/{path: .+}")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response uploadFile(
@PathParam("alias") String alias,
......@@ -184,6 +190,7 @@ public class FTPResource {
@HeaderParam("X-FTP-Pass") String pass,
InputStream fileStream) {
System.out.println("uploadFile()");
FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias);
FTPClient ftp = new FTPClient();
try {
......@@ -206,13 +213,14 @@ public class FTPResource {
}
@POST
@Path("/{alias}/{path: .+}/mkdir")
@Path("/{alias}/{path: .+}")
public Response createDirectory(
@PathParam("alias") String alias,
@PathParam("path") String path,
@HeaderParam("X-FTP-User") String user,
@HeaderParam("X-FTP-Pass") String pass) throws SocketException, IOException {
System.out.println("createFirectory()");
FTPClient ftp = new FTPClient();
try {
FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias);
......@@ -233,13 +241,14 @@ public class FTPResource {
}
@DELETE
@Path("/{alias}/{path: .+}/rmdir")
@Path("/{alias}/{path: .+}")
public Response deleteDirectory(
@PathParam("alias") String alias,
@PathParam("path") String path,
@HeaderParam("X-FTP-User") String user,
@HeaderParam("X-FTP-Pass") String pass) throws SocketException, IOException {
System.out.println("deleteDirectory()");
FTPClient ftp = new FTPClient();
try {
FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment