Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

339 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SIM TREE RESTFUL API SERVICE

Last Update: 4/22/2019
Written by Samuel Labrador
Intended To Be Used For BitSecure Lab
Currently under development

Dependencies

  • Java 1.8
  • JRE 1.8
  • Apache Maven
  • Curl (For testing)

Preface

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.

Intro

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.

How It Works

Starting the service

  1. Navigate to the folder complete.
  2. Run the script start_service
  3. The Maven script should handle all the dependencies and building

Testing the service

  1. In root folder, run a file named test_upload.sh
  2. test_upload.sh takes the file, test.txt (in the same directory), and sends it to the RESTful service.
  3. 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.

Using the service

  • 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.
  1. 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)

    1. Example using curl: curl -F 'file=@path_to_file' http://localhost:8080/file
  2. The service should return a response with 2 pre-defined changes and a change with the content of the file.

Technical Details

JSON Response Format

  • 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.

Request Processing Details

  • 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).

TODO:

  • 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).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages