List of usage examples for org.apache.commons.vfs2 FileType FOLDER
FileType FOLDER
To view the source code for org.apache.commons.vfs2 FileType FOLDER.
Click Source Link
From source file:edu.byu.nlp.data.streams.DirectoryReader.java
public DirectoryReader(FileObject directory, String fieldname) throws FileSystemException { Preconditions.checkNotNull(directory); Preconditions.checkArgument(directory.getType() == FileType.FOLDER, directory + " is not a directory"); this.source = directory.toString(); this.directory = directory; this.fieldname = fieldname; }
From source file:net.sourceforge.fullsync.fs.connection.CommonsVfsConnection.java
private File buildNode(final File parent, final FileObject file) throws org.apache.commons.vfs2.FileSystemException { String name = file.getName().getBaseName(); File n = new AbstractFile(this, name, parent, file.getType() == FileType.FOLDER, true); if (file.getType() == FileType.FILE) { FileContent content = file.getContent(); n.setLastModified(content.getLastModifiedTime()); n.setSize(content.getSize());/* w w w . jav a 2 s.c o m*/ } return n; }
From source file:com.github.songsheng.vfs2.provider.nfs.NfsFileObject.java
/** * Determines the type of the file, returns null if the file does not * exist.//from w w w. j av a 2s .c om */ @Override protected FileType doGetType() throws Exception { if (!file.exists()) { return FileType.IMAGINARY; } else if (file.isDirectory()) { return FileType.FOLDER; } else if (file.isFile()) { return FileType.FILE; } throw new FileSystemException("vfs.provider.Nfs/get-type.error", getName()); }
From source file:com.mirth.connect.util.messagewriter.MessageWriterVfs.java
@Override public boolean write(Message message) throws MessageWriterException { try {/*from ww w . j a va2 s. co m*/ String content = (contentType == null) ? toXml(message) : extractContent(message); if (StringUtils.isNotBlank(content)) { String file = uri + IOUtils.DIR_SEPARATOR + replacer.replaceValues(filePattern, message, false); if (!file.equals(currentFile)) { if (writer != null) { writer.close(); } if (currentFileObject != null) { currentFileObject.close(); } currentFile = file; currentFileObject = VFS.getManager().resolveFile(file); if (currentFileObject.getType() == FileType.FOLDER) { throw new MessageWriterException( "Cannot save message to file \"" + file + "\", it is a directory"); } writer = new OutputStreamWriter(currentFileObject.getContent().getOutputStream(true)); } writer.write(content); writer.append(IOUtils.LINE_SEPARATOR_WINDOWS); // the VFS output stream requires windows newlines writer.flush(); return true; } return false; } catch (Exception e) { throw new MessageWriterException(e); } }
From source file:net.sourceforge.fullsync.fs.connection.CommonsVfsConnection.java
@Override public final Map<String, File> getChildren(final File dir) throws IOException { try {//from www . j ava2 s . c o m Map<String, File> children = new HashMap<>(); FileObject obj = base.resolveFile(dir.getPath()); if (obj.exists() && (obj.getType() == FileType.FOLDER)) { FileObject[] list = obj.getChildren(); for (FileObject element : list) { children.put(element.getName().getBaseName(), buildNode(dir, element)); } } return children; } catch (org.apache.commons.vfs2.FileSystemException fse) { throw new IOException(fse.getMessage(), fse); } }
From source file:com.sonicle.webtop.vfs.bol.js.JsGridFile.java
private String getFileType(FileObject fo) { try {//from ww w . ja v a2 s . c o m if (fo.getType().equals(FileType.FOLDER)) { return "folder"; } else { return "file"; } } catch (FileSystemException ex) { return "file"; } }
From source file:de.innovationgate.wgpublisher.design.fs.FileSystemDesignSource.java
public List<String> getDesignNames() throws WGADesignRetrievalException { try {//from www .j av a2 s .c o m List<String> designs = new ArrayList<String>(); // Add child design directories - All with a syncinfo/design.xml or those that are completely empty and can be initialized _dir.refresh(); FileObject[] children = _dir.getChildren(); for (int i = 0; i < children.length; i++) { FileObject child = children[i]; if (child.getType().equals(FileType.FOLDER)) { FileObject resolvedChild = WGUtils.resolveDirLink(child); if (resolvedChild.getType().equals(FileType.FOLDER)) { FileObject syncInfo = DesignDirectory.getDesignDefinitionFile(resolvedChild); if (syncInfo != null || child.getChildren().length == 0) { designs.add(child.getName().getBaseName()); } } } else if (child.getType().equals(FileType.FILE) && child.getName().getExtension().equalsIgnoreCase(ARCHIVED_DESIGN_EXTENSION)) { designs.add(DESIGNNAMEPREFIX_ARCHIVE + child.getName().getBaseName().substring(0, child.getName().getBaseName().lastIndexOf("."))); } } // Add additional directories Iterator<Map.Entry<String, String>> dirs = _additionalDirs.entrySet().iterator(); while (dirs.hasNext()) { Map.Entry<String, String> entry = dirs.next(); FileObject dir = VFS.getManager().resolveFile((String) entry.getValue()); if (dir.exists() && dir.getType().equals(FileType.FOLDER)) { FileObject syncInfo = DesignDirectory.getDesignDefinitionFile(dir); if (syncInfo != null || dir.getChildren().length == 0) { designs.add(DESIGNNAMEPREFIX_ADDITIONALDIR + entry.getKey()); } } } return designs; } catch (FileSystemException e) { throw new WGADesignRetrievalException("Exception retrieving file system designs", e); } }
From source file:edu.byu.nlp.data.docs.DocumentDatasetBuilder.java
/** * See class description./*from ww w.ja va2 s . c om*/ * * @throws FileSystemException if there is a problem finding the specified directories on the * filesystem. */ public DocumentDatasetBuilder(String basedir, String dataset, String split, @Nullable Function<String, String> docTransform, @Nullable Function<String, Iterable<String>> sentenceSplitter, @Nullable Function<String, Iterable<String>> tokenizer, @Nullable Function<String, String> tokenTransform, FeatureSelectorFactory featureSelectorFactory, @Nullable Integer featureNormalizationConstant) throws FileSystemException { // TODO: consider taking the FileObject as a parameter FileSystemManager fsManager = VFS.getManager(); if (fsManager instanceof DefaultFileSystemManager) { ((DefaultFileSystemManager) fsManager).setBaseFile(new File(".")); } this.basedir = fsManager.resolveFile(basedir); Preconditions.checkNotNull(this.basedir, "%s cannot be resolved", basedir); Preconditions.checkArgument(this.basedir.getType() == FileType.FOLDER, this.basedir + " must be a folder"); FileObject indices = this.basedir.getChild("indices"); Preconditions.checkNotNull(indices, "cannot find indices directory in %s", basedir); FileObject datasetDir = indices.getChild(dataset); Preconditions.checkNotNull(datasetDir, "cannot find index for dataset %s", dataset); this.indexDirectory = datasetDir.getChild(split); Preconditions.checkNotNull(indexDirectory, "cannot find split %s", split); Preconditions.checkArgument(indexDirectory.getType() == FileType.FOLDER); this.docTransform = docTransform; this.sentenceSplitter = sentenceSplitter; this.tokenizer = tokenizer; this.tokenTransform = tokenTransform; this.featureSelectorFactory = featureSelectorFactory; this.featureNormalizationConstant = featureNormalizationConstant; }
From source file:de.blizzy.backup.vfs.RemoteFileOrFolder.java
@Override public boolean isFolder() throws IOException { if (isFolder == null) { isFolder = Boolean.valueOf(getFileObject().getType().equals(FileType.FOLDER)); }/* w w w .ja va2 s . c o m*/ return isFolder.booleanValue(); }
From source file:com.stratuscom.harvester.deployer.CommandLineAppRunner.java
/** * If clientAppName has been set, then we're running a predetermined app as * a result of the entry in Config.xml. In that case, we're not going to * bother with any '-with' options.// w w w. j a v a2 s . co m * * @throws IOException * @throws ParseException * @throws org.apache.commons.cli.ParseException */ private void tryInitialize() throws IOException, ParseException, org.apache.commons.cli.ParseException { log.log(Level.FINE, MessageNames.STARTER_SERVICE_DEPLOYER_STARTING, myName); /* Establish the deployment directory. */ deploymentDirectoryFile = fileUtility.getProfileDirectory().resolveFile(deployDirectory); if (deploymentDirectoryFile == null || deploymentDirectoryFile.getType() != FileType.FOLDER) { log.log(Level.WARNING, MessageNames.NO_DEPLOYMENT_DIRECTORY, new Object[] { deployDirectory, fileUtility.getProfileDirectory() }); } /* * Find the name of the client we need to deploy. */ /* First argument was the profile name. Second argument is the name of * the client app to run. All the rest are parameters to the client * app. */ if (clientAppName == null && commandLineArguments.length < 2) { System.out.println(messages.getString(MessageNames.CLIENT_APP_USAGE)); System.exit(1); } String[] clientAppArgs = new String[0]; String additionalApps = Strings.EMPTY; if (clientAppName == null) { String[] argsWithoutProfile = new String[commandLineArguments.length - 1]; System.arraycopy(commandLineArguments, 1, argsWithoutProfile, 0, argsWithoutProfile.length); CommandLine cl = CommandLineParsers.parseCommandLineAppRunnerLine(argsWithoutProfile); // At this point, any remaining args after -with are in getArgs() // The first of those is the app name. clientAppName = cl.getArgs()[0]; clientAppArgs = new String[cl.getArgs().length - 1]; System.arraycopy(cl.getArgs(), 1, clientAppArgs, 0, clientAppArgs.length); if (cl.hasOption(CommandLineParsers.WITH)) { additionalApps = cl.getOptionValue(CommandLineParsers.WITH); } } else { clientAppArgs = new String[commandLineArguments.length - 1]; System.arraycopy(commandLineArguments, 1, clientAppArgs, 0, clientAppArgs.length); } if (!Strings.EMPTY.equals(additionalApps)) { startAdditionalApps(additionalApps); } /* See if the clientAppName happens to be a 'jar' name and refers to a jar file. If so, that's the service archive. */ FileObject serviceArchive = null; if (isAppArchive(clientAppName)) { serviceArchive = fileUtility.resolveFile(clientAppName); } else { serviceArchive = findServiceArchiveForName(clientAppName); } if (serviceArchive == null) { System.err.println( MessageFormat.format(messages.getString(MessageNames.NO_SUCH_CLIENT_APP), clientAppName)); System.exit(1); } // Deploy the service deployServiceArchive(serviceArchive, clientAppArgs); // Run the main method with the remaining command line parameters. }