Skip to content

Conversation

@Laukkala
Copy link

@Laukkala Laukkala commented May 16, 2025

Description

First version of NotebookServer

  • Immutable representation of saved notebook files with file management functionality
  • Notebooks persisted on disk (or another implementation of file storage)
  • Basic server functionality via HTTP requests
  • API endpoints for other microservices to connect to
  • Source of truth at any given time should be the files saved to storage

Check NBS_01 page on internal wiki for goals and design documentation on NBS_01

Below is a list of the most important Interfaces and objects of the component
Server & Servlets

  • NotebookServer - Entry point to NBS_01. Defines available Servlets and assigns a path for each. Contains a Storage for file operations. Starts a Jetty server.
  • HTTPServlet - Implementation of jakarta.servlet.http.HttpServlet that reads a HTTPServletRequests' body and passes the request to an Endpoint and finally sends a HTTPServletResponse back to the requester.
  • FilesystemServlet - Implementation of jakarta.servlet.http.HttpServlet that parses the URL path and the body of a received HTTPServletRequest, and passes both to an Endpoint and finally sends a HTTPServletResponse back to the requester.

HTTP communication

  • Request - Interface for a representation of a Request an Endpoint can process. Contains a request path, a Body and a collection of Headers
  • Response - Interface for a representation of a Response that is generated by an Endpoint. Contains a HTTP response code, a Body and a collection of Headers.
  • Body - Interface for a representation of the payload of a Request or a Response. Can turn itself into a string. Can be implemented to represent different kinds of structured data.
  • Header - apache.http.Header

Endpoints

  • EndPoint - Interface for an Endpoint that takes a Request, does an arbitrary action based on the contents of the Request and returns a Response.
  • CreateNotebookEndpoint etc... - Implementations for Endpoints that do different file operations using a Storage.

Repository

  • Directory - An in-memory collection of Notebooks that is capable of turning itself into JSON.
  • Notebook - An in-memory collection of Paragraphs that is capable of turning itself into JSON.
  • Paragraph - An in-memory representation of a paragraph containing a Script that is capable of turning itself into JSON.
  • Script - An in-memory representation of user-supplied text to be run that is capable of turning iteslf into JSON.

Storage

  • Storage - Interface for executing file operations on some file storage. Can create, delete, copy and move files and directories based on Paths.
  • LocalFileSystemStorage - Default implementation of Storage using java.nio.Files.

Checklists

Checklists blank as this is the initial version, may still see major changes

Testing

General

  • I have checked that my test files and functions have meaningful names.
  • I have checked that each test tests only a single behavior.
  • I have done happy tests.
  • I have tested only my own code.
  • I have tested at least all public methods.

Assertions

  • I have checked that my tests use assertions and not runtime overhead.
  • I have checked that my tests end in assertions.
  • I have checked that there is no comparison statements in assertions.
  • I have checked that assertions are in tests and not in helper functions.
  • I have checked that assertions for iterables are outside of for loops and both sides of the iteration blocks.
  • I have checked that assertions are not tested inside consumers.

Testing Data

  • I have tested algorithms and anything else with the possibility of unbound growth.
  • I have checked that all testing data is local and fully replaceable or reproducible or both.
  • I have checked that all test files are standalone.
  • I have checked that all test-specific fake objects and classes are in the test directory.
  • I have checked that my tests do not contain anything related to customers, infrastructure or users.
  • I have checked that my tests do not contain non-generic information.
  • I have checked that my tests do not do external requests and are not privately or publicly routable.

Statements

  • I have checked that my tests do not use throws for exceptions.
  • I have checked that my tests do not use try-catch statements.
  • I have checked that my tests do not use if-else statements.

Java

  • I have checked that my tests for Java uses JUnit library.
  • I have checked that my tests for Java uses JUnit utilities for parameters.

Other

  • I have only tested public behavior and not private implementation details.
  • I have checked that my tests are not (partially) commented out.
  • I have checked that hand-crafted variables in assertions are used accordingly.
  • I have tested Object Equality.
  • I have checked that I do not have any manual tests or I have a valid reason for them and I have explained it in the PR description.

Code Quality

  • I have checked that my code follows metrics set in Procedure: Class Metrics.
  • I have checked that my code follows metrics set in Procedure: Method Metrics.
  • I have checked that my code follows metrics set in Procedure: Object Quality.
  • I have checked that my code does not have any NULL values.
  • I have checked my code does not contain FIXME or TODO comments.

Laukkala and others added 23 commits May 14, 2025 07:49
…ndpoints to provide their responses with Json format instead of plain text
Added a test case
Added a specific Exception message when trying to move a directory into the same path where it already is.
…o 3_Filesystem_implementation

# Conflicts:
#	src/test/java/com/teragrep/nbs_01/endpoints/MoveDirectoryEndPointTest.java
@Laukkala Laukkala self-assigned this May 16, 2025
@Laukkala Laukkala requested review from eemhu and kortemik May 20, 2025 11:04
…t be coupled with any specific format. Now LocalFilesystemStorage is the one that decides in which format the Notebooks are serailzied in.
…ir proper objects. Request body contains sourceIdentifiers, sourceParagraphIds, titles and texts, Request path is parsed to retrieve targetIdentifiers and targetParagraphIds.

Previously this parsing was done in BasicHTTPRequest, but that introduces coupling with JSON format and Paths. You might want to use other formats, so the parsing was moved to separate objects behind Interfaces so that they can be changed without having to rewrite BasicHTTPRequest.

Removed Request.Type enum which was used to split paragraphIds from request paths, and replaced it with a HTTPRequestPath and HTTPParagraphRequestPath objects.
…istent. "name" is still supported when reading from legacy files, where it was still in use.
…oint, as UpdateParagraphEndpoint and CreateNotebookEndpoint were expecting different kinds of handling for missing "title" parameter. Now they handle these cases on their own.

Removed some unused Exceptions based on code analysis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants