示例#1
0
  private static void deleteFileImpl(String path, File file, File uploadsDir, Upload upload)
      throws IOException {
    checkUploadPath(file, uploadsDir);

    if (!file.exists()) {
      notFound(path);
    }

    Logger.info("delete: %s exists: %s", path, file.exists());

    if (uploadsDir.getCanonicalPath().equals(file.getCanonicalPath())) {
      // clear the entire repo
      for (File f : uploadsDir.listFiles()) {
        if (f.isDirectory()) FileUtils.deleteDirectory(f);
        else f.delete();
      }
      // let's be helpful and remove maven dependencies too
      for (MavenDependency md : upload.mavenDependencies) {
        md.delete();
      }
      flash("message", "Upload cleared");
    } else if (file.isDirectory()) {
      FileUtils.deleteDirectory(file);
      flash("message", "Directory deleted");
    } else {
      file.delete();
      flash("message", "File deleted");
    }
  }
示例#2
0
  public static void removeMavenDependency(Long id, String name, String version)
      throws IOException {
    models.Upload upload = getUpload(id);

    MavenDependency md = getMavenDependency(upload, name, version);
    if (md == null) {
      Validation.addError(null, "Module was not resolved from Maven");
      prepareForErrorRedirect();
      view(id);
    }
    md.delete();
    view(upload.id);
  }
示例#3
0
 public static void clearMavenDependencies(Long id) throws IOException {
   models.Upload upload = getUpload(id);
   for (MavenDependency md : upload.mavenDependencies) md.delete();
   flash("message", "Maven dependencies cleared");
   view(id);
 }