org.apache.commons.io.FileCleaningTracker Java Examples

The following examples show how to use org.apache.commons.io.FileCleaningTracker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DiskFileItemFactory.java    From Mars-Java with MIT License 3 votes vote down vote up
/**
 * 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) {
    DiskFileItem result = new DiskFileItem(fieldName, contentType,
            isFormField, fileName, sizeThreshold, repository);
    result.setDefaultCharset(defaultCharset);
    FileCleaningTracker tracker = getFileCleaningTracker();
    if (tracker != null) {
        tracker.track(result.getTempFile(), result);
    }
    return result;
}
 
Example #2
Source File: DiskFileItemFactory.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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.
 */
public FileItem createItem(String fieldName, String contentType,
        boolean isFormField, String fileName) {
    DiskFileItem result = new DiskFileItem(fieldName, contentType,
            isFormField, fileName, sizeThreshold, repository);
    FileCleaningTracker tracker = getFileCleaningTracker();
    if (tracker != null) {
        tracker.track(result.getTempFile(), result);
    }
    return result;
}
 
Example #3
Source File: DiskFileItemFactory.java    From AndroidWebServ with Apache License 2.0 3 votes vote down vote up
/**
 * 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.
 */
public FileItem createItem(String fieldName, String contentType,
        boolean isFormField, String fileName) {
    DiskFileItem result = new DiskFileItem(fieldName, contentType,
            isFormField, fileName, sizeThreshold, repository);
    FileCleaningTracker tracker = getFileCleaningTracker();
    if (tracker != null) {
        tracker.track(result.getTempFile(), result);
    }
    return result;
}
 
Example #4
Source File: DiskFileItemFactory.java    From Mars-Java with MIT License 2 votes vote down vote up
/**
 * 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() {
    return fileCleaningTracker;
}
 
Example #5
Source File: DiskFileItemFactory.java    From Mars-Java with MIT License 2 votes vote down vote up
/**
 * 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) {
    fileCleaningTracker = pTracker;
}
 
Example #6
Source File: FileCleanerCleanup.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the instance of {@link FileCleaningTracker}, which is
 * associated with the given {@link ServletContext}.
 *
 * @param pServletContext The servlet context to query
 * @return The contexts tracker
 */
public static FileCleaningTracker
        getFileCleaningTracker(ServletContext pServletContext) {
    return (FileCleaningTracker)
        pServletContext.getAttribute(FILE_CLEANING_TRACKER_ATTRIBUTE);
}
 
Example #7
Source File: FileCleanerCleanup.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the instance of {@link FileCleaningTracker}, which is
 * associated with the given {@link ServletContext}.
 *
 * @param pServletContext The servlet context to modify
 * @param pTracker The tracker to set
 */
public static void setFileCleaningTracker(ServletContext pServletContext,
        FileCleaningTracker pTracker) {
    pServletContext.setAttribute(FILE_CLEANING_TRACKER_ATTRIBUTE, pTracker);
}
 
Example #8
Source File: FileCleanerCleanup.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Called when the web application is initialized. Does
 * nothing.
 *
 * @param sce The servlet context, used for calling
 *   {@link #setFileCleaningTracker(ServletContext, FileCleaningTracker)}.
 */
public void contextInitialized(ServletContextEvent sce) {
    setFileCleaningTracker(sce.getServletContext(),
            new FileCleaningTracker());
}
 
Example #9
Source File: DiskFileItemFactory.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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() {
    return fileCleaningTracker;
}
 
Example #10
Source File: DiskFileItemFactory.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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) {
    fileCleaningTracker = pTracker;
}
 
Example #11
Source File: DiskFileItemFactory.java    From AndroidWebServ with Apache License 2.0 2 votes vote down vote up
/**
 * 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() {
    return fileCleaningTracker;
}
 
Example #12
Source File: DiskFileItemFactory.java    From AndroidWebServ with Apache License 2.0 2 votes vote down vote up
/**
 * 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) {
    fileCleaningTracker = pTracker;
}