Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/DiskFileItem.java.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/DiskFileItem.java.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/DiskFileItem.java.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1,648 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DiskFileItem.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.source.html" class="el_package">org.apache.commons.fileupload.disk</a> > <span cla ss="el_source">DiskFileItem.java</span></div><h1>DiskFileItem.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.disk; + +import static java.lang.String.format; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemHeaders; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.ParameterParser; +import org.apache.commons.fileupload.util.Streams; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.output.DeferredFileOutputStream; + +/** + * <p> The default implementation of the + * {@link org.apache.commons.fileupload.FileItem FileItem} interface. + * + * <p> After retrieving an instance of this class from a {@link + * DiskFileItemFactory} instance (see + * {@link org.apache.commons.fileupload.servlet.ServletFileUpload + * #parseRequest(javax.servlet.http.HttpServletRequest)}), you may + * either request all contents of file at once using {@link #get()} or + * request an {@link java.io.InputStream InputStream} with + * {@link #getInputStream()} and process the file without attempting to load + * it into memory, which may come handy with large files. + * + * <p>Temporary files, which are created for file items, should be + * deleted later on. The best way to do this is using a + * {@link org.apache.commons.io.FileCleaningTracker}, which you can set on the + * {@link DiskFileItemFactory}. However, if you do use such a tracker, + * then you must consider the following: Temporary files are automatically + * deleted as soon as they are no longer needed. (More precisely, when the + * corresponding instance of {@link java.io.File} is garbage collected.) + * This is done by the so-called reaper thread, which is started and stopped + * automatically by the {@link org.apache.commons.io.FileCleaningTracker} when + * there are files to be tracked. + * It might make sense to terminate that thread, for example, if + * your web application ends. See the section on "Resource cleanup" + * in the users guide of commons-fileupload.</p> + * + * @since FileUpload 1.1 + */ +public class DiskFileItem + implements FileItem { + + // ----------------------------------------------------- Manifest constants + + /** + * Default content charset to be used when no explicit charset + * parameter is provided by the sender. Media subtypes of the + * "text" type are defined to have a default charset value of + * "ISO-8859-1" when received via HTTP. + */ + public static final String DEFAULT_CHARSET = "ISO-8859-1"; + + // ----------------------------------------------------------- Data members + + /** + * UID used in unique file name generation. + */ + private static final String UID = +<span class="fc" id="L90"> UUID.randomUUID().toString().replace('-', '_');</span> + + /** + * Counter used in unique identifier generation. + */ +<span class="fc" id="L95"> private static final AtomicInteger COUNTER = new AtomicInteger(0);</span> + + /** + * The name of the form field as provided by the browser. + */ + private String fieldName; + + /** + * The content type passed by the browser, or <code>null</code> if + * not defined. + */ + private final String contentType; + + /** + * Whether or not this item is a simple form field. + */ + private boolean isFormField; + + /** + * The original filename in the user's filesystem. + */ + private final String fileName; + + /** + * The size of the item, in bytes. This is used to cache the size when a + * file item is moved from its original location. + */ +<span class="fc" id="L122"> private long size = -1;</span> + + + /** + * The threshold above which uploads will be stored on disk. + */ + private final int sizeThreshold; + + /** + * The directory in which uploaded files will be stored, if stored on disk. + */ + private final File repository; + + /** + * Cached contents of the file. + */ + private byte[] cachedContent; + + /** + * Output stream for this item. + */ + private transient DeferredFileOutputStream dfos; + + /** + * The temporary file to use. + */ + private transient File tempFile; + + /** + * The file items headers. + */ + private FileItemHeaders headers; + + /** + * Default content charset to be used when no explicit charset + * parameter is provided by the sender. + */ +<span class="fc" id="L159"> private String defaultCharset = DEFAULT_CHARSET;</span> + + // ----------------------------------------------------------- Constructors + + /** + * Constructs a new <code>DiskFileItem</code> instance. + * + * @param fieldName The name of the form field. + * @param contentType The content type passed by the browser or + * <code>null</code> if not specified. + * @param isFormField Whether or not this item is a plain form field, as + * opposed to a file upload. + * @param fileName The original filename in the user's filesystem, or + * <code>null</code> if not specified. + * @param sizeThreshold The threshold, in bytes, below which items will be + * retained in memory and above which they will be + * stored as a file. + * @param repository The data repository, which is the directory in + * which files will be created, should the item size + * exceed the threshold. + */ + public DiskFileItem(String fieldName, + String contentType, boolean isFormField, String fileName, +<span class="fc" id="L182"> int sizeThreshold, File repository) {</span> +<span class="fc" id="L183"> this.fieldName = fieldName;</span> +<span class="fc" id="L184"> this.contentType = contentType;</span> +<span class="fc" id="L185"> this.isFormField = isFormField;</span> +<span class="fc" id="L186"> this.fileName = fileName;</span> +<span class="fc" id="L187"> this.sizeThreshold = sizeThreshold;</span> +<span class="fc" id="L188"> this.repository = repository;</span> +<span class="fc" id="L189"> }</span> + + // ------------------------------- Methods from javax.activation.DataSource + + /** + * Returns an {@link java.io.InputStream InputStream} that can be + * used to retrieve the contents of the file. + * + * @return An {@link java.io.InputStream InputStream} that can be + * used to retrieve the contents of the file. + * + * @throws IOException if an error occurs. + */ + @Override + public InputStream getInputStream() + throws IOException { +<span class="nc bnc" id="L205" title="All 2 branches missed."> if (!isInMemory()) {</span> +<span class="nc" id="L206"> return new FileInputStream(dfos.getFile());</span> + } + +<span class="nc bnc" id="L209" title="All 2 branches missed."> if (cachedContent == null) {</span> +<span class="nc" id="L210"> cachedContent = dfos.getData();</span> + } +<span class="nc" id="L212"> return new ByteArrayInputStream(cachedContent);</span> + } + + /** + * Returns the content type passed by the agent or <code>null</code> if + * not defined. + * + * @return The content type passed by the agent or <code>null</code> if + * not defined. + */ + @Override + public String getContentType() { +<span class="fc" id="L224"> return contentType;</span> + } + + /** + * Returns the content charset passed by the agent or <code>null</code> if + * not defined. + * + * @return The content charset passed by the agent or <code>null</code> if + * not defined. + */ + public String getCharSet() { +<span class="fc" id="L235"> ParameterParser parser = new ParameterParser();</span> +<span class="fc" id="L236"> parser.setLowerCaseNames(true);</span> + // Parameter parser can handle null input +<span class="fc" id="L238"> Map<String, String> params = parser.parse(getContentType(), ';');</span> +<span class="fc" id="L239"> return params.get("charset");</span> + } + + /** + * Returns the original filename in the client's filesystem. + * + * @return The original filename in the client's filesystem. + * @throws org.apache.commons.fileupload.InvalidFileNameException The file name contains a NUL character, + * which might be an indicator of a security attack. If you intend to + * use the file name anyways, catch the exception and use + * {@link org.apache.commons.fileupload.InvalidFileNameException#getName()}. + */ + @Override + public String getName() { +<span class="fc" id="L253"> return Streams.checkFileName(fileName);</span> + } + + // ------------------------------------------------------- FileItem methods + + /** + * Provides a hint as to whether or not the file contents will be read + * from memory. + * + * @return <code>true</code> if the file contents will be read + * from memory; <code>false</code> otherwise. + */ + @Override + public boolean isInMemory() { +<span class="fc bfc" id="L267" title="All 2 branches covered."> if (cachedContent != null) {</span> +<span class="fc" id="L268"> return true;</span> + } +<span class="fc" id="L270"> return dfos.isInMemory();</span> + } + + /** + * Returns the size of the file. + * + * @return The size of the file, in bytes. + */ + @Override + public long getSize() { +<span class="pc bpc" id="L280" title="1 of 2 branches missed."> if (size >= 0) {</span> +<span class="nc" id="L281"> return size;</span> +<span class="pc bpc" id="L282" title="1 of 2 branches missed."> } else if (cachedContent != null) {</span> +<span class="nc" id="L283"> return cachedContent.length;</span> +<span class="fc bfc" id="L284" title="All 2 branches covered."> } else if (dfos.isInMemory()) {</span> +<span class="fc" id="L285"> return dfos.getData().length;</span> + } else { +<span class="fc" id="L287"> return dfos.getFile().length();</span> + } + } + + /** + * Returns the contents of the file as an array of bytes. If the + * contents of the file were not yet cached in memory, they will be + * loaded from the disk storage and cached. + * + * @return The contents of the file as an array of bytes + * or {@code null} if the data cannot be read + */ + @Override + public byte[] get() { +<span class="fc bfc" id="L301" title="All 2 branches covered."> if (isInMemory()) {</span> +<span class="pc bpc" id="L302" title="1 of 4 branches missed."> if (cachedContent == null && dfos != null) {</span> +<span class="fc" id="L303"> cachedContent = dfos.getData();</span> + } +<span class="fc" id="L305"> return cachedContent;</span> + } + +<span class="fc" id="L308"> byte[] fileData = new byte[(int) getSize()];</span> +<span class="fc" id="L309"> InputStream fis = null;</span> + + try { +<span class="fc" id="L312"> fis = new FileInputStream(dfos.getFile());</span> +<span class="fc" id="L313"> IOUtils.readFully(fis, fileData);</span> +<span class="nc" id="L314"> } catch (IOException e) {</span> +<span class="nc" id="L315"> fileData = null;</span> + } finally { +<span class="fc" id="L317"> IOUtils.closeQuietly(fis);</span> + } + +<span class="fc" id="L320"> return fileData;</span> + } + + /** + * Returns the contents of the file as a String, using the specified + * encoding. This method uses {@link #get()} to retrieve the + * contents of the file. + * + * @param charset The charset to use. + * + * @return The contents of the file, as a string. + * + * @throws UnsupportedEncodingException if the requested character + * encoding is not available. + */ + @Override + public String getString(final String charset) + throws UnsupportedEncodingException { +<span class="nc" id="L338"> return new String(get(), charset);</span> + } + + /** + * Returns the contents of the file as a String, using the default + * character encoding. This method uses {@link #get()} to retrieve the + * contents of the file. + * + * <b>TODO</b> Consider making this method throw UnsupportedEncodingException. + * + * @return The contents of the file, as a string. + */ + @Override + public String getString() { +<span class="fc" id="L352"> byte[] rawdata = get();</span> +<span class="fc" id="L353"> String charset = getCharSet();</span> +<span class="pc bpc" id="L354" title="1 of 2 branches missed."> if (charset == null) {</span> +<span class="fc" id="L355"> charset = defaultCharset;</span> + } + try { +<span class="fc" id="L358"> return new String(rawdata, charset);</span> +<span class="nc" id="L359"> } catch (UnsupportedEncodingException e) {</span> +<span class="nc" id="L360"> return new String(rawdata);</span> + } + } + + /** + * A convenience method to write an uploaded item to disk. The client code + * is not concerned with whether or not the item is stored in memory, or on + * disk in a temporary location. They just want to write the uploaded item + * to a file. + * <p> + * This implementation first attempts to rename the uploaded item to the + * specified destination file, if the item was originally written to disk. + * Otherwise, the data will be copied to the specified file. + * <p> + * This method is only guaranteed to work <em>once</em>, the first time it + * is invoked for a particular item. This is because, in the event that the + * method renames a temporary file, that file will no longer be available + * to copy or rename again at a later time. + * + * @param file The <code>File</code> into which the uploaded item should + * be stored. + * + * @throws Exception if an error occurs. + */ + @Override + public void write(File file) throws Exception { +<span class="pc bpc" id="L386" title="1 of 2 branches missed."> if (isInMemory()) {</span> +<span class="nc" id="L387"> FileOutputStream fout = null;</span> + try { +<span class="nc" id="L389"> fout = new FileOutputStream(file);</span> +<span class="nc" id="L390"> fout.write(get());</span> +<span class="nc" id="L391"> fout.close();</span> + } finally { +<span class="nc" id="L393"> IOUtils.closeQuietly(fout);</span> + } +<span class="nc" id="L395"> } else {</span> +<span class="fc" id="L396"> File outputFile = getStoreLocation();</span> +<span class="pc bpc" id="L397" title="1 of 2 branches missed."> if (outputFile != null) {</span> + // Save the length of the file +<span class="fc" id="L399"> size = outputFile.length();</span> + /* + * The uploaded file is being stored on disk + * in a temporary location so move it to the + * desired file. + */ +<span class="pc bpc" id="L405" title="1 of 2 branches missed."> if (file.exists()) {</span> +<span class="fc" id="L406"> file.delete();</span> + } +<span class="fc" id="L408"> FileUtils.moveFile(outputFile, file);</span> + } else { + /* + * For whatever reason we cannot write the + * file to disk. + */ +<span class="nc" id="L414"> throw new FileUploadException(</span> + "Cannot write uploaded file to disk!"); + } + } +<span class="fc" id="L418"> }</span> + + /** + * Deletes the underlying storage for a file item, including deleting any + * associated temporary disk file. Although this storage will be deleted + * automatically when the <code>FileItem</code> instance is garbage + * collected, this method can be used to ensure that this is done at an + * earlier time, thus preserving system resources. + */ + @Override + public void delete() { +<span class="fc" id="L429"> cachedContent = null;</span> +<span class="fc" id="L430"> File outputFile = getStoreLocation();</span> +<span class="pc bpc" id="L431" title="2 of 6 branches missed."> if (outputFile != null && !isInMemory() && outputFile.exists()) {</span> +<span class="fc" id="L432"> outputFile.delete();</span> + } +<span class="fc" id="L434"> }</span> + + /** + * Returns the name of the field in the multipart form corresponding to + * this file item. + * + * @return The name of the form field. + * + * @see #setFieldName(java.lang.String) + * + */ + @Override + public String getFieldName() { +<span class="fc" id="L447"> return fieldName;</span> + } + + /** + * Sets the field name used to reference this file item. + * + * @param fieldName The name of the form field. + * + * @see #getFieldName() + * + */ + @Override + public void setFieldName(String fieldName) { +<span class="nc" id="L460"> this.fieldName = fieldName;</span> +<span class="nc" id="L461"> }</span> + + /** + * Determines whether or not a <code>FileItem</code> instance represents + * a simple form field. + * + * @return <code>true</code> if the instance represents a simple form + * field; <code>false</code> if it represents an uploaded file. + * + * @see #setFormField(boolean) + * + */ + @Override + public boolean isFormField() { +<span class="fc" id="L475"> return isFormField;</span> + } + + /** + * Specifies whether or not a <code>FileItem</code> instance represents + * a simple form field. + * + * @param state <code>true</code> if the instance represents a simple form + * field; <code>false</code> if it represents an uploaded file. + * + * @see #isFormField() + * + */ + @Override + public void setFormField(boolean state) { +<span class="nc" id="L490"> isFormField = state;</span> +<span class="nc" id="L491"> }</span> + + /** + * Returns an {@link java.io.OutputStream OutputStream} that can + * be used for storing the contents of the file. + * + * @return An {@link java.io.OutputStream OutputStream} that can be used + * for storing the contents of the file. + * + * @throws IOException if an error occurs. + */ + @Override + public OutputStream getOutputStream() + throws IOException { +<span class="pc bpc" id="L505" title="1 of 2 branches missed."> if (dfos == null) {</span> +<span class="fc" id="L506"> File outputFile = getTempFile();</span> +<span class="fc" id="L507"> dfos = new DeferredFileOutputStream(sizeThreshold, outputFile);</span> + } +<span class="fc" id="L509"> return dfos;</span> + } + + // --------------------------------------------------------- Public methods + + /** + * Returns the {@link java.io.File} object for the <code>FileItem</code>'s + * data's temporary location on the disk. Note that for + * <code>FileItem</code>s that have their data stored in memory, + * this method will return <code>null</code>. When handling large + * files, you can use {@link java.io.File#renameTo(java.io.File)} to + * move the file to new location without copying the data, if the + * source and destination locations reside within the same logical + * volume. + * + * @return The data file, or <code>null</code> if the data is stored in + * memory. + */ + public File getStoreLocation() { +<span class="pc bpc" id="L528" title="1 of 2 branches missed."> if (dfos == null) {</span> +<span class="nc" id="L529"> return null;</span> + } +<span class="fc bfc" id="L531" title="All 2 branches covered."> if (isInMemory()) {</span> +<span class="fc" id="L532"> return null;</span> + } +<span class="fc" id="L534"> return dfos.getFile();</span> + } + + // ------------------------------------------------------ Protected methods + + /** + * Removes the file contents from the temporary storage. + */ + @Override + protected void finalize() { +<span class="fc bfc" id="L544" title="All 4 branches covered."> if (dfos == null || dfos.isInMemory()) {</span> +<span class="fc" id="L545"> return;</span> + } +<span class="fc" id="L547"> File outputFile = dfos.getFile();</span> + +<span class="pc bpc" id="L549" title="1 of 4 branches missed."> if (outputFile != null && outputFile.exists()) {</span> +<span class="fc" id="L550"> outputFile.delete();</span> + } +<span class="fc" id="L552"> }</span> + + /** + * Creates and returns a {@link java.io.File File} representing a uniquely + * named temporary file in the configured repository path. The lifetime of + * the file is tied to the lifetime of the <code>FileItem</code> instance; + * the file will be deleted when the instance is garbage collected. + * <p> + * <b>Note: Subclasses that override this method must ensure that they return the + * same File each time.</b> + * + * @return The {@link java.io.File File} to be used for temporary storage. + */ + protected File getTempFile() { +<span class="pc bpc" id="L566" title="1 of 2 branches missed."> if (tempFile == null) {</span> +<span class="fc" id="L567"> File tempDir = repository;</span> +<span class="fc bfc" id="L568" title="All 2 branches covered."> if (tempDir == null) {</span> +<span class="fc" id="L569"> tempDir = new File(System.getProperty("java.io.tmpdir"));</span> + } + +<span class="fc" id="L572"> String tempFileName = format("upload_%s_%s.tmp", UID, getUniqueId());</span> + +<span class="fc" id="L574"> tempFile = new File(tempDir, tempFileName);</span> + } +<span class="fc" id="L576"> return tempFile;</span> + } + + // -------------------------------------------------------- Private methods + + /** + * Returns an identifier that is unique within the class loader used to + * load this class, but does not have random-like appearance. + * + * @return A String with the non-random looking instance identifier. + */ + private static String getUniqueId() { +<span class="fc" id="L588"> final int limit = 100000000;</span> +<span class="fc" id="L589"> int current = COUNTER.getAndIncrement();</span> +<span class="fc" id="L590"> String id = Integer.toString(current);</span> + + // If you manage to get more than 100 million of ids, you'll + // start getting ids longer than 8 characters. +<span class="pc bpc" id="L594" title="1 of 2 branches missed."> if (current < limit) {</span> +<span class="fc" id="L595"> id = ("00000000" + id).substring(id.length());</span> + } +<span class="fc" id="L597"> return id;</span> + } + + /** + * Returns a string representation of this object. + * + * @return a string representation of this object. + */ + @Override + public String toString() { +<span class="nc" id="L607"> return format("name=%s, StoreLocation=%s, size=%s bytes, isFormField=%s, FieldName=%s",</span> +<span class="nc" id="L608"> getName(), getStoreLocation(), Long.valueOf(getSize()),</span> +<span class="nc" id="L609"> Boolean.valueOf(isFormField()), getFieldName());</span> + } + + /** + * Returns the file item headers. + * @return The file items headers. + */ + @Override + public FileItemHeaders getHeaders() { +<span class="fc" id="L618"> return headers;</span> + } + + /** + * Sets the file item headers. + * @param pHeaders The file items headers. + */ + @Override + public void setHeaders(FileItemHeaders pHeaders) { +<span class="fc" id="L627"> headers = pHeaders;</span> +<span class="fc" id="L628"> }</span> + + /** + * Returns the default charset for use when no explicit charset + * parameter is provided by the sender. + * @return the default charset + */ + public String getDefaultCharset() { +<span class="nc" id="L636"> return defaultCharset;</span> + } + + /** + * Sets the default charset for use when no explicit charset + * parameter is provided by the sender. + * @param charset the default charset + */ + public void setDefaultCharset(String charset) { +<span class="fc" id="L645"> defaultCharset = charset;</span> +<span class="fc" id="L646"> }</span> +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file
Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/DiskFileItemFactory.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/DiskFileItemFactory.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/DiskFileItemFactory.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DiskFileItemFactory</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.html" class="el_package">org.apache.commons.fileupload.disk</a> > <span class="el_class">DiskFileItemFactory</span></div><h1>DiskFileItemFactory</h1><table class="coverage" ce llspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">16 of 76</td><td class="ctr2">78%</td><td class="bar">1 of 2</td><td class="ctr2">50%</td><td class="ct r1">4</td><td class="ctr2">12</td><td class="ctr1">6</td><td class="ctr2">26</td><td class="ctr1">3</td><td class="ctr2">11</td></tr></tfoot><tbody><tr><td id="a0"><a href="DiskFileItemFactory.java.html#L200" class="el_method">createItem(String, String, boolean, String)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="21" height="10" title="5" alt="5"/><img src="../jacoco-resources/greenbar.gif" width="98" height="10" title="23" alt="23"/></td><td class="ctr2" id="c7">82%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="60" height="10" title="1" alt="1"/><img src="../jacoco-resources/greenbar.gif" width="60" height="10" title="1" alt="1"/></td><td class="ctr2" id="e0">50%</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g0">2</td><td class="ctr1" id="h2">1</td><td class="ctr2" id="i0">6</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a9"><a href="DiskFileItemFactory.java.html#L154" class="el_method">setRepository(File)</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="4" alt="4"/></td><td class="ctr2" id="c8">0%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">1</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h0">2</td><td class="ctr2" id="i2">2</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a8"><a href="DiskFileItemFactory.java.html#L230" class="el_method">setFileCleaningTracker(FileCleaningTracker)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="4" alt="4"/></td><td class="ctr2" id="c9">0%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">1</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h1">2</td><td class="ctr2" id="i3">2</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a3"><a href="DiskFil eItemFactory.java.html#L239" class="el_method">getDefaultCharset()</a></td><td class="bar" id="b3"><img src="../jacoco-resources/redbar.gif" width="12" height="10" title="3" alt="3"/></td><td class="ctr2" id="c10">0%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f3">1</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h3">1</td><td class="ctr2" id="i7">1</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a2"><a href="DiskFileItemFactory.java.html#L89" class="el_method">DiskFileItemFactory(int, File)</a></td><td class="bar" id="b4"><img src="../jacoco-resources/greenbar.gif" width="64" height="10" title="15" alt="15"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i1">6</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></tr><tr><td id ="a1"><a href="DiskFileItemFactory.java.html#L111" class="el_method">DiskFileItemFactory()</a></td><td class="bar" id="b5"><img src="../jacoco-resources/greenbar.gif" width="21" height="10" title="5" alt="5"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d5"/><td class="ctr2" id="e5">n/a</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g5">1</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i4">2</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">1</td></tr><tr><td id="a10"><a href="DiskFileItemFactory.java.html#L178" class="el_method">setSizeThreshold(int)</a></td><td class="bar" id="b6"><img src="../jacoco-resources/greenbar.gif" width="17" height="10" title="4" alt="4"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d6"/><td class="ctr2" id="e6">n/a</td><td class="ctr1" id="f6">0</td><td class="ctr2" id="g6">1</td><td class="ctr1" id="h6">0</td><td class="ctr2" id="i5">2</td><td class="ctr1" id="j6">0</td><td class="ctr2" id="k6">1</ td></tr><tr><td id="a7"><a href="DiskFileItemFactory.java.html#L248" class="el_method">setDefaultCharset(String)</a></td><td class="bar" id="b7"><img src="../jacoco-resources/greenbar.gif" width="17" height="10" title="4" alt="4"/></td><td class="ctr2" id="c3">100%</td><td class="bar" id="d7"/><td class="ctr2" id="e7">n/a</td><td class="ctr1" id="f7">0</td><td class="ctr2" id="g7">1</td><td class="ctr1" id="h7">0</td><td class="ctr2" id="i6">2</td><td class="ctr1" id="j7">0</td><td class="ctr2" id="k7">1</td></tr><tr><td id="a5"><a href="DiskFileItemFactory.java.html#L141" class="el_method">getRepository()</a></td><td class="bar" id="b8"><img src="../jacoco-resources/greenbar.gif" width="12" height="10" title="3" alt="3"/></td><td class="ctr2" id="c4">100%</td><td class="bar" id="d8"/><td class="ctr2" id="e8">n/a</td><td class="ctr1" id="f8">0</td><td class="ctr2" id="g8">1</td><td class="ctr1" id="h8">0</td><td class="ctr2" id="i8">1</td><td class="ctr1" id="j8">0</td><td class="ct r2" id="k8">1</td></tr><tr><td id="a6"><a href="DiskFileItemFactory.java.html#L166" class="el_method">getSizeThreshold()</a></td><td class="bar" id="b9"><img src="../jacoco-resources/greenbar.gif" width="12" height="10" title="3" alt="3"/></td><td class="ctr2" id="c5">100%</td><td class="bar" id="d9"/><td class="ctr2" id="e9">n/a</td><td class="ctr1" id="f9">0</td><td class="ctr2" id="g9">1</td><td class="ctr1" id="h9">0</td><td class="ctr2" id="i9">1</td><td class="ctr1" id="j9">0</td><td class="ctr2" id="k9">1</td></tr><tr><td id="a4"><a href="DiskFileItemFactory.java.html#L218" class="el_method">getFileCleaningTracker()</a></td><td class="bar" id="b10"><img src="../jacoco-resources/greenbar.gif" width="12" height="10" title="3" alt="3"/></td><td class="ctr2" id="c6">100%</td><td class="bar" id="d10"/><td class="ctr2" id="e10">n/a</td><td class="ctr1" id="f10">0</td><td class="ctr2" id="g10">1</td><td class="ctr1" id="h10">0</td><td class="ctr2" id="i10">1</td><td class="ctr1" id= "j10">0</td><td class="ctr2" id="k10">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/DiskFileItemFactory.java.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/DiskFileItemFactory.java.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/DiskFileItemFactory.java.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1,251 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DiskFileItemFactory.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.source.html" class="el_package">org.apache.commons.fileupload.disk</a> > <s pan class="el_source">DiskFileItemFactory.java</span></div><h1>DiskFileItemFactory.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.disk; + +import java.io.File; + +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.io.FileCleaningTracker; + +/** + * <p>The default {@link org.apache.commons.fileupload.FileItemFactory} + * implementation. This implementation creates + * {@link org.apache.commons.fileupload.FileItem} instances which keep their + * content either in memory, for smaller items, or in a temporary file on disk, + * for larger items. The size threshold, above which content will be stored on + * disk, is configurable, as is the directory in which temporary files will be + * created.</p> + * + * <p>If not otherwise configured, the default configuration values are as + * follows:</p> + * <ul> + * <li>Size threshold is 10KB.</li> + * <li>Repository is the system default temp directory, as returned by + * <code>System.getProperty("java.io.tmpdir")</code>.</li> + * </ul> + * <p> + * <b>NOTE</b>: Files are created in the system default temp directory with + * predictable names. This means that a local attacker with write access to that + * directory can perform a TOUTOC attack to replace any uploaded file with a + * file of the attackers choice. The implications of this will depend on how the + * uploaded file is used but could be significant. When using this + * implementation in an environment with local, untrusted users, + * {@link #setRepository(File)} MUST be used to configure a repository location + * that is not publicly writable. In a Servlet container the location identified + * by the ServletContext attribute <code>javax.servlet.context.tempdir</code> + * may be used. + * </p> + * + * <p>Temporary files, which are created for file items, should be + * deleted later on. The best way to do this is using a + * {@link FileCleaningTracker}, which you can set on the + * {@link DiskFileItemFactory}. However, if you do use such a tracker, + * then you must consider the following: Temporary files are automatically + * deleted as soon as they are no longer needed. (More precisely, when the + * corresponding instance of {@link java.io.File} is garbage collected.) + * This is done by the so-called reaper thread, which is started and stopped + * automatically by the {@link FileCleaningTracker} when there are files to be + * tracked. + * It might make sense to terminate that thread, for example, if + * your web application ends. See the section on "Resource cleanup" + * in the users guide of commons-fileupload.</p> + * + * @since FileUpload 1.1 + */ +public class DiskFileItemFactory implements FileItemFactory { + + // ----------------------------------------------------- Manifest constants + + /** + * The default threshold above which uploads will be stored on disk. + */ + public static final int DEFAULT_SIZE_THRESHOLD = 10240; + + // ----------------------------------------------------- Instance Variables + + /** + * The directory in which uploaded files will be stored, if stored on disk. + */ + private File repository; + + /** + * The threshold above which uploads will be stored on disk. + */ +<span class="fc" id="L89"> private int sizeThreshold = DEFAULT_SIZE_THRESHOLD;</span> + + /** + * <p>The instance of {@link FileCleaningTracker}, which is responsible + * for deleting temporary files.</p> + * <p>May be null, if tracking files is not required.</p> + */ + private FileCleaningTracker fileCleaningTracker; + + /** + * Default content charset to be used when no explicit charset + * parameter is provided by the sender. + */ +<span class="fc" id="L102"> private String defaultCharset = DiskFileItem.DEFAULT_CHARSET;</span> + + // ----------------------------------------------------------- Constructors + + /** + * Constructs an unconfigured instance of this class. The resulting factory + * may be configured by calling the appropriate setter methods. + */ + public DiskFileItemFactory() { +<span class="fc" id="L111"> this(DEFAULT_SIZE_THRESHOLD, null);</span> +<span class="fc" id="L112"> }</span> + + /** + * Constructs a preconfigured instance of this class. + * + * @param sizeThreshold The threshold, in bytes, below which items will be + * retained in memory and above which they will be + * stored as a file. + * @param repository The data repository, which is the directory in + * which files will be created, should the item size + * exceed the threshold. + */ +<span class="fc" id="L124"> public DiskFileItemFactory(int sizeThreshold, File repository) {</span> +<span class="fc" id="L125"> this.sizeThreshold = sizeThreshold;</span> +<span class="fc" id="L126"> this.repository = repository;</span> +<span class="fc" id="L127"> }</span> + + // ------------------------------------------------------------- Properties + + /** + * Returns the directory used to temporarily store files that are larger + * than the configured size threshold. + * + * @return The directory in which temporary files will be located. + * + * @see #setRepository(java.io.File) + * + */ + public File getRepository() { +<span class="fc" id="L141"> return repository;</span> + } + + /** + * Sets the directory used to temporarily store files that are larger + * than the configured size threshold. + * + * @param repository The directory in which temporary files will be located. + * + * @see #getRepository() + * + */ + public void setRepository(File repository) { +<span class="nc" id="L154"> this.repository = repository;</span> +<span class="nc" id="L155"> }</span> + + /** + * Returns the size threshold beyond which files are written directly to + * disk. The default value is 10240 bytes. + * + * @return The size threshold, in bytes. + * + * @see #setSizeThreshold(int) + */ + public int getSizeThreshold() { +<span class="fc" id="L166"> return sizeThreshold;</span> + } + + /** + * Sets the size threshold beyond which files are written directly to disk. + * + * @param sizeThreshold The size threshold, in bytes. + * + * @see #getSizeThreshold() + * + */ + public void setSizeThreshold(int sizeThreshold) { +<span class="fc" id="L178"> this.sizeThreshold = sizeThreshold;</span> +<span class="fc" id="L179"> }</span> + + // --------------------------------------------------------- Public Methods + + /** + * Create a new {@link org.apache.commons.fileupload.disk.DiskFileItem} + * instance from the supplied parameters and the local factory + * configuration. + * + * @param fieldName The name of the form field. + * @param contentType The content type of the form field. + * @param isFormField <code>true</code> if this is a plain form field; + * <code>false</code> otherwise. + * @param fileName The name of the uploaded file, if any, as supplied + * by the browser or other client. + * + * @return The newly created file item. + */ + @Override + public FileItem createItem(String fieldName, String contentType, + boolean isFormField, String fileName) { +<span class="fc" id="L200"> DiskFileItem result = new DiskFileItem(fieldName, contentType,</span> + isFormField, fileName, sizeThreshold, repository); +<span class="fc" id="L202"> result.setDefaultCharset(defaultCharset);</span> +<span class="fc" id="L203"> FileCleaningTracker tracker = getFileCleaningTracker();</span> +<span class="pc bpc" id="L204" title="1 of 2 branches missed."> if (tracker != null) {</span> +<span class="nc" id="L205"> tracker.track(result.getTempFile(), result);</span> + } +<span class="fc" id="L207"> return result;</span> + } + + /** + * Returns the tracker, which is responsible for deleting temporary + * files. + * + * @return An instance of {@link FileCleaningTracker}, or null + * (default), if temporary files aren't tracked. + */ + public FileCleaningTracker getFileCleaningTracker() { +<span class="fc" id="L218"> return fileCleaningTracker;</span> + } + + /** + * Sets the tracker, which is responsible for deleting temporary + * files. + * + * @param pTracker An instance of {@link FileCleaningTracker}, + * which will from now on track the created files, or null + * (default), to disable tracking. + */ + public void setFileCleaningTracker(FileCleaningTracker pTracker) { +<span class="nc" id="L230"> fileCleaningTracker = pTracker;</span> +<span class="nc" id="L231"> }</span> + + /** + * Returns the default charset for use when no explicit charset + * parameter is provided by the sender. + * @return the default charset + */ + public String getDefaultCharset() { +<span class="nc" id="L239"> return defaultCharset;</span> + } + + /** + * Sets the default charset for use when no explicit charset + * parameter is provided by the sender. + * @param pCharset the default charset + */ + public void setDefaultCharset(String pCharset) { +<span class="fc" id="L248"> defaultCharset = pCharset;</span> +<span class="fc" id="L249"> }</span> +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/index.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/index.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/index.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>org.apache.commons.fileupload.disk</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.source.html" class="el_source">Source Files</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <span class="el_package">org.apache.commons.fileupload.disk</span></div><h1>org.apache.commons.file upload.disk</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="to ggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">130 of 511</td><td class="ctr2">74%</td><td class="bar">19 of 54</td><td class="ctr2">64%</td><td class="ctr1">26</td><td class="ctr2">65</td><td class="ctr1">34</td><td class="ctr2">142</td><td class="ctr1">9</td><td class="ctr2">38</td><td class="ctr1">0</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="DiskFileItem.html" class="el_class">DiskFileItem</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="31" height="10" title="114" alt="114"/><img src="../jacoco-resources/greenbar.gif" width="88" height="10" title="321" alt="321"/></td><td class="ctr2" id="c1">73%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="41" height="10" title="18" alt="18"/><img src="../jacoco-resources/greenbar.gif" width="78" height="10" title="34" alt="34"/></td><td class="ctr2" id="e0">65%</td><td class="ctr1" id="f0">22</td><td class="ctr2" id=" g0">53</td><td class="ctr1" id="h0">28</td><td class="ctr2" id="i0">116</td><td class="ctr1" id="j0">6</td><td class="ctr2" id="k0">27</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr><tr><td id="a1"><a href="DiskFileItemFactory.html" class="el_class">DiskFileItemFactory</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="4" height="10" title="16" alt="16"/><img src="../jacoco-resources/greenbar.gif" width="16" height="10" title="60" alt="60"/></td><td class="ctr2" id="c0">78%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="2" height="10" title="1" alt="1"/><img src="../jacoco-resources/greenbar.gif" width="2" height="10" title="1" alt="1"/></td><td class="ctr2" id="e1">50%</td><td class="ctr1" id="f1">4</td><td class="ctr2" id="g1">12</td><td class="ctr1" id="h1">6</td><td class="ctr2" id="i1">26</td><td class="ctr1" id="j1">3</td><td class="ctr2" id="k1">11</td><td class="ctr1" id="l1">0</td><td class= "ctr2" id="m1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/index.source.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/index.source.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.disk/index.source.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>org.apache.commons.fileupload.disk</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="index.html" class="el_class">Classes</a><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <span class="el_package">org.apache.commons.fileupload.disk</span></div><h1>org.apache.commons.fileupload.disk</ h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this )">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">130 of 511</td><td class="ctr2">74%</td><td class="bar">19 of 54</td><td class="ctr2">64%</td><td class="ctr1">26</td><td class="ctr2">65</td><td class="ctr1">34</td><td class="ctr2">142</td><td class="ctr1">9</td><td class="ctr2">38</td><td class="ctr1">0</td><td class="ctr2">2</td></tr></tfoot><tbody><tr><td id="a0"><a href="DiskFileItem.java.html" class="el_source">DiskFileItem.java</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="31" height="10" title="114" alt="114"/><img src="../jacoco-resources/greenbar.gif" width="88" height="10" title="321" alt="321"/></td><td class="ctr2" id="c1">73%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="41" height="10" title="18" alt="18"/><img src="../jacoco-resources/greenbar.gif" width="78" height="10" title="34" alt="34"/></td><td class="ctr2" id="e0">65%</td><td class="ctr1" id="f0">22</td><td class="ctr2" id="g0 ">53</td><td class="ctr1" id="h0">28</td><td class="ctr2" id="i0">116</td><td class="ctr1" id="j0">6</td><td class="ctr2" id="k0">27</td><td class="ctr1" id="l0">0</td><td class="ctr2" id="m0">1</td></tr><tr><td id="a1"><a href="DiskFileItemFactory.java.html" class="el_source">DiskFileItemFactory.java</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="4" height="10" title="16" alt="16"/><img src="../jacoco-resources/greenbar.gif" width="16" height="10" title="60" alt="60"/></td><td class="ctr2" id="c0">78%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="2" height="10" title="1" alt="1"/><img src="../jacoco-resources/greenbar.gif" width="2" height="10" title="1" alt="1"/></td><td class="ctr2" id="e1">50%</td><td class="ctr1" id="f1">4</td><td class="ctr2" id="g1">12</td><td class="ctr1" id="h1">6</td><td class="ctr2" id="i1">26</td><td class="ctr1" id="j1">3</td><td class="ctr2" id="k1">11</td><td class="ctr1" id="l1">0</td>< td class="ctr2" id="m1">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletFileUpload.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletFileUpload.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletFileUpload.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>PortletFileUpload</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.html" class="el_package">org.apache.commons.fileupload.portlet</a> > <span class="el_class">PortletFileUpload</span></div><h1>PortletFileUpload</h1><table class="coverage" cells pacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">23 of 34</td><td class="ctr2">32%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1" >4</td><td class="ctr2">6</td><td class="ctr1">5</td><td >class="ctr2">8</td><td class="ctr1">4</td><td >class="ctr2">6</td></tr></tfoot><tbody><tr><td id="a3"><a >href="PortletFileUpload.java.html#L107" >class="el_method">parseRequest(ActionRequest)</a></td><td class="bar" >id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" >title="7" alt="7"/></td><td class="ctr2" id="c2">0%</td><td class="bar" >id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">1</td><td >class="ctr2" id="g0">1</td><td class="ctr1" id="h1">1</td><td class="ctr2" >id="i2">1</td><td class="ctr1" id="j0">1</td><td class="ctr2" >id="k0">1</td></tr><tr><td id="a0"><a href="PortletFileUpload.java.html#L146" >class="el_method">getItemIterator(ActionRequest)</a></td><td class="bar" >id="b1"><img src="../jacoco-resources/redbar.gif" width="120" height="10" >title="7" alt="7"/></td><td class="ctr2" id="c3">0%</td><td class="bar" >id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">1< /td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h2">1</td><td class="ctr2" id="i3">1</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a1"><a href="PortletFileUpload.java.html#L63" class="el_method">isMultipartContent(ActionRequest)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="102" height="10" title="6" alt="6"/></td><td class="ctr2" id="c4">0%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">1</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h3">1</td><td class="ctr2" id="i4">1</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a4"><a href="PortletFileUpload.java.html#L77" class="el_method">PortletFileUpload()</a></td><td class="bar" id="b3"><img src="../jacoco-resources/redbar.gif" width="51" height="10" title="3" alt="3"/></td><td class="ctr2" id="c5">0%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ct r1" id="f3">1</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h0">2</td><td class="ctr2" id="i0">2</td><td class="ctr1" id="j3">1</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a2"><a href="PortletFileUpload.java.html#L125" class="el_method">parseParameterMap(ActionRequest)</a></td><td class="bar" id="b4"><img src="../jacoco-resources/greenbar.gif" width="120" height="10" title="7" alt="7"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i5">1</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></tr><tr><td id="a5"><a href="PortletFileUpload.java.html#L88" class="el_method">PortletFileUpload(FileItemFactory)</a></td><td class="bar" id="b5"><img src="../jacoco-resources/greenbar.gif" width="68" height="10" title="4" alt="4"/></td><td class="ctr2" id="c1">100%</td><td class="bar" id="d5"/><td class ="ctr2" id="e5">n/a</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g5">1</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i1">2</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletFileUpload.java.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletFileUpload.java.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletFileUpload.java.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>PortletFileUpload.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.source.html" class="el_package">org.apache.commons.fileupload.portlet</a> > < span class="el_source">PortletFileUpload.java</span></div><h1>PortletFileUpload.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.portlet; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import javax.portlet.ActionRequest; + +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.FileItemIterator; +import org.apache.commons.fileupload.FileUpload; +import org.apache.commons.fileupload.FileUploadBase; +import org.apache.commons.fileupload.FileUploadException; + +/** + * <p>High level API for processing file uploads.</p> + * + * <p>This class handles multiple files per single HTML widget, sent using + * <code>multipart/mixed</code> encoding type, as specified by + * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use + * {@link org.apache.commons.fileupload.servlet.ServletFileUpload + * #parseRequest(javax.servlet.http.HttpServletRequest)} to acquire a list + * of {@link org.apache.commons.fileupload.FileItem FileItems} associated + * with a given HTML widget.</p> + * + * <p>How the data for individual parts is stored is determined by the factory + * used to create them; a given part may be in memory, on disk, or somewhere + * else.</p> + * + * @since FileUpload 1.1 + */ +public class PortletFileUpload extends FileUpload { + + // ---------------------------------------------------------- Class methods + + /** + * Utility method that determines whether the request contains multipart + * content. + * + * @param request The portlet request to be evaluated. Must be non-null. + * + * @return <code>true</code> if the request is multipart; + * <code>false</code> otherwise. + */ + public static final boolean isMultipartContent(ActionRequest request) { +<span class="nc" id="L63"> return FileUploadBase.isMultipartContent(</span> + new PortletRequestContext(request)); + } + + // ----------------------------------------------------------- Constructors + + /** + * Constructs an uninitialised instance of this class. A factory must be + * configured, using <code>setFileItemFactory()</code>, before attempting + * to parse requests. + * + * @see FileUpload#FileUpload(FileItemFactory) + */ + public PortletFileUpload() { +<span class="nc" id="L77"> super();</span> +<span class="nc" id="L78"> }</span> + + /** + * Constructs an instance of this class which uses the supplied factory to + * create <code>FileItem</code> instances. + * + * @see FileUpload#FileUpload() + * @param fileItemFactory The factory to use for creating file items. + */ + public PortletFileUpload(FileItemFactory fileItemFactory) { +<span class="fc" id="L88"> super(fileItemFactory);</span> +<span class="fc" id="L89"> }</span> + + // --------------------------------------------------------- Public methods + + /** + * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> + * compliant <code>multipart/form-data</code> stream. + * + * @param request The portlet request to be parsed. + * + * @return A list of <code>FileItem</code> instances parsed from the + * request, in the order that they were transmitted. + * + * @throws FileUploadException if there are problems reading/parsing + * the request or storing files. + */ + public List<FileItem> parseRequest(ActionRequest request) + throws FileUploadException { +<span class="nc" id="L107"> return parseRequest(new PortletRequestContext(request));</span> + } + + /** + * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> + * compliant <code>multipart/form-data</code> stream. + * + * @param request The portlet request to be parsed. + * + * @return A map of <code>FileItem</code> instances parsed from the request. + * + * @throws FileUploadException if there are problems reading/parsing + * the request or storing files. + * + * @since 1.3 + */ + public Map<String, List<FileItem>> parseParameterMap(ActionRequest request) + throws FileUploadException { +<span class="fc" id="L125"> return parseParameterMap(new PortletRequestContext(request));</span> + } + + /** + * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> + * compliant <code>multipart/form-data</code> stream. + * + * @param request The portlet request to be parsed. + * + * @return An iterator to instances of <code>FileItemStream</code> + * parsed from the request, in the order that they were + * transmitted. + * + * @throws FileUploadException if there are problems reading/parsing + * the request or storing files. + * @throws IOException An I/O error occurred. This may be a network + * error while communicating with the client or a problem while + * storing the uploaded content. + */ + public FileItemIterator getItemIterator(ActionRequest request) + throws FileUploadException, IOException { +<span class="nc" id="L146"> return super.getItemIterator(new PortletRequestContext(request));</span> + } + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletRequestContext.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletRequestContext.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletRequestContext.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>PortletRequestContext</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.html" class="el_package">org.apache.commons.fileupload.portlet</a> > <span class="el_class">PortletRequestContext</span></div><h1>PortletRequestContext</h1><table class="cov erage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">23 of 53</td><td class="ctr2">56%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1">1</td><td class="ctr2">7</td><td class="ctr1">5</td><td class="ctr2">15</td><td class="ctr1">1</td><td class="ctr2">7</td></tr></tfoot><tbody><tr><td id="a6"><a href="PortletRequestContext.java.html#L127" class="el_method">toString()</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="16" alt="16"/></td><td class="ctr2" id="c6">0%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">3</td><td class="ctr2" id="i1">3</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a0"><a href="PortletRequestContext.java.html#L101" class="el_method">contentLength()</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="52" height="10" title="7" alt="7"/><img src="../jacoco-resources/greenbar.gif" width="60" height="10" title="8" alt="8"/></td><td class="ctr2" id="c5">53%</td><td clas s="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">0</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">2</td><td class="ctr2" id="i0">5</td><td class="ctr1" id="j1">0</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a5"><a href="PortletRequestContext.java.html#L52" class="el_method">PortletRequestContext(ActionRequest)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/greenbar.gif" width="45" height="10" title="6" alt="6"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">0</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h2">0</td><td class="ctr2" id="i2">3</td><td class="ctr1" id="j2">0</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a1"><a href="PortletRequestContext.java.html#L66" class="el_method">getCharacterEncoding()</a></td><td class="bar" id="b3"><img src="../jacoco-resources/greenbar.gif" width="30" height="10" title="4" alt="4"/></td><td cla ss="ctr2" id="c1">100%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f3">0</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h3">0</td><td class="ctr2" id="i3">1</td><td class="ctr1" id="j3">0</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a3"><a href="PortletRequestContext.java.html#L76" class="el_method">getContentType()</a></td><td class="bar" id="b4"><img src="../jacoco-resources/greenbar.gif" width="30" height="10" title="4" alt="4"/></td><td class="ctr2" id="c2">100%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">0</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h4">0</td><td class="ctr2" id="i4">1</td><td class="ctr1" id="j4">0</td><td class="ctr2" id="k4">1</td></tr><tr><td id="a2"><a href="PortletRequestContext.java.html#L88" class="el_method">getContentLength()</a></td><td class="bar" id="b5"><img src="../jacoco-resources/greenbar.gif" width="30" height="10" title="4" alt="4"/>< /td><td class="ctr2" id="c3">100%</td><td class="bar" id="d5"/><td class="ctr2" id="e5">n/a</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g5">1</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i5">1</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k5">1</td></tr><tr><td id="a4"><a href="PortletRequestContext.java.html#L117" class="el_method">getInputStream()</a></td><td class="bar" id="b6"><img src="../jacoco-resources/greenbar.gif" width="30" height="10" title="4" alt="4"/></td><td class="ctr2" id="c4">100%</td><td class="bar" id="d6"/><td class="ctr2" id="e6">n/a</td><td class="ctr1" id="f6">0</td><td class="ctr2" id="g6">1</td><td class="ctr1" id="h6">0</td><td class="ctr2" id="i6">1</td><td class="ctr1" id="j6">0</td><td class="ctr2" id="k6">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file Added: websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletRequestContext.java.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletRequestContext.java.html (added) +++ websites/production/commons/content/proper/commons-fileupload/jacoco/org.apache.commons.fileupload.portlet/PortletRequestContext.java.html Mon Feb 13 10:43:35 2023 @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>PortletRequestContext.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons FileUpload</a> > <a href="index.source.html" class="el_package">org.apache.commons.fileupload.portlet</a> &g t; <span class="el_source">PortletRequestContext.java</span></div><h1>PortletRequestContext.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.portlet; + +import static java.lang.String.format; + +import java.io.IOException; +import java.io.InputStream; + +import javax.portlet.ActionRequest; + +import org.apache.commons.fileupload.FileUploadBase; +import org.apache.commons.fileupload.UploadContext; + +/** + * <p>Provides access to the request information needed for a request made to + * a portlet.</p> + * + * @since FileUpload 1.1 + */ +public class PortletRequestContext implements UploadContext { + + // ----------------------------------------------------- Instance Variables + + /** + * The request for which the context is being provided. + */ + private final ActionRequest request; + + + // ----------------------------------------------------------- Constructors + + /** + * Construct a context for this request. + * + * @param request The request to which this context applies. + */ +<span class="fc" id="L52"> public PortletRequestContext(ActionRequest request) {</span> +<span class="fc" id="L53"> this.request = request;</span> +<span class="fc" id="L54"> }</span> + + + // --------------------------------------------------------- Public Methods + + /** + * Retrieve the character encoding for the request. + * + * @return The character encoding for the request. + */ + @Override + public String getCharacterEncoding() { +<span class="fc" id="L66"> return request.getCharacterEncoding();</span> + } + + /** + * Retrieve the content type of the request. + * + * @return The content type of the request. + */ + @Override + public String getContentType() { +<span class="fc" id="L76"> return request.getContentType();</span> + } + + /** + * Retrieve the content length of the request. + * + * @return The content length of the request. + * @deprecated 1.3 Use {@link #contentLength()} instead + */ + @Override + @Deprecated + public int getContentLength() { +<span class="fc" id="L88"> return request.getContentLength();</span> + } + + /** + * Retrieve the content length of the request. + * + * @return The content length of the request. + * @since 1.3 + */ + @Override + public long contentLength() { + long size; + try { +<span class="nc" id="L101"> size = Long.parseLong(request.getProperty(FileUploadBase.CONTENT_LENGTH));</span> +<span class="fc" id="L102"> } catch (NumberFormatException e) {</span> +<span class="fc" id="L103"> size = request.getContentLength();</span> +<span class="nc" id="L104"> }</span> +<span class="fc" id="L105"> return size;</span> + } + + /** + * Retrieve the input stream for the request. + * + * @return The input stream for the request. + * + * @throws IOException if a problem occurs. + */ + @Override + public InputStream getInputStream() throws IOException { +<span class="fc" id="L117"> return request.getPortletInputStream();</span> + } + + /** + * Returns a string representation of this object. + * + * @return a string representation of this object. + */ + @Override + public String toString() { +<span class="nc" id="L127"> return format("ContentLength=%s, ContentType=%s",</span> +<span class="nc" id="L128"> Long.valueOf(this.contentLength()),</span> +<span class="nc" id="L129"> this.getContentType());</span> + } + +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html> \ No newline at end of file
