Classes documentation
Here you can found technical documentation about the implementation code of this API.
Config Package
The Config
package contains configuration classes.

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
).
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.
The class includes one public method :
s3Client
- Configures a Spring Bean for the S3Client
The s3Client
method creates an S3 client bean configured with
credentials and properties retrieved from the s3storage.properties
file.
It follows these steps :
Retrieve credentials such as the S3 access key and secret key from the environment properties.
Build the S3 Client using the retrieved credentials, region, and endpoint URL to create and configure an S3Client instance.
Return the S3 Client as a Spring Bean.
This method requires one parameter :
env
: TheEnvironment
object used to access the properties defined in thes3storage.properties
file.
It returns a configured S3Client
instance, ready to communicate with the specified S3 storage.
Controllers Package
The Controller
package contains controllers used to handle HTTP request.

CompoundsController Class
The CompoundsController
class is a SpringBoot Controller responsible for handling
HTTP GET requests to the /compounds
endpoint. It retrieves files from S3 Storage,
based on the parameters provided in the request.
This controller delegates the processing of these requests to the CompoundsService
service,
and it returns the appropriate response.
It has two variables :
logger
: The local logger.service
: An instance ofCompoundsService
service, responsible for processing requests to retrieve files from S3 storage.
The class contains one constructor :
CompoundsController
- Instantiates the controller with the necessary dependencies
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 CompoundsService instance.
The constructor requires one parameter :
service
: An instance of theCompoundsService
service, which handles the logic for retrieving files.
It doesn’t return anything.
It also includes one public method :
getFile
- Handle GET requests to retrieve a file based on the specified parameters.
The getFile
public method handles HTTP GET requests directed to the /compounds
endpoint.
It retrieves either a MOL file or a PNG image associated with a chemical compound along
with its metadata, based on the parameters provided. The retrieved file can
be returned either as either a direct resource (the actual file content) or as a URL pointing to the
file in S3 storage.
It follows these steps :
Initialize Response Headers : Initializes the necessary HTTP headers for the response.
Retrieve the Requested File : Depending on the format parameter (
mol
orpng
), the method delegates to the appropriate service method (getMolFile
orgetPngImage
). If an invalid format is provided, anInvalidFormatException
is thrown.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 parameters :
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)
Exception Package
The Exception
package contains exceptions that can be thrown by the application.

FileNotFoundException Class
The FileNotFoundException
class is a custom exception used to
indicate that a requested file was not found in the S3 storage. It is
thrown when an attempt to retrieve a file fails because the file does
not exist in the storage system.
It has one variable :
serialVersionUID
: The default serial version UID used for serialization.
The class includes one constructor :
FileNotFoundException
- Instantiates the exception with a specified detail message
The constructor initializes the exception with a detail message explaining the reason for the exception.
The constructor requires one parameter :
errorMessage
: AString
containing the detail message that explains why the exception is thrown.
It doesn’t return anything.
InvalidCommunityException Class
The InvalidCommunityException
class is a custom exception that is thrown when an invalid community is requested.
It contains one variable :
serialVersionUID
: The default serial version UID used for serialization.
The class defines one constructor :
InvalidCommunityException
- Instantiates the exception with a specified detail message
The constructor initializes the exception with a detail message explaining the reason for the exception.
This constructor requires one parameter :
errorMessage
: AString
containing the detail message that explains why the exception is thrown.
It doesn’t return anything.
InvalidFormatException Class
The InvalidFormatException
class is a custom exception that is thrown when an invalid format is requested.
It contains one variable :
serialVersionUID
: The default serial version UID used for serialization.
The class defines one constructor :
InvalidFormatException
- Instantiates the exception with a specified detail message
The constructor initializes the exception with a detail message explaining the reason for the exception.
This constructor requires one parameter :
errorMessage
: AString
containing the detail message that explains why the exception is thrown.
It doesn’t return anything.
InvalidImageSizeException Class
The InvalidImageSizeException
class is a custom exception that is thrown when an invalid image size is requested.
It contains one variable :
serialVersionUID
: The default serial version UID used for serialization.
The class defines one constructor :
InvalidImageSizeException
- Instantiates the exception with a specified detail message
The constructor initializes the exception with a detail message explaining the reason for the exception.
This constructor requires one parameter :
errorMessage
: AString
containing the detail message that explains why the exception is thrown.
It doesn’t return anything.
InvalidOutputTypeException Class
The InvalidOutputTypeException
class is a custom exception that is thrown when an invalid output type is requested.
It contains one variable :
serialVersionUID
: The default serial version UID used for serialization.
The class defines one constructor :
InvalidOutputTypeException
- Instantiates the exception with a specified detail message
The constructor initializes the exception with a detail message explaining the reason for the exception.
This constructor requires one parameter :
errorMessage
: AString
containing the detail message that explains why the exception is thrown.
It doesn’t return anything.
OutdatedFileException Class
The OutdatedFileException
class is a custom exception that is thrown when a requested file is outdated (over than 1-month).
It contains one variable :
serialVersionUID
: The default serial version UID used for serialization.
The class defines one constructor :
OutdatedFileException
- Instantiates the exception with a specified detail message
The constructor initializes the exception with a detail message explaining the reason for the exception.
This constructor requires one parameter :
errorMessage
: AString
containing the detail message that explains why the exception is thrown.
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.
It has one variable :
logger
: The local logger
The class includes two exception handling methods :
handleInvalidParameterException
- Handles Invalid*Exception exceptions.
This method handles InvalidCommunityException
, InvalidFormatException
, InvalidOutputTypeException
and InvalidOutputTypeException
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.
It 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 exception instance that was thrown.
It returns an HTTP 400 Bad Request response status along with an error message.
handleFileNotFoundException
- Handles FileNotFoundException exceptions.
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.
It 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
: TheFileNotFoundException
instance that was thrown.
It returns a HTTP 404 Not Found response status along with an error message.
Implementation Package
The Implementation
package contains the core of the application.
Implementation.Builders Package
The Implementation.Builders
package contains the builder classes.

Implementation.Builders.Metadata Package
The Implementation.Builders.Metadata
package contains the builders used to build the file metadata.
MetadataBuilder Class
MetadataBuilder
is an abstract class designed to build the metadata associated to a file.
It has one direct subclass, ChebiMetadataBuilder
.
It has one variable :
logger
: The local logger
The class includes one public abstract method, implemented in the subclasses :
buildMetadata
- Builds the metadata associated to a file
The method buildMetadata
builds the metadata associated to a file in a JSONObject
.
It is implemented in :
ChebiMetadataBuilder Class : To build metadata for files coming from ChEBI database.
ChebiMetadataBuilder Class
ChebiMetadataBuilder
is a subclass of the MetadataBuilder
abstract class.
It is responsible for generating a JSONObject
containing relevant metadata for
files coming from the ChEBI database.
The metadata includes the ChEBI ID, the Creation date, the License and the Source.
Example :
{
"X-METADATA-CHEBI-ID" : "27732",
"X-METADATA-CREATION-DATE" : "2024-10-04",
"X-METADATA-DATA-LICENSE" : "Creative Commons License (CC BY 4.0)",
"X-METADATA-DATA-SOURCE" : "Chemical Entities of Biological Interest (ChEBI) Database"
}
It has one variable :
chebiId
: The ChEBI ID associated to a file.
The class includes one public method, implementing a parent abstract method :
buildMetadata
- Builds the metadata associated to a ChEBI file
This implementation of the abstract method buildMetadata
is responsible for building the
metadata associated to a file coming from the ChEBI database.
It follow these steps :
Initializes a JSONObject.
Add to this JSONObject four metadata fields :
X-METADATA-CHEBI-ID
: The ChEBI ID associated to the file, stored in thechebiId
variable.X-METADATA-CREATION-DATE
: The current date when the method is executed.X-METADATA-DATA-LICENSE
: The license type for the file from ChEBI (Creative Commons License (CC BY 4.0)).X-METADATA-DATA-SOURCE
: The data source, in this case, “Chemical Entities of Biological Interest (ChEBI) Database”.
Returns the JSONObject containing the metadata.
The method doesn’t require any parameter.
It returns a JSONObject
containing the metadata associated to the file from CHEBI.
Implementation.Builders.Path Package
The Implementation.Builders.Path
package contains the builders used to build the file path.
PathBuilder Abstract Class
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
.
It 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.
The class includes one public abstract method, implemented in the subclasses :
getResult
- Builds and returns the path associated to a file
The method getResult
builds the path which will be associated to a file
based on the set attributes.
It is implemented in :
MolPathBuilder Class : To build the path for a MOL file.
PngPathBuilder Class : To build the path for a PNG image.
It also includes two public methods :
setCommunity
- Validates and sets the community to which the requested object belongs
The setCommunity
method sets the ``community`` attribute after
validating its value.
It follows these steps :
Retrieve the list of all possible communities from the
Community
enum.Check if the provided community exists in this list.
Set the
community
attribute with the provided value.
This method requires one parameter :
community
: The community (e.g., chebi) as aString
.
It doesn’t return anything.
setInchiKey
- Validates and sets the InChI Key associated with the desired molecule
The setInchiKey
method sets the ``inchiKey`` attribute after
validating its value.
It follows these steps :
Compile a pattern the
inchiKey
attribute must match.Check if the provided InChI Key matches the regular expression.
Set the
inchiKey
attribute with the provided value.
This method requires one parameters :
inchiKey
: The InChI Key as aString
.
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 is responsible for building the path for an image after validating the required attributes.
It 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.
The class includes one public method :
setImageSize
- Validates and sets the size label and pixel for an image
The setImageSize
method sets the ``sizeLabel`` and ``sizePixel``
attributes after validating their values.
It follows these steps :
Retrieve the list of all possible image size labels from the
ImageSize
enum.Check if the provided size label exists in this list.
Set the
sizeLabel
andsizePixel
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 is responsible for
building a path for a PNG image after validating the required attributes.
The class includes one public method, implementing a parent abstract method :
getResult
- Builds and returns the path associated to a PNG image
This implementation of the getResult
abstract method is responsible for
building the path for a PNG image based on the community
, sizeLabel
,
inchiKey
, and sizePixel
attributes inherited from the ImagePathBuilder
and PathBuilder
classes.
It follows these steps :
Defines the format as PNG.
Build the path using a formatted string, following the syntax
png/community/size_label/inchikey_sizePixel.png
It retrieve thecommunity
,sizeLabel
,inchiKey
, andsizePixel
attributes using their getter methods.Example : png/chebi/medium/COFJZDUAVQUGRU-UHFFFAOYSA-N_350.png
This method does not require any parameters.
It returns the path of a PNG image.
MolPathBuilder Class (Subclass of PathBuilder Abstract Class)
The MolPathBuilder
class is a subclass of the PathBuilder
abstract class.
It is responsible for building a path for a MOL file after validating the required attributes.
The class includes one public method, implementing a parent abstract method :
getResult
- Builds and returns the path associated to a MOL file
This implementation of the getResult
abstract method is responsible for
building the path for a MOL file based on the community
, and inchiKey
attributes inherited from PathBuilder
classes.
It follows these steps :
Defines the format as MOL.
Build the path using a formatted string, following the syntax
mol/community/inchikey.mol
It retrieve thecommunity
, andinchiKey
attributes using their getter methods.Example : mol/chebi/COFJZDUAVQUGRU-UHFFFAOYSA-N.mol
This method does not require any parameters.
It returns the path of a MOL file.
Implementation.Directors Package
The Implementation.Directors
package contains the director classes.

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.
The interface defines two methods to implement :
buildMolPath
- Builds a valid path to retrieve a MOL file
The method buildMolPath
builds a valid path to retrieve a MOL file.
It is implemented in :
SimplePathDirector Class : Single implementation of
PathDirector
interface.
buildPngPath
- Builds a valid path to retrieve a PNG image
The method buildPngPath
builds a valid path to retrieve a PNG image.
It is implemented in :
SimplePathDirector Class : Single implementation of
PathDirector
interface.
SimplePathDirector Class (Implements PathDirector Interface)
The SimplePathDirector
implements the PathDirector
interface.
The class includes two public methods, implementing methods from an interface :
buildMolPath
- Builds a valid path to retrieve a MOL file
This implementation of the interface method buildMolPath
is responsible for
building a valid path to retrieve a MOL file based on community
and inchiKey
parameters.
It follows these steps :
Instantiates a
MolPathBuilder
.Sets the
community
attribute.Sets the
inchiKey
attribute.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 MOL file to retrieved.
It returns the path of the MOL file
buildPngPath
- Builds a valid path to retrieve a PNG image
This implementation of the interface method buildPngPath
for
building a valid path to retrieve a PNG image based on community
,
sizeLabel
and inchiKey
parameters.
It follows these steps :
Instantiate a
PngPathBuilder
.Set the
community
attribute.Set the
sizeLabel
attribute.Set the
inchiKey
attribute.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 PNG image to retrieved.
It returns the path of the PNG file.
Implementation.Factories Package
The Implementation.Factories
package contains the factory classes.

Implementation.Factories.Reader Package
The Implementation.Factories.Reader
package contains the factory classes for the readers.
ReaderFactory Interface
The ReaderFactory
is an interface designed to create a Reader
object that corresponds
to a particular file format and then use it to retrieve the file along with its metadata
in the requested output type. It has one subclass : SimpleReaderFactory
.
The interface defines two methods to implement :
createReader
- Provides the appropriate reader for the given file format
The method createReader
creates and provides the appropriate Reader
to use for
a given file format.
It is implemented in :
SimpleReaderFactory Class : Single implementation of
ReaderFactory
interface.
retrieveResource
- Retrieves a resource from S3 storage based on the desired output type
The method retrieveResource
retrieves a resource from S3 Storage based on the desired
output type (either resource
or url
)
It is implemented in :
SimpleReaderFactory Class : Single implementation of
ReaderFactory
interface.
SimpleReaderFactory Class (Implements ReaderFactory Interface)
The SimpleReaderFactory
implements the ReaderFactory
interface.
It contains two variables :
logger
: The local loggerreaderMap
: A map containing all available readers, where the key is the file format, and the value is the respective reader.
The class defines two public methods, implementing methods from an interface :
createReader
- Provides the appropriate reader for the given file format
This implementation of the interface method createReader
is responsible for
creating and providing a reader based on the specified format.
Currently, it supports two formats : MOL files or PNG images
It follows these steps :
Check the
readerMap
for the reader corresponding to the provided format.If a reader is found, return the reader.
If no reader is found for the format, log an error and throw an
InvalidFormatException
.
This method requires one parameter :
format
: The format of the desired file.
It returns a Reader
object corresponding to the specified format.
retrieveResource
- Retrieves a resource from S3 storage based on the desired output type
This implementation of the interface method retrieveResource
is responsible for
retrieving a file from S3 storage either as content or as a URL, depending on the specified output type.
It follows these steps :
Use the
createReader
method to get the appropriate reader for the file format.Depending on the
outputType
, either: * Retrieve the file content along with its metadata. * Retrieve the file URL along with its metadata and override the content type in the headers astext/plain
.If the
outputType
is invalid, log an error and throw anInvalidOutputTypeException
.
This method requires four parameters :
format
: The format of the desired file.path
: The path of the file in S3 storage.headers
: The HTTP response headers.outputType
: The type of output requested, either “resource” for file content or “url” for a URL.
It returns a Resource
object containing the retrieved file or URL.
Implementation.Factories.Updater Package
The Implementation.Factories.Updater
package contains the factory classes for the updaters.
DataUpdaterFactory Interface
The DataUpdaterFactory
is an interface designed to create a DataUpdater
object that corresponds
to a particular file format for a specific community and then use it to update a file in the S3 storage.
It has one subclass : ChebiDataUpdaterFactory
.
The interface defines two methods to implement :
createUpdater
- Provides the appropriate updaters for the given file format
The method createUpdater
creates and provides the appropriate DataUpdater
to use for
a given file format.
It is implemented in :
ChebiDataUpdaterFactory Class : To update files coming from ChEBI database.
updateFile
- Updates a file based on its format
The method updateFile
updates a resource on the S3 Storage based on the format.
It is implemented in :
ChebiDataUpdaterFactory Class : To update files coming from ChEBI database.
ChebiDataUpdaterFactory Class (Implements DataUpdaterFactory Interface)
The ChebiDataUpdaterFactory
class, implementing the DataUpdaterFactory
interface, is responsible
for the updates of the files coming from ChEBI database.
It contains one variable :
updaterMap
: A map containing all available updaters, where the key is the file format, and the value is the respective updater.
The class defines two public methods, implementing methods from an interface :
createUpdater
- Provides the appropriate updaters for the “chebi” community in the given file format
This implementation of the interface method createUpdater
is responsible for
creating and providing a updater based on the specified format for the chebi
community.
Currently, it supports two formats : MOL files or PNG images
It follows these steps :
Check the
updaterMap
for the updater corresponding to the provided format.If a updater is found, return the updater.
If no updater is found for the format, log an error and throw an
InvalidFormatException
.
This method requires one parameter :
format
: The format of the desired file.
It returns a ChebiDataUpdater
object corresponding to the specified format.
updateFile
- Updates a file coming from ChEBI database based on its format
This implementation of the interface method updateFile
is responsible for
updating a file coming from ChEBI database in the S3 storage.
It follows these steps :
Use the
createUpdater
method to get the appropriate updater for the file format.Retrieve the ChEBI ID from the HTTP headers and checks if it exists.
Updates the desired ChEBI file using a
ChebiDataUpdater
.
This method requires three parameters :
format
: The format of the desired file.inchiKey
: The InChI Key associated with the file.headers
: The HTTP response headers.
It doesn’t return anything.
Implementation.Readers Package
The Implementation.Readers
package contains the readers classes.

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
.
It contains two variables :
logger
: The local logger.s3Service
: The service used for communication with S3 storage.
The class contains one protected constructor :
Reader
- Instantiates the reader with the necessary dependencies
The Reader
constructor is used to instantiate the service that will communicate with the S3 Storage.
It initialize the service
variable with the provided S3Service instance.
The constructor requires one parameter :
service
: An instance of theS3Service
, which handles the communication with the S3 Storage.
It doesn’t return anything.
The class defines one public abstract method, which is implemented in the subclasses :
extractMetadata
- Extracts metadata directly from the file’s byte array
The method extractMetadata
extracts metadata from the file represented as byte array.
It is implemented in :
MolReader Class : To extract metadata from MOL files.
PngReader Class : To extract metadata from PNG images.
It also has two public methods :
getFileContent
- Retrieve the file from S3 Storage along with its metadata
The getFileContent
method retrieves the file from S3 storage as
content, along with its extracted metadata formatted in the response HTTP headers.
It follows these steps :
Fetch the file from S3 storage as a byte array.
Use the
processMetadataFromFile
method fromMetadataProcessor
class to extract metadata from the file and update the response headers.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
- Retrieve the file URL from S3 Storage along with its metadata
The getUrl
method retrieves the file from S3 storage as a URL,
extracts metadata, along with its extracted metadata formatted in the response HTTP headers.
It follows these steps :
Retrieve the URL of the file from S3 storage.
Use the
processMetadataFromUrl
method fromMetadataProcessor
class to extract metadata from the URL and update the response headers.Return the file URL 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.
PngReader Class (Subclass of Reader Abstract Class)
The
PngReader
class is a subclass of theReader
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.The class contains one constructor :
PngReader
- Instantiates the PNG reader with the necessary dependenciesThe
PngReader
constructor is used to instantiate the service that will communicate with the S3 Storage in theReader
class for the PNG format.The constructor requires one parameter :
service
: An instance of theS3Service
, which handles the communication with the S3 Storage.It doesn’t return anything.
It includes one public method, implementing a parent abstract method :
extractMetadata
- Extracts metadata from the PNG imageThis implementation of the abstract method
extractMetadata
is responsible for extracting metadata from a PNG image and formats it as JSON.It follows these steps :
Read the file bytes as a PNG image.
Extract the metadata and returns them formatted in JSON.
The method requires one parameter :
file
: A byte array representing the PNG image.It returns a Java
JSONObject
containing the extracted metadata.It also includes one private method :
parseXmlMetadata
- Parses the PNG metadata from XML format into a JSON objectThe method
parseXmlMetadata
parses the PNG metadata from XML format into a JSON object. It identifies the specific XML layer (“tEXtEntry”) where custom metadata is stored in the PNG file, extracts each key-value pair, and converts them into a JSON format.It follows these steps :
Extracts the relevant metadata from the specific layer where they are stored (
tEXtEntry
).Formats the metadata into a JSON object, associating each key with its corresponding value.
Returns the JSON object containing all the custom image metadata.
The method requires one parameter :
imageMetadata
: TheIIOMetadata
instance containing image metadata in XML format.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.
The class contains one constructor :
MolReader
- Instantiates the MOL reader with the necessary dependencies
The MolReader
constructor is used to instantiate the service that will communicate with the S3 Storage
in the Reader
class for the MOL format.
The constructor requires one parameter :
service
: An instance of theS3Service
, which handles the communication with the S3 Storage.
It doesn’t return anything.
It includes one public method, implementing a parent abstract method :
extractMetadata
- Extracts metadata from the MOL file
This implementation of the abstract method extractMetadata
is responsible for
extracting metadata from a MOL file and formats it as JSON.
It follows these steps :
Read the file bytes as a String.
Extract the metadata that are on the first three lines and returns them formatted in JSON.
The method requires one parameter :
file
: A byte array representing the MOL file.
It returns a Java JSONObject
containing the extracted metadata.
It also includes one private method :
parseMolMetadata
- Parses metadata from the first three lines of the MOL file content
The method parseMolMetadata
parses the first three lines of a MOL file to extract metadata.
It then converts them into a JSON format.
It follows these steps :
Parses the first three lines of the MOL file.
Extracts the relevant metadata from them and checks if they exist and follow the supported syntax.
Formats the metadata into a JSON object, associating each key with its corresponding value.
Returns the JSON object containing all the custom file metadata.
Note
The metadata from the MOL file must use the following syntax (valid only for chebi
community).
YYYY-MM-DD ChEBI ID
Source
License
The method requires one parameter :
mol
: The string representation of the MOL file content.
It returns a Java JSONObject
containing the extracted metadata.
Implementation.Services Package
The Implementation.Services
package contains the services used in the application.

CompoundsService Class
The CompoundsService
class is a service use for retrieving chemical compound files 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 as a URL.
Additionally, the service checks if a requested file is outdated — defined as being older than one month — and updates it if necessary.
The update method varies by community :
For the
chebi
community, files are updated by querying the ChEBI website.
It has six variables :
logger
: The local logger.
maxLifetime
: Number of months before a file becomes outdated.
headers
: HTTP headers for the response (with associated Getter and Setter methods).
pathDirector
: Director class responsible for building the path of the requested file.
updaterFactory
: Factory to update files, if there are outdated, based on their format.
readerFactory
: Factory to retrieve files from S3 Storage based on their format.
The class contains one constructor :
CompoundsService
- Instantiates the service with the necessary dependencies
The CompoundsService
constructor instantiates the path director and the reader and updater factories used to
retrieve/update files.
It initialize the pathDirector
, updaterFactory
and readerFactory
variables.
The constructor requires three parameters :
pathDirector
: ThePathDirector
instance used to build the path of the requested file.updaterFactory
: TheDataUpdaterFactory
instance used to update the file if it is outdated.readerFactory
: TheReaderFactory
instance used to retrieve the file from the S3 storage.
It doesn’t return anything.
It includes two public methods :
getMolFile
- Retrieve a MOL file of a molecule from the S3 Storage
The method getMolFile
retrieves a molecule’s MOL file from S3
storage. It sets appropriate headers for the response, checks if
the MOL file is outdated (older than 1 month), updates it if necessary
and returns it as either a direct resource
or a URL
, based on
the specified output type.
It follows these steps :
Sets the generic headers :
Content-Type
header toplain/text
so that the MOL file is returned as a text, and theAccess-Control-Allow-Headers
/Access-Control-Expose-Headers
to enables the exposition of custom headers used to return metadata with the response.Builds 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).Retrieves the MOL file according to the specified
outputType
.Checks if the MOL file is outdated and updates it if necessary.
Returns the MOL file either :
as a URL (e.g https://unh-metabocloud-resources.s3.mesocentre.uca.fr/mol/chebi/RYYVLZVUVIJVGH-UHFFFAOYSA-N.mol). The
Content-Type
header is then overridden bytext/plain
.or directly as text content.
It also retrieves formats metadata associated with the file in response headers.
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 — eitherurl
to return a URL orresource
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
- Retrieve a PNG image of a molecule from the S3 Storage
The method getPngImage
enables retrieves a molecule’s PNG image
from S3 storage. It sets appropriate headers for the response, checks if
the PNG image is outdated (older than 1 month), updates it if necessary
and returns it as either a direct resource
or a URL
,
based on the specified output type.
It follows several steps :
Sets the generic headers :
Content-Type
header toimage/png
so that the file is returned as a PNG image, theAccess-Control-Allow-Headers
/Access-Control-Expose-Headers
to enables the exposition of custom headers used to return metadata with the response and the customX-Metadata-Image-Size
header to indicate the size of the PNG image returned.Builds 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).Retrieves the PNG image according to the specified
outputType
.Checks if the PNG image is outdated and updates it if necessary.
Returns the PNG image either :
as a URL (e.g https://unh-metabocloud-resources.s3.mesocentre.uca.fr/png/chebi/medium/RYYVLZVUVIJVGH-UHFFFAOYSA-N_350.png). The
Content-Type
header is then overridden bytext/plain
.or directly as an image content.
It also retrieves formats metadata associated with the image in response headers.
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 (eithersmall
,medium
orlarge
).inchiKey
: The InChI key of the molecule whose PNG image is to be retrieved.outputType
: The desired output type — eitherurl``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.
It also includes four private methods :
addHeaders
- Add generic HTTP headers
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 tonull
for other formats).
It doesn’t return anything.
checkAndUpdateIfOutdated
- Check if a file is outdated and update it if necessary
The method checkAndUpdateIfOutdated
is responsible for checking if a file is outdated
(older than one month) and updating it if necessary.
It follows several steps :
Retrieves the creation date of the file from the custom headers
X-METADATA-CREATION-DATE
.Check if the file is outdated based on this creation date.
Update the file if it is outdated.
It requires three parameters :
community
: The community from which the file was retrieved.format
: The format of the file.inchiKey
: The InChI Key of the molecule.
It doesn’t return anything.
isOutdated
- Determine if a file is outdated
The method isOutdated
is responsible for determining if a file is outdated (over than 1-month-old)
based on its creation date.
It follows several steps :
Converts the creation date into a Date format.
Sets up a calendar of 1 month.
Check if the creation date is older than 1 month, if it is returns True, otherwise returns False.
It requires one parameter :
creationDate
: The creation date of the file.
It returns True if the file is outdated, otherwise it returns False.
updateBasedOnCommunity
- Updates the file based on the specified community
The method updateBasedOnCommunity
is responsible for updating the file based on the specified community.
It will delegate the update operation to a DataUpdaterFactory specific to a community for any molecule file identified by the provided inchiKey.
Currently, this method only supports the chebi
community.
It requires three parameters :
community
: The community from which the file was retrieved.format
: The format of the file.inchiKey
: The InChI Key of the molecule.
It doesn’t return anything.
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, adding, deleting objects and generating public URLs for stored files.
It has three variables :
logger
: The local logger.BUCKET_NAME
: Constant indicating the bucket name (unh-metabocloud-resources
).s3Client
: The configured S3 client (autowired).
The class includes four public methods :
getObject
- Retrieves an object from the S3 Storage
The getObject
method retrieves an object from the S3 storage as a byte array
using a path as key.
It follows these steps :
Builds a request to get the object from the S3 bucket using the provided key.
Reads the content of the object as a byte array.
This method requires one parameter :
key
: The key to retrieve the desired object from the S3 storage (here a path).
It returns a byte array containing the S3 object data.
deleteObject
- Deletes an object from the S3 Storage
The deleteObject
method deletes an object from the S3 storage from its path.
it builds a request to delete the object from the S3 bucket using the provided key.
It requires one parameter :
key
: The key to delete the desired object from the S3 storage.
It doesn’t return anything.
putObject
- Adds an object to the S3 Storage
The putObject
method adds an object to the S3 storage.
It follows these steps :
Builds a request to put the object into the S3 bucket with the specified key.
Uploads the content of the object as a byte array.
It requires two parameters :
key
: The key of the object to add in the S3 storage.resource
: The resource object to be added.
It doesn’t return anything.
getPublicUrl
- Retrieves the public URL of an S3 object
The method getPublicUrl
retrieves the public URL of an S3 object
using a path as key.
It follows these steps :
Checks the existence of the object in the S3 storage by requesting the metadata.
Generates and returns the public URL for the specified object.
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.
Implementation.Updaters Package
The Implementation.Updaters
package contains the updaters classes.

Implementation.Updaters.Data Package
The Implementation.Updaters.Data
package contains the updaters used to update files by querying their respective sources.
DataUpdater Interface
DataUpdater
is an interface which regroup classes used to update the S3 files.
Currently, it regroups the updaters classes for the community :
chebi
: through the ChebiDataUpdater Abstract Class, for two formats, PNG (ChebiPngDataUpdater
) and MOL (ChebiMolDataUpdater
)
ChebiDataUpdater Abstract Class
ChebiDataUpdater
is an abstract class designed to update the files in the S3 Storage coming from the ChEBI database.
It has one variable :
logger
: The local logger.
The class defines one public abstract method, which is implemented in the subclasses :
update
- Updates a ChEBI file in the S3 Storage
The method update
updates a file coming from the ChEBI database in the S3 Storage.
It is implemented in :
ChebiPngDataUpdater Class : To update PNG images coming from ChEBI database.
ChebiMolDataUpdater Class : To update MOL files coming from ChEBI database.
It also has one private method :
getCompoundStructureInfo
- Retrieves the chemical structure information of a compound from ChEBI.
The getCompoundStructureInfo
method retrieves information on the chemical structure of a compound
using the ChEBI database web service, based on the ChEBI identifier supplied.
It follow these steps :
Request the ChEBI Web Service endpoint “/getCompleteEntity” with the ChEBI ID.
Parse the XML responses to extract the InChI Key and the MOL file into a LiteCompound object.
Return the LiteCompound object.
The method requires one parameter :
chebiId
: The ChEBI ID of the compound whose structure information is to be retrieved.
It returns a LiteCompound object containing the InChI Key and MOL file associated to the ChEBI ID.
ChebiPngDataUpdater Class
The ChebiPngDataUpdater
class is a subclass of ChebiDataUpdater
abstract class.
It is responsible for updating PNG images originating from ChEBI database in the S3 storage.
It retrieves a large compound image from ChEBI database, resizes it in two smaller sizes, adds metadata, and uploads them to the S3.
It contains two variables :
writer
: ThePngMetadataWriter
instance used to write metadata.s3Updater
: ThePngS3Updater
instance used to update PNG images.
The class contains one constructor :
ChebiPngDataUpdater
- Instantiates the PNG ChEBI updater with the necessary dependencies
The ChebiPngDataUpdater
constructor is used to instantiate the metadata writer and the S3 updater for PNG images.
The constructor requires two parameters :
writer
: ThePngMetadataWriter
instance used to write metadata in PNG images.s3Updater
: ThePngS3Updater
instance used to update PNG images.
It doesn’t return anything.
It includes one public method, implementing a parent abstract method :
update
- Updates a ChEBI PNG image in the S3 Storage
This implementation of the abstract method update
is responsible for
updating a ChEBI PNG image in the S3 storage according to its ChEBI ID.
It follows these steps :
Retrieve the InChI Key associated with the ChEBI ID.
Still with the ChEBI ID, retrieve PNG images in three different sizes after writing their metadata.
Update in the S3 Storage.
The method requires two parameters :
chebiId
: The ChEBI ID of the compound whose images need to be updated.originalInchiKey
: The original InChIKey of the compound used to locate the old images.
It doesn’t return anything.
It also includes one private method :
getPngImages
- Retrieves the PNG images in different sizes after writing their metadata.
The method getPngImages
retrieves a large PNG image for a given ChEBI ID, resizes them in two smaller sizes (medium and small),
and write metadata for the three images.
It follows these steps :
Requests the ChEBI Website with the ChEBI ID to retrieve the compound
large
PNG image (700 x 700 px).Resizes this image to obtain two more images in
medium
(350 x 350 px) andsmall
sizes (50 x 50 px).Write metadata directly in all three PNG images.
Return the three images as a list of
Resource
objects.
The method requires one parameter :
chebiId
: The ChEBI ID used to retrieve the compound PNG image.
It returns a list of Resource
objects representing the images.
ChebiMolDataUpdater Class
The ChebiMolDataUpdater
class is a subclass of ChebiDataUpdater
abstract class.
It is responsible for updating MOL files originating from ChEBI database in the S3 storage.
It retrieves the MOL file from ChEBI database, adds metadata, and uploads it to the S3.
It contains two variables :
writer
: TheMolMetadataWriter
instance used to write metadata.s3Updater
: TheMolS3Updater
instance used to update MOL files.
The class contains one constructor :
ChebiMolDataUpdater
- Instantiates the MOL ChEBI updater with the necessary dependencies
The ChebiMolDataUpdater
constructor is used to instantiate the metadata writer and the S3 updater for MOL files.
The constructor requires two parameters :
writer
: TheMolMetadataWriter
instance used to write metadata in MOL files.s3Updater
: TheMolS3Updater
instance used to update MOL files.
It doesn’t return anything.
It includes one public method, implementing a parent abstract method :
update
- Updates a ChEBI MOL file in the S3 Storage
This implementation of the abstract method update
is responsible for
updating a ChEBI MOL file in the S3 storage according to its ChEBI ID.
It follows these steps :
Retrieve the InChI Key and the MOL file associated with the ChEBI ID through the ChEBI Web Service.
Writes metadata in the MOL file.
Update in the S3 Storage.
The method requires two parameters :
chebiId
: The ChEBI ID of the compound whose MOL file need to be updated.originalInchiKey
: The original InChIKey of the compound used to locate the old MOL file.
It doesn’t return anything.
Implementation.Utils Package
The Implementation.Utils
package contains the classes containing utils method needed in other classes.

ImageResizer Class
ImageResizer
is a utils class responsible for resizing images to specified dimensions while preserving quality.
It has one variables :
logger
: The local logger.
The class includes one public static method :
resize
- Resizes an image to specified dimensions.
The static method resize
is responsible for resizing images into a specified dimension,
while maintaining its quality. The width and the height of the image are set to the same dimensions.
It follows these steps :
Resize the original image
Create a new image and draws the resized image onto it.
Convert the image into a Byte array for easier processing.
Return the image as a Byte Array Resource.
The method requires two parameters :
originalImage
: The original image to be resized.size
: The new width and height (both are set to the same value) for the resized image in pixel.
It returns a resized image with the specified dimension.
MetadataProcessor Class
The MetadataProcessor
class is responsible for processing metadata extracted from files
or their URLs and updating HTTP response headers with the extracted metadata.
It contains one variable :
logger
: The local logger.
The class defines two public static methods :
processMetadataFromFile
- Extracts metadata from a file’s byte array and updates the response headers with the extracted metadata
The processMetadataFromFile
method extracts metadata from a file’s byte array using
the metadata extractor function specific to the format of the file requested. It then
updates the HTTP response headers with the extracted metadata.
It follows these steps :
Apply the metadata extractor function to extract metadata from the byte array.
If metadata is extracted, call
updateHeaders
to add the metadata to the response headers.If no metadata is extracted, log a warning message.
This method requires three parameters :
fileBytes
: The file represented as a byte array.headers
: The HTTP response headers.metadataExtractor
: A function that extracts metadata from the byte array.
It doesn’t return anything.
processMetadataFromUrl
- Extracts metadata from a file located at a URL and updates the response headers with the extracted metadata
The processMetadataFromUrl
method processes metadata from a file located at a URL using
the metadata extractor function specific to the format of the file requested. It then
updates the HTTP response headers with the extracted metadata.
It follows these steps :
Open the provided URL and read its content as a byte array.
Apply the metadata extractor function to extract metadata from the byte array.
If metadata is extracted, call
updateHeaders
to add the metadata to the response headers.If an error occurs while reading the URL or no metadata is extracted, log an error or warning message.
This method requires three parameters :
url
: The URL of the file.headers
: The HTTP response headers.metadataExtractor
: A function that extracts metadata from the byte array.
It doesn’t return anything.
It also includes one private method :
updateHeaders
- Updates the HTTP response headers with metadata
The updateHeaders
method adds metadata extracted from a file or URL to the HTTP response headers.
It follows these steps :
Iterate over the metadata’s keys and values.
Add each key-value pair to the response headers.
This method requires two parameters :
metadata
: AJSONObject
containing the extracted metadata.headers
: The HTTP response headers.
It doesn’t return anything.
Implementation.Writers Package
The Implementation.Writers
package contains the writers classes.

Implementation.Writers.Metadata Package
The Implementation.Writers.Metadata
package contains classes that handle the embedding of metadata into various resource types.
Currently, it includes metadata writers for PNG images and MOL files.
MetadataWriter Interface
The MetadataWriter
interface is designed for embedding metadata into a resource.
It includes one public method to implement :
writeMetadata
- Writes metadata into a resource
The method writeMetadata
is responsible for embedding metadata into the provided resource.
It is implemented in :
PngMetadataWriter : to write metadata into a PNG image.
ChebiMolMetadataWriter : to write metadata in a MOL file coming specifically from ChEBI database.
MolMetadataWriter Abstract Class (Implements MetadataWriter Interface)
The MolMetadataWriter
is an abstract subclass of the MetadataWriter
interface.
It designed to embed metadata into MOL files.
The class defines one abstract method, implemented in the subclasses :
writeMetadata
- Writes metadata into a MOL file.
This implementation of the method writeMetadata
is responsible for embedding metadata into a MOL file.
It is implemented in :
ChebiMolMetadataWriter : to write metadata in a MOL file coming specifically from ChEBI database.
ChebiMolMetadataWriter Class (Subclass of MolMetadataWriter Abstract Class)
The ChebiMolMetadataWriter
class is a concrete implementation of the MolMetadataWriter
abstract class.
It embeds metadata into MOL files coming specifically from ChEBI database.
The class defines one public method, implementing the parent abstract method:
writeMetadata
- Writes metadata into a MOL file coming specifically from ChEBI database
This implementation of the method writeMetadata
is responsible for writing metadata into a MOL file coming specifically from ChEBI database.
It modifies the first three lines of a MOL file to include ChEBI-specific metadata.
It follows these steps :
Reads the MOL file’s content into a string.
Updates the first three lines with :
Line 1 : The creation date (YYYY-MM-DD) and the CHEBI ID separated by a tab.
Line 2 : The data source.
Line 3 : The data license.
Writes the updated content back to a resource.
The method requires two parameters :
resource
: AByteArrayResource
containing the original MOL file.metadata
: AJSONObject
with key-value metadata pairs specific to ChEBI community.
It returns a ByteArrayResource
containing the MOL file updated with the metadata.
PngMetadataWriter Class (Implements MetadataWriter Interface)
The PngMetadataWriter
is a concrete implementation of the MetadataWriter
interface.
It embeds metadata into PNG image for all communities.
The class defines one public method, implementing the parent interface’s abstract method :
writeMetadata
- Writes metadata into a PNG image
This implementation of the writeMetadata
method is responsible for wrinting metadata into a PNG file.
It follows these steps :
Reads the PNG file as a
BufferedImage
.Creates metadata nodes for each key-value pair in the provided
JSONObject
.Embeds the metadata nodes into the image using the
javax_imageio_png_1.0
standard.Writes the updated image back to a new resource.
The method requires two parameters :
resource
: AByteArrayResource
containing the original PNG file.metadata
: AJSONObject
with key-value metadata pairs to embed.
It returns a ByteArrayResource
containing the PNG file updated with the metadata.
Models Package
The Models
package contains the models used in the application.

Models.Objects Package
The Models.Objects
package contains the object models used in the application.
LiteCompound Object
The LiteCompound
class is a simple data structure designed to hold information about a compound, including its InChI Key and its MOL file representation.
Each attribute is associated with a getter and setter methods.
This object contains the following attributes :
Attribute |
Description |
Type |
---|---|---|
|
The InChI Key associated with the compound. |
|
|
The MOL file associated with the compound. |
|
Models.Enums Package
The Models.Enums
package contains the enum models used in the application.
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.
This enum currently includes the following community :
CHEBI
: Represents the Chemical Entities of Biological Interest (ChEBI) database (“chebi”).
It includes one variable :
label
: A String that holds the label associated with the community.
This enum include one constructor :
Community
- Initializes the enum constant with its corresponding label
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.
It doesn’t return anything.
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
.
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.
It includes one variable :
label
: AString
that holds the label associated with the header key or value.
This enum include one constructor :
Headers
- Initializes the enum constant with its corresponding label
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.
It doesn’t return anything.
ImageSize Enum
The ImageSize
enumeration represents the available image sizes
within the application. This enum defines three specific sizes available
in the S3 storage.
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.
It includes one variable :
label
: A String that holds the label representing the size of the image in pixels.
This enum include one constructor :
ImageSize
- Initializes the enum constant with its corresponding label
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.
It doesn’t return anything.
IndexErrorMessages Enum
The IndexErrorMessages
enumeration centralizes specific error
messages that the application may return under various error
conditions.
This enum defines six constants, each representing a specific error scenario along with an associated error message :
INVALID_FORMAT
: Occurs when theformat
parameter provided by the user is invalid. The only acceptable values arepng
andmol
.“The parameter ‘format’ is invalid. Only ‘png’ and ‘mol’ are accepted. See the documentation for more details.”
INVALID_COMMUNITY
: Occurs when thecommunity
parameter provided by the user is invalid. The only acceptable value ischebi
.“The parameter ‘community’ is invalid. Only ‘chebi’ is accepted. See the documentation for more details.” -
INVALID_SIZE
: Occurs when thesize
parameter provided by the user is invalid. The only acceptable values aresmall
,medium
, andlarge
.“The parameter ‘size’ is invalid. Only ‘small’, ‘medium’ and ‘large’ are accepted. See the documentation for more details.”
INVALID_INCHI_KEY
: Occurs when theinchiKey
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 theoutputType
parameter provided by the user is invalid. The only acceptable values areresource
andurl
.“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.”
It includes one variable :
label
: A String representing the error message thrown by a specific error.
This enum include one constructor :
IndexErrorMessages
- Initializes the enum constant with its corresponding label
The IndexErrorMessages
constructor initializes the enum constant with its
corresponding error message.
It requires one parameter :
label
: The label representing the error message thrown by a specific error.
It doesn’t return anything.
OutputType Enum
The OutputType
defines the types of output that can be requested
from the application.
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”).
It includes one variable :
label
: A String that holds the label representing the output type.
This enum include one constructor :
OutputType
- Initializes the enum constant with its corresponding label
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.
It doesn’t return anything.