Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): v0.0.40 #78

Merged
merged 55 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
838b020
[ci skip] chore(release): 0.0.13
shoriwe Sep 13, 2023
914a1e7
feat: Normalize method responses (#36)
Woynert Sep 13, 2023
97e2fea
[ci skip] chore(release): 0.0.14
shoriwe Sep 13, 2023
636627e
chore: JSON library (#37)
Woynert Sep 13, 2023
d922bf7
[ci skip] chore(release): 0.0.15
shoriwe Sep 13, 2023
9e32329
feat: Config from env vars (#38)
Woynert Sep 15, 2023
1544696
[ci skip] chore(release): 0.0.16
shoriwe Sep 15, 2023
8dc5bbe
feat: adding register implementation and some changes in .gitignore (…
SilviaPabon Sep 17, 2023
afbf948
[ci skip] chore(release): 0.0.17
shoriwe Sep 17, 2023
dd26b8d
Feat login (#40)
andres123dbh Sep 23, 2023
7b202db
[ci skip] chore(release): 0.0.18
shoriwe Sep 23, 2023
8237b21
docs: SOAP OpenAPI specification (#41)
Woynert Sep 23, 2023
6928b81
[ci skip] chore(release): 0.0.19
shoriwe Sep 23, 2023
5a80939
feat: Upload File, Tests, Restructure (#42)
Woynert Sep 28, 2023
1970246
[ci skip] chore(release): 0.0.20
shoriwe Sep 28, 2023
36d1f99
Update login and Add tests (#47)
andres123dbh Oct 1, 2023
a14b096
[ci skip] chore(release): 0.0.21
shoriwe Oct 1, 2023
0d2eaa1
feat: download file (#46)
Woynert Oct 3, 2023
123ce9d
[ci skip] chore(release): 0.0.22
shoriwe Oct 3, 2023
ecd386c
Merge branch 'main' into dev
Woynert Oct 3, 2023
6b4cc06
[ci skip] chore(release): 0.0.23
shoriwe Oct 3, 2023
20f12ba
feat: file check ready (#57)
Woynert Oct 3, 2023
f94c143
[ci skip] chore(release): 0.0.24
shoriwe Oct 3, 2023
a1629b4
chore: Rename soap endpoint (#59)
Woynert Oct 3, 2023
413ec7c
[ci skip] chore(release): 0.0.25
shoriwe Oct 3, 2023
613d108
feat: challenge endpoint (#56)
crijumubu Oct 5, 2023
d4789d0
[ci skip] chore(release): 0.0.26
shoriwe Oct 5, 2023
4eea954
Fix: Delete Unnecesary resFileNew (#63)
andres123dbh Oct 7, 2023
ad23c94
[ci skip] chore(release): 0.0.27
shoriwe Oct 7, 2023
bad63bf
test: Add tests for register method (#60)
SilviaPabon Oct 8, 2023
56b6efb
[ci skip] chore(release): 0.0.28
shoriwe Oct 8, 2023
ff0efa6
Feat: share file feature (#61)
SilviaPabon Oct 8, 2023
0314364
[ci skip] chore(release): 0.0.29
shoriwe Oct 8, 2023
4cc6466
Merge branch 'main' into dev
SilviaPabon Oct 8, 2023
747c13e
[ci skip] chore(release): 0.0.30
shoriwe Oct 8, 2023
f424acc
fix: Move /api/version base path
Woynert Oct 9, 2023
4e50d6f
[ci skip] chore(release): 0.0.31
shoriwe Oct 9, 2023
4309419
feat: File rename (#69)
Woynert Oct 12, 2023
e028383
[ci skip] chore(release): 0.0.32
shoriwe Oct 12, 2023
0aec012
Update password (#68)
andres123dbh Oct 12, 2023
1b48a27
[ci skip] chore(release): 0.0.33
shoriwe Oct 12, 2023
0f0594d
feat: create new directory (#71)
Woynert Oct 12, 2023
968d914
[ci skip] chore(release): 0.0.34
shoriwe Oct 12, 2023
d952b38
Merge branch 'main' into dev
Woynert Oct 12, 2023
6ff4d9c
[ci skip] chore(release): 0.0.35
shoriwe Oct 12, 2023
d90a999
fix: Update field validation (#73)
Woynert Oct 13, 2023
b8fb2c3
[ci skip] chore(release): 0.0.36
shoriwe Oct 13, 2023
3785327
feat: Get file by UUID (#76)
PedroChaparro Oct 15, 2023
bf3448e
[ci skip] chore(release): 0.0.37
shoriwe Oct 15, 2023
53112a2
feat: File move (#77)
SilviaPabon Oct 15, 2023
ae19802
[ci skip] chore(release): 0.0.38
shoriwe Oct 15, 2023
9da5799
feat: List Files (#74)
andres123dbh Oct 15, 2023
215abe4
[ci skip] chore(release): 0.0.39
shoriwe Oct 15, 2023
cb53874
Merge branch 'main' into dev
SilviaPabon Oct 15, 2023
b747b79
[ci skip] chore(release): 0.0.40
shoriwe Oct 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### 0.0.40 (2023-10-15)

### 0.0.39 (2023-10-15)


### Features

* List Files ([#74](https://github.com/hawks-atlanta/gateway-java/issues/74)) ([9da5799](https://github.com/hawks-atlanta/gateway-java/commit/9da57996c01e88f2176674ed0c118666010e0223))

### 0.0.38 (2023-10-15)


### Features

* File move ([#77](https://github.com/hawks-atlanta/gateway-java/issues/77)) ([53112a2](https://github.com/hawks-atlanta/gateway-java/commit/53112a2a6ec759dad65ffc8a76baa6a29e3b62ca))

### 0.0.37 (2023-10-15)


### Features

* Get file by UUID ([#76](https://github.com/hawks-atlanta/gateway-java/issues/76)) ([3785327](https://github.com/hawks-atlanta/gateway-java/commit/3785327b11ef4daceb3840681d95a406350e141d))

### 0.0.36 (2023-10-13)


### Bug Fixes

* Update field validation ([#73](https://github.com/hawks-atlanta/gateway-java/issues/73)) ([d90a999](https://github.com/hawks-atlanta/gateway-java/commit/d90a999378485acf84a8040249ccebb0c436ee42))

### 0.0.35 (2023-10-12)

### 0.0.34 (2023-10-12)
Expand Down
57 changes: 57 additions & 0 deletions app/src/main/java/gateway/controller/CtrlFileGet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package gateway.controller;

import gateway.services.ServiceAuth;
import gateway.services.ServiceMetadata;
import gateway.services.UtilValidator;
import gateway.soap.request.ReqFile;
import gateway.soap.response.File;
import gateway.soap.response.ResFileGet;
import gateway.soap.response.ResStatus;
import java.util.UUID;

public class CtrlFileGet
{
public static ResFileGet file_get (ReqFile args)
{
ResFileGet s = new ResFileGet ();

// validations
ResStatus resValidate = UtilValidator.validate (args);
if (resValidate.error) {
return ResStatus.downCast (ResFileGet.class, resValidate);
}

// Check if user is authenticated
ResStatus resAuth = ServiceAuth.authenticate (args.token);
if (resAuth.error) {
return ResStatus.downCast (ResFileGet.class, resAuth);
}

// Check if user can read the file
UUID userUUID = UUID.fromString (ServiceAuth.tokenGetClaim (args.token, "uuid"));
ResStatus resCanRead = ServiceMetadata.canRead (userUUID, args.fileUUID);
if (resCanRead.error) {
return ResStatus.downCast (ResFileGet.class, resCanRead);
}

// get metadata
ServiceMetadata.ResFileMetadata resM = ServiceMetadata.getFileMetadata (args.fileUUID);
s.code = resM.code;
s.error = resM.error;
s.msg = resM.msg;

if (s.code == 200) {
File file = new File ();
file.uuid = args.fileUUID;
file.name = resM.name;
file.isFile = resM.volume != null;
file.extension = resM.extension;
file.size = resM.size;

s.file = file;
s.msg = "File metadata has been retrieved";
}

return s;
}
}
96 changes: 96 additions & 0 deletions app/src/main/java/gateway/controller/CtrlFileList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package gateway.controller;

import gateway.config.Config;
import gateway.services.ServiceAuth;
import gateway.soap.request.ReqFileList;
import gateway.soap.response.File;
import gateway.soap.response.ResFileList;
import gateway.soap.response.ResStatus;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.UUID;
import org.json.JSONArray;
import org.json.JSONObject;

public class CtrlFileList
{
public static ResFileList file_list (ReqFileList args)
{
// Create a new instance of ResFileList to store the results
ResFileList resFileList = new ResFileList ();
UUID userUUID;
String url;

// User authentication
ResStatus resAuth = ServiceAuth.authenticate (args.token);
if (resAuth.error) {
return ResStatus.downCast (ResFileList.class, resAuth);
}

// Get the user's UUID from the authentication token
userUUID = UUID.fromString (ServiceAuth.tokenGetClaim (args.token, "uuid"));

// Build the URL for the request.
if (args.location == null) {
// If no location is specified, build the URL without a parentUUID parameter
url = Config.getMetadataBaseUrl () + "/files/list/" + userUUID;
} else {
// If a location is specified, include the parentUUID parameter
url = Config.getMetadataBaseUrl () + "/files/list/" + userUUID +
"?parentUUID=" + args.location;
}

try {
// Make an HTTP GET request
HttpResponse<String> response = HttpClient.newHttpClient ().send (
HttpRequest.newBuilder ().uri (URI.create (url)).GET ().build (),
HttpResponse.BodyHandlers.ofString ());

JSONObject responseBody = new JSONObject (response.body ());
resFileList.code = response.statusCode ();

if (resFileList.code == 200) {
// If the response code is 200, process the received files
JSONArray filesArray = responseBody.getJSONArray ("files");
File[] files = new File[filesArray.length ()];

for (int i = 0; i < filesArray.length (); i++) {
// Process each file in the response JSON
JSONObject fileObject = filesArray.getJSONObject (i);

// Create a File object and assign it the file information
File file = new File ();

file.uuid = UUID.fromString (fileObject.getString ("uuid"));
file.name = fileObject.getString ("fileName");
file.extension = fileObject.isNull ("fileExtension")
? null
: fileObject.getString ("fileExtension");
file.isFile = fileObject.getString ("fileType").equals ("archive");
file.size = fileObject.getInt ("fileSize");

files[i] = file;
}

resFileList.files = files;
resFileList.error = false;
resFileList.msg = "Files listed successfully";
} else {
// If the response code is not 200, set error and error message based on the
// response
resFileList.error = true;
resFileList.msg = responseBody.getString ("message");
}
} catch (Exception e) {
// In case of an exception
e.printStackTrace ();
resFileList.code = 500;
resFileList.error = true;
resFileList.msg = "Internal error, try again later";
}

return resFileList;
}
}
79 changes: 79 additions & 0 deletions app/src/main/java/gateway/controller/CtrlFileMove.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package gateway.controller;

import gateway.config.Config;
import gateway.services.ServiceAuth;
import gateway.services.UtilValidator;
import gateway.soap.request.ReqFileMove;
import gateway.soap.response.ResStatus;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
import java.util.UUID;
import org.json.JSONObject;

public class CtrlFileMove
{
public static ResStatus file_move (ReqFileMove args)
{
ResStatus statusRes = new ResStatus ();

// validation all fields
ResStatus resValidate = UtilValidator.validate (args);
if (resValidate.error) {
return ResStatus.downCast (ResStatus.class, resValidate);
}

// validation auth
ResStatus resAuth = ServiceAuth.authenticate (args.token);
if (resAuth.error) {
return ResStatus.downCast (ResStatus.class, resAuth);
}

// obtain uuid from user
UUID userUUID = UUID.fromString (ServiceAuth.tokenGetClaim (args.token, "uuid"));

// request to move file
JSONObject requestBody = new JSONObject ();
if (args.targetDirectoryUUID != null) {
requestBody.put ("parentUUID", args.targetDirectoryUUID);
} else {
// move it to root
requestBody.put ("parentUUID", JSONObject.NULL);
}

String url = Config.getMetadataBaseUrl () + "/files/move/" + userUUID + "/" + args.fileUUID;

try {

HttpClient client = HttpClient.newHttpClient ();
HttpRequest request = HttpRequest.newBuilder ()
.uri (URI.create (url))
.PUT (BodyPublishers.ofString (requestBody.toString ()))
.header ("Content-Type", "application/json")
.build ();

// Response
HttpResponse<String> response =
client.send (request, HttpResponse.BodyHandlers.ofString ());
statusRes.code = response.statusCode ();

if (statusRes.code == 204) {
statusRes.error = false;
statusRes.msg = "The file have been moved";
} else {
JSONObject responseBody = new JSONObject (response.body ());
statusRes.error = true;
statusRes.msg = responseBody.getString ("message");
}
} catch (Exception e) {
e.printStackTrace ();
statusRes.code = 500;
statusRes.error = true;
statusRes.msg = "Internal error, try again later";
}

return statusRes;
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/gateway/controller/CtrlFileUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static ResFileNew file_upload (ReqFileUpload args)
if (args.fileContent.length == 0) {
s.code = 400;
s.error = true;
s.msg = "{\"fileContent: must not be empty\"}";
s.msg = "\"fileContent must not be empty\"";
return s;
} else if (args.fileContent.length > Config.MAX_FILE_SIZE) {
s.code = 413; // payload too large
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/gateway/services/ServiceMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public static class ResFileMetadata extends ResStatus
{
public String name;
public String extension;
public int volume;
public long size;
public Integer volume;
public int size;
public boolean isShared;
}

Expand All @@ -129,8 +129,8 @@ public static ResFileMetadata getFileMetadata (UUID fileUUID)
s.error = false;
s.name = resBody.getString ("name");
s.extension = resBody.isNull ("extension") ? null : resBody.getString ("extension");
s.volume = resBody.getInt ("volume");
s.size = resBody.getLong ("size");
s.volume = resBody.isNull ("volume") ? null : resBody.getInt ("volume");
s.size = resBody.getInt ("size");
s.isShared =
resBody.getBoolean ("is_shared"); // TODO make a test for true and false
} else {
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/gateway/services/UtilValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ public static <T> ResStatus validate (T obj)
Validation.buildDefaultValidatorFactory ().getValidator ().validate (obj);

if (val.size () > 0) {
s.msg += "{";
for (ConstraintViolation<T> violation : val) {
s.msg += String.format (
"\"%s: %s\",", violation.getPropertyPath ().toString (),
"\"%s %s\",", violation.getPropertyPath ().toString (),
violation.getMessage ());
}
s.msg = s.msg.substring (0, s.msg.length () - 1);
s.msg += "}";

s.msg = s.msg.substring (0, s.msg.length () - 1);
s.code = 400;
s.error = true;
return s;
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/gateway/soap/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public interface Service {
@WebMethod ResStatus account_password (ReqAccPassword parameters);

// file system
@WebMethod ResFileGet file_get (ReqFile args);

@WebMethod ResFileList file_list (ReqFileList args);

Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/gateway/soap/ServiceImp.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,29 @@
return CtrlFileNewDir.file_new_dir (args);
}

@Override public ResFileGet file_get (ReqFile args) { return CtrlFileGet.file_get (args); }

@WebMethod public ResFileCheck file_check (ReqFile args)
{
return CtrlFileCheck.file_check (args);
}

@WebMethod public ResStatus file_delete (ReqFileDelete args) { return null; }

@WebMethod public ResFileList file_list (ReqFileList args) { return null; }
@WebMethod public ResFileList file_list (ReqFileList args)
{
return CtrlFileList.file_list (args);
}

@WebMethod public ResFileDownload file_download (ReqFile args)
{
return CtrlFileDownload.file_download (args);
}

@WebMethod public ResStatus file_move (ReqFileMove args) { return null; }
@WebMethod public ResStatus file_move (ReqFileMove args)
{
return CtrlFileMove.file_move (args);
}

@WebMethod public ResStatus file_rename (ReqFileRename args)
{
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/gateway/soap/request/Credentials.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package gateway.soap.request;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotEmpty;

public class Credentials
{
@NotNull public String username;
@NotNull public String password;
@NotEmpty public String username;
@NotEmpty public String password;

public Credentials () {}
public Credentials (String username, String password)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/gateway/soap/request/ReqAccPassword.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package gateway.soap.request;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

public class ReqAccPassword extends Authorization
{
@NotNull public String oldpassword;
@NotNull public String newpassword;
@NotEmpty public String newpassword;
}
3 changes: 2 additions & 1 deletion app/src/main/java/gateway/soap/request/ReqFileDelete.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package gateway.soap.request;

import jakarta.validation.constraints.NotNull;
import java.util.UUID;

public class ReqFileDelete extends Authorization
{
public UUID[] fileUUID; // 1+
@NotNull public UUID[] fileUUID; // 1+
}
Loading