class CommandLineApiHandler implements Callable<FullHttpResponse> {

	@Override
	public FullHttpResponse call() throws Exception {
		LoggingService.logDebug(MODULE_NAME, "Handle commandline api http request");
		if (!ApiHandlerHelpers.validateMethod(this.req, POST)) {
			LoggingService.logError(MODULE_NAME, "Request method not allowed", new AgentUserException("Request method not allowed"));
			return ApiHandlerHelpers.methodNotAllowedResponse();
		}

		final String contentTypeError = ApiHandlerHelpers.validateContentType(this.req, "application/json");
		if (contentTypeError != null) {
			LoggingService.logError(MODULE_NAME, contentTypeError, new AgentUserException(contentTypeError));
			return ApiHandlerHelpers.badRequestResponse(outputBuffer, contentTypeError);
		}

		if (!ApiHandlerHelpers.validateAccessToken(this.req)) {
			String errorMsg = "Incorrect access token";
			LoggingService.logError(MODULE_NAME, errorMsg, new AgentUserException(errorMsg));
			return ApiHandlerHelpers.unauthorizedResponse(outputBuffer, errorMsg);
		}

		try {
			String msgString = new String(content, UTF_8);
			JsonReader reader = Json.createReader(new StringReader(msgString));
			JsonObject jsonObject = reader.readObject();

			String command = jsonObject.getString("command");
			Map<String, String> resultMap = new HashMap<>();
			ObjectMapper objectMapper = new ObjectMapper();
			String result;
			try {
				result = CommandLineParser.parse(command);
				resultMap.put("response", result);
				String jsonResult = objectMapper.writeValueAsString(resultMap);
				LoggingService.logDebug(MODULE_NAME, "Finished processing commandline api request");
				return ApiHandlerHelpers.successResponse(outputBuffer, jsonResult);
			} catch (AgentUserException e) {
				result = e.getMessage();
				resultMap.put("response", result);
				resultMap.put("error", "Internal server error");
				String jsonResult = objectMapper.writeValueAsString(resultMap);
				LoggingService.logError(MODULE_NAME, "Error in handling command line http request", e);
				return ApiHandlerHelpers.internalServerErrorResponse(outputBuffer, jsonResult);
			}		

		} catch (Exception e) {
			String errorMsg = " Log message parsing error, " + e.getMessage();
			LoggingService.logError(MODULE_NAME, errorMsg, e);
			return ApiHandlerHelpers.badRequestResponse(outputBuffer, errorMsg);
		}
	}

	public  CommandLineApiHandler(HttpRequest request, ByteBuf outputBuffer, byte[] content);

}