Exemple #1
0
  @RequestMapping("/jump")
  public void jump(HttpServletRequest request, HttpServletResponse response) {
    logger.debug("---------------------------jump----------------------");
    LoginContext loginContext = RequestUtils.getLoginContext(request);
    if (loginContext == null) {
      try {
        response.sendRedirect(request.getContextPath() + ViewProperties.getString("loginUrl"));
        return;
      } catch (Exception ex) {
      }
    }
    String menuId = request.getParameter("menuId");
    if (menuId != null) {
      menuId = RequestUtils.decodeString(menuId);
    }
    logger.debug("menuId:" + menuId);
    if (menuId != null && StringUtils.isNumeric(menuId)) {
      SysApplication app = sysApplicationService.findById(Long.parseLong(menuId));
      if (app != null) {
        boolean accessable = false;
        if (loginContext.isSystemAdministrator()) {
          accessable = true;
        } else {
          AuthorizeBean bean = new AuthorizeBean();
          SysUser sysUser = bean.getUser(loginContext.getActorId());
          if (sysUser != null) {
            accessable = sysUser.hasApplicationAccess(app.getId());
          }
        }
        logger.debug("accessable:" + accessable);
        if (accessable) {
          try {
            String url = app.getUrl();
            if (url != null) {
              if (!(url.toLowerCase().startsWith("http://")
                  || url.toLowerCase().startsWith("https://"))) {
                if (url.startsWith("/")) {
                  url = request.getContextPath() + url;
                } else {
                  url = request.getContextPath() + "/" + url;
                }
              }
              if (url.indexOf("?") != -1) {
                url = url + "&time=" + System.currentTimeMillis();
              } else {
                url = url + "?time=" + System.currentTimeMillis();
              }

              String key = SystemProperties.getDefaultSecurityKey();

              String actorId = SecurityUtils.encode(key, loginContext.getActorId());

              if (StringUtils.endsWithIgnoreCase(app.getLinkFileName(), ".cpt")) {
                url = SystemConfig.getString("report_service_url");
                String cpt_path = "fileId=" + app.getLinkFileId();
                String dsJson = DBConfiguration.encodeJsonCurrentSystem();
                if (url.indexOf("?") == -1) {
                  url = url + "?q=1";
                }
                url = url + "&" + cpt_path + "&datasourceJson=" + dsJson;
                if (app.getRefId1() != null) {
                  url = url + "&refId1=" + app.getRefId1() + "&treedot_index_id=" + app.getRefId1();
                }
                if (app.getRefId2() != null) {
                  url =
                      url + "&refId2=" + app.getRefId2() + "&treepinfo_index_id=" + app.getRefId2();
                }

                if (StringUtils.isNotEmpty(app.getLinkParam())) {
                  url = url + "&" + app.getLinkParam();
                }
              }

              if (StringUtils.endsWithIgnoreCase(app.getPrintFileName(), ".cpt")) {
                url = url + "&printFileId=" + app.getPrintFileId();
                if (StringUtils.isNotEmpty(app.getPrintParam())) {
                  url = url + "&" + app.getPrintParam();
                }
              }

              url = url + "&security_actorId=" + actorId;
              logger.debug(url);
              response.sendRedirect(url);
            } else {
              return;
            }
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        }
      }
    }
    try {
      request.getRequestDispatcher("/WEB-INF/views/404.jsp").forward(request, response);
    } catch (Exception e) {
    }
  }