Last Update: 4/22/2019
Written by Samuel Labrador
Intended To Be Used For BitSecure Lab
Currently under development
- Java 1.8
- JRE 1.8
- Apache Maven
- Curl (For testing)
This project was built on top of another project. It can be found here: https://github.com/spring-guides/gs-rest-service
This should be ran on a Linux machine. Although it can be used on a Windows machine, I have not written the script to build and start the service on a Windows machine.
The purpose of this project is to create a service that takes in a file via a GET request and returns a json response after processing the file. This services utilizes the Spring Framework for handling requests and returning reponses.
The intention is that the front end Visual Studio plugin (https://github.com/SamuelLabrador/SimTree.git) sends a file to this service (via a GET request). Once this service receives the file, it passes the file's contents to the SimilarityTree algorithm. After the algorithm analyzes the file and produces the changes, the restful service returns a json response that contains the produced changes.
- Navigate to the folder complete.
- Run the script start_service
- The Maven script should handle all the dependencies and building
- In root folder, run a file named test_upload.sh
- test_upload.sh takes the file, test.txt (in the same directory), and sends it to the RESTful service.
- The response should be in a json format. It should contain two changes along with the content of the file. This shows that the service received the file correctly and was able to read its contents. Feel free to modify the contents of test.txt to change the response.
- The service should run on http://localhost:8080/file when using the start script. In production, the service should be modified to run on a different address and port.
-
To use the service, send a GET request WITH the attached file to: http://localhost:8080/file (or whatever address and port the service is listening on)
- Example using curl: curl -F 'file=@path_to_file' http://localhost:8080/file
-
The service should return a response with 2 pre-defined changes and a change with the content of the file.
-
The JSON response consists of an array of Change objects.
-
The Change object is specified in in the file: \complete\src\main\java\hello\Change.java
-
The Change object consists of two private members:
- target -- What string should be found in the editor.
- replacement -- What string to replace the target with in the editor.
-
The Spring framework is modeled after MVC (Model View Controller).
-
When a request is sent to http://localhost:8080/file, the function change, in the file \complete\src\main\java\hello\Change.java, processes the request.
-
The change function:
- Deserializes the file from the request
- Returns the response, specified in JSON response format (above).
-
Integrate the similarity tree algorithm into the service. Possibly pass the file content to another class, dedicated to processing the content.
-
Clean up the project structure... There are still some files from the original project that was used as a buildupon (ie Greeting.java, GreetingController.java, etc).