Package org.apache.commons.vfs

Examples of org.apache.commons.vfs.FileSystemManager

@author Adam Murdoch

  public String execute(CommandLine commandLine)
    throws Exception
  {
    InputStream in = null;
    OutputStream out = null;
    FileSystemManager fsManager = null;
    try{
      String file = commandLine.getValue(Options.FILE_OPTION);

      fsManager = VFS.getManager();
      FileObject fileObject = fsManager.resolveFile(file.replace("%", "%25"));
      FileObject tempFile = fsManager.resolveFile(
          SystemUtils.JAVA_IO_TMPDIR + "/eclim/" +
          fileObject.getName().getPath().replace("%", "%25"));

      // the vfs file cache isn't very intelligent, so clear it.
      fsManager.getFilesCache().clear(fileObject.getFileSystem());
      fsManager.getFilesCache().clear(tempFile.getFileSystem());

      // NOTE: FileObject.getName().getPath() does not include the drive
      // information.
      String path = tempFile.getName().getURI().substring(URI_PREFIX.length());
      // account for windows uri which has an extra '/' in front of the drive
View Full Code Here


        lastPath = location.substring(0, index + 1);
        location = location.substring(index);

        location = TEMP_PREFIX + location;

        FileSystemManager fsManager = VFS.getManager();
        FileObject tempFile = fsManager.resolveFile(location.replace("%", "%25"));

        // check if temp file already exists.
        if(!tempFile.exists() || tempFile.getContent().getSize() == 0){
          InputStream in = null;
          OutputStream out = null;
View Full Code Here

          }
          String srcFile = FileUtils.toUrl(
              rootPath + File.separator + classFile + ".java");

          // see if source file exists at source path.
          FileSystemManager fsManager = VFS.getManager();
          FileObject fileObject = fsManager.resolveFile(srcFile.replace("%", "%25"));
          if(fileObject.exists()){
            file = srcFile;

          // jdk sources on osx are under a "src/" dir in the jar
          }else if (Os.isFamily(Os.FAMILY_MAC)){
            srcFile = FileUtils.toUrl(
                rootPath + File.separator + "src" +
                File.separator + classFile + ".java");
            fileObject = fsManager.resolveFile(srcFile.replace("%", "%25"));
            if(fileObject.exists()){
              file = srcFile;
            }
          }
        }
View Full Code Here

  {
    if(path.startsWith("/") ||
        path.toLowerCase().startsWith("jar:") ||
        path.toLowerCase().startsWith("zip:"))
    {
      FileSystemManager fsManager = VFS.getManager();
      FileObject file = fsManager.resolveFile(path.replace("%", "%25"));
      if(file.exists()){
        BufferedReader in = null;
        try{
          in = new BufferedReader(
              new InputStreamReader(file.getContent().getInputStream()));
View Full Code Here

      if (clip != null && destUri != null) {
        String tmp = (String) clip.getContents(TextTransfer.getInstance());
        String[] paths = tmp.split(" ");

        FileSystemManager fsManager = fVFSView.getFileSystemManager();

        try {
          // destination object
          FileObject targetFile = fVFSView.resolveURI(destUri, destConnectionId);
View Full Code Here

     * @param filter
     *
     * @return
     */
    public List<String> listFiles(final File archiveFile, final FilenameFilter filter) {
        FileSystemManager fsManager;
        try {
            fsManager = VFS.getManager();
            String absolutePath = resolveArchiveURI(archiveFile);
            FileObject resolvedFile = fsManager.resolveFile(absolutePath);

            FileSelector fileSelector = new FileSelector() {
                /**
                 * @see org.apache.commons.vfs.FileSelector#traverseDescendents(org.apache.commons.vfs.FileSelectInfo)
                 */
                public boolean traverseDescendents(FileSelectInfo folderInfo) throws Exception {
                    return true;
                }

                /**
                 * @see org.apache.commons.vfs.FileSelector#includeFile(org.apache.commons.vfs.FileSelectInfo)
                 */
                public boolean includeFile(FileSelectInfo fileInfo) throws Exception {
                    File folder = archiveFile.getParentFile();
                    String name = fileInfo.getFile().getName().getFriendlyURI();
                    return filter.accept(folder, name);
                }
            };

            FileObject fileSystem;
            if (fsManager.canCreateFileSystem(resolvedFile)) {
                fileSystem = fsManager.createFileSystem(resolvedFile);
            } else {
                fileSystem = resolvedFile;
            }
            LOGGER.fine("Listing spatial data files archived in " + archiveFile.getName());
            FileObject[] containedFiles = fileSystem.findFiles(fileSelector);
View Full Code Here

     * Extracts the archive file {@code archiveFile} to {@code targetFolder}; both shall previously
     * exist.
     */
    public void extractTo(File archiveFile, File targetFolder) throws IOException {

        FileSystemManager manager = VFS.getManager();
        String sourceURI = resolveArchiveURI(archiveFile);
        // String targetURI = resolveArchiveURI(targetFolder);
        FileObject source = manager.resolveFile(sourceURI);
        if (manager.canCreateFileSystem(source)) {
            source = manager.createFileSystem(source);
        }
        FileObject target = manager.createVirtualFileSystem(manager.resolveFile(targetFolder
                .getAbsolutePath()));

        FileSelector selector = new AllFileSelector() {
            @Override
            public boolean includeFile(FileSelectInfo fileInfo) {
                LOGGER.fine("Uncompressing " + fileInfo.getFile().getName().getFriendlyURI());
                return true;
            }
        };
        target.copyFrom(source, selector);
        source.close();
        manager.closeFileSystem(source.getFileSystem());
    }
View Full Code Here

   */
  public static boolean generateRequest(ClientPrimitives primitive, OverEncryptRequestType opType, String userId, String path, String... values) {
    boolean allOk = false;
   
    OutputStream fileWriter = null;
    FileSystemManager vfsManager = null;
   
    //Get a Virtual File System Manager
    vfsManager = WebDAVClientManager.getVFSManager();
    if(vfsManager == null)LOGGER.debug("vfsManager is null");
   
    switch (opType) {
    case LOCK:
      try{
        //send lock request thought ghost file name
        LOGGER.debug("webdav path: " + path.replace("dav", "webdav") + "/.lock_" + userId); //TODO Retrieve client unique identifier
        WebdavFileObject fileObject = (WebdavFileObject) vfsManager.resolveFile(path.replace("dav", "webdav") + "/.lock_" + userId);
        fileWriter = fileObject.getOutputStream();
      }catch(Exception e){
        LOGGER.debug("It's all ok.. sending lock request");
      }
      allOk = true;
      break;
    case UNLOCK:
      try{
        //send unlock request thought ghost file name
        LOGGER.debug("webdav path: " + path.replace("dav", "webdav") + "/.unlock_" + userId); //TODO Retrieve client unique identifier
        WebdavFileObject fileObject = (WebdavFileObject) vfsManager.resolveFile(path.replace("dav", "webdav") + "/.unlock_" + userId);
        fileWriter = fileObject.getOutputStream();
      }catch(Exception e){
        LOGGER.debug("It's all ok.. sending unlock request");
      }
      allOk = true;
View Full Code Here

            .getLogger(ApacheWebDAVClient.class);

    @Override
    public void download(String remoteFilePath, String localFilePath) {
        try {
            FileSystemManager vfsManager = VFS.getManager();

            WebdavFileObject remoteFile = (WebdavFileObject) vfsManager
                    .resolveFile(remoteFilePath.replace("dav://", "webdav://"));

            FileObject localFile = vfsManager.resolveFile("file://"
                    + localFilePath);

            localFile.copyFrom(remoteFile, new AllFileSelector());
        } catch (FileSystemException e) {
            // TODO Auto-generated catch block
View Full Code Here

    }

    @Override
    public void upload(String localFilePath, String remoteFilePath) {
        try {
            FileSystemManager vfsManager = VFS.getManager();

            FileObject localFile = vfsManager.resolveFile("file://"
                    + localFilePath);

            WebdavFileObject remoteFile = (WebdavFileObject) vfsManager
                    .resolveFile(remoteFilePath.replace("dav://", "webdav://"));

            remoteFile.copyFrom(localFile, new AllFileSelector());
        } catch (FileSystemException e) {
            // TODO Auto-generated catch block
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs.FileSystemManager

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.