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 Stringprivate static final Stringprivate final com.fasterxml.jackson.core.JsonFactoryprivate static final Stringprivate static final org.slf4j.Loggerprivate static final Stringprivate final TextChecker -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidensureGetMethod(HttpExchange httpExchange, String url) private voidensurePostMethod(HttpExchange httpExchange, String url) private AnnotatedTextgetAnnotatedTextFromJson(com.fasterxml.jackson.databind.JsonNode data) private AnnotatedTextgetAnnotatedTextFromString(com.fasterxml.jackson.databind.JsonNode data, String text) (package private) StringgetConfigurationInfo(Language lang, HTTPServerConfig config) (package private) String(package private) Stringprivate UserLimitsgetUserLimits(Map<String, String> parameters, HTTPServerConfig config) private voidhandleCheckRequest(HttpExchange httpExchange, Map<String, String> parameters, ErrorRequestLimiter errorRequestLimiter, String remoteAddress, HTTPServerConfig config) private voidhandleGetConfigurationInfoRequest(HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) private voidhandleGetUserInfoRequest(HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) private voidhandleIpLogMatch(HttpExchange httpExchange, String remoteAddress, Map<String, String> parameters) private voidhandleLanguagesRequest(HttpExchange httpExchange) private voidhandleMaxTextLengthRequest(HttpExchange httpExchange, HTTPServerConfig config) private voidhandleRefreshUserInfoRequest(HttpExchange httpExchange, Map<String, String> params, HTTPServerConfig config) (package private) voidhandleRequest(String path, HttpExchange httpExchange, Map<String, String> parameters, ErrorRequestLimiter errorRequestLimiter, String remoteAddress, HTTPServerConfig config) private voidhandleRuleExamplesRequest(HttpExchange httpExchange, Map<String, String> params) private voidhandleSoftwareInfoRequest(HttpExchange httpExchange) private voidhandleWordAddRequest(HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) private voidhandleWordDeleteRequest(HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) private voidhandleWordsRequest(HttpExchange httpExchange, Map<String, String> params, HTTPServerConfig config) private voidsendJson(HttpExchange httpExchange, StringWriter sw) private voidwriteListResponse(String fieldName, List<String> words, HttpExchange httpExchange) private voidwriteResponse(String fieldName, boolean added, HttpExchange httpExchange)
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
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, HttpExchange httpExchange, Map<String, String> parameters, ErrorRequestLimiter errorRequestLimiter, String remoteAddress, HTTPServerConfig config) throws Exception- Throws:
Exception
-
handleLanguagesRequest
- Throws:
IOException
-
handleMaxTextLengthRequest
private void handleMaxTextLengthRequest(HttpExchange httpExchange, HTTPServerConfig config) throws IOException - Throws:
IOException
-
handleGetConfigurationInfoRequest
private void handleGetConfigurationInfoRequest(HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) throws IOException- Throws:
IOException
-
handleSoftwareInfoRequest
- Throws:
IOException
-
handleCheckRequest
private void handleCheckRequest(HttpExchange httpExchange, Map<String, String> parameters, ErrorRequestLimiter errorRequestLimiter, String remoteAddress, HTTPServerConfig config) throws Exception- Throws:
Exception
-
handleIpLogMatch
private void handleIpLogMatch(HttpExchange httpExchange, String remoteAddress, Map<String, String> parameters) -
handleWordsRequest
private void handleWordsRequest(HttpExchange httpExchange, Map<String, String> params, HTTPServerConfig config) throws Exception- Throws:
Exception
-
handleWordAddRequest
private void handleWordAddRequest(HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) throws Exception- Throws:
Exception
-
handleWordDeleteRequest
private void handleWordDeleteRequest(HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) throws Exception- Throws:
Exception
-
handleRuleExamplesRequest
private void handleRuleExamplesRequest(HttpExchange httpExchange, Map<String, String> params) throws Exception- Throws:
Exception
-
handleRefreshUserInfoRequest
private void handleRefreshUserInfoRequest(HttpExchange httpExchange, Map<String, String> params, HTTPServerConfig config) throws Exception- Throws:
Exception
-
handleGetUserInfoRequest
private void handleGetUserInfoRequest(HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) throws Exception- Throws:
Exception
-
ensureGetMethod
-
ensurePostMethod
-
getUserLimits
-
writeResponse
private void writeResponse(String fieldName, boolean added, HttpExchange httpExchange) throws IOException - Throws:
IOException
-
writeListResponse
private void writeListResponse(String fieldName, List<String> words, HttpExchange httpExchange) throws IOException - Throws:
IOException
-
sendJson
- Throws:
IOException
-
getAnnotatedTextFromString
private AnnotatedText getAnnotatedTextFromString(com.fasterxml.jackson.databind.JsonNode data, String text) -
getAnnotatedTextFromJson
-
getLanguages
- Throws:
IOException
-
getSoftwareInfo
- Throws:
IOException
-
getConfigurationInfo
- Throws:
IOException
-