-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs(openapi): Update spec * fix(services): Make volume fild nullable Since that endpoint can also be used to list directories, it's possible for the volume field to be null * feat: Add new service to get file metadata * test: Add tests to the service to get metadata by UUID * chore(cli): Add new service to the CLI client * fix: Add missing extension and size fields to File object
- Loading branch information
1 parent
b8fb2c3
commit 3785327
Showing
10 changed files
with
211 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package gateway.soap.response; | ||
|
||
public class ResFileGet extends ResStatus | ||
{ | ||
public File file; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.