Skip to content

Clotho Internals : REST Flowchart

David Tran edited this page May 24, 2017 · 2 revisions

When using the REST API...

Flowchart

RestApi.java

src/main/java/org/clothocad/webserver/jetty/RestApi.java

  • Handles receives all requests and parses the HTML path (example.com**/path/is/here/**)
  • Based on the path, Clotho will respond accordingly
    • Most CRUD goes to Persistor.java
    • Pagination requests go to JongoConnection.java directly
    • CreateUser goes to Router.java, which performs more parsing/security checks and then passes it along to ServerSideAPI.java, which will eventually access Persistor or JongoConnection if needed.
      • Note that Router and ServerSideAPI were originally created for use as the WebSocket API (discontinued) and ClothoRealm (also stripped/removed, to be replaced). Because of this, I would recommend moving away from using those two in the future, and would also recommend eliminating their need completely unless we decide to use a WebSocket-like API again.

Persistor.java

src/main/java/org/clothocad/core/persistence/Persistor.java

  • Clotho-facing door to the database.
    • Checks user permissions before allowing access to CRUD (Security currently disabled/planning to be reworked
  • If you need to interact with the database, I would recommend going through here instead of going directly through JongoConnection.

Router.java

src/main/java/org/clothocad/core/communication/Router.java

  • Receives Message objects from ClientConnections (websocket or rest connection)
  • Checks current user and permissions (broken/to be replaced) and then passes the message along to the appropriate method of ServerSideAPI.

ServerSideAPI.java

src/main/java/org/clothocad/core/communication/ServerSideAPI.java

  • Similar to REST API in that it checks security permissions and then passes the message off to Persistor if needed. They fulfill the same role

JongoConnection.java

src/main/java/org/clothocad/core/persistence/jongo/JongoConnection.java

  • Receives CRUD operations from Persistor.java
  • Direct access to the database, opens connection to MongoDB as specified by default parameters in ConfigOptions.java or by parameters specified by .clothoconfig in the user's home directory
  • All instances of ClothoConnection in the Java classes are bound to JongoConnection, which implements ClothoConnection
Clone this wiki locally