/**
   * Method execute
   *
   * @param ActionMapping mapping
   * @param ActionForm form
   * @param HttpServletRequest request
   * @param HttpServletResponse response
   * @return ActionForward
   * @throws Exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    HttpSession session = request.getSession();
    // clientXML = (XMLClient) session.getAttribute("client");
    clientXML = XMLClient.getInstance();
    sessionLogin = (String) session.getAttribute("login");

    ajoutsuppressionForm ajoutForm = (ajoutsuppressionForm) form;

    String idperm = ajoutForm.getId1();
    String idrole = ajoutForm.getId2();

    response.setContentType("text/html");

    boolean ajout = clientXML.ajouterPermissionRole(sessionLogin, idperm, idrole);

    if (ajout) {
      String result = "INFO: Permission ajoutée au role";

      session.setAttribute("Resultat", result);
      return mapping.findForward("ok");
    } else {
      String erreur = "ERREUR: Permission non ajoutée au role";

      session.setAttribute("Resultat", erreur);
      return mapping.findForward("failed");
    }
  }
Exemplo n.º 2
0
  /**
   * Populate the properties of the specified <code>ActionForm</code> instance from the request
   * parameters included with this request. In addition, request attribute <code>Globals.CANCEL_KEY
   * </code> will be set if the request was submitted with a button created by <code>CancelTag
   * </code>.
   *
   * @param request The servlet request we are processing
   * @param response The servlet response we are creating
   * @param form The ActionForm instance we are populating
   * @param mapping The ActionMapping we are using
   * @throws ServletException if thrown by RequestUtils.populate()
   */
  protected void processPopulate(
      HttpServletRequest request,
      HttpServletResponse response,
      ActionForm form,
      ActionMapping mapping)
      throws ServletException {
    if (form == null) {
      return;
    }

    // Populate the bean properties of this ActionForm instance
    if (log.isDebugEnabled()) {
      log.debug(" Populating bean properties from this request");
    }

    form.setServlet(this.servlet);
    form.reset(mapping, request);

    if (mapping.getMultipartClass() != null) {
      request.setAttribute(Globals.MULTIPART_KEY, mapping.getMultipartClass());
    }

    RequestUtils.populate(form, mapping.getPrefix(), mapping.getSuffix(), request);

    // Set the cancellation request attribute if appropriate
    if ((request.getParameter(Globals.CANCEL_PROPERTY) != null)
        || (request.getParameter(Globals.CANCEL_PROPERTY_X) != null)) {
      request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE);
    }
  }
Exemplo n.º 3
0
  public ActionForward execute(
      ActionMapping actionMapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ListForm aWebForm = (ListForm) actionForm;

    if (aWebForm.getMethod() == null) { // 初次进行页面,需要取初始值
      Deal.doList(aWebForm, request, response); // 查询处理
      return actionMapping.getInputForward();
    } else {
      String sMessage = "未能找到 " + aWebForm.getMethod() + " 对应的处理方法";
      if (aWebForm.getMethod().equals("jgys_submit")) { // 修改
        Deal.doList(aWebForm, request, response); // 查询处理
        Deal.doJgys_submit(aWebForm, request, response);
        sMessage = "确定竣工验收报告,并提交到工程结算处理成功";
      }

      CCommonMessage mMessage = new CCommonMessage(); // 统一提示页面
      mMessage.setMessage(sMessage); // 默认为"处理成功!"
      String[] button = {"关闭"}; // 按钮数组
      String[] onclick = {"parent.window.close()"}; // 按钮响应事件
      mMessage.setButtonName(button);
      mMessage.setOnClickFunc(onclick);
      request.setAttribute(CConstants.MESSAGE_OBJECT, mMessage);
      // 在处理页面最后调用(事先要配置名字为success的forward,在全局配置里有 message)
      return actionMapping.findForward("message");
    }
  }
Exemplo n.º 4
0
  /**
   * Retrieve and return the <code>ActionForm</code> associated with this mapping, creating and
   * retaining one if necessary. If there is no <code>ActionForm</code> associated with this
   * mapping, return <code>null</code>.
   *
   * @param request The servlet request we are processing
   * @param response The servlet response we are creating
   * @param mapping The mapping we are using
   * @return The <code>ActionForm</code> associated with this mapping.
   */
  protected ActionForm processActionForm(
      HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) {
    // Create (if necessary) a form bean to use
    ActionForm instance = RequestUtils.createActionForm(request, mapping, moduleConfig, servlet);

    if (instance == null) {
      return (null);
    }

    // Store the new instance in the appropriate scope
    if (log.isDebugEnabled()) {
      log.debug(
          " Storing ActionForm bean instance in scope '"
              + mapping.getScope()
              + "' under attribute key '"
              + mapping.getAttribute()
              + "'");
    }

    if ("request".equals(mapping.getScope())) {
      request.setAttribute(mapping.getAttribute(), instance);
    } else {
      HttpSession session = request.getSession();

      session.setAttribute(mapping.getAttribute(), instance);
    }

    return (instance);
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse reponse)
      throws Exception {
    BeanEcrireCommentaire bean = (BeanEcrireCommentaire) actionForm;
    String contenu = bean.getContenu();
    BeanCommentaire beanCommentaire = new BeanCommentaire();
    beanCommentaire.setContenu(contenu);
    Abonne abonne =
        (Abonne)
            bdutil.getUtilisateur(((Integer) request.getSession().getAttribute("id")).intValue());
    beanCommentaire.setIdRedacteur(abonne.getId());

    Article article = bdart.getArticle(Integer.parseInt(request.getParameter("idArticle")));
    beanCommentaire.setIdArticle(article.getId());

    // beanCommentaire.setId(bdart.getIdLibre());

    if (contenu.equals("")) return mapping.findForward("echec");
    else {

      bdcom.addCommentaire(beanCommentaire.getCommentaire());

      //        bdart.addArticle(beanArticle.getArticle());

      //	beanCommentaire.setIdRedacteur(request.getSession(true));
      //	beanCommentaire.setIdArticle(((Article)request.getAttribute("article")).getId());
      //	bean.setId(BDArticles.getIdLibre())
      /// bdart.addArticle(beanCommentaire.getCommentaire());     // /!\ omg!!!

      return mapping.findForward("succes");
    }
  }
Exemplo n.º 6
0
  protected ActionForward performAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String forward = FWD_SUCCESS;

    DynaActionForm dynaForm = (DynaActionForm) form;
    // get selected qaEvents
    String[] selectedIDs = (String[]) dynaForm.get("selectedIDs");

    // get sysUserId from login module
    UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
    String sysUserId = String.valueOf(usd.getSystemUserId());

    List qaEvents = new ArrayList();

    for (int i = 0; i < selectedIDs.length; i++) {
      QaEvent qaEvent = new QaEvent();
      qaEvent.setId(selectedIDs[i]);
      qaEvent.setSysUserId(sysUserId);
      qaEvents.add(qaEvent);
    }
    ActionMessages errors = null;
    try {

      QaEventDAO qaEventDAO = new QaEventDAOImpl();
      qaEventDAO.deleteData(qaEvents);
      // System.out.println("Just deleted QaEvent");
      // initialize the form
      dynaForm.initialize(mapping);

    } catch (LIMSRuntimeException lre) {
      // bugzilla 2154
      LogEvent.logError("QaEventDeleteAction", "performAction()", lre.toString());
      request.setAttribute(IActionConstants.REQUEST_FAILED, true);

      errors = new ActionMessages();
      ActionError error = null;
      if (lre.getException() instanceof org.hibernate.StaleObjectStateException) {
        error = new ActionError("errors.OptimisticLockException", null, null);
      } else {
        error = new ActionError("errors.DeleteException", null, null);
      }
      errors.add(ActionMessages.GLOBAL_MESSAGE, error);
      saveErrors(request, errors);
      request.setAttribute(Globals.ERROR_KEY, errors);
      forward = FWD_FAIL;
    }
    if (forward.equals(FWD_FAIL)) return mapping.findForward(forward);

    if ("true".equalsIgnoreCase(request.getParameter("close"))) {
      forward = FWD_CLOSE;
    }

    request.setAttribute("menuDefinition", "QaEventMenuDefinition");
    return mapping.findForward(forward);
  }
Exemplo n.º 7
0
  public ActionForward execute(
      ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    try {
      GpsImportForm gpsForm = (GpsImportForm) form;
      User user = (User) req.getSession().getAttribute("user");
      int entryId = gpsForm.getEntryId();
      String fileName = gpsForm.getFileName();
      String title = gpsForm.getTitle();
      String activityId = gpsForm.getActivityId();
      String xml = gpsForm.getXml();
      log.debug(xml);

      List<GpsTrack> tracks = new TcxParser().parse(xml.getBytes());
      GpsTrack track = tracks.get(0); // Horrible hack.
      createAttachment(user, entryId, fileName, title, activityId, track);
      createGeotag(fileName, track);

      req.setAttribute("status", "success");
      req.setAttribute("message", "");
      log.debug("Returning status: success.");
      return mapping.findForward("results");
    } catch (Exception e) {
      log.fatal("Error processing incoming Garmin XML", e);
      req.setAttribute("status", "failure");
      req.setAttribute("message", e.toString());
      return mapping.findForward("results");
    }
  }
  /**
   * Method 'execute'
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @throws Exception
   * @return ActionForward
   */
  public ActionForward handle(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    try {
      // parse parameters
      // create the DAO class
      TelesalesCallSourceDao dao = TelesalesCallSourceDaoFactory.create();

      // execute the finder
      TelesalesCallSource dto[] = dao.findAll();

      // store the results
      request.setAttribute("result", dto);

      return mapping.findForward("success");
    } catch (Exception e) {
      ActionErrors _errors = new ActionErrors();
      _errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError("internal.error", e.getClass().getName() + ": " + e.getMessage()));
      saveErrors(request, _errors);
      return mapping.findForward("failure");
    }
  }
Exemplo n.º 9
0
  public void testGetUri() {
    ActionMapping am = new ActionMapping();
    am.setName("view");
    am.setNamespace("secure");
    am.setParams(Collections.<String, Object>emptyMap());

    assertEquals("secureview", mapper.getUriFromActionMapping(am));
  }
Exemplo n.º 10
0
  public void testGetMapping() throws Exception {
    StrutsMockHttpServletRequest request = new StrutsMockHttpServletRequest();
    request.setupGetServletPath("/myapp/view/12");

    ActionMapping am = mapper.getMapping(request, null);
    assertEquals("myapp", am.getName());
    assertEquals(1, am.getParams().size());
    assertEquals("12", am.getParams().get("view"));
  }
Exemplo n.º 11
0
  /**
   * Return an <code>Action</code> instance that will be used to process the current request,
   * creating a new one if necessary.
   *
   * @param request The servlet request we are processing
   * @param response The servlet response we are creating
   * @param mapping The mapping we are using
   * @return An <code>Action</code> instance that will be used to process the current request.
   * @throws IOException if an input/output error occurs
   */
  protected Action processActionCreate(
      HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
      throws IOException {
    // Acquire the Action instance we will be using (if there is one)
    String className = mapping.getType();

    if (log.isDebugEnabled()) {
      log.debug(" Looking for Action instance for class " + className);
    }

    // If there were a mapping property indicating whether
    // an Action were a singleton or not ([true]),
    // could we just instantiate and return a new instance here?
    Action instance;

    synchronized (actions) {
      // Return any existing Action instance of this class
      instance = (Action) actions.get(className);

      if (instance != null) {
        if (log.isTraceEnabled()) {
          log.trace("  Returning existing Action instance");
        }

        return (instance);
      }

      // Create and return a new Action instance
      if (log.isTraceEnabled()) {
        log.trace("  Creating new Action instance");
      }

      try {
        instance = (Action) RequestUtils.applicationInstance(className);

        // Maybe we should propagate this exception
        // instead of returning null.
      } catch (Exception e) {
        log.error(getInternal().getMessage("actionCreate", mapping.getPath()), e);

        response.sendError(
            HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
            getInternal().getMessage("actionCreate", mapping.getPath()));

        return (null);
      }

      actions.put(className, instance);
    }

    if (instance.getServlet() == null) {
      instance.setServlet(this.servlet);
    }

    return (instance);
  }
Exemplo n.º 12
0
  public void testGetMapping2() throws Exception {
    StrutsMockHttpServletRequest request = new StrutsMockHttpServletRequest();
    request.setupGetServletPath("/myapp/12/region/europe");

    ActionMapping am = mapper.getMapping(request, null);
    assertEquals("myapp", am.getName());
    assertEquals(2, am.getParams().size());
    assertEquals("12", am.getParams().get("myappId"));
    assertEquals("europe", am.getParams().get("region"));
  }
Exemplo n.º 13
0
  public void testGetUriParam() {
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("article", "123");
    ActionMapping am = new ActionMapping();
    am.setName("view");
    am.setNamespace("secure");
    am.setParams(param);

    assertEquals("secureview", mapper.getUriFromActionMapping(am));
  }
 public ActionForward execute(
     ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
     throws Exception {
   ProductLoaderForm obj = (ProductLoaderForm) form;
   String productName = obj.getProductName();
   String productId = obj.getProductId();
   String store = obj.getStore();
   String notes = obj.getNotes();
   String productDesc = obj.getProductDesc();
   String price = obj.getPrice();
   Connection con = null;
   Class.forName(ConnectionStats.DRIVER);
   String url = ConnectionStats.DB_URL;
   String usr = ConnectionStats.DB_USER;
   String pwd = ConnectionStats.DB_PASSWORD;
   con = DriverManager.getConnection(url, usr, pwd);
   Statement stmt = con.createStatement();
   try {
     ResultSet rs =
         stmt.executeQuery("select * from service2_main where productId = '" + productId + "'");
     if (!(rs.next())) {
       stmt.executeUpdate(
           "insert into service2_main values('"
               + productId
               + "','"
               + productName
               + "','"
               + productDesc
               + "',)");
     }
     stmt.executeUpdate(
         "delete from service2_tbl where productId = '"
             + productId
             + "' and store = '"
             + store
             + "'");
     stmt.executeUpdate(
         "insert into service2_tbl values('"
             + productId
             + "','"
             + store
             + "',"
             + Float.parseFloat(price)
             + ",'"
             + notes
             + "')");
     req.setAttribute("msg", "Succeeded");
     System.out.println("succeded");
     return mapping.findForward("success");
   } catch (Exception ex) {
     System.out.println("failure");
     req.setAttribute("msg", "Data updating failed");
     return mapping.findForward("failure");
   }
 }
Exemplo n.º 15
0
  public void testGetIndex() throws Exception {
    req.setupGetRequestURI("/my/namespace/foo/");
    req.setupGetServletPath("/my/namespace/foo/");
    req.setupGetAttribute(null);
    req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
    req.setupGetMethod("GET");

    ActionMapping mapping = mapper.getMapping(req, configManager);

    assertEquals("/my/namespace", mapping.getNamespace());
    assertEquals("foo/", mapping.getName());
    assertEquals("index", mapping.getMethod());
  }
Exemplo n.º 16
0
 /**
  * 响应页面提交
  *
  * @param actionMapping ActionMapping这个 Action 的配置信息
  * @param actionForm ActionForm 用户提交的表单数据
  * @param request HttpServletRequest当前的 HTTP 请求对象
  * @param response HttpServletResponse当前的 HTTP 响应对象
  * @return ActionForward 提交到查询页面
  * @throws Exception
  */
 public ActionForward execute(
     ActionMapping actionMapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   EditForm aWebForm = (EditForm) actionForm;
   Deal.setEditDefault(aWebForm, request, response); // 设置进入增加页面的初始值
   if (request.getParameter("print") == null) {
     return actionMapping.getInputForward();
   } else {
     return actionMapping.findForward("print");
   }
 }
Exemplo n.º 17
0
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest req, HttpServletResponse resp ){
		
		if("GET".equals(req.getMethod())){
			JSONObject json = AndroidHelper.DoGetForbiddenException();
			req.setAttribute("json", json.toString());
			return mapping.findForward("succes");
		
		}else if("POST".equals(req.getMethod())){
			
			String email = request.getParameter("mail");
			String mdp = req.getParameter("mdp");
			org.json.JSONObject json = new JSONObject();
			PersonneDAO persDAO = new PersonneDAO();
			
			// check the login and the pwd
			if( mail != null && mdp != null){
				Personne p = persDAO.getmailPersonne(mail);
				// managing the misfound exceptions
				if(p == null) {
					json = AndroidHelper.UserNotFoundException();
				// Uncorrect password
				}else if(!mdp.equals(p.getmdpPersonne())){
					json = AndroidHelper.PassIncorrectException()
				} else {
					p.setmailPersonne("");
					p.setmdpPersonne("");
					json = new JSONObject(p);
				}
			
			} else{
Exemplo n.º 18
0
  /**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). Return an <code>ActionForward</code> instance
   * describing where and how control should be forwarded, or <code>null</code> if the response has
   * already been completed.
   *
   * @param form
   * @param req
   * @param res
   * @param mapping The ActionMapping used to select this instance
   * @exception IOException if an input/output error occurs
   * @exception ServletException if a servlet exception occurs
   * @return destination
   */
  public ActionForward execute(
      ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
      throws IOException, ServletException {
    ActionMessages errors = new ActionMessages();
    ActionForward destination = null;

    if (!this.checkLogon(req)) {
      return mapping.findForward("logon");
    }
    Integer action;

    try {
      action = Integer.parseInt(req.getParameter("action"));
    } catch (Exception e) {
      action = BlacklistAction.ACTION_LIST;
    }

    AgnUtils.logger().info("Action: " + action);

    try {
      destination = executeIntern(mapping, req, errors, destination, action);
    } catch (Exception e) {
      AgnUtils.logger().error("execute: " + e + "\n" + AgnUtils.getStackTrace(e));
      errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.exception"));
    }

    // Report any errors we have discovered back to the original form
    if (!errors.isEmpty()) {
      saveErrors(req, errors);
    }
    return destination;
  }
Exemplo n.º 19
0
  /**
   * Ask our exception handler to handle the exception. Return the <code>ActionForward</code>
   * instance (if any) returned by the called <code>ExceptionHandler</code>.
   *
   * @param request The servlet request we are processing
   * @param response The servlet response we are processing
   * @param exception The exception being handled
   * @param form The ActionForm we are processing
   * @param mapping The ActionMapping we are using
   * @return The <code>ActionForward</code> instance (if any) returned by the called <code>
   *     ExceptionHandler</code>.
   * @throws IOException if an input/output error occurs
   * @throws ServletException if a servlet exception occurs
   */
  protected ActionForward processException(
      HttpServletRequest request,
      HttpServletResponse response,
      Exception exception,
      ActionForm form,
      ActionMapping mapping)
      throws IOException, ServletException {
    // Is there a defined handler for this exception?
    ExceptionConfig config = mapping.findException(exception.getClass());

    if (config == null) {
      log.warn(getInternal().getMessage("unhandledException", exception.getClass()));

      if (exception instanceof IOException) {
        throw (IOException) exception;
      } else if (exception instanceof ServletException) {
        throw (ServletException) exception;
      } else {
        throw new ServletException(exception);
      }
    }

    // Use the configured exception handling
    try {
      ExceptionHandler handler =
          (ExceptionHandler) RequestUtils.applicationInstance(config.getHandler());

      return (handler.execute(exception, config, mapping, form, request, response));
    } catch (Exception e) {
      throw new ServletException(e);
    }
  }
Exemplo n.º 20
0
  public void testGetEdit() throws Exception {
    mapper.setIdParameterName("id");
    mapper.setAllowDynamicMethodCalls("true");
    req.setupGetRequestURI("/my/namespace/foo/3!edit");
    req.setupGetServletPath("/my/namespace/foo/3!edit");
    req.setupGetAttribute(null);
    req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
    req.setupGetMethod("GET");

    ActionMapping mapping = mapper.getMapping(req, configManager);

    assertEquals("/my/namespace", mapping.getNamespace());
    assertEquals("foo/3", mapping.getName());
    assertEquals("edit", mapping.getMethod());
    assertEquals("3", mapping.getParams().get("id"));
  }
Exemplo n.º 21
0
 public ActionForward execute(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws IOException, ServletException {
   if (true) throw new java.io.IOException();
   return (mapping.findForward("success"));
 }
Exemplo n.º 22
0
 /**
  * 响应页面提交
  *
  * @param actionMapping ActionMapping 这个 Action 的配置信息
  * @param actionForm ActionForm 用户提交的表单数据
  * @param request HttpServletRequest 当前的 HTTP 请求对象
  * @param response HttpServletResponse 当前的 HTTP 响应对象
  * @return ActionForward 请求转发路径
  * @throws Exception
  */
 public ActionForward execute(
     ActionMapping actionMapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   QueryForm aWebForm = (QueryForm) actionForm;
   Deal.doQuery(aWebForm, request, response); // 查询处理
   return actionMapping.getInputForward();
 }
Exemplo n.º 23
0
  /**
   * 响应页面提交
   *
   * @param actionMapping ActionMapping这个 Action 的配置信息
   * @param actionForm ActionForm 用户提交的表单数据
   * @param request HttpServletRequest当前的 HTTP 请求对象
   * @param response HttpServletResponse当前的 HTTP 响应对象
   * @return ActionForward 提交到查询页面
   * @throws Exception
   */
  public ActionForward execute(
      ActionMapping actionMapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    EditForm aWebForm = (EditForm) actionForm;
    if (aWebForm.getMethod() == null) { // 初次进行页面,需要取初始值
      Deal.setEditDefault(aWebForm, request, response); // 设置进入增加页面的初始值
      return actionMapping.getInputForward();
    } else {
      String sMessage = "未能找到 " + aWebForm.getMethod() + " 对应的处理方法";
      String[] button; // 按钮数组
      String[] onclick; // 按钮响应事件

      if (aWebForm.getMethod().equals("edit")) { // 修改
        Deal.doDHHFEdit(aWebForm, request, response); // 处理修改
        sMessage = mModuleName + "修改处理成功";
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      } else if (aWebForm.getMethod().equals("add")) { // 修改
        Deal.doDHHFAdd(aWebForm, request, response); // 处理修改
        sMessage = mModuleName + "增加处理成功";
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      } else if (aWebForm.getMethod().equals("del")) { // 删除
        Deal.doDHHFDelete(aWebForm, request, response); // 处理删除
        sMessage = mModuleName + "删除处理成功";
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      } else { // 未能找到 " + aWebForm.getMethod() + " 对应的处理方法
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      }
      CCommonMessage mMessage = new CCommonMessage(); // 统一提示页面
      mMessage.setMessage(sMessage); // 默认为"处理成功!"
      mMessage.setButtonName(button);
      mMessage.setOnClickFunc(onclick);
      request.setAttribute(CConstants.MESSAGE_OBJECT, mMessage);
      // 在处理页面最后调用(事先要配置名字为success的forward,在全局配置里有 message)
      return actionMapping.findForward("message");
    }
  }
Exemplo n.º 24
0
  /**
   * 增加主机服务
   *
   * @param mapping .
   * @param form .
   * @param request .
   * @param response .
   * @return .
   * @throws Exception .
   */
  public ActionForward addMonitorService(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ActionMessages errors = new ActionMessages();
    MonitorService monitorService = (MonitorService) ((DynaActionForm) form).get("monitorService");
    String type = (String) ((DynaActionForm) form).get("type");
    DependencyUtil.clearDependencyProperty(monitorService);
    monitorHostserviceService.saveMonitorService(monitorService);

    if (!errors.isEmpty()) {
      saveErrors(request, errors);
      return mapping.findForward("input");
    } else {
      return mapping.findForward("success");
    }
  }
Exemplo n.º 25
0
  /**
   * Handle the Exception. Return the ActionForward instance (if any) returned by the called
   * ExceptionHandler.
   *
   * @param ex The exception to handle
   * @param ae The ExceptionConfig corresponding to the exception
   * @param mapping The ActionMapping we are processing
   * @param formInstance The ActionForm we are processing
   * @param request The servlet request we are processing
   * @param response The servlet response we are creating
   * @return The <code>ActionForward</code> instance (if any) returned by the called <code>
   *     ExceptionHandler</code>.
   * @throws ServletException if a servlet exception occurs
   * @since Struts 1.1
   */
  public ActionForward execute(
      Exception ex,
      ExceptionConfig ae,
      ActionMapping mapping,
      ActionForm formInstance,
      HttpServletRequest request,
      HttpServletResponse response)
      throws ServletException {
    LOG.debug("ExceptionHandler executing for exception " + ex);

    ActionForward forward;
    ActionMessage error;
    String property;

    // Build the forward from the exception mapping if it exists
    // or from the form input
    if (ae.getPath() != null) {
      forward = new ActionForward(ae.getPath());
    } else {
      forward = mapping.getInputForward();
    }

    // Figure out the error
    if (ex instanceof ModuleException) {
      error = ((ModuleException) ex).getActionMessage();
      property = ((ModuleException) ex).getProperty();
    } else {
      error = new ActionMessage(ae.getKey(), ex.getMessage());
      property = error.getKey();
    }

    this.logException(ex);

    // Store the exception
    request.setAttribute(Globals.EXCEPTION_KEY, ex);
    this.storeException(request, property, error, forward, ae.getScope());

    if (!response.isCommitted()) {
      return forward;
    }

    LOG.debug(
        "Response is already committed, so forwarding will not work."
            + " Attempt alternate handling.");

    if (!silent(ae)) {
      handleCommittedResponse(ex, ae, mapping, formInstance, request, response, forward);
    } else {
      LOG.warn(
          "ExceptionHandler configured with " + SILENT_IF_COMMITTED + " and response is committed.",
          ex);
    }

    return null;
  }
Exemplo n.º 26
0
 public ActionForward updateMonitorService(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   MonitorService monitorService = (MonitorService) ((DynaActionForm) form).get("monitorService");
   DependencyUtil.clearDependencyProperty(monitorService);
   monitorHostserviceService.updateMonitorService(monitorService);
   return mapping.findForward("success");
 }
  /**
   * Method execute
   *
   * @param ActionMapping mapping
   * @param ActionForm form
   * @param HttpServletRequest request
   * @param HttpServletResponse response
   * @return ActionForward
   * @throws Exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    HttpSession session = request.getSession();
    // clientXML = (XMLClient) session.getAttribute("client");
    clientXML = XMLClient.getInstance();
    sessionLogin = (String) session.getAttribute("login");

    planifProgForm planifForm = (planifProgForm) form;

    String idprog = planifForm.getIdprog();
    String idcanal = planifForm.getIdcanal();
    String jour = planifForm.getJour();
    String mois = planifForm.getMois();
    String annee = planifForm.getAnnee();
    String heure = planifForm.getHeure();
    String minute = planifForm.getMinute();
    String seconde = planifForm.getSeconde();

    response.setContentType("text/html");

    boolean planifie =
        clientXML.planifierProgramme(
            sessionLogin, idprog, idcanal, jour, mois, annee, heure, minute, seconde);

    if (planifie) {
      String result = "INFO: Programme planifié sur le canal";

      session.setAttribute("Resultat", result);
      return mapping.findForward("ok");
    } else {
      String erreur = "ERREUR: Programme non planifié";

      session.setAttribute("Resultat", erreur);
      return mapping.findForward("failed");
    }
  }
 public ActionForward execute(
     ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
     throws Exception {
   ServiceDataForm obj = (ServiceDataForm) form;
   String serviceId = obj.getServiceId();
   CalculateService obj2 = new CalculateService();
   obj2.calculate(serviceId);
   Connection con = null;
   Class.forName(ConnectionStats.DRIVER);
   String url = ConnectionStats.DB_URL;
   String usr = ConnectionStats.DB_USER;
   String pwd = ConnectionStats.DB_PASSWORD;
   con = DriverManager.getConnection(url, usr, pwd);
   Statement stmt = con.createStatement();
   ResultSet rs = null;
   rs = stmt.executeQuery("select * from " + serviceId + "_main");
   ResultSetMetaData rsmd = rs.getMetaData();
   int col = rsmd.getColumnCount();
   String[] mainHeader = new String[col];
   for (int i = 0; i < col; i++) {
     mainHeader[i] = rsmd.getColumnLabel(i + 1);
   }
   ArrayList<String[]> serviceDataMain = new ArrayList<String[]>();
   while (rs.next()) {
     String[] str = new String[col];
     for (int i = 0; i < col; i++) {
       str[i] = rs.getString(i + 1);
     }
     serviceDataMain.add(str);
   }
   req.setAttribute("mainHeader", mainHeader);
   req.setAttribute("serviceDataMain", serviceDataMain);
   rs = stmt.executeQuery("select * from " + serviceId + "_tbl");
   rsmd = rs.getMetaData();
   col = rsmd.getColumnCount();
   String[] tblHeader = new String[col];
   for (int i = 0; i < col; i++) {
     tblHeader[i] = rsmd.getColumnLabel(i + 1);
   }
   ArrayList<String[]> serviceDatatbl = new ArrayList<String[]>();
   while (rs.next()) {
     String[] str = new String[col];
     for (int i = 0; i < col; i++) {
       str[i] = rs.getString(i + 1);
     }
     serviceDatatbl.add(str);
   }
   req.setAttribute("tblHeader", tblHeader);
   req.setAttribute("serviceDatatbl", serviceDatatbl);
   rs.close();
   con.close();
   return mapping.findForward("success");
 }
Exemplo n.º 29
0
  /**
   * If this action is protected by security roles, make sure that the current user possesses at
   * least one of them. Return <code>true</code> to continue normal processing, or <code>false
   * </code> if an appropriate response has been created and processing should terminate.
   *
   * @param request The servlet request we are processing
   * @param response The servlet response we are creating
   * @param mapping The mapping we are using
   * @return <code>true</code> to continue normal processing; <code>false</code> if a response has
   *     been created.
   * @throws IOException if an input/output error occurs
   * @throws ServletException if a servlet exception occurs
   */
  protected boolean processRoles(
      HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
      throws IOException, ServletException {
    // Is this action protected by role requirements?
    String[] roles = mapping.getRoleNames();

    if ((roles == null) || (roles.length < 1)) {
      return (true);
    }

    // Check the current user against the list of required roles
    for (int i = 0; i < roles.length; i++) {
      if (request.isUserInRole(roles[i])) {
        if (log.isDebugEnabled()) {
          log.debug(
              " User '"
                  + request.getRemoteUser()
                  + "' has role '"
                  + roles[i]
                  + "', granting access");
        }

        return (true);
      }
    }

    // The current user is not authorized for this action
    if (log.isDebugEnabled()) {
      log.debug(
          " User '"
              + request.getRemoteUser()
              + "' does not have any required role, denying access");
    }

    response.sendError(
        HttpServletResponse.SC_FORBIDDEN,
        getInternal().getMessage("notAuthorized", mapping.getPath()));

    return (false);
  }
Exemplo n.º 30
0
 public ActionForward viewMonitorService(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   String id = request.getParameter("id");
   MonitorService monitorService =
       monitorHostserviceService.getMonitorService(Integer.valueOf(id));
   DependencyUtil.initDependencyProperty(monitorService);
   ((DynaActionForm) form).set("monitorService", monitorService);
   return mapping.findForward("view");
 }