Exemple #1
0
  /** Delete the MIRCdocuments corresponding to a list of URLs, and then return the query page. */
  public void doGet(HttpRequest req, HttpResponse res) throws Exception {

    String urlsParam = req.getParameter("urls");

    if (req.isFromAuthenticatedUser() && (urlsParam != null)) {

      MircConfig mc = MircConfig.getInstance();
      File mircRoot = mc.getRootDirectory();
      User user = req.getUser();

      String[] urls = urlsParam.split("\\|");
      for (String url : urls) {
        if (mc.isLocal(url)) {
          int k = url.indexOf("/storage/");
          if (k != -1) {
            url = url.substring(k + 1);
            int kk = url.indexOf("?");
            if (kk > 0) url = url.substring(0, kk);

            Path path = new Path(url);
            String ssid = path.element(1);
            String docref = path.subpath(2).substring(1);

            url.replace("/", File.separator);
            File mdFile = new File(mircRoot, url);

            MircDocument md = new MircDocument(mdFile);
            boolean ok = md.authorizes("delete", user);

            if (ok) StorageServiceAdmin.deleteDocument(ssid, docref);
          }
        }
      }
    }
    res.redirect("/query");
  }
Exemple #2
0
 /**
  * Construct a DeleteService.
  *
  * @param root the root directory of the server.
  * @param context the path identifying the servlet.
  */
 public DeleteService(File root, String context) {
   super(root, context);
   // Override the root supplied by the HttpServer
   // with the root of the MIRC plugin.
   this.root = MircConfig.getInstance().getRootDirectory();
 }