Class RequestController
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetInfo
(DungReasonerPost dungPost) Handles a POST request to retrieve information about the Dung reasoner services.handleRequest
(AbaReasonerPost AbaReasonerPost) Handles HTTP POST requests at the endpoint "/aba".handleRequest
(DeLPPost delpPost) Handles HTTP POST requests for Defeasible logic programming DeLP Reasoner operations.handleRequest
(DungReasonerPost dungReasonerPost) Handles HTTP POST requests for Dung Reasoner operations.handleRequest
(InconsistencyPost incmesPost) Handles HTTP POST requests for Inconsistency Measures operations.Handles HTTP POST requests for ping operations.
-
Constructor Details
-
RequestController
public RequestController()
-
-
Method Details
-
handleRequest
@PostMapping(value="/aba", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody AbaReasonerPost AbaReasonerPost) throws ParserException, IOException, org.json.JSONException, org.codehaus.jettison.json.JSONException Handles HTTP POST requests at the endpoint "/aba". Parses and processes the incoming JSON payload to perform various ABA reasoning commands. Supported commands are: - get_models: Return all models for a given semantics and beliefbase - get_model: Return some model for a given semantics and beliefbase - query: Query an assumption - semantics: Return supported semantics- Parameters:
AbaReasonerPost
- The request payload containing information for ABA reasoning.- Returns:
- A Response object containing the result of the ABA reasoning operation.
- Throws:
ParserException
- If there is an error while parsing the input data.IOException
- If there is an error reading or writing data.org.json.JSONException
- If there is an error with JSON processing.org.codehaus.jettison.json.JSONException
- If there is an error with Jettison JSON processing.
-
handleRequest
@PostMapping(value="/dung", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody DungReasonerPost dungReasonerPost) Handles HTTP POST requests for Dung Reasoner operations.This method processes requests with the endpoint "/dung" that have the specified content types for both request and response. It takes a DungReasonerPost object as the request body and returns a Response object as the response body.
The method checks the command (cmd) from the DungReasonerPost object and performs different operations based on the command. If the command is "info," it delegates the request to the getInfo method. If the command is "get_models" or "get_model," it processes the request using the DungTheory, AbstractExtensionReasoner, and other components. The result includes information about the execution time, answer, and status, which is encapsulated in a DungReasonerResponse object.
In case of a timeout during execution, the method sets the response status to "TIMEOUT" and includes the specified timeout duration. If any other exception occurs, the response status is set to "Error," and the method provides a generic response with a time of 0.0 and a null answer.
If the command is not recognized or not applicable, the method returns a default DungReasonerResponse.
- Parameters:
dungReasonerPost
- The DungReasonerPost object representing the request payload.- Returns:
- A Response object representing the response payload.
-
ping
@PostMapping(value="/ping", produces="application/json") @ResponseBody public Ping ping(@RequestBody Ping ping_Greeting) Handles HTTP POST requests for ping operations.This method processes requests with the endpoint "/ping" that have the specified content type for the request and response. It takes a Ping object as the request body and returns the same Ping object as the response body.
The method echoes the received Ping object, providing a simple way to test the connectivity or response of the service. The response contains the same information as the request, including the identifier (id) and content of the Ping object.
- Parameters:
ping_Greeting
- The Ping object representing the request payload.- Returns:
- A Ping object representing the response payload.
-
getInfo
@PostMapping(value="/info", produces="application/json") @ResponseBody public DungServicesInfoResponse getInfo(@RequestBody DungReasonerPost dungPost) Handles a POST request to retrieve information about the Dung reasoner services. This method constructs a response with general information about the services available, such as available semantics and commands. The input data includes email and other user-specific details, which are used to tailor the response.- Parameters:
dungPost
- ADungReasonerPost
object containing the data sent by the client in the POST request body. This typically includes identifiers like email that can be used to personalize or secure the response.- Returns:
- A
DungServicesInfoResponse
object containing a variety of information about the services, including available semantics and commands supported by the Dung reasoner. The response is structured for JSON representation suitable for client-side consumption.
-
handleRequest
@PostMapping(value="/delp", produces="application/json", consumes="application/json") @ResponseBody public Response handleRequest(@RequestBody DeLPPost delpPost) Handles HTTP POST requests for Defeasible logic programming DeLP Reasoner operations. This method processes requests with the endpoint "/delp" that have the specified content types for both request and response. It takes a DeLPPost object as the request body and returns a DelpResponse object as the response body. The method prints the received DelpPost object to the console for debugging purposes. It then constructs a DeLPResponse object with default values, prepares the DelpReasoner, and executes it asynchronously using a separate thread. The result includes information about the execution time, answer, and status, encapsulated in a DelpResponse object. If the execution times out, the method sets the response status to "TIMEOUT" and includes the specified timeout duration. If a parsing exception occurs during knowledge base or query parsing, the method throws a JSONException with an appropriate error message. If any other unexpected exception occurs, the method prints the stack trace and throws a JSONException with a generic error message.- Parameters:
delpPost
- The DelpPost object representing the request payload.- Returns:
- A Response object representing the response payload.
- Throws:
org.json.JSONException
- If there is a parsing error or an unexpected error occurs during processing.
-
handleRequest
@PostMapping(value="/incmes", produces="application/json") @ResponseBody public Response handleRequest(@RequestBody InconsistencyPost incmesPost) Handles HTTP POST requests for Inconsistency Measures operations. This method processes requests with the endpoint "/incmes" that have the specified content type for the request and response. It takes an InconsistencyPost object as the request body and returns a Response object as the response body. The method initializes an InconsistencyValueResponse object for the response. It then checks the command (cmd) from the InconsistencyPost object and delegates the request to specific methods based on the command. If the command is "value," it calls the handleGetICMESValue method. If the command is "measures," it calls the handleGetMeasures method. Any exceptions that occur during the processing are caught, and a generic error message is printed to the console. If the command is not recognized or not applicable, the method returns a default InconsistencyValueResponse.- Parameters:
incmesPost
- The InconsistencyPost object representing the request payload.- Returns:
- A Response object representing the response payload.
-