Example usage for org.apache.commons.vfs FileSystem addJunction

List of usage examples for org.apache.commons.vfs FileSystem addJunction

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileSystem addJunction.

Prototype

void addJunction(String junctionPoint, FileObject targetFile) throws FileSystemException;

Source Link

Document

Adds a junction to this file system.

Usage

From source file:org.jboss.dashboard.filesystem.BinariesMapping.java

public void addToVirtualFilesystem(FileSystem fileSystem) throws FileSystemException {
    if (!isWebappDirectoryRelative()) {
        FileObject file = VfsWrapper.getManager()
                .resolveFile(getSchema() + "://" + StringUtils.defaultString(getJunctionUrl()));
        file.createFolder(); //ensure it exists
        fileSystem.addJunction(getJunctionPoint(), file);
    } else {/*from   w  ww  .j a v  a2  s. co  m*/
        File parentFile = new File(Application.lookup().getBaseAppDirectory());
        String junctionUrl = getJunctionUrl();

        while (junctionUrl.startsWith("../")) {
            junctionUrl = junctionUrl.substring(3);
            parentFile = parentFile.getParentFile();
        }

        FileObject file = VfsWrapper.getManager().resolveFile(getSchema() + "://" + parentFile
                + (StringUtils.isEmpty(junctionUrl) ? "" : ("/" + junctionUrl)));
        file.createFolder(); //ensure it exists
        fileSystem.addJunction(getJunctionPoint(), file);

    }
}