Package org.apache.wicket.util.file

Examples of org.apache.wicket.util.file.FileCleaner


    // Add resolver for automatically resolving HTML links
    getPageSettings().addComponentResolver(new AutoLinkResolver());
    getPageSettings().addComponentResolver(new AutoLabelResolver());
    getPageSettings().addComponentResolver(new AutoLabelTextResolver());

    getResourceSettings().setFileCleaner(new FileCleaner());

    if (getConfigurationType() == RuntimeConfigurationType.DEVELOPMENT)
    {
      // Add optional sourceFolder for resources.
      String resourceFolder = getInitParameter("sourceFolder");
View Full Code Here


    // Add resolver for automatically resolving HTML links
    getPageSettings().addComponentResolver(new AutoLinkResolver());
    getPageSettings().addComponentResolver(new AutoLabelResolver());
    getPageSettings().addComponentResolver(new AutoLabelTextResolver());

    getResourceSettings().setFileCleaner(new FileCleaner());

    if (getConfigurationType() == RuntimeConfigurationType.DEVELOPMENT)
    {
      // Add optional sourceFolder for resources.
      String resourceFolder = getInitParameter("sourceFolder");
View Full Code Here

   * @throws Exception
   */
  @Test
  public void getInputStream() throws Exception
  {
    final IFileCleaner fileUploadCleaner = new FileCleaner();

    DiskFileItemFactory itemFactory = new DiskFileItemFactory()
    {
      @Override
      public FileCleaningTracker getFileCleaningTracker()
      {
        return new FileCleanerTrackerAdapter(fileUploadCleaner);
      }
    };
    FileItem fileItem = itemFactory.createItem("dummyFieldName",
        "text/java", false, "FileUploadTest.java");
    // Initialize the upload
    fileItem.getOutputStream();

    // Get the internal list out
    Field inputStreamsField = FileUpload.class.getDeclaredField("inputStreamsToClose");
    inputStreamsField.setAccessible(true);

    FileUpload fileUpload = new FileUpload(fileItem);

    List<?> inputStreams = (List<?>)inputStreamsField.get(fileUpload);

    assertNull(inputStreams);

    InputStream is1 = fileUpload.getInputStream();
    inputStreams = (List<?>)inputStreamsField.get(fileUpload);

    assertEquals(1, inputStreams.size());

    InputStream is2 = fileUpload.getInputStream();
    inputStreams = (List<?>)inputStreamsField.get(fileUpload);

    assertEquals(2, inputStreams.size());

    assertNotSame(is1, is2);

    // Ok lets close all the streams
    try
    {
      fileUpload.closeStreams();
    }
    catch (Exception e)
    {
      fail();
    }

    inputStreams = (List<?>)inputStreamsField.get(fileUpload);

    assertNull(inputStreams);

    fileUploadCleaner.destroy();
  }
View Full Code Here

    getPageSettings().addComponentResolver(new AutoLabelTextResolver());

    // Set resource finder to web app path
    getResourceSettings().setResourceFinder(getResourceFinder());

    getResourceSettings().setFileCleaner(new FileCleaner());

    // Add optional sourceFolder for resources.
    String resourceFolder = getInitParameter("sourceFolder");
    if (resourceFolder != null)
    {
View Full Code Here

    // Add resolver for automatically resolving HTML links
    getPageSettings().addComponentResolver(new AutoLinkResolver());
    getPageSettings().addComponentResolver(new AutoLabelResolver());
    getPageSettings().addComponentResolver(new AutoLabelTextResolver());

    getResourceSettings().setFileCleaner(new FileCleaner());

    if (getConfigurationType() == RuntimeConfigurationType.DEVELOPMENT)
    {
      // Add optional sourceFolder for resources.
      String resourceFolder = getInitParameter("sourceFolder");
View Full Code Here

    // Add resolver for automatically resolving HTML links
    getPageSettings().addComponentResolver(new AutoLinkResolver());
    getPageSettings().addComponentResolver(new AutoLabelResolver());
    getPageSettings().addComponentResolver(new AutoLabelTextResolver());

    getResourceSettings().setFileCleaner(new FileCleaner());

    if (getConfigurationType() == RuntimeConfigurationType.DEVELOPMENT)
    {
      // Add optional sourceFolder for resources.
      String resourceFolder = getInitParameter("sourceFolder");
View Full Code Here

    getPageSettings().addComponentResolver(new AutoLabelTextResolver());

    // Set resource finder to web app path
    getResourceSettings().setResourceFinder(getResourceFinder());

    getResourceSettings().setFileCleaner(new FileCleaner());

    // Add optional sourceFolder for resources.
    String resourceFolder = getInitParameter("sourceFolder");
    if (resourceFolder != null)
    {
View Full Code Here

   *
   * @throws Exception
   */
  public void testGetInputStream() throws Exception
  {
    IFileCleaner fileUploadCleaner = new FileCleaner();

    FileItem fileItem = new DiskFileItemFactory(fileUploadCleaner).createItem("dummyFieldName",
      "text/java", false, "FileUploadTest.java");
    // Initialize the upload
    fileItem.getOutputStream();

    // Get the internal list out
    Field inputStreamsField = FileUpload.class.getDeclaredField("inputStreamsToClose");
    inputStreamsField.setAccessible(true);

    FileUpload fileUpload = new FileUpload(fileItem);

    List<?> inputStreams = (List<?>)inputStreamsField.get(fileUpload);

    assertNull(inputStreams);

    InputStream is1 = fileUpload.getInputStream();
    inputStreams = (List<?>)inputStreamsField.get(fileUpload);

    assertEquals(1, inputStreams.size());

    InputStream is2 = fileUpload.getInputStream();
    inputStreams = (List<?>)inputStreamsField.get(fileUpload);

    assertEquals(2, inputStreams.size());

    assertNotSame(is1, is2);

    // Ok lets close all the streams
    try
    {
      fileUpload.closeStreams();
    }
    catch (Exception e)
    {
      fail();
    }

    inputStreams = (List<?>)inputStreamsField.get(fileUpload);

    assertNull(inputStreams);

    fileUploadCleaner.destroy();
  }
View Full Code Here

    getPageSettings().addComponentResolver(new AutoLabelTextResolver());

    // Set resource finder to web app path
    getResourceSettings().setResourceFinder(getResourceFinder());

    getResourceSettings().setFileCleaner(new FileCleaner());

    // Add optional sourceFolder for resources.
    String resourceFolder = getInitParameter("sourceFolder");
    if (resourceFolder != null)
    {
View Full Code Here

            return;
        }
        try {

            ServletFileUpload upload = new ServletFileUpload(
                    new DiskFileItemFactory(new FileCleaner()));
            List<FileItem> items = upload.parseRequest(req);

            for (FileItem item : items) {

                if (Utils.isBlank(item.getName()))
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.file.FileCleaner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.