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 { ...@@ -22,6 +22,7 @@ public class FTPResource {
@GET @GET
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Response listFTPServers() { public Response listFTPServers() {
System.out.println("listFTPServers()");
List<FTPServerConfig> servers = FTPServerRepository.getInstance().getAllServers(); List<FTPServerConfig> servers = FTPServerRepository.getInstance().getAllServers();
return Response.ok(servers).build(); return Response.ok(servers).build();
} }
...@@ -31,6 +32,7 @@ public class FTPResource { ...@@ -31,6 +32,7 @@ public class FTPResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Response addFTPServer(FTPServerConfig config, @Context UriInfo uriInfo) { public Response addFTPServer(FTPServerConfig config, @Context UriInfo uriInfo) {
System.out.println("addFTPServer()");
boolean created = FTPServerRepository.getInstance().addServer(config); boolean created = FTPServerRepository.getInstance().addServer(config);
if (!created) { if (!created) {
return Response.status(Response.Status.CONFLICT) return Response.status(Response.Status.CONFLICT)
...@@ -51,6 +53,7 @@ public class FTPResource { ...@@ -51,6 +53,7 @@ public class FTPResource {
@PathParam("path") String path, @PathParam("path") String path,
@HeaderParam("X-FTP-User") String ftpUser, @HeaderParam("X-FTP-User") String ftpUser,
@HeaderParam("X-FTP-Pass") String ftpPass) { @HeaderParam("X-FTP-Pass") String ftpPass) {
System.out.println("getFTPContent()");
FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias); FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias);
if (config == null) { if (config == null) {
return Response.status(Response.Status.NOT_FOUND) return Response.status(Response.Status.NOT_FOUND)
...@@ -80,6 +83,7 @@ public class FTPResource { ...@@ -80,6 +83,7 @@ public class FTPResource {
@DELETE @DELETE
@Path("/{alias}") @Path("/{alias}")
public Response removeFTPServer(@PathParam("alias") String alias) { public Response removeFTPServer(@PathParam("alias") String alias) {
System.out.println("removeFTPServer()");
boolean removed = FTPServerRepository.getInstance().removeServer(alias); boolean removed = FTPServerRepository.getInstance().removeServer(alias);
return removed ? Response.noContent().build() : Response.status(Response.Status.NOT_FOUND).build(); return removed ? Response.noContent().build() : Response.status(Response.Status.NOT_FOUND).build();
} }
...@@ -88,12 +92,13 @@ public class FTPResource { ...@@ -88,12 +92,13 @@ public class FTPResource {
@Path("/{alias}") @Path("/{alias}")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public Response updateFTPServer(@PathParam("alias") String alias, FTPServerConfig newConfig) { public Response updateFTPServer(@PathParam("alias") String alias, FTPServerConfig newConfig) {
System.out.println("updateFTPServer()");
boolean updated = FTPServerRepository.getInstance().updateServer(alias, newConfig); boolean updated = FTPServerRepository.getInstance().updateServer(alias, newConfig);
return updated ? Response.ok(newConfig).build() : Response.status(Response.Status.NOT_FOUND).build(); return updated ? Response.ok(newConfig).build() : Response.status(Response.Status.NOT_FOUND).build();
} }
@GET @GET
@Path("/{alias}/{path: .+}/download") @Path("/{alias}/{path: .+}")
@Produces(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response downloadFile( public Response downloadFile(
@PathParam("alias") String alias, @PathParam("alias") String alias,
...@@ -101,6 +106,7 @@ public class FTPResource { ...@@ -101,6 +106,7 @@ public class FTPResource {
@HeaderParam("X-FTP-User") String user, @HeaderParam("X-FTP-User") String user,
@HeaderParam("X-FTP-Pass") String pass) { @HeaderParam("X-FTP-Pass") String pass) {
System.out.println("downloadFile()");
FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias); FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias);
if (config == null) { if (config == null) {
return Response.status(Response.Status.NOT_FOUND) return Response.status(Response.Status.NOT_FOUND)
...@@ -175,7 +181,7 @@ public class FTPResource { ...@@ -175,7 +181,7 @@ public class FTPResource {
} }
@PUT @PUT
@Path("/{alias}/{path: .+}/upload") @Path("/{alias}/{path: .+}")
@Consumes(MediaType.APPLICATION_OCTET_STREAM) @Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response uploadFile( public Response uploadFile(
@PathParam("alias") String alias, @PathParam("alias") String alias,
...@@ -184,6 +190,7 @@ public class FTPResource { ...@@ -184,6 +190,7 @@ public class FTPResource {
@HeaderParam("X-FTP-Pass") String pass, @HeaderParam("X-FTP-Pass") String pass,
InputStream fileStream) { InputStream fileStream) {
System.out.println("uploadFile()");
FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias); FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias);
FTPClient ftp = new FTPClient(); FTPClient ftp = new FTPClient();
try { try {
...@@ -206,13 +213,14 @@ public class FTPResource { ...@@ -206,13 +213,14 @@ public class FTPResource {
} }
@POST @POST
@Path("/{alias}/{path: .+}/mkdir") @Path("/{alias}/{path: .+}")
public Response createDirectory( public Response createDirectory(
@PathParam("alias") String alias, @PathParam("alias") String alias,
@PathParam("path") String path, @PathParam("path") String path,
@HeaderParam("X-FTP-User") String user, @HeaderParam("X-FTP-User") String user,
@HeaderParam("X-FTP-Pass") String pass) throws SocketException, IOException { @HeaderParam("X-FTP-Pass") String pass) throws SocketException, IOException {
System.out.println("createFirectory()");
FTPClient ftp = new FTPClient(); FTPClient ftp = new FTPClient();
try { try {
FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias); FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias);
...@@ -233,13 +241,14 @@ public class FTPResource { ...@@ -233,13 +241,14 @@ public class FTPResource {
} }
@DELETE @DELETE
@Path("/{alias}/{path: .+}/rmdir") @Path("/{alias}/{path: .+}")
public Response deleteDirectory( public Response deleteDirectory(
@PathParam("alias") String alias, @PathParam("alias") String alias,
@PathParam("path") String path, @PathParam("path") String path,
@HeaderParam("X-FTP-User") String user, @HeaderParam("X-FTP-User") String user,
@HeaderParam("X-FTP-Pass") String pass) throws SocketException, IOException { @HeaderParam("X-FTP-Pass") String pass) throws SocketException, IOException {
System.out.println("deleteDirectory()");
FTPClient ftp = new FTPClient(); FTPClient ftp = new FTPClient();
try { try {
FTPServerConfig config = FTPServerRepository.getInstance().getServer(alias); 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