コード例 #1
0
  protected void process() {
    String actPath = getParameter("actPath");

    if (!checkAccess(actPath)) {
      return;
    }

    String actPathOS = actPath.replace('/', File.separatorChar);

    String commentAuthor = uid;

    boolean modifyPermission = true;

    if (userMgr.getUserType(uid).equals("virtual")) {
      modifyPermission = InvitationManager.getInstance().commentsAllowed(uid);

      String author = req.getParameter("author");

      if ((author != null) && (author.trim().length() > 0)) {
        commentAuthor = author;
      }
    }

    if (!modifyPermission) {
      Logger.getLogger(getClass())
          .warn(
              "attempt to add comments for "
                  + actPath
                  + " from virtual user "
                  + uid
                  + " without permission");
      return;
    }

    String newComment = getParameter("newComment");

    if ((newComment != null) && (newComment.trim().length() > 0)) {
      MetaInfManager.getInstance()
          .addComment(actPathOS, new Comment(commentAuthor, new Date(), newComment));
    }

    String mobile = (String) session.getAttribute("mobile");

    if (mobile != null) {
      // (new MobileFolderFileListHandler(req, resp, session, output, uid)).handleRequest();
      (new XslListCommentsHandler(req, resp, session, output, uid)).handleRequest();
    } else {
      String role = userMgr.getRole(uid);

      if ((role != null) && role.equals("album")) {
        (new XslAlbumImageHandler(req, resp, session, output, uid)).handleRequest();
      } else {
        (new XslListCommentsHandler(req, resp, session, output, uid)).handleRequest();
      }
    }
  }
コード例 #2
0
  protected void process() {
    if (!checkWriteAccess()) {
      return;
    }

    String relPath = null;

    String path = getParameter("path");

    if (isMobile()) {
      relPath = path;
      path = getAbsolutePath(path);
    }

    if (!checkAccess(path)) {
      return;
    }

    Element resultElement = doc.createElement("result");

    String success = null;

    String resultMsg = "";

    String lowerCaseDocRoot = userMgr.getLowerCaseDocRoot(uid);

    if (path.toLowerCase().replace('\\', '/').equals(lowerCaseDocRoot)) {
      success = "error";

      resultMsg = getResource("alert.delhomedir", "The home directory may not be deleted!");
    } else {
      File dirToBeDeleted = new File(path);

      if (!dirToBeDeleted.canWrite() || (!dirToBeDeleted.isDirectory())) {
        Logger.getLogger(getClass())
            .warn(dirToBeDeleted + " cannot be deleted (is not a writable directory)");

        success = "error";

        resultMsg = getResource("alert.delDirError", "could not be deleted!");
      } else {
        String fileList[] = dirToBeDeleted.list();

        if (fileList.length > 0) {
          if ((fileList.length > 1) || (!fileList[0].equals(MetaInfManager.METAINF_FILE))) {
            String confirmed = getParameter("confirmed");

            if ((confirmed == null) || (!confirmed.equalsIgnoreCase("true"))) {
              success = "notEmpty";

              String shortPath = null;

              if (relPath != null) {
                shortPath = CommonUtils.shortName(relPath, 35);
              } else {
                shortPath = CommonUtils.shortName(path, 35);
              }

              resultMsg =
                  shortPath
                      + "\n"
                      + getResource("confirm.forcedirdel", "is not empty.\nDelete it anyway?");
            }
          }
        }

        if (success == null) {
          File parentDir = dirToBeDeleted.getParentFile();

          if (delDirTree(path)) {
            MetaInfManager.getInstance().removePath(path);

            SubdirExistCache.getInstance().cleanupExistSubdir(path);

            FastPathManager.getInstance().removeTree(uid, path);

            success = "deleted";

            XmlUtil.setChildText(resultElement, "parentPath", parentDir.getAbsolutePath());
          } else {
            success = "error";

            resultMsg = getResource("alert.delDirError", "could not be deleted!");
          }

          // even if only a part of the tree could be deleted we have to refresh the
          // subdir status

          (new TestSubDirThread(parentDir.getAbsolutePath())).start();
        }
      }
    }

    XmlUtil.setChildText(resultElement, "success", success);

    XmlUtil.setChildText(resultElement, "message", resultMsg);

    XmlUtil.setChildText(resultElement, "path", path);

    doc.appendChild(resultElement);

    this.processResponse();
  }
コード例 #3
0
  protected void process() {
    String imagePath = getParameter("imagePath");

    if ((imagePath == null) || (imagePath.trim().length() == 0)) {
      Logger.getLogger(getClass()).error("RateVotingHandler: imagePath missing");
      return;
    }

    if (!this.checkAccess(imagePath)) {
      return;
    }

    String imagePathOS = imagePath.replace('/', File.separatorChar);

    String temp = getParameter("rating");

    if (temp == null) {
      Logger.getLogger(getClass()).error("rating is null");
      return;
    }

    int rating = (-1);

    try {
      rating = Integer.parseInt(temp);
    } catch (NumberFormatException nfe) {
      Logger.getLogger(getClass()).error("invalid rating: " + temp);
      return;
    }

    MetaInfManager metaInfMgr = MetaInfManager.getInstance();

    if (readonly) {
      Hashtable ratedPictures = (Hashtable) session.getAttribute("ratedPictures");

      if (ratedPictures == null) {
        ratedPictures = new Hashtable(5);

        session.setAttribute("ratedPictures", ratedPictures);
      }

      if (ratedPictures.get(imagePathOS) == null) {
        String visitorId =
            (String) req.getSession().getAttribute(VisitorServlet.SESSION_ATTRIB_VISITOR_ID);

        if (visitorId != null) {
          metaInfMgr.addIdentifiedVisitorRating(visitorId, imagePathOS, rating);
        } else {
          metaInfMgr.addVisitorRating(imagePathOS, rating);
        }

        ratedPictures.put(imagePathOS, new Boolean(true));
      }
    } else {
      metaInfMgr.setOwnerRating(imagePathOS, rating);
    }

    String role = userMgr.getRole(uid);

    if ((role != null) && role.equals("album")) {
      (new XslAlbumPictureHandler(req, resp, session, output, uid)).handleRequest();
    } else {
      this.setParameter("imgname", imagePath);

      (new XslShowImageHandler(req, resp, session, output, uid)).handleRequest();
    }
  }