Example usage for org.apache.commons.vfs2 FileObject getName

List of usage examples for org.apache.commons.vfs2 FileObject getName

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 FileObject getName.

Prototype

FileName getName();

Source Link

Document

Returns the name of this file.

Usage

From source file:com.stratuscom.harvester.deployer.FolderBasedAppRunner.java

private Map<String, DeploymentRecord> scanDeploymentArchives() throws FileSystemException {
    /*//from   w w  w . ja v  a2 s  . c o m
     Go through the deployment directory looking for services to deploy.
     */
    Map<String, DeploymentRecord> deployDirListing = new HashMap<String, DeploymentRecord>();
    deploymentDirectoryFile.refresh();
    List<FileObject> serviceArchives = Utils.findChildrenWithSuffix(deploymentDirectoryFile,
            com.stratuscom.harvester.Strings.JAR);
    if (serviceArchives != null) {
        log.log(Level.FINER, MessageNames.FOUND_SERVICE_ARCHIVES,
                new Object[] { serviceArchives.size(), deployDirectory });
        for (FileObject serviceArchive : serviceArchives) {
            DeploymentRecord rec = new DeploymentRecord();
            rec.fileObject = serviceArchive;
            rec.name = serviceArchive.getName().getBaseName();
            rec.updateTime = serviceArchive.getContent().getLastModifiedTime();
            deployDirListing.put(rec.name, rec);
        }
    }
    return deployDirListing;
}

From source file:com.seeburger.vfs2.util.VFSClassLoader.java

/**
 * Does a reverse lookup to find the FileObject when we only have the
 * URL./* ww  w . j  ava  2 s.c  o m*/
 */
private FileObject lookupFileObject(final String name) {
    final Iterator<FileObject> it = resources.iterator();
    while (it.hasNext()) {
        final FileObject object = it.next();
        if (name.equals(object.getName().getURI())) {
            return object;
        }
    }
    return null;
}

From source file:com.flicklib.folderscanner.AdvancedFolderScanner.java

protected FileMeta createFileMeta(FileObject f, MovieFileType type) throws FileSystemException {
    return new FileMeta(f.getName().getBaseName(), type, f.getContent().getSize());
}

From source file:com.flicklib.folderscanner.AdvancedFolderScanner.java

/**
 * add the compressed files to the file group, which are in the specified directory.
 * @param sm//from   w w  w .ja  v  a2 s.  co  m
 * @param fg
 * @param fileList
 * @param folderName
 * @throws FileSystemException 
 */
private void addCompressedFiles(FileGroup fg, FileObject[] fileList, String folderName)
        throws FileSystemException {
    for (FileObject f : fileList) {
        if (f.getType().hasChildren() && folderName.equals(f.getName().getBaseName().toLowerCase())) {
            addCompressedFiles(fg, f.getChildren());
        }
    }
}

From source file:fi.mystes.synapse.mediator.vfs.VfsFileTransferUtility.java

/**
 * Creates File filter that matches file names to given regex
 *
 * @param regex/*from  w w w. jav a 2 s.  c  o m*/
 * @return
 */
private FileFilter initFileFilter(final String regex) {
    FileFilter ff = new FileFilter() {
        public boolean accept(FileSelectInfo fileInfo) {
            FileObject fo = fileInfo.getFile();
            return fo.getName().getBaseName().matches(regex);
        }

    };
    return ff;
}

From source file:com.sludev.commons.vfs2.provider.s3.SS3FileProviderTest.java

/**
 * By default FileObject.getChildren() will use doListChildrenResolved() if available
 * /*w w  w. ja v a2s.  c  o  m*/
 * @throws Exception 
 */
@Test
public void A007_listChildren() throws Exception {
    String currAccountStr = testProperties.getProperty("s3.access.id");
    String currKey = testProperties.getProperty("s3.access.secret");
    String currContainerStr = testProperties.getProperty("s3.test0001.bucket.name");
    String currHost = testProperties.getProperty("s3.host");
    String currRegion = testProperties.getProperty("s3.region");

    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    SS3FileProvider currSS3 = new SS3FileProvider();

    // Optional set endpoint
    //currSS3.setEndpoint(currHost);

    // Optional set region
    //currSS3.setRegion(currRegion);

    currMan.addProvider(SS3Constants.S3SCHEME, currSS3);
    currMan.init();

    StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey);
    FileSystemOptions opts = new FileSystemOptions();
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);

    String currFileNameStr = "uploadFile02";
    String currUriStr = String.format("%s://%s/%s/%s", SS3Constants.S3SCHEME, currHost, currContainerStr,
            currFileNameStr);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);

    FileObject[] currObjs = currFile.getChildren();
    for (FileObject obj : currObjs) {
        FileName currName = obj.getName();
        Boolean res = obj.exists();
        FileType ft = obj.getType();

        log.info(String.format("\nNAME.PATH : '%s'\nEXISTS : %b\nTYPE : %s\n\n", currName.getPath(), res, ft));
    }
}

From source file:fi.mystes.synapse.mediator.vfs.VfsFileTransferUtility.java

/**
 * Helper method to retrieve given file object's friendly URI.
 * /* w w  w.  j av a 2s .  c  om*/
 * @param fileObject
 *            To retrieve friendly URI from
 * @return Friendly URI or null
 */
private String fileObjectNameForDebug(FileObject fileObject) {
    return fileObject == null ? null : fileObject.getName().getFriendlyURI();
}

From source file:com.sludev.commons.vfs.simpleshell.SimpleShell.java

/**
 * Lists the children of a folder./* www  .  ja va  2  s .  c o  m*/
 */
public void listChildren(final FileObject dir, final boolean recursive, final String prefix)
        throws FileSystemException {
    final FileObject[] children = dir.getChildren();
    for (int i = 0; i < children.length; i++) {
        final FileObject child = children[i];
        System.out.print(prefix);
        System.out.print(child.getName().getBaseName());
        if (child.getType() == FileType.FOLDER) {
            System.out.println("/");
            if (recursive) {
                listChildren(child, recursive, prefix + "    ");
            }
        } else {
            System.out.println();
        }
    }
}

From source file:com.googlecode.vfsjfilechooser2.filechooser.AbstractVFSFileSystemView.java

/**
 * Name of a file, directory, or folder as it would be displayed in
 * a system file browser. Example from Windows: the "M:\" directory
 * displays as "CD-ROM (M:)"/*w  ww  . j av a2  s .  c  o  m*/
 *
 * The default implementation gets information from the ShellFolder class.
 *
 * @param f a <code>File</code> object
 * @return the file name as it would be displayed by a native file chooser
 * @see JFileChooser#getName
 * @since 1.4
 */
public String getSystemDisplayName(FileObject f) {
    String name = null;

    if (f != null) {
        name = f.getName().getBaseName();

        if (!name.trim().equals("")) {
            name = VFSUtils.getFriendlyName(f.getName() + "");
        }
    }

    return name;
}

From source file:architecture.ee.component.core.lifecycle.ConfigServiceImpl.java

/**
 * @return//from   w ww .j  av a2 s  .c om
 */
public String getEffectiveRootPath() {
    if (!StringUtils.isEmpty(effectiveRootPath)) {
        return effectiveRootPath;
    } else {
        String uri = getConfigRoot().getRootURI();
        FileObject obj = VFSUtils.resolveFile(uri);
        effectiveRootPath = obj.getName().getPath();
        return effectiveRootPath;
    }
}