ImportDataFormAction.java

  1. /*
  2.  * This software was designed and created by Jason Carroll.
  3.  * Copyright (c) 2002, 2003, 2004 Jason Carroll.
  4.  * The author can be reached at jcarroll@cowsultants.com
  5.  * ITracker website: http://www.cowsultants.com
  6.  * ITracker forums: http://www.cowsultants.com/phpBB/index.php
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it only under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  */

  18. package org.itracker.web.actions.admin.configuration;

  19. import org.apache.log4j.Logger;
  20. import org.apache.struts.action.*;
  21. import org.itracker.model.util.UserUtilities;
  22. import org.itracker.web.actions.base.ItrackerBaseAction;
  23. import org.itracker.web.forms.ImportForm;

  24. import javax.servlet.ServletException;
  25. import javax.servlet.http.HttpServletRequest;
  26. import javax.servlet.http.HttpServletResponse;
  27. import java.io.IOException;


  28. public class ImportDataFormAction extends ItrackerBaseAction {
  29.     private static final Logger log = Logger.getLogger(ImportDataFormAction.class);

  30.     public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  31.         ActionMessages errors = new ActionMessages();

  32.         try {
  33.             ImportForm importForm = (ImportForm) form;
  34.             if (importForm == null) {
  35.                 importForm = new ImportForm();
  36.             }
  37.             importForm.setOptionreuseusers(Boolean.TRUE);
  38.             importForm.setOptionreuseprojects(Boolean.TRUE);
  39.             importForm.setOptionreuseconfig(Boolean.TRUE);
  40.             importForm.setOptionreusefields(Boolean.TRUE);
  41.             importForm.setOptioncreatepasswords(Boolean.TRUE);

  42.             request.setAttribute("importForm", importForm);
  43.             saveToken(request);
  44.             return mapping.getInputForward();
  45.         } catch (Exception e) {
  46.             log.error("Exception while creating import data form.", e);
  47.             errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system"));
  48.         }

  49.         if (!errors.isEmpty()) {
  50.             saveErrors(request, errors);
  51.         }

  52.         return mapping.findForward("error");
  53.     }

  54. }
  55.