Classes documentation

Controller Package

CompoundsController Class

The CompoundsController class is a Spring Boot controller responsible for handling HTTP GET requests to the /compounds endpoint. It retrieves files (MOL and PNG) from S3 Storage, based on the parameters provided in the request. This controller delegates the processing of these requests to the CompoundsImpl service, and it returns the appropriate response, including any relevant metadata.

Variables

The class has two variables :

  • logger : The local logger.

  • service : An instance of CompoundsImpl service, responsible for processing requests to retrieve files from S3 storage.

Public Methods

The class includes two public methods :

  • CompoundsController : An autowired constructor to instantiate the service for processing requests to retrieve files from S3 storage.

  • getFile : Handle GET requests to retrieve a file (MOL or PNG) based on the specified parameters.

CompoundsController

The CompoundsController constructor is used to instantiate the service that will process requests to retrieve files from S3 storage.

It initialize the service variable with the provided CompoundsImpl instance.

The constructor requires two parameters :

  • service : An instance of the CompoundsImpl service, which handles the logic for retrieving files.

It doesn’t return anything.

getFile

The getFile method handles GET requests to the /compounds endpoint. It retrieves either a MOL file or a PNG image associated with a chemical compound along with its associated metadata, based on the parameters provided. The retrieved file can be returned either as a direct resource (the actual file content) or as a URL pointing to the file in S3 storage.

It follows these steps :

  1. Initialize Response Headers : Sets up the necessary HTTP headers for the response.

  2. Retrieve the Requested File : Depending on the format parameter (mol or png), the method delegates to the appropriate service method (getMolFile or getPngImage). If an invalid format is provided, an IllegalArgumentException is thrown.

  3. Return the Resource : If the requested file is found, the method returns the resource along with the generated headers. If the file is not found, a FileNotFoundException is thrown.

This method requires five parameter :

  • inchiKey : The InChI Key of the compound.

  • format : The format of the file to retrieve(“mol” or “png”).

  • community : The community from which to retrieve the file (“chebi”).

  • size : The size of the image - “small”, “medium”, or “large” (only applicable for PNG format).

  • outputType : The desired output type (“resource” or “url”).

It returns an HTTP response containing the requested file as a resource or URL, along with associated metadata formatted in the headers.

  • The metadata associated with each MOL file coming from the chebi community are :

    X-Metadata-Chebi-Id : XXXX # The ChEBI ID
    X-Metadata-Creation-Date : YYYY-MM-DD # The date on which the MOL file was stored in the S3
    X-Metadata-Data-License : Creative Commons License (CC BY 4.0) # The MOL file license
    X-Metadata-Data-Source : Chemical Entities of Biological Interest (ChEBI) Database # The MOL file provenance
    
  • The metadata associated with each PNG image coming from the chebi community are :

    X-Metadata-Chebi-Id : XXXX # The ChEBI ID
    X-Metadata-Creation-Date : YYYY-MM-DD # The date on which the MOL file was stored in the S3
    X-Metadata-Data-License : Creative Commons License (CC BY 4.0) # The MOL file license
    X-Metadata-Data-Source : Chemical Entities of Biological Interest (ChEBI) Database # The MOL file provenance
    X-Metadata-Image-Size : XXX x XXX px # The image size (in pixels)
    

Config Package

S3Config Class

The S3Config class is a configuration class responsible for setting up the S3 client used to communicate with custom S3 storage. It defines a Spring Bean for the S3Client that is configured using properties loaded from an external properties file (s3storage.properties).

Annotations

  • @Configuration : Indicates that this class is a source of bean definitions and configuration settings for the application context.

  • @PropertySource("classpath:s3storage.properties") : Specifies the location of the properties file from which to load the configuration properties for the S3 client.

Properties File

The s3storage.properties file should include the following properties for configuring the S3 client :

aws.access.key : The S3 access key for authentication.
aws.secret.key : The S3 secret key for authentication.
aws.region : The region where the S3 bucket is located.
aws.s3.endpointUrl : The endpoint URL of the S3 service.

Public Methods

The class includes one public method :

  • s3Client : Creates a Spring Bean for the S3Client with the specified configuration.

s3Client

The s3Client method creates an S3 client bean configured with credentials and properties retrieved from the s3storage.properties file. The method reads configuration details such as access keys, region, and endpoint URL from the properties file and uses them to configure the S3 client.

It follows these steps :

  1. Retrieve credentials as the S3 access key and secret key from the environment properties.

  2. Build the S3 Client using the retrieved credentials, region, and endpoint URL to create and configure an S3Client instance.

  3. Return the S3 Client as a Spring Bean.

This method requires one parameter :

  • env : The Environment object used to access the properties defined in the s3storage.properties file.

It returns a configured S3Client instance, ready to communicate with the specified S3 storage.


Exceptions Package

FileNotFoundException Class

The FileNotFoundException class is a custom exception used to indicate that a requested file was not found in the S3 storage. It thrown when an attempt to retrieve a file fails because the file does not exist in the storage system.

Variables

The class has one variable :

  • serialVersionUID : A unique identifier for serialization.

Public Methods

The class includes one public method :

FileNotFoundException

This constructor creates a new instance of ``FileNotFoundException`` and passes the provided detail message to the superclass (RuntimeException). The detail message explains the reason why the exception was thrown.

The constructor requires one parameter :

  • errorMessage: A String that contains the detail message explaining the reason for the exception.

It doesn’t return anything.

GlobalExceptionHandler Class

The GlobalExceptionHandler class is a global exception handler for all controllers in the application. It handles specific exceptions that may occur during the execution of controller methods, providing a centralized mechanism for error handling and consistent responses across the application.

Annotations

  • @RestControllerAdviceDefine a global exception handler that

    applies to all controllers in the application. It allows the class to handle exceptions across the whole application and return appropriate HTTP responses.

Variables

The class has one variable :

  • logger : The local logger

Exception Handling Methods

The class includes two exception handling methods :

handleIllegalArgumentException

This method handles IllegalArgumentException exceptions that are thrown by any controller method in the application. It returns a HTTP 400 Bad Request response status along with an error message.

The method logs the exception with a message indicating a 400 - Bad Request status and returns the exception message in the HTTP response.

The method requires one parameter :

  • ex : The IllegalArgumentException instance that was thrown.

It returns an HTTP 400 Bad Request response status along with an error message.

handleFileNotFoundException

This method handles FileNotFoundException exceptions that are thrown by any controller method in the application. It returns a HTTP 404 Not Found response status along with an error message.

The method logs the exception with a message indicating a 404 - Not Found status and returns the exception message in the HTTP response.

The method requires one parameter :

  • ex : The FileNotFoundException instance that was thrown.

It returns a HTTP 404 Not Found response status along with an error message.


Implementation Package

S3Service Class

The S3Service class is a service use for communicating with the S3 Storage. It provides methods to interact with the custom S3 Storage by retrieving objects and generating public URLs for stored files.

Variables

The class has three variables :

  • logger : The local logger.

  • BUCKET_NAME : Constant indicating the bucket name (unh-metabocloud-resources).

  • s3Client : The configured S3 client (autowired).

Public Methods

The class includes two public methods :

  • getObject : Retrieve an object from the S3 Storage.

  • getPublicUrl : Retrieve the public URL of an S3 object.

getObject

The method getObject retrieves an object from the S3 Storage using a path as key.

It queries the unh-metabocloud-resources S3 bucket.

This method requires one parameter :

  • key : The key to retrieve the desired object from the S3 storage (here a path).

It returns the byte array containing the S3 object data.

getPublicUrl

The method getPublicUrl retrieves the public URL of an S3 object using a path as key.

It first checks if the key correspond to a S3 object by requesting metadata, then generates the public URL.

This method requires one parameter :

  • key : The key to retrieve the public URL of the desired object.

It returns the public URL of the requested S3 object.

CompoundsImpl Class

The CompoundsImpl class is a service use for retrieving chemical compound files (MOL and PNG) from S3 Storage. It provides methods to fetch MOL and PNG files associated with chemical compounds and return them in the desired format, either as a direct resource or a URL.

Variables

The class has five variables :

  • logger : The local logger.

  • headers : The HTTP headers for the response (with associated Getter and Setter methods).

  • pathDirector : The Director class responsible for building the path of the requested file.

  • molReader : The reader for retrieving MOL files.

  • pngReader : The reader for retrieving PNG images.

Public Methods

The class includes three public methods for retrieving two type of file formats :

  • CompoundsImpl : An autowired constructor to instantiate readers for retrieving PNG and MOL files.

  • getMolFile : Retrieve a MOL file of a molecule from the S3 Storage.

  • getPngImage : Retrieve a PNG image of a molecule from the S3 Storage.

CompoundsImpl

The CompoundsImpl constructor instantiates the readers used to retrieve PNG and MOL files.

It initialize the molReader and pngReader variables.

The constructor requires two parameters :

  • molReader : The MolReader instance used to retrieve MOL files.

  • pngReader : The PngReader instance used to retrieve PNG images.

It doesn’t return anything.

getMolFile

The method getMolFile retrieves a molecule’s MOL file from S3 storage. It sets appropriate headers for the response and returns the MOL file as either a direct resource or a URL, based on the specified output type.

It follows these steps :

  1. Sets the generic headers : Content-Type header to plain/text so that the MOL file is returned as a text, and the Access-Control-Allow-Headers/Access-Control-Expose-Headers to enables the exposition of custom headers used to return metadata with the response.

  2. Build the path to the requested MOL file in S3 Storage. The path follow the syntax : mol/{community}/{inchiKey}.mol (e.g mol/chebi/RYYVLZVUVIJVGH-UHFFFAOYSA-N.mol).

  3. Retrieve the MOL file according to the specified outputType and returns it either :

This method requires three parameters :

  • community : The community from which to retrieve the molecule’s MOL file (currently only ``chebi`` is accepted).

  • inchiKey : The InChI key of the molecule whose MOL file is to be retrieved.

  • outputType : The desired output type — either url to return a URL or resource to return the file’s content directly.

It returns a SpringBoot Java Resource object containing either the URL of the MOL file or the file’s content.

getPngImage

The method getPngImage enables retrieves a molecule’s PNG image from S3 storage. It sets appropriate headers for the response and returns the PNG image as either a direct resource or a URL, based on the specified output type.

It follows several steps :

  1. Sets the generic headers : Content-Type header to plain/text so that the MOL file is returned as a text, the Access-Control-Allow-Headers/Access-Control-Expose-Headers to enables the exposition of custom headers used to return metadata with the response and the custom X-Metadata-Image-Size header to indicate the size of the PNG image returned.

  2. Build the path to the requested PNG image in the S3 Storage. The path follow the syntax : png/{community}/{imageSizeLabel}/{inchiKey}_{imageSizeInt}.png (e.g png/chebi/small/RYYVLZVUVIJVGH-UHFFFAOYSA-N_50.png).

  3. Retrieve the PNG image according to the specified outputType and returns it either :

This method requires four parameters :

  • community : The community from which to retrieve the molecule’s MOL file (currently only ``chebi`` is accepted).

  • sizeLabel : The label indicating the image size to retrieve (either small, medium or large).

  • inchiKey : The InChI key of the molecule whose PNG image is to be retrieved.

  • outputType : The desired output type — either url``to return a URL or ``resource to return the file’s content directly.

It returns a SpringBoot Java Resource object containing either the URL of the PNG image or the image’s content.

Private Methods

The class includes two private methods :

  • addHeaders : Add generic HTTP headers.

  • getSpecificOutput : Determines the output format and retrieves the file and its metadata accordingly from S3 storage.

addHeaders

The method addHeaders adds generic HTTP headers like content type and access control headers. If an image size is provided, it sets a custom image size header as well.

It adds the Content-Type, Access-Control-Allow-Headers, and Access-Control-Expose-Headers headers, and if the file retrieved is a PNG image, it also adds the X-Metadata-Image-Size custom header.

It requires three parameters :

  • contentType : The content type header for the format (e.g., text/plain, image/png).

  • allowExposeHeaderValue : The access control allow/expose header value.

  • sizeLabel : An optional image size in pixels, only used for image formats (set to null for other formats).

It doesn’t return anything.

getSpecificOutput

The method getSpecificOutput selects whether the file is retrieved as a URL or as direct content, and recovers the associated metadata, formatting it into the response headers.

It follows these steps :

  1. Reset the reader instance’s variables to clear any residual data from previous requests.

  2. Select the appropriate reader method based on the desired outputType and retrieves and returns the file either as content or as a URL along with the associated metadata formatted in the response headers.

It requires three parameters :

  • reader : The reader used to retrieve the file (either a MolReader or a PngReader).

  • path : The path of the file to be retrieved.

  • outputType : The desired output type — either url to return a URL or resource to return the file’s content directly.

It returns a SpringBoot Java Resource object containing either the URL of the file or the file’s content.


Implementation.Builders Package

PathBuilder Abstract Class

The PathBuilder is an abstract class designed to build the path of a file after validating the required attributes. It has two direct subclasses, ImagePathBuilder and MolPathBuilder, and one indirect subclass, PngPathBuilder, derived through ImagePathBuilder.

Variables

The class has three variables :

  • logger : The local logger.

  • community : The community to which the requested object belongs (e.g chebi), associated with a Getter method.

  • inchiKey : The InChI Key associated with the molecule wanted to be retrieved, associated with a Getter method.

Public Methods

The class defines one public abstract method, implemented in the subclasses :

  • getResult : Constructs and returns the path based on the set attributes.

It also includes two public methods :

  • setCommunity : Validates and sets the community to which the requested object belongs.

  • setInchiKey : Validates and sets the InChI Key associated with the desired molecule.

setCommunity

The setCommunity method sets the ``community`` attribute after validating its value.

It follows these steps :

  1. Retrieve the list of all possible communities from the Community enum.

  2. Check if the provided community exists in this list.

  3. Set the community attribute with the provided value.

This method requires one parameter :

  • community : The community (e.g., chebi) as a String.

It doesn’t return anything.

setInchiKey

The setInchiKey method sets the ``inchiKey`` attribute after validating its value.

It follows these steps :

  1. Compile a pattern the inchiKey attribute must match.

  2. Check if the provided InChI Key matches the regular expression.

  3. Set the inchiKey attribute with the provided value.

This method requires one parameters :

  • inchiKey : The InChI Key as a String.

It doesn’t return anything.

ImagePathBuilder Abstract Class (Subclass of PathBuilder Abstract Class)

The ImagePathBuilder abstract class is a subclass of the PathBuilder abstract class. It enables the construction of a path of an image after validating the required attributes.

Variables

The class has two variables :

  • sizeLabel : The label indicating the image size to be retrieved (small, medium or large), associated with a Getter method.

  • sizePixel : The image size in pixels corresponding to the label (50, 350 or 700), associated with a Getter method.

Public Methods

The class includes one public method :

  • setImageSize : Sets the sizeLabel and sizePixel attributes after validating their values.

setImageSize

The setImageSize method sets the ``sizeLabel`` and ``sizePixel`` attributes validating their values.

It follows these steps :

  1. Retrieve the list of all possible image size labels from the ImageSize enum.

  2. Check if the provided size label exists in this list.

  3. Set the sizeLabel and sizePixel attributes based on the provided value.

This method requires one parameter :

  • sizeLabel : The label indicating the image size to be retrieved (small, medium or large).

It doesn’t return anything.

PngPathBuilder Class (Subclass of ImagePathBuilder Abstract Class)

The PngPathBuilder class is a subclass of the ImagePathBuilder abstract class and indirectly of the PathBuilder class. It enables the construction of a path for a PNG image after validating the required attributes.

Public Methods

The class includes one public method :

  • getResult (PNG) : Constructs the PNG image path based on the community, sizeLabel, inchiKey, and sizePixel attributes.

getResult (PNG)

The getResult method constructs the PNG image path based on the community, sizeLabel, inchiKey, and sizePixel attributes inherited from the ImagePathBuilder and PathBuilder classes.

It follows these steps :

  1. Retrieve the community, sizeLabel, inchiKey, and sizePixel attributes using their getter methods.

  2. Build the path using a formatted string, following the syntax png/community/size_label/inchikey_sizePixel.png

    Example : png/chebi/medium/COFJZDUAVQUGRU-UHFFFAOYSA-N_350.png

This method does not require any parameters.

It returns the path of the PNG image.

MolPathBuilder Class (Subclass of PathBuilder Abstract Class)

The MolPathBuilder class is a subclass of the PathBuilder abstract class. It enables the construction of a path for a MOL file after validating the required attributes.

Public Methods

The class includes one public method :

  • getResult (MOL) : Constructs the MOL file path based on the community and inchiKey attributes.

getResult (MOL)

The getResult method constructs the MOL file path based on the community and inchiKey attributes inherited from the PathBuilder class.

It follows these steps :

  1. Retrieve the community and inchiKey attributes using the getter methods.

  2. Build the path using a formatted string, following the syntax mol/community/inchikey.mol

    Example : mol/chebi/COFJZDUAVQUGRU-UHFFFAOYSA-N.mol

This method does not require any parameters.

It returns the path of the MOL file wanted.


Implementation.Directors Package

PathDirector Interface

The PathDirector interface serves as a director that facilitates the construction of paths for retrieving files. It provides methods for creating valid paths to retrieve MOL files and PNG images from a specified community based on given parameters.

Public Methods

The interface defines two methods to implement :

  • buildMolPath : Builds a valid path to retrieve a MOL file.

  • buildPngPath : Builds a valid path to retrieve a PNG image.

SimplePathDirector Class (Implements PathDirector Interface)

The SimplePathDirector implements the PathDirector interface.

Public Methods

The class includes two public methods :

  • buildMolPath : Builds a valid path to retrieve a MOL file.

  • buildPngPath : Builds a valid path to retrieve a PNG image.

buildMolPath

The buildMolPath method builds a valid path to retrieve a MOL file based on community and inchiKey parameters.

It follows these steps :

  1. Instantiate a MolPathBuilder.

  2. Set the community attribute after validating its value.

  3. Set the inchiKey attribute after validating its value.

  4. Build the path using the getResult method of the builder.

This method requires two parameters :

  • community : The community from which the molecule’s MOL file is to be retrieved.

  • inchiKey : The InChI Key associated with the molecule to retrieved.

It returns the path of the MOL file

buildPngPath

The buildPngPath method builds a valid path to retrieve a PNG image based on community, sizeLabel and inchiKey parameters.

It follows these steps :

  1. Instantiate a PngPathBuilder.

  2. Set the community attribute after after validating its value.

  3. Set the sizeLabel attribute after after validating its value.

  4. Set the inchiKey attribute after after validating its value.

  5. Build the path using the getResult method of the builder.

This method requires three parameters :

  • community : The community from which the molecule’s PNG image is to be retrieved.

  • sizeLabel : The label indicating the size of the image to retrieve.

  • inchiKey : The InChI Key associated with the molecule to retrieved.

It returns the path of the PNG file.


Implementation.Readers Package

Reader Abstract Class

The Reader is an abstract class designed to retrieve a file and extract its metadata. It has two subclasses : MolReader and PngReader.

Variables

The class has four variables :

  • logger : The local logger

  • S3Service : The service used for communication with S3 storage.

  • fileBytes : A byte array representing the file, with associated getter and setter methods.

  • FileUrl : The URL of the file, with associated getter and setter methods.

Public Methods

The class defines one public abstract method, which is implemented in the subclasses : * extractMetadata : Extracts metadata directly from the file.

It also has two public methods :

  • getFileContent : Retrieves the file from S3 storage as content, extracts metadata, and updates the response headers with the metadata.

  • getUrl : Retrieves the file URL from S3 storage, extracts metadata, and updates the response headers with the metadata.

getFileContent

The getFileContent method retrieves the file from S3 storage as content, extracts metadata, and updates the response headers with the metadata.

It follows these steps :

  1. Fetch the file from S3 Storage and read it as byte array.

  2. Store the byte array in the fileBytes variable.

  3. Extract metadata from the file (using the byte array).

  4. Update the response headers with extracted metadata.

    1. Return the file as a Resource object.

This method requires two parameters :

  • path : The path of the desired file.

  • headers : The HTTP response headers.

It returns a Spring Boot Resource object containing the content of the retrieved file.

getUrl

The getUrl method retrieves the file from S3 storage as a URL, extracts metadata, and updates the response headers with the metadata.

It follows these steps :

  1. Retrieve the URL of the file.

  2. Store the URL in the fileUrl variable.

  3. Extract metadata from the file (via the URL).

  4. Update the response headers with extracted metadata.

  5. Return the file as a Resource object.

This method requires two parameters :

  • path : The path of the desired file.

  • headers : The HTTP response headers.

It returns a SpringBoot Resource object containing the URL of the retrieved file.

Private Methods

The class includes two private methods :

updateHeaders

The updateHeaders method updates the response headers with metadata extracted from the file/URL.

It iterates through all the keys and values in the JSON object and adds them to the response headers.

This method requires two parameters :

  • metadata : The JSON object containing the extracted metadata.

  • headers : The HTTP response headers.

It doesn’t return anything.

extractMetadataFromUrl

The extractMetadataFromUrl method extracts metadata from the file via its URL and formats it as JSON.

It follows these steps :

  1. Read the content of the URL and store it as a byte array in the fileBytes variable.

  2. Extract metadata, format it in a JSON object by associating each key with its value, and return the JSON object containing the custom image metadata using the extractMetadata method.

This method requires one parameter :

  • url : The URL of the file.

It returns a Java JSONObject containing the extracted metadata.

PngReader Class (Subclass of Reader Abstract Class)

The PngReader class is a subclass of the Reader abstract class. It enables the retrieval of a PNG image and the extraction of its metadata, either from the resource directly or via the URL.

Public Methods

The class has two public methods :

PngReader

The PngReader constructor instantiates the S3 service to facilitate communication with the S3 storage.

It uses a setter method to initialize the s3Service variable inherited from the parent class (Reader).

The constructor requires one parameter :

  • service: The S3Service instance used to communicate with S3 storage.

It doesn’t return anything.

extractMetadata (PNG)

The extractMetadata method extracts metadata from a PNG image and formats it as JSON.

It follows these steps :

  1. Checks if the file’s bytes, passed as a parameter, exist. If the parameter is null, it logs an error message and returns null.

  2. If the parameter is not null, the method proceeds to extract the metadata by :

    1. Reading the file’s bytes as a PNG image.

    2. Extracting the relevant metadata from the specific layer where they are stored (tEXtEntry).

    3. Formatting the metadata into a JSON object, associating each key with its corresponding value.

    4. Returning the JSON object containing all the custom image metadata.

The method requires one parameter :

  • file : A byte array representing the PNG image.

It returns a Java JSONObject containing the extracted metadata.

MolReader Class (Subclass of Reader Abstract Class)

The MolReader class is a subclass of the Reader abstract class. It enables the retrieval of a MOL file and the extraction of its metadata, either from the resource directly or via the URL.

Public Methods

The class has two public methods :

MolReader

The MolReader constructor instantiates the S3 service to facilitate communication with the S3 storage.

It uses a setter method to initialize the s3Service variable inherited from the parent class (Reader).

The constructor requires one parameter :

  • service: The S3Service instance used to communicate with S3 storage.

It doesn’t return anything.

extractMetadata (MOL)

The extractMetadata method extracts metadata from a MOL file and formats it as JSON.

It follows these steps :

  1. Checks if the file’s bytes, passed as a parameter, exist. If the parameter is null, it logs an error message and returns null.

  2. If the parameter is not null, the method proceeds to extract the metadata by : 1. Reading the file’s bytes as a String. 2. Extracting the relevant metadata from the first three lines after checking that they exist and follow the supported syntax. 3. Formatting the metadata into a JSON object, associating each key with its corresponding value. 4. Returning the JSON object containing all the custom image metadata.

Note

The metadata from the MOL file must use the following syntax (valid for chebi community).

YYYY-MM-JJ  ChEBI ID
Source
License

The method requires one parameter :

  • file : A byte array representing the PNG image.

It returns a Java JSONObject containing the extracted metadata.


Models Package

Community Enum

The Community enumeration represents the different communities available for retrieving data. Each community corresponds to a specific data source or database from which chemical compound information can be retrieved.

Enum Constants

This enum currently includes the following community :

  • CHEBI : Represents the Chemical Entities of Biological Interest (ChEBI) database (“chebi”).

Variables

It includes one variable :

  • label : A String that holds the label associated with the community.

Private Methods

This enum include one private methods :

  • Community : A private constructor that initializes the enum constant with its corresponding label.

Community

The Community constructor initializes the enum constant with its corresponding community.

It requires one parameter :

  • label : The label associated with the community, passed as a string.

Headers Enum

The Headers enumeration represents the various HTTP header keys and values used in the application. It categorizes headers into two main types : Key Headers and Value Headers.

Enum Constants

The Headers enum is divided into two main categories :

  • Key Headers : These are standard and custom header keys used in HTTP responses.

    • CONTENT_TYPE : “Content-Type” - Specifies the content type of the response.

    • ALLOW_HEADERS : “Access-Control-Allow-Headers” - Specifies which HTTP headers can be used during the actual request.

    • EXPOSE_HEADERS : “Access-Control-Expose-Headers” - Specifies which headers are safe to expose to the client.

    • IMAGE_SIZE : “X-Metadata-Image-Size” - Custom header to store the image size.

    • CHEBI_ID: “X-Metadata-Chebi-Id” - Custom header to store the ChEBI ID.

    • CREATION_DATE : “X-Metadata-Creation-Date” - Custom header to store the date the files were saved in S3.

    • SOURCE : “X-Metadata-Data-Source” - Custom header to store the file source.

  • Value Headers : These are predefined values corresponding to the key headers.

    • IMAGE_PNG : “image/png” - Value for the “Content-Type” header when the content is a PNG image.

    • PLAIN_TEXT : “text/plain” - Value for the “Content-Type” header when the content is plain text.

    • ALLOW_EXPOSE_HEADERS_VALUE_PNG : A combination of custom headers that should be exposed when the content is a PNG image.

    • ALLOW_EXPOSE_HEADERS_VALUE_MOL : A combination of custom headers that should be exposed when the content is a MOL file.

Variables

It includes one variable :

  • label : A String that holds the label associated with the header key or value.

Private Methods

This enum include one private methods :

  • Headers : A private constructor that initializes the enum constant with its corresponding headers key or value.

Headers

The Headers constructor initializes the enum constant with its corresponding label.

It requires one parameter :

  • label : The label associated with the header key or value, passed as a string.

ImageSize Enum

The ImageSize enumeration represents the available image sizes within the application. This enum defines three specific sizes available in the S3 storage.

Enum Constants

This enum defines three constants, each representing a specific image size in pixels :

  • SMALL : Represents a small image size with dimensions of 50 x 50 pixels.

  • MEDIUM : Represents a medium image size with dimensions of 350 x 350 pixels.

  • LARGE : Represents a large image size with dimensions of 700 x 700 pixels.

Variables

It includes one variable :

  • label : A String that holds the label representing the size of the image in pixels.

Private Methods

This enum include one private methods :

** ImageSize : A private constructor that initializes the enum constant with its corresponding label.

ImageSize

The ImageSize constructor initializes the enum constant with its corresponding image size.

It requires one parameter :

  • label : The label representing the size in pixels (both width and height), passed as a string.

IndexErrorMessages Enum

The IndexErrorMessages enumeration centralizes specific error messages that the application may return under various error conditions.

Enum Constants

This enum defines six constants, each representing a specific error scenario along with an associated error message :

  • INVALID_FORMAT : Occurs when the format parameter provided by the user is invalid. The only acceptable values are png and mol.

    “The parameter ‘format’ is invalid. Only ‘png’ and ‘mol’ are accepted. See the documentation for more details.”
    
  • INVALID_COMMUNITY : Occurs when the community parameter provided by the user is invalid. The only acceptable value is chebi.

    “The parameter ‘community’ is invalid. Only ‘chebi’ is accepted. See the documentation for more details.” -
    
  • INVALID_SIZE : Occurs when the size parameter provided by the user is invalid. The only acceptable values are small, medium, and large.

    “The parameter ‘size’ is invalid. Only ‘small’, ‘medium’ and ‘large’ are accepted. See the documentation for more details.”
    
  • INVALID_INCHI_KEY : Occurs when the inchiKey parameter provided by the user is malformed or invalid.

    “The parameter ‘inchiKey’ is invalid. See the documentation for more details.”
    
  • INVALID_OUTPUT_TYPE : Occurs when the outputType parameter provided by the user is invalid. The only acceptable values are resource and url.

    “The parameter ‘outputType’ is invalid. Only ‘resource’ and ‘url’ are accepted. See the documentation for more details.”
    
  • FILE_NOT_FOUND : Occurs when a requested file cannot be found in the S3 storage.

    “The file requested does not exist.”
    

Variables

It includes one variable :

  • label : A String that holds the label representing the error message.

Private Methods

This enum include one private methods :

  • IndexErrorMessages : A private constructor that initializes the enum constant with its corresponding label.

IndexErrorMessages

The IndexErrorMessages constructor initializes the enum constant with its corresponding error message.

It requires one parameter :

  • label : The label representing the error message, passed as a string.

OutputType Enum

The OutputType defines the types of output that can be requested from the application, specifying whether the output should be the resource content itself or a URL pointing to the resource’s location.

Enum Constants

This enum defines two constants, each representing a different output type :

  • RESOURCE : Represents an output type where the result is the resource itself, such as the file’s content (“resource”).

  • URL : Represents an output type where the result is a URL string. This URL points to the resource’s location in the S3 storage, allowing users to access the resource via the generated link (“url”).

Variables

It includes one variable :

  • label : A String that holds the label associated with the output type.

Private Methods

This enum include one private methods :

  • OutputType : A private constructor that initializes the enum constant with its corresponding label.

OutputType

The OutputType constructor initializes the enum constant with its corresponding output type.

It requires one parameter :

  • label : The label representing the output type, passed as a string.