Package org.apache.wiki.attachment
Class AttachmentServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.wiki.attachment.AttachmentServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
This is the chief JSPWiki attachment management servlet. It is used for
both uploading new content and downloading old content. It can handle
most common cases, e.g. check for modifications and return 304's as necessary.
Authentication is done using JSPWiki's normal AAA framework.
This servlet is also capable of managing dynamically created attachments.
- Since:
- 1.9.45.
- See Also:
-
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Serves a GET with two parameters: 'wikiname' specifying the wikiname of the attachment, 'version' specifying the version indicator.protected voiddoOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Implements the OPTIONS method.voiddoPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Grabs mime/multipart data and stores it into the temporary area.protected booleanexecuteUpload(org.apache.wiki.api.core.Context context, InputStream data, String filename, String errorPage, String parentPage, String changenote, long contentLength) voidinit(jakarta.servlet.ServletConfig config) Initializes the servlet from Engine properties.protected Stringupload(jakarta.servlet.http.HttpServletRequest req) Uploads a specific mime multipart input set, intercepts exceptions.Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doPatch, doPut, doTrace, getLastModified, isSensitiveHeader, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
AttachmentServlet
public AttachmentServlet()
-
-
Method Details
-
init
Initializes the servlet from Engine properties.- Specified by:
initin interfacejakarta.servlet.Servlet- Overrides:
initin classjakarta.servlet.http.HttpServlet- Parameters:
config-- Throws:
jakarta.servlet.ServletException
-
doOptions
protected void doOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Implements the OPTIONS method.- Overrides:
doOptionsin classjakarta.servlet.http.HttpServlet- Parameters:
req- The servlet requestres- The servlet response
-
doGet
public void doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) throws IOException Serves a GET with two parameters: 'wikiname' specifying the wikiname of the attachment, 'version' specifying the version indicator.- Overrides:
doGetin classjakarta.servlet.http.HttpServlet- Throws:
IOException
-
doPost
public void doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) throws IOException Grabs mime/multipart data and stores it into the temporary area. Uses other parameters to determine which name to store as.The input to this servlet is generated by an HTML FORM with two parts. The first, named 'page', is the WikiName identifier for the parent file. The second, named 'content', is the binary content of the file.
- Overrides:
doPostin classjakarta.servlet.http.HttpServlet- Throws:
IOException
-
upload
protected String upload(jakarta.servlet.http.HttpServletRequest req) throws org.apache.wiki.api.exceptions.RedirectException, IOException Uploads a specific mime multipart input set, intercepts exceptions. If the total request size is too big, the user will be redirected to the Error.jsp page- Parameters:
req- The servlet request- Returns:
- The page to which we should go next.
- Throws:
org.apache.wiki.api.exceptions.RedirectException- If there's an error and a redirection is neededIOException- If upload fails
-
executeUpload
protected boolean executeUpload(org.apache.wiki.api.core.Context context, InputStream data, String filename, String errorPage, String parentPage, String changenote, long contentLength) throws org.apache.wiki.api.exceptions.RedirectException, IOException, org.apache.wiki.api.exceptions.ProviderException - Parameters:
context- the wiki contextdata- the input stream datafilename- the name of the file to uploaderrorPage- the place to which you want to get a redirectionparentPage- the page to which the file should be attachedchangenote- The change notecontentLength- The content length- Returns:
trueif upload results in the creation of a new page;falseotherwise- Throws:
org.apache.wiki.api.exceptions.RedirectException- If the content needs to be redirectedIOException- If there is a problem in the upload.org.apache.wiki.api.exceptions.ProviderException- If there is a problem in the backend.
-