Package org.languagetool.server
Class ApiV2
- java.lang.Object
-
- org.languagetool.server.ApiV2
-
class ApiV2 extends java.lang.ObjectHandle requests to/v2/of the HTTP API.- Since:
- 3.4
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringallowOriginUrlprivate static java.lang.StringENCODINGprivate com.fasterxml.jackson.core.JsonFactoryfactoryprivate static java.lang.StringJSON_CONTENT_TYPEprivate static java.lang.StringTEXT_CONTENT_TYPEprivate TextCheckertextChecker
-
Constructor Summary
Constructors Constructor Description ApiV2(TextChecker textChecker, java.lang.String allowOriginUrl)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidensureGetMethod(com.sun.net.httpserver.HttpExchange httpExchange, java.lang.String url)private voidensurePostMethod(com.sun.net.httpserver.HttpExchange httpExchange, java.lang.String url)private org.languagetool.markup.AnnotatedTextgetAnnotatedTextFromJson(com.fasterxml.jackson.databind.JsonNode data)private org.languagetool.markup.AnnotatedTextgetAnnotatedTextFromString(com.fasterxml.jackson.databind.JsonNode data, java.lang.String text)(package private) java.lang.StringgetConfigurationInfo(org.languagetool.Language lang, HTTPServerConfig config)(package private) java.lang.StringgetLanguages()private @NotNull UserLimitsgetUserLimits(java.util.Map<java.lang.String,java.lang.String> parameters, HTTPServerConfig config)private voidhandleCheckRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters, ErrorRequestLimiter errorRequestLimiter, java.lang.String remoteAddress)private voidhandleGetConfigurationInfoRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters, HTTPServerConfig config)private voidhandleLanguagesRequest(com.sun.net.httpserver.HttpExchange httpExchange)private voidhandleLogRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters)private voidhandleMaxTextLengthRequest(com.sun.net.httpserver.HttpExchange httpExchange, HTTPServerConfig config)(package private) voidhandleRequest(java.lang.String path, com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters, ErrorRequestLimiter errorRequestLimiter, java.lang.String remoteAddress, HTTPServerConfig config)private voidhandleRuleExamplesRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> params)private voidhandleWordAddRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters, HTTPServerConfig config)private voidhandleWordDeleteRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters, HTTPServerConfig config)private voidhandleWordsRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> params, HTTPServerConfig config)private voidsendJson(com.sun.net.httpserver.HttpExchange httpExchange, java.io.StringWriter sw)private voidwriteListResponse(java.lang.String fieldName, java.util.List<UserDictEntry> words, com.sun.net.httpserver.HttpExchange httpExchange)private voidwriteResponse(java.lang.String fieldName, boolean added, com.sun.net.httpserver.HttpExchange httpExchange)
-
-
-
Field Detail
-
JSON_CONTENT_TYPE
private static final java.lang.String JSON_CONTENT_TYPE
- See Also:
- Constant Field Values
-
TEXT_CONTENT_TYPE
private static final java.lang.String TEXT_CONTENT_TYPE
- See Also:
- Constant Field Values
-
ENCODING
private static final java.lang.String ENCODING
- See Also:
- Constant Field Values
-
textChecker
private final TextChecker textChecker
-
allowOriginUrl
private final java.lang.String allowOriginUrl
-
factory
private final com.fasterxml.jackson.core.JsonFactory factory
-
-
Constructor Detail
-
ApiV2
ApiV2(TextChecker textChecker, java.lang.String allowOriginUrl)
-
-
Method Detail
-
handleRequest
void handleRequest(java.lang.String path, com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters, ErrorRequestLimiter errorRequestLimiter, java.lang.String remoteAddress, HTTPServerConfig config) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleLanguagesRequest
private void handleLanguagesRequest(com.sun.net.httpserver.HttpExchange httpExchange) throws java.io.IOException- Throws:
java.io.IOException
-
handleMaxTextLengthRequest
private void handleMaxTextLengthRequest(com.sun.net.httpserver.HttpExchange httpExchange, HTTPServerConfig config) throws java.io.IOException- Throws:
java.io.IOException
-
handleGetConfigurationInfoRequest
private void handleGetConfigurationInfoRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters, HTTPServerConfig config) throws java.io.IOException- Throws:
java.io.IOException
-
handleCheckRequest
private void handleCheckRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters, ErrorRequestLimiter errorRequestLimiter, java.lang.String remoteAddress) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleWordsRequest
private void handleWordsRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> params, HTTPServerConfig config) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleWordAddRequest
private void handleWordAddRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters, HTTPServerConfig config) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleWordDeleteRequest
private void handleWordDeleteRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters, HTTPServerConfig config) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleRuleExamplesRequest
private void handleRuleExamplesRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> params) throws java.lang.Exception- Throws:
java.lang.Exception
-
ensureGetMethod
private void ensureGetMethod(com.sun.net.httpserver.HttpExchange httpExchange, java.lang.String url)
-
ensurePostMethod
private void ensurePostMethod(com.sun.net.httpserver.HttpExchange httpExchange, java.lang.String url)
-
getUserLimits
@NotNull private @NotNull UserLimits getUserLimits(java.util.Map<java.lang.String,java.lang.String> parameters, HTTPServerConfig config)
-
writeResponse
private void writeResponse(java.lang.String fieldName, boolean added, com.sun.net.httpserver.HttpExchange httpExchange) throws java.io.IOException- Throws:
java.io.IOException
-
writeListResponse
private void writeListResponse(java.lang.String fieldName, java.util.List<UserDictEntry> words, com.sun.net.httpserver.HttpExchange httpExchange) throws java.io.IOException- Throws:
java.io.IOException
-
sendJson
private void sendJson(com.sun.net.httpserver.HttpExchange httpExchange, java.io.StringWriter sw) throws java.io.IOException- Throws:
java.io.IOException
-
handleLogRequest
private void handleLogRequest(com.sun.net.httpserver.HttpExchange httpExchange, java.util.Map<java.lang.String,java.lang.String> parameters) throws java.io.IOException- Throws:
java.io.IOException
-
getAnnotatedTextFromString
private org.languagetool.markup.AnnotatedText getAnnotatedTextFromString(com.fasterxml.jackson.databind.JsonNode data, java.lang.String text)
-
getAnnotatedTextFromJson
private org.languagetool.markup.AnnotatedText getAnnotatedTextFromJson(com.fasterxml.jackson.databind.JsonNode data)
-
getLanguages
java.lang.String getLanguages() throws java.io.IOException- Throws:
java.io.IOException
-
getConfigurationInfo
java.lang.String getConfigurationInfo(org.languagetool.Language lang, HTTPServerConfig config) throws java.io.IOException- Throws:
java.io.IOException
-
-