Examples of ConnectorException


Examples of org.elfinder.servlets.ConnectorException

      try {
        // write with empty data
        getFs().createFile(newFile, null);
      } catch (Exception e) {
        logger.error("", e);
        throw new ConnectorException("Unable to create folder");
      }
      if (out != null) {
        try {
          out.close();
        } catch (Exception e) {
View Full Code Here

Examples of org.elfinder.servlets.ConnectorException

    File dir = null;
    if (dirHash != null && !"".equals(dirHash)) {
      dir = _findDir(dirHash, null);

      if (dir == null) {
        throw new ConnectorException("Invalid parameters");
      }

      if (!getConfig()._isAllowedExistingDir(dir, actionCheck)) {
        throw new ConnectorException("Access denied");
      }
    }
    return dir;
  }
View Full Code Here

Examples of org.elfinder.servlets.ConnectorException

  }

  protected File getExistingFile(String fileHash, File existingDir, FileActionEnum actionCheck) throws ConnectorException {
    File existingFile = _find(fileHash, existingDir);
    if (existingFile == null) {
      throw new ConnectorException("File not found");
    }

    if (!getConfig()._isAllowedExistingFile(existingFile, actionCheck)) {
      throw new ConnectorException("Access denied");
    }
    return existingFile;
  }
View Full Code Here

Examples of org.elfinder.servlets.ConnectorException

    return existingFile;
  }

  protected File getNewFile(String fileName, File existingDir, FileActionEnum actionCheck) throws ConnectorException {
    if (!_checkName(fileName)) {
      throw new ConnectorException("Invalid name");
    }

    File newFile = new File(existingDir, fileName);
    if (newFile.exists()) {
      throw new ConnectorException("File or folder with the same name already exists");
    }

    if (!config._isAllowedNewFile(newFile, actionCheck)) {
      throw new ConnectorException("Access denied");
    }
    return newFile;
  }
View Full Code Here

Examples of org.elfinder.servlets.ConnectorException

    return newFile;
  }

  protected File getNewDirectory(String dirName, File existingDir, FileActionEnum actionCheck) throws ConnectorException {
    if (!_checkName(dirName)) {
      throw new ConnectorException("Invalid name");
    }

    File newFile = new File(existingDir, dirName);
    if (newFile.exists()) {
      throw new ConnectorException("File or folder with the same name already exists");
    }

    if (!config._isAllowedNewDir(newFile, actionCheck)) {
      throw new ConnectorException("Access denied");
    }
    return newFile;
  }
View Full Code Here

Examples of org.elfinder.servlets.ConnectorException

        File dirDst = getExistingDir(getParam("dst"), FileActionEnum.READ);
        if (dirDst != null) {

          List<String> targets = (List<String>) getParamObject("targets[]");
          if (targets == null || targets.isEmpty()) {
            throw new ConnectorException("Invalid parameters");
          }

          boolean cut = "1".equals(getParam("cut"));

          for (String targetHash : targets) {
            File fileTarget = getExistingFile(targetHash, dirSrc, FileActionEnum.READ);
            if (fileTarget == null) {
              _content(dirCurrent, true);
              throw new ConnectorException("File not found");
            }

            if (dirSrc.getAbsolutePath().equals(dirDst.getAbsolutePath())) {
              _content(dirCurrent, true);
              throw new ConnectorException("Unable to copy into itself");
            }

            File futureFile = getNewFile(basename(fileTarget), dirDst, FileActionEnum.WRITE);

            if (cut) {
              // moving file...
              if (!getConfig()._isAllowedExistingFile(fileTarget, FileActionEnum.DELETE)) {
                throw new ConnectorException("Access denied");
              }

              try {
                getFs().renameFileOrDirectory(fileTarget, futureFile);
                // TODO
                //                if (!is_dir($f)) {
                //                  $this->_rmTmb($f);
                //                }
              } catch (FsException e) {
                _content(dirCurrent, true);
                throw new ConnectorException("Unable to move files");
              }
            } else {
              // copying file...
              try {
                getFs().copyFileOrDirectory(fileTarget, futureFile);
              } catch (FsException e) {
                _content(dirCurrent, true);
                throw new ConnectorException("Unable to copy files");
              }
            }
          }
        }
      }
View Full Code Here

Examples of org.elfinder.servlets.ConnectorException

      File newDir = getNewFile(getParam("name"), dirCurrent, FileActionEnum.WRITE);

      try {
        getFs().createFolder(newDir);
      } catch (Exception e) {
        throw new ConnectorException("Unable to create folder");
      }

      putResponse("select", _hash(newDir));

      _content(dirCurrent, true);
View Full Code Here

Examples of org.elfinder.servlets.ConnectorException

      closeWriter(getResponseWriter());
      setResponseOutputDone(true);
    } catch (Exception e) {
      logger.error("", e);
      throw new ConnectorException("Unknown error");
    } finally {
      if (is != null) {
        try {
          is.close();
        } catch (IOException e) {
View Full Code Here

Examples of org.elfinder.servlets.ConnectorException

  public void execute() throws ConnectorException {
    File dirCurrent = getExistingDir(getParam("current"), FileActionEnum.WRITE);
    if (dirCurrent != null) {
      List<String> targets = (List<String>) getParamObject("targets[]");
      if (targets == null || targets.isEmpty()) {
        throw new ConnectorException("Invalid parameters");
      }

      for (String targetHash : targets) {
        File fileTarget = getExistingFile(targetHash, dirCurrent, FileActionEnum.DELETE);
        if (fileTarget == null) {
          throw new ConnectorException("File not found");
        }
        _remove(fileTarget, false);
      }

      _content(dirCurrent, true);
View Full Code Here

Examples of org.elfinder.servlets.ConnectorException

  /**
   * Remove file or folder (recursively)
   **/
  protected void _remove(File path, boolean fromRecursive) throws ConnectorException {
    if (path == null || !path.exists()) {
      throw new ConnectorException("Invalid parameters");
    }
    if (!path.isDirectory()) {
      if (!getConfig()._isAllowedExistingDir(path, FileActionEnum.DELETE)) {
        throw new ConnectorException("Access denied");
      }
      try {
        getFs().removeFile(path);
      } catch (FsException e) {
        throw new ConnectorException("Unable to remove file", e);
      }
    } else {
      if (!getConfig()._isAllowedExistingFile(path, FileActionEnum.DELETE)) {
        throw new ConnectorException("Access denied");
      }
      removeDirectory(path, fromRecursive);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.