Package net.stoerr.chatgpt.codevengine
Class AbstractPluginAction
- java.lang.Object
-
- jakarta.servlet.GenericServlet
-
- jakarta.servlet.http.HttpServlet
-
- net.stoerr.chatgpt.codevengine.AbstractPluginAction
-
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
- Direct Known Subclasses:
ExecuteExternalAction,ExecuteOpenAIToolCallAction,GrepAction,ListFilesAction,ReadFileAction,ReplaceAction,ReplaceRegexAction,UrlAction,WriteFileAction
public abstract class AbstractPluginAction extends jakarta.servlet.http.HttpServlet- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static PatternBINARY_FILES_PATTERNA pattern for filenames of binary files where grep would not work.protected static Map<Path,net.stoerr.chatgpt.codevengine.AbstractPluginAction.GitIgnoreRules>gitIgnoreRulesprotected com.google.gson.Gsongson
-
Constructor Summary
Constructors Constructor Description AbstractPluginAction()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Stringabbreviate(String s, int max)protected static Stream<Path>findMatchingFiles(boolean suppressMessage, jakarta.servlet.http.HttpServletResponse response, Path path, Pattern filePathPattern, Pattern grepPattern, boolean recursive, boolean listDirectories)protected StringgetBodyParameter(jakarta.servlet.http.HttpServletResponse response, String json, String parameterName, boolean mandatory)Returns a parameter encoded in JSON the request body; returns "" if that parameter isn't there.protected StringgetMandatoryQueryParam(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String name)protected PathgetPath(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean mustExist, boolean usedefault)Returns the path parameter from the request, checks if it is within the current directory.protected StringgetQueryParam(jakarta.servlet.http.HttpServletRequest request, String name)protected static StringgetSimilarFilesMessage(jakarta.servlet.http.HttpServletResponse response, Path path, String filename, boolean listDirectories)abstract StringgetUrl()The URL it is deployed at, e.g.protected static booleangitIgnored(Path path)protected static booleanisIgnored(Path path)protected booleanisNotEmpty(String s)abstract StringopenApiDescription()The OpenAPI description for this operation.protected static ExecutionAbortedExceptionsendError(jakarta.servlet.http.HttpServletResponse response, int statusCode, String error)Logs an error and sends it to ChatGPT, always throwsExecutionAbortedException.-
Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
-
-
-
-
Field Detail
-
BINARY_FILES_PATTERN
public static final Pattern BINARY_FILES_PATTERN
A pattern for filenames of binary files where grep would not work.
-
gson
protected final transient com.google.gson.Gson gson
-
-
Method Detail
-
sendError
protected static ExecutionAbortedException sendError(jakarta.servlet.http.HttpServletResponse response, int statusCode, String error) throws ExecutionAbortedException
Logs an error and sends it to ChatGPT, always throwsExecutionAbortedException. Use with patternthrow sendError(...)to let compiler know that.- Throws:
ExecutionAbortedException
-
findMatchingFiles
protected static Stream<Path> findMatchingFiles(boolean suppressMessage, jakarta.servlet.http.HttpServletResponse response, Path path, Pattern filePathPattern, Pattern grepPattern, boolean recursive, boolean listDirectories)
-
isIgnored
protected static boolean isIgnored(Path path)
-
getUrl
public abstract String getUrl()
The URL it is deployed at, e.g. /listFiles.
-
openApiDescription
public abstract String openApiDescription()
The OpenAPI description for this operation.
-
getQueryParam
protected String getQueryParam(jakarta.servlet.http.HttpServletRequest request, String name)
-
getMandatoryQueryParam
protected String getMandatoryQueryParam(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String name)
-
getPath
protected Path getPath(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean mustExist, boolean usedefault)
Returns the path parameter from the request, checks if it is within the current directory.
-
getSimilarFilesMessage
protected static String getSimilarFilesMessage(jakarta.servlet.http.HttpServletResponse response, Path path, String filename, boolean listDirectories)
-
getBodyParameter
@Nullable protected String getBodyParameter(jakarta.servlet.http.HttpServletResponse response, String json, String parameterName, boolean mandatory)
Returns a parameter encoded in JSON the request body; returns "" if that parameter isn't there.
-
isNotEmpty
protected boolean isNotEmpty(String s)
-
gitIgnored
protected static boolean gitIgnored(Path path)
-
-