コード例 #1
0
ファイル: Support.java プロジェクト: trackplus/Genji
  public void setURIs(HttpServletRequest request) {
    String serverURL = ApplicationBean.getInstance().getSiteBean().getServerURL();

    String baseURI = request.getRequestURI();
    int extension = baseURI.lastIndexOf("/");
    // This is automatically overwritten by StartServlet
    // if there is an entry "serverURL" in web.xml
    if (serverURL == null || serverURL.length() < 1) {
      ApplicationBean.getInstance()
          .getSiteBean()
          .setServerURL(
              request.getScheme()
                  + "://"
                  + request.getServerName()
                  + ":"
                  + request.getServerPort());
    }
    if (extension != -1) {
      Constants.BaseURL = serverURL + baseURI.substring(0, extension);
      Constants.setHyperlink(Constants.BaseURL);
    }

    // So that JSP can access it...
    HttpSession session = request.getSession();
    session.setAttribute("BASEURL", Constants.BaseURL);

    // persist the last serverURL
    persistLastServerURL(serverURL, Constants.BaseURL);
  }
コード例 #2
0
ファイル: Support.java プロジェクト: trackplus/Genji
 public static String getLastBaseURL() {
   TSiteBean site = SiteConfigBL.loadTSite();
   if (site != null) {
     String serverURL = site.getPreferenceProperty("lastServerURL");
     String baseURL = site.getPreferenceProperty("lastBaseURL");
     ApplicationBean.getInstance().getSiteBean().setServerURL(serverURL);
     Constants.BaseURL = baseURL;
     Constants.setHyperlink(baseURL);
     return baseURL;
   }
   return null;
 }
コード例 #3
0
 /**
  * Returns a {@link GroovyClassLoader} that contains all scripts from the database. This method is
  * synchronized, so you can call scripts even though they are just being reloaded from the
  * database.
  */
 private void getGroovyScripts() {
   try {
     InputStream grooving = null;
     StringBuilder sb = new StringBuilder();
     try {
       URL groovyURL =
           ApplicationBean.getInstance()
               .getServletContext()
               .getResource("/WEB-INF/classes/plugins/groovy/system/DefaultActionHandler.groovy");
       grooving = groovyURL.openStream();
       byte[] buffer = new byte[2048];
       int length;
       while ((length = grooving.read(buffer)) != -1) {
         sb.append(new String(buffer, 0, length));
       }
       grooving.close();
     } catch (Exception exx) {
       LOGGER.warn(
           "Could not load "
               + Constants.getGroovyURL()
               + "DefaultActionHandler.groovy. This is normal for the test environment.");
     }
     // get the sources from DB and parse them...
     Class<?> parsedClass = groovyClassLoader.parseClass(sb.toString());
     availableClasses.put("plugins.groovy.system.DefaultActionHandler", parsedClass);
     // class names to get on database...
     List<TScriptsBean> scriptBeansList = ScriptAdminBL.getAllScripts();
     if (scriptBeansList != null) {
       for (TScriptsBean scriptsBean : scriptBeansList) {
         Integer scriptType = scriptsBean.getScriptType();
         if (scriptType == null || !scriptType.equals(TScriptsBean.SCRIPT_TYPE.PARAMETER_SCRIPT)) {
           parseScript(scriptsBean.getClazzName(), scriptsBean.getSourceCode());
         }
       }
     }
   } catch (Exception ex) {
     LOGGER.warn("Problem loading Groovy scripts. This is normal for the test environment.");
   }
 }