Package org.apache.commons.vfs.provider.webdav

Examples of org.apache.commons.vfs.provider.webdav.WebdavFileObject


    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;
      break;
View Full Code Here


  }
 
  private static boolean sendRequest(FileSystemManager vfsManager, OutputStream fileWriter, String path, ClientPrimitives primitive, String... values ){
    boolean allOk = false;
    try{
      WebdavFileObject fileObject = (WebdavFileObject) vfsManager.resolveFile(path.replace("dav", "webdav") + "/.request");
     
      //TODO Se la Risorsa virtuale rimane montata sul file system del client questa funzione
      //genera dei problemi in quanto ottiene l'output stream dalla connessione che al momento non c'è
      fileWriter = fileObject.getOutputStream();
      //Use it
      PrintStream write = new PrintStream(fileWriter);
      write.println(primitive.toString() + " \"" + path + "\" HTTP/1.1");
      write.println("host: " + InetAddress.getLocalHost());
      for (int i = 0; i < primitive.getArgs().length; i++) {
View Full Code Here

    @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);
View Full Code Here

            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
            e.printStackTrace();
        }
    }
View Full Code Here

    public void put(String content, String remoteFilePath) {
        try {
            FileSystemManager vfsManager = VFS.getManager();

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

            PrintStream printer = new PrintStream(remoteFile.getOutputStream());
            printer.println(content);
            printer.close();
        } catch (FileSystemException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
View Full Code Here

        }
    }

    @Override
    public InputStream get(String remoteFilePath) {
        WebdavFileObject remoteFile = null;
        InputStream stream = null;

        try {
            while (remoteFile == null || !remoteFile.exists()) {
                remoteFile = (WebdavFileObject) VFS.getManager().resolveFile(
                        remoteFilePath.replace("dav://", "webdav://"));
            }

            if (remoteFile != null && remoteFile.exists()) {
                stream = remoteFile.getInputStream();
            }
        } catch (FileSystemException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
View Full Code Here

    if(vfsManager == null){
      getVFSManager();
    }
   
    LOGGER.debug("Get From DAV file: " + webDAVFilePath);
    WebdavFileObject from = null;
   
    try {
      from = (WebdavFileObject) vfsManager.resolveFile(webDAVFilePath.replace("dav://", "webdav://"));
    } catch (FileSystemException e) {
      LOGGER.error("Error during resolve file process into webdav",e);
View Full Code Here

    } catch (FileSystemException e) {
      LOGGER.error("Error during resolve file process into local file system",e);
    }

    LOGGER.debug("Get to DAV file: " + webDAVFilePath);
    WebdavFileObject to = null;
   
    try {
      to = (WebdavFileObject) vfsManager.resolveFile(webDAVFilePath.replace("dav://", "webdav://"));
    } catch (FileSystemException e) {
      LOGGER.error("Error during resolve file process into webdav",e);
    }

    LOGGER.debug("Upload file from client to server. " + correctLocalFileSystemPath + "->" + webDAVFilePath);
   
    try {
      to.copyFrom(from, new AllFileSelector());
    } catch (FileSystemException e) {
      LOGGER.error("Error during download process",e);
    }   
  }
View Full Code Here

   * @param items the items to retrieve from response
   * @return a string array containing the values of items
   */
  public static String[] retrieveCommunication(String path, ServerPrimitives primitive, String... items) {
    String [] returnValues =  new String[items.length];
    WebdavFileObject response  = null;

    FileSystemManager vfsManager = WebDAVClientManager.getVFSManager();

    try {
      //control if .response arrive..
      while((response == null || !response.exists())){
        LOGGER.debug("webdav path: " + path.replace("dav", "webdav") + "/.response");
        if(response == null) LOGGER.debug("response == null");
        LOGGER.debug("path: " + path);
        if(vfsManager == null) LOGGER.debug("vfsManager == null");
        response = (WebdavFileObject) vfsManager.resolveFile(path.replace("dav", "webdav") + "/.response");
      }
    } catch (FileSystemException fsException) {
      LOGGER.error(fsException.getMessage());
    }
    try {
      if(response != null && response.exists()){
        //retrieve WebDAV resource
        LOGGER.debug("webdav path: " + path.replace("dav", "webdav") + "/.request");

        //process .response
        ServerPrimitives primitiveReceived = ResponseManager.manageResponse(response);
        LOGGER.debug("primitive received: " + primitiveReceived);
        if(primitive == ServerPrimitives.OE_SUCCESSFUL){
          String[] returnTrue = {"true"};
          response.delete();
          return returnTrue;
        } else if(ServerPrimitives.OE_ERROR == primitiveReceived){
          OverEncryptClient.showError(FileSystemUtils.getArgFromFile(response, "reason"));
          System.exit(0);
        } else if(ServerPrimitives.OE_FORBIDDEN == primitiveReceived) {
          JOptionPane.showMessageDialog(null, "User's session expired. Login again.", "Session error.", JOptionPane.ERROR_MESSAGE);
          System.exit(0);
        } else if(primitive == primitiveReceived) {
          for(int i = 0; i < items.length; i++) {
            returnValues[i] = FileSystemUtils.getArgFromFile(response, items[i]);
            LOGGER.debug("ReturnValue: " + returnValues[i]);
          }
        } else {
          JOptionPane.showMessageDialog(null, "Communication error", "Retrieve server information failed.", JOptionPane.ERROR_MESSAGE);
        }
        response.delete();
      }
    } catch (HeadlessException e) {
      LOGGER.error(e.getMessage());
    } catch (FileSystemException e) {
      LOGGER.error(e.getMessage());
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs.provider.webdav.WebdavFileObject

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.