Package org.languagetool.server
Class ApiV2
java.lang.Object
org.languagetool.server.ApiV2
Handle requests to
/v2/
of the HTTP API.- Since:
- 3.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
private static final String
private final com.fasterxml.jackson.core.JsonFactory
private static final String
private static final String
private final TextChecker
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
ensureGetMethod
(com.sun.net.httpserver.HttpExchange httpExchange, String url) private void
ensurePostMethod
(com.sun.net.httpserver.HttpExchange httpExchange, String url) private org.languagetool.markup.AnnotatedText
getAnnotatedTextFromJson
(com.fasterxml.jackson.databind.JsonNode data) private org.languagetool.markup.AnnotatedText
getAnnotatedTextFromString
(com.fasterxml.jackson.databind.JsonNode data, String text) (package private) String
getConfigurationInfo
(org.languagetool.Language lang, HTTPServerConfig config) (package private) String
private @NotNull UserLimits
getUserLimits
(Map<String, String> parameters, HTTPServerConfig config) private void
handleCheckRequest
(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters, ErrorRequestLimiter errorRequestLimiter, String remoteAddress) private void
handleGetConfigurationInfoRequest
(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) private void
handleLanguagesRequest
(com.sun.net.httpserver.HttpExchange httpExchange) private void
handleLogRequest
(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters) private void
handleMaxTextLengthRequest
(com.sun.net.httpserver.HttpExchange httpExchange, HTTPServerConfig config) (package private) void
handleRequest
(String path, com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters, ErrorRequestLimiter errorRequestLimiter, String remoteAddress, HTTPServerConfig config) private void
handleRuleExamplesRequest
(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> params) private void
handleWordAddRequest
(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) private void
handleWordDeleteRequest
(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) private void
handleWordsRequest
(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> params, HTTPServerConfig config) private void
sendJson
(com.sun.net.httpserver.HttpExchange httpExchange, StringWriter sw) private void
writeListResponse
(String fieldName, List<UserDictEntry> words, com.sun.net.httpserver.HttpExchange httpExchange) private void
writeResponse
(String fieldName, boolean added, com.sun.net.httpserver.HttpExchange httpExchange)
-
Field Details
-
JSON_CONTENT_TYPE
- See Also:
-
TEXT_CONTENT_TYPE
- See Also:
-
ENCODING
- See Also:
-
textChecker
-
allowOriginUrl
-
factory
private final com.fasterxml.jackson.core.JsonFactory factory
-
-
Constructor Details
-
ApiV2
ApiV2(TextChecker textChecker, String allowOriginUrl)
-
-
Method Details
-
handleRequest
void handleRequest(String path, com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters, ErrorRequestLimiter errorRequestLimiter, String remoteAddress, HTTPServerConfig config) throws Exception- Throws:
Exception
-
handleLanguagesRequest
private void handleLanguagesRequest(com.sun.net.httpserver.HttpExchange httpExchange) throws IOException - Throws:
IOException
-
handleMaxTextLengthRequest
private void handleMaxTextLengthRequest(com.sun.net.httpserver.HttpExchange httpExchange, HTTPServerConfig config) throws IOException - Throws:
IOException
-
handleGetConfigurationInfoRequest
private void handleGetConfigurationInfoRequest(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) throws IOException- Throws:
IOException
-
handleCheckRequest
private void handleCheckRequest(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters, ErrorRequestLimiter errorRequestLimiter, String remoteAddress) throws Exception- Throws:
Exception
-
handleWordsRequest
private void handleWordsRequest(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> params, HTTPServerConfig config) throws Exception- Throws:
Exception
-
handleWordAddRequest
private void handleWordAddRequest(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) throws Exception- Throws:
Exception
-
handleWordDeleteRequest
private void handleWordDeleteRequest(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) throws Exception- Throws:
Exception
-
handleRuleExamplesRequest
private void handleRuleExamplesRequest(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> params) throws Exception- Throws:
Exception
-
ensureGetMethod
-
ensurePostMethod
-
getUserLimits
@NotNull private @NotNull UserLimits getUserLimits(Map<String, String> parameters, HTTPServerConfig config) -
writeResponse
private void writeResponse(String fieldName, boolean added, com.sun.net.httpserver.HttpExchange httpExchange) throws IOException - Throws:
IOException
-
writeListResponse
private void writeListResponse(String fieldName, List<UserDictEntry> words, com.sun.net.httpserver.HttpExchange httpExchange) throws IOException - Throws:
IOException
-
sendJson
private void sendJson(com.sun.net.httpserver.HttpExchange httpExchange, StringWriter sw) throws IOException - Throws:
IOException
-
handleLogRequest
private void handleLogRequest(com.sun.net.httpserver.HttpExchange httpExchange, Map<String, String> parameters) throws IOException- Throws:
IOException
-
getAnnotatedTextFromString
private org.languagetool.markup.AnnotatedText getAnnotatedTextFromString(com.fasterxml.jackson.databind.JsonNode data, String text) -
getAnnotatedTextFromJson
private org.languagetool.markup.AnnotatedText getAnnotatedTextFromJson(com.fasterxml.jackson.databind.JsonNode data) -
getLanguages
- Throws:
IOException
-
getConfigurationInfo
String getConfigurationInfo(org.languagetool.Language lang, HTTPServerConfig config) throws IOException - Throws:
IOException
-