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

docs: SOAP OpenAPI specification #41

Merged
merged 8 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
12 changes: 6 additions & 6 deletions CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This document describes how to use the service as a CLI tool.

## Environment variables

| Variable | Description | Example |
|--------------------------|-----------------------------|--------------|
| `AUTHENTICATION_BASEURL` | Authentication service host | `172.18.0.1` |
| `METADATA_BASEURL` | Metadata service host | `172.18.0.1` |
| `WORKER_HOST` | Worker service host | `172.18.0.1` |
| `WORKER_PORT` | Worker service RMI port | `1099` |
| Variable | Description | Example |
|--------------------------|-----------------------------|-------------------------|
| `AUTHENTICATION_BASEURL` | Authentication service host | `http://127.0.0.1:8081` |
| `METADATA_BASEURL` | Metadata service host | `http://127.0.0.1:8082` |
| `WORKER_HOST` | Worker service host | `127.0.0.1` |
| `WORKER_PORT` | Worker service RMI port | `1099` |
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ Microservice to expose main CapyFile services.

## Documentation

| Document | URL |
|-------------------------|------------------------------------------------------------------------------------|
| CLI documentation | [CLI.md](CLI.md) |
| CICD | [CICD.md](https://github.com/hawks-atlanta/docs/blob/main/CICD.md) |
| CONTRIBUTING | [CONTRIBUTING.md](https://github.com/hawks-atlanta/docs/blob/main/CONTRIBUTING.md) |
| SOAP service definition | [Service.java](app/src/main/java/gateway/soap/Service.java) |
| Document | URL |
|-----------------------------|------------------------------------------------------------------------------------|
| CLI documentation | [CLI.md](CLI.md) |
| CICD | [CICD.md](https://github.com/hawks-atlanta/docs/blob/main/CICD.md) |
| CONTRIBUTING | [CONTRIBUTING.md](https://github.com/hawks-atlanta/docs/blob/main/CONTRIBUTING.md) |
| SOAP Java interfaces | [Service.java](app/src/main/java/gateway/soap/Service.java) |
| SOAP service API definition | [Specification](docs/spec.openapi.yml) |

## Development

Expand Down
33 changes: 2 additions & 31 deletions app/src/main/java/gateway/App.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package gateway;

import capyfile.rmi.interfaces.*;
import gateway.config.Config;
import gateway.soap.*;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import gateway.soap.ServiceImp;
import javax.xml.ws.Endpoint;

public class App
Expand All @@ -16,33 +11,9 @@ public static void main (String[] args)
// init config from env vars
Config.initializeFromEnv ();

// consume RMI
try {
// get service

System.out.println ("Gateway: RMI demo");
Registry registry =
LocateRegistry.getRegistry (Config.getWorkerHost (), Config.getWorkerPort ());
IWorkerService server = (IWorkerService)registry.lookup ("WorkerService");

// TODO: Replace me
// example

File queryUpload = new File ("----", null);
server.uploadFile (queryUpload);

FileDownload queryDownload = new FileDownload ("----");
File resultFile = server.downloadFile (queryDownload);

System.out.println ("Successfully communicated with worker RMI");

} catch (Exception e) {
System.err.println (e);
}

// serve SOAP
System.out.println ("Gateway: Starting SOAP");

// serve SOAP
Endpoint.publish ("http://0.0.0.0:8080/service", new ServiceImp ());
}
}
32 changes: 19 additions & 13 deletions app/src/main/java/gateway/soap/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,39 @@
public interface Service {
// auth

@WebMethod SessionRes login (Credentials credentials);
@WebMethod ResSession auth_login (Credentials credentials);

@WebMethod SessionRes register(Credentials credentials);
@WebMethod ResSession auth_refresh (Authorization auth);

@WebMethod StatusRes updatePassword (UpdatePasswordReq parameters);
// account

@WebMethod ResSession account_register (Credentials credentials);

@WebMethod ResStatus account_password (ReqAccPassword parameters);

// file system

@WebMethod StatusRes createFile (CreateFileReq args);
@WebMethod ResFileList file_list (ReqFileList args);

@WebMethod ResFileNew file_upload (ReqFileUpload args);

@WebMethod StatusRes createDirectory (CreateDirectoryReq args);
@WebMethod ResFileNew file_new_dir (ReqFileNewDir args);

@WebMethod StatusRes deleteFile (DeleteFileReq args);
@WebMethod ResFileCheck file_check (ReqFile args);

@WebMethod ListFileRes listFiles (ListFileReq args);
@WebMethod ResStatus file_delete (ReqFileDelete args);

@WebMethod DownloadFileRes downloadFile (DownloadFileReq args);
@WebMethod ResFileDownload file_download (ReqFile args);

@WebMethod StatusRes moveFile (MoveFileReq args);
@WebMethod ResStatus file_move (ReqFileMove args);

// sharing

@WebMethod StatusRes shareWith (ShareWithReq args);
@WebMethod ResStatus share_file (ReqShareFile args);

@WebMethod StatusRes unShareWith (UnShareWithReq args);
@WebMethod ResStatus share_remove (ReqShareRemove args);

@WebMethod SharedWithWhoRes sharedWithWho (SharedWithWhoReq args);
@WebMethod ResShareList share_list (Authorization auth);

@WebMethod ListSharedWithMeRes listSharedWithMe (Authorization auth);
@WebMethod ResShareListWithWho share_list_with_who (ReqFile args);
}
62 changes: 30 additions & 32 deletions app/src/main/java/gateway/soap/ServiceImp.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
{
// auth

@WebMethod public SessionRes login (Credentials credentials)
@WebMethod public ResSession auth_login (Credentials credentials)
{
// Create a new SessionRes object to hold the response data
SessionRes res = new SessionRes ();
// Create a new ResSession object to hold the response data
ResSession res = new ResSession ();

// Define the URL for the authentication request
String url = Config.getAuthBaseUrl () + "/login";
Expand Down Expand Up @@ -60,13 +60,13 @@
// If the status code is 201, indicating login succeed, initialize an Authorization
// object in the response and extract the JWT token.
res.auth = new Authorization ();
res.success = true;
res.error = false;
res.auth.token = jsonObject.getString ("jwt");
} else {
// If the status code is different from 201, indicating an error response, extract
// success status and message from the JSON object.
res.success = jsonObject.getBoolean ("succeed");
res.message = jsonObject.getString ("msg");
res.error = true;
res.msg = jsonObject.getString ("msg");
}

} catch (IOException | InterruptedException e) {
Expand All @@ -78,10 +78,12 @@
return res;
}

@WebMethod public ResSession auth_refresh (Authorization auth) { return null; }

// user register in auth service, returns an access token
@WebMethod public SessionRes register(Credentials credentials)
@WebMethod public ResSession account_register (Credentials credentials)
{
SessionRes res = new SessionRes ();
ResSession res = new ResSession ();

String url = Config.getAuthBaseUrl () + "/register";

Expand Down Expand Up @@ -110,11 +112,11 @@

if (statusCode == 201) {
res.auth = new Authorization ();
res.success = true;
res.error = false;
res.auth.token = jsonObject.getString ("jwt");
} else {
res.success = jsonObject.getBoolean ("succeed");
res.message = jsonObject.getString ("msg");
res.error = true;
res.msg = jsonObject.getString ("msg");
}

} catch (IOException | InterruptedException e) {
Expand All @@ -124,47 +126,43 @@
return res;
}

@WebMethod public StatusRes updatePassword (UpdatePasswordReq parameters)
{
return new StatusRes ();
}
@WebMethod public ResStatus account_password (ReqAccPassword parameters) { return null; }

// file system

@WebMethod public StatusRes createFile (CreateFileReq args)
@WebMethod public ResFileNew file_upload (ReqFileUpload args)
{
// TODO: Replace me
System.out.println ("---");
System.out.println (args);
System.out.println (args.token);
System.out.println (args.fileName);
System.out.println ("---");
StatusRes s = new StatusRes ();
s.success = true;
s.message = "File created successfully";
return s;
ResStatus s = new ResStatus ();
s.error = false;
s.msg = "File created successfully";
return (ResFileNew)s;
}

@WebMethod public StatusRes createDirectory (CreateDirectoryReq args)
{
return new StatusRes ();
}
@WebMethod public ResFileNew file_new_dir (ReqFileNewDir args) { return null; }

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

@WebMethod public StatusRes deleteFile (DeleteFileReq args) { return new StatusRes (); }
@WebMethod public ResStatus file_delete (ReqFileDelete args) { return null; }

@WebMethod public ListFileRes listFiles (ListFileReq args) { return null; }
@WebMethod public ResFileList file_list (ReqFileList args) { return null; }

@WebMethod public DownloadFileRes downloadFile (DownloadFileReq args) { return null; }
@WebMethod public ResFileDownload file_download (ReqFile args) { return null; }

@WebMethod public StatusRes moveFile (MoveFileReq args) { return new StatusRes (); }
@WebMethod public ResStatus file_move (ReqFileMove args) { return null; }

// sharing

@WebMethod public StatusRes shareWith (ShareWithReq args) { return new StatusRes (); }
@WebMethod public ResStatus share_file (ReqShareFile args) { return null; }

@WebMethod public StatusRes unShareWith (UnShareWithReq args) { return new StatusRes (); }
@WebMethod public ResStatus share_remove (ReqShareRemove args) { return null; }

@WebMethod public SharedWithWhoRes sharedWithWho (SharedWithWhoReq args) { return null; }
@WebMethod public ResShareList share_list (Authorization auth) { return null; }

@WebMethod public ListSharedWithMeRes listSharedWithMe (Authorization auth) { return null; }
@WebMethod public ResShareListWithWho share_list_with_who (ReqFile args) { return null; }
}
6 changes: 0 additions & 6 deletions app/src/main/java/gateway/soap/request/Operation.java

This file was deleted.

7 changes: 7 additions & 0 deletions app/src/main/java/gateway/soap/request/ReqAccPassword.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package gateway.soap.request;

public class ReqAccPassword extends Authorization
{
public String oldpassword;
public String newpassword;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.UUID;

public class DownloadFileReq extends Operation
public class ReqFile extends Authorization
{
public UUID fileUUID;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.UUID;

public class DeleteFileReq extends Operation
public class ReqFileDelete extends Authorization
{
public UUID[] fileUUID; // 1+
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.UUID;

public class ListFileReq extends Operation
public class ReqFileList extends Authorization
{
public UUID location;
}
10 changes: 10 additions & 0 deletions app/src/main/java/gateway/soap/request/ReqFileMove.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gateway.soap.request;

import java.util.UUID;

public class ReqFileMove extends Authorization
{
public UUID fileUUID;
public UUID targetDirectoryUUID; // always a directory
public String newName; // optional
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.UUID;

public class CreateDirectoryReq extends Operation
public class ReqFileNewDir extends Authorization
{
public String directoryName;
public UUID location;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import java.util.UUID;

public class CreateFileReq extends Operation
public class ReqFileUpload extends Authorization
{
public String fileName;
public Byte[] fileContent;
public byte[] fileContent;
public UUID location;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.UUID;

public class MoveFileReq extends Operation
public class ReqRenameFile extends Authorization
{
public UUID nameUUID;
public UUID targetLocationUUID; // always a directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.UUID;

public class ShareWithReq extends Operation
public class ReqShareFile extends Authorization
{
public UUID fileUUID;
public String otherUsername;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.UUID;

public class UnShareWithReq
public class ReqShareRemove
{
public UUID fileUUID;
public String otherUsername;
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/java/gateway/soap/request/SharedWithWhoReq.java

This file was deleted.

8 changes: 0 additions & 8 deletions app/src/main/java/gateway/soap/request/UpdatePasswordReq.java

This file was deleted.

7 changes: 0 additions & 7 deletions app/src/main/java/gateway/soap/response/DownloadFileRes.java

This file was deleted.

6 changes: 6 additions & 0 deletions app/src/main/java/gateway/soap/response/ResFileCheck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package gateway.soap.response;

public class ResFileCheck extends ResStatus
{
public boolean ready;
}
Loading