Package org.myphotodiary.json

Examples of org.myphotodiary.json.JsonAdminCmd


  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    getServletContext().log(
        "-> DbAdminSvr.doPost()\nParameters= "
            + request.getParameterMap().toString());
    // Extract request parameters
    JsonAdminCmd cmd = null;
    try {
      cmd = JsonAdminCmd.decode(request.getInputStream());
    }
    catch (Exception ex) {
      getServletContext().log("Cannot get POSTed administrative command", ex);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return;
    }
    getServletContext().log("Process administrative command: " + cmd.getCmd() + "(" + Arrays.toString(cmd.getParams())+")");
   
      if (cmd.getCmd().equals(Configuration.backupDbCmd)) {
        // Backup the database
        cfg.getAdminOpPlugin().backupData(cfg);
      }
      else if (cmd.getCmd().equals(Configuration.exportDbCmd)) {
        // Export the database into a SQL script
        // TODO
      }
      else if (cmd.getCmd().equals(Configuration.restoreDbCmd)) {
        // Restore the database from a previous backup
        cfg.getAdminOpPlugin().restoreData(cfg);;
      }
      else if (cmd.getCmd().equals(Configuration.deleteCmd)) {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        getServletContext().log("<- DbAdminSvr.doPost() - Unknown administrative command: " + cmd.getCmd());
        return;
      }
    response.setStatus(HttpServletResponse.SC_OK);
    getServletContext().log("<- DbAdminSvr.doPost()");
  }
View Full Code Here


  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    getServletContext().log(
        "-> DbAdminSvr.doPost()\nParameters= "
            + request.getParameterMap().toString());
    // Extract request parameters
    JsonAdminCmd cmd = null;
    try {
      cmd = JsonAdminCmd.decode(request.getInputStream());
    }
    catch (Exception ex) {
      getServletContext().log("Cannot get POSTed administrative command", ex);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return;
    }
    getServletContext().log("Process administrative command: " + cmd.getCmd() + "(" + Arrays.toString(cmd.getParams())+")");
   
      if (cmd.getCmd().equals(Configuration.backupDbCmd)) {
        // Backup the database
        cfg.getAdminOpPlugin().backupData(cfg);
      }
      else if (cmd.getCmd().equals(Configuration.exportDbCmd)) {
        // Export the database into a SQL script
        // TODO
      }
      else if (cmd.getCmd().equals(Configuration.restoreDbCmd)) {
        // Restore the database from a previous backup
        cfg.getAdminOpPlugin().restoreData(cfg);;
      }
      else if (cmd.getCmd().equals(Configuration.deleteCmd)) {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        getServletContext().log("<- DbAdminSvr.doPost() - Unknown administrative command: " + cmd.getCmd());
        return;
      }
    response.setStatus(HttpServletResponse.SC_OK);
    getServletContext().log("<- DbAdminSvr.doPost()");
  }
View Full Code Here

   *      response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    getServletContext().log("-> DirIndexSvr.doPost()\nParameters= " + request.getParameterMap().toString());
    // Extract request parameters
    JsonAdminCmd cmd = null;
    try {
      cmd = JsonAdminCmd.decode(request.getInputStream());
    }
    catch (Exception ex) {
      getServletContext().log("Cannot get POSTed administrative command", ex);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return;
    }
    getServletContext().log("Process administrative command: " + cmd.getCmd() + "(" + Arrays.toString(cmd.getParams())+")");

    for (String dirPath: cmd.getParams()) {
      try {
        DirectoryIndexer indexer = new DirectoryIndexer();
        if (cmd.getCmd().equals(Configuration.indexCmd)) {
          // force indexing
          indexer.indexDirectory(dirPath, true, request);
          // Complete thumbnails and web images if necessary
          indexer.checkAndUpdateThumbnails(dirPath);
          indexer.checkAndUpdateWebImg(dirPath);
        }
        else if (cmd.getCmd().equals(Configuration.resetIndexCmd)) {
          // delete directory index
          indexer.deleteDirectoryIndex(dirPath, request);
        }
        else if (cmd.getCmd().equals(Configuration.deleteCmd)) {
          // delete directory index and images
          indexer.deleteDirectoryIndexAndImages(dirPath, request);
        }
      } catch (AuthenticationException e) {
        // TODO Auto-generated catch block
View Full Code Here

      HttpServletResponse response) throws ServletException, IOException {
    getServletContext().log(
        "-> DirIndexSvr.doPost()\nParameters= "
            + request.getParameterMap().toString());
    // Extract request parameters
    JsonAdminCmd cmd = null;
    try {
      cmd = JsonAdminCmd.decode(request.getInputStream());
    }
    catch (Exception ex) {
      getServletContext().log("Cannot get POSTed administrative command", ex);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return;
    }
    getServletContext().log("Process administrative command: " + cmd.getCmd() + "(" + Arrays.toString(cmd.getParams())+")");
   
    for (String dirPath: cmd.getParams()) {
      try {
        if (cmd.getCmd().equals(Configuration.indexCmd)) {
          // force indexing
          new DirectoryIndexer().indexDirectory(dirPath, true, request);
        }
        else if (cmd.getCmd().equals(Configuration.resetIndexCmd)) {
          // delete directory index
          new DirectoryIndexer().deleteDirectoryIndex(dirPath, request);
        }
        else if (cmd.getCmd().equals(Configuration.deleteCmd)) {
          // delete directory index and images
          new DirectoryIndexer().deleteDirectoryIndexAndImages(dirPath, request);
        }
      } catch (AuthenticationException e) {
        // TODO Auto-generated catch block
View Full Code Here

      HttpServletResponse response) throws ServletException, IOException {
    getServletContext().log(
        "-> DirIndexSvr.doPost()\nParameters= "
            + request.getParameterMap().toString());
    // Extract request parameters
    JsonAdminCmd cmd = null;
    try {
      cmd = JsonAdminCmd.decode(request.getInputStream());
    }
    catch (Exception ex) {
      getServletContext().log("Cannot get POSTed administrative command", ex);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
      return;
    }
    getServletContext().log("Process administrative command: " + cmd.getCmd() + "(" + Arrays.toString(cmd.getParams())+")");
   
    for (String dirPath: cmd.getParams()) {
      if (cmd.getCmd().equals(Configuration.indexCmd)) {
        // Force indexing, even if not allowed because it is an administrative command
        new DirectoryIndexer().indexDirectory(dirPath, true);
      }
      else if (cmd.getCmd().equals(Configuration.resetIndexCmd)) {
        new DirectoryIndexer().deleteDirectoryIndex(dirPath);
      }
      else if (cmd.getCmd().equals(Configuration.deleteCmd)) {
        new DirectoryIndexer().deleteDirectoryIndexAndImages(dirPath);
      }
    }
    response.setStatus(HttpServletResponse.SC_OK);
    getServletContext().log("<- DirIndexSvr.doPost()");
View Full Code Here

TOP

Related Classes of org.myphotodiary.json.JsonAdminCmd

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.