Example usage for org.apache.wicket.util.file Folder Folder

List of usage examples for org.apache.wicket.util.file Folder Folder

Introduction

In this page you can find the example usage for org.apache.wicket.util.file Folder Folder.

Prototype

public Folder(final URI uri) 

Source Link

Document

Constructor.

Usage

From source file:nl.knaw.dans.common.wicket.components.jumpoff.SimpleUploadPanel.java

License:Apache License

private Folder getUploadFolder() {
    File tmpDir = new File(System.getProperty("java.io.tmpdir"));
    File uploadDir = new File(tmpDir, Session.get().getId());
    uploadDir.mkdirs();/*from   ww  w  .  j a  v  a2s.  c  om*/
    Folder folder = new Folder(uploadDir);
    return folder;//((UploadApplication)Application.get()).getUploadFolder();
}

From source file:org.artifactory.common.wicket.component.file.path.PathHelper.java

License:Open Source License

public void setWorkingDirectoryPath(String workingDirectoryPath) {
    if (workingDirectoryPath == null) {
        this.workingDirectoryPath = null;
        return;/*from w ww  . j  a v  a2 s.  com*/
    }

    this.workingDirectoryPath = new Folder(workingDirectoryPath).getAbsolutePath().replace('\\', '/');
    if (!this.workingDirectoryPath.endsWith("/")) {
        this.workingDirectoryPath += "/";
    }
}

From source file:org.artifactory.common.wicket.component.file.path.PathHelper.java

License:Open Source License

public List<File> getFiles(String path, PathMask mask) {
    String absolutePath = getAbsolutePath(path);
    Folder folder = new Folder(getPathFolder(absolutePath));

    if (!folder.exists() || !folder.isDirectory()) {
        return Collections.emptyList();
    }//from   w w  w  . j a  v  a 2 s.  com

    if (!isParentOf(workingDirectoryPath, folder)) {
        return Collections.emptyList();
    }
    Folder[] folders = folder.getFolders();
    File[] files = folder.getFiles();
    List<File> filesList = new ArrayList<>(folders.length + files.length);

    if (mask.includeFolders()) {
        for (Folder file : folders) {
            String fileAbsPath = file.getAbsolutePath().replace('\\', '/');
            if (startsWithIgnoreCase(fileAbsPath, absolutePath)) {
                filesList.add(file);
            }
        }
    }

    if (mask.includeFiles()) {
        for (File file : files) {
            String fileAbsPath = file.getPath().replace('\\', '/');
            if (startsWithIgnoreCase(fileAbsPath, absolutePath)) {
                filesList.add(file);
            }
        }
    }
    return filesList;
}

From source file:org.cast.cwm.components.DeployJava.java

License:Open Source License

/**
 * Provides a URL to a shared resource for the given jarFile.  If a resource
 * does not exist, it searches the /WEB-INF/lib folder for a file that starts with 
 * the provided name and adds the resource first.
 * /*from   w ww . j a  v  a  2 s  . com*/
 * @param jarName
 * @return
 */
public String getSharedArchiveURL(final String jarName) {
    SharedResources sr = Application.get().getSharedResources();

    // If this jarName is not listed as a shared resource, add it as one.
    if (sr.get(DeployJava.class, jarName, null, null, null, false) == null) {
        ServletContext sc = WebApplication.get().getServletContext();
        String path = "/WEB-INF/lib";
        File jar = findMatchingFile(new Folder(sc.getRealPath(path)), jarName);
        if (jar == null) {
            path = "/WEB-INF/classes";
            jar = findMatchingFile(new Folder(sc.getRealPath(path)), jarName);
        }
        if (jar == null) {
            log.error("No JAR found matching {}, looked in {} and {}", jarName, sc.getRealPath("/WEB-INF/lib"),
                    sc.getRealPath("/WEB-INF/classes"));
        } else {
            log.debug("Adding JAR to Shared Resources: {}", jar.getAbsolutePath());
            ContextRelativeResource resource = new ContextRelativeResource(path + "/" + jar.getName());
            sr.add(DeployJava.class, jarName, null, null, null, resource);
        }
    }

    return urlFor(new PackageResourceReference(DeployJava.class, jarName), null).toString();
}

From source file:org.devproof.portal.module.uploadcenter.panel.UploadFilePanel.java

License:Apache License

private Form<Collection<FileUpload>> newUploadForm() {
    return new Form<Collection<FileUpload>>("uploadForm", uploadModel) {
        private static final long serialVersionUID = 1L;

        @Override/* w w  w . jav  a  2 s.c  o  m*/
        protected void onSubmit() {
            Folder uploadFolder = new Folder(uploadFolderModel.getObject().getAbsolutePath());
            Collection<FileUpload> fileUploads = uploadModel.getObject();
            for (FileUpload fileUpload : fileUploads) {
                File newFile = new File(uploadFolder, fileUpload.getClientFileName());
                UploadFilePanel.this.deleteFile(newFile);
                try {
                    if (newFile.createNewFile()) {
                        fileUpload.writeTo(newFile);
                        UploadFilePanel.this.info(new StringResourceModel("msg.uploaded", UploadFilePanel.this,
                                null, new Object[] { fileUpload.getClientFileName() }).getString());
                    } else {
                        throw new IllegalStateException("Unable to write file" + newFile);
                    }
                } catch (Exception e) {
                    throw new UnhandledException(e);
                }
            }
            UploadFilePanel.this.onSubmit();
            super.onSubmit();
        }
    };
}

From source file:pl.klimczakowie.cpublication2.web.WicketApplication.java

License:Apache License

/**
 * Init// w ww . j  a  v  a  2  s . com
 */
@Override
public void init() {
    getResourceSettings().getResourceFinders().add(new Path(new Folder("htmls/cpublication2/")));
    getResourceSettings().setResourcePollFrequency(Duration.milliseconds(1000));
    getRequestCycleSettings().setRenderStrategy(IRequestCycleSettings.RenderStrategy.ONE_PASS_RENDER);
}