Changeset 37136


Ignore:
Timestamp:
2023-01-15T00:52:24+13:00 (3 weeks ago)
Author:
davidb
Message:

LibraryServlet.java changed to test for GlobalProperties revproxy.protocol, revproxy_domain etc, and if they exists set servlet_protocol, servlet_domain etc as InterfaceOptions. If they don't exist then the values default back to servlet.protocol (localhost) etc values.

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java

    r37096 r37136  
    222222      }
    223223
    224     String greenstone_context = GlobalProperties.getGSDL3WebAddress();
    225     config_params.put(GSConstants.SERVLET_CONTEXT, greenstone_context);
     224    // The following is now superceeded by the for-loop below
     225    //String greenstone_context = GlobalProperties.getGSDL3WebAddress();
     226    //config_params.put(GSConstants.SERVLET_CONTEXT, greenstone_context);
     227
     228    String[] servlet_url_parts  = { GSConstants.SERVLET_PROTOCOL,  GSConstants.SERVLET_DOMAIN,  GSConstants.SERVLET_OPT_PORT,  GSConstants.SERVLET_CONTEXT };
     229    String[] servlet_url_props  = { "server.protocol",   "tomcat.server",   "tomcat.port",       "tomcat.context" };
     230    String[] revproxy_url_props = { "revproxy.protocol", "revproxy.domain", "revproxy.opt_port", "revproxy.context" };
     231
     232    boolean explicit_revproxy_domain = false;
     233   
     234    for (int i=0; i<servlet_url_parts.length; i++) {
     235    String servlet_part_name = servlet_url_parts[i];
     236
     237    String revproxy_prop_name = revproxy_url_props[i];
     238    String servlet_prop_name  = servlet_url_props[i];   
     239
     240    String revproxy_prop_val = GlobalProperties.getProperty(revproxy_prop_name);   
     241    String servlet_prop_val  = GlobalProperties.getProperty(servlet_prop_name);
     242
     243    String unassigned_prop_val = "${" + revproxy_prop_name + "}";
     244   
     245    if (revproxy_prop_val.equals(unassigned_prop_val)) {
     246        // default to SERVLET version of val
     247        // with a special exception if the port
     248        if (revproxy_prop_name.equals("revproxy.opt_port")) {
     249        if (explicit_revproxy_domain) {
     250            // explicitly set revproxy.domain, but provided no revproxy.opt_port
     251            // => set to be the empty string
     252            config_params.put(servlet_part_name, "");
     253        }
     254        else {
     255            // No explicity revproxy domain => default back to the servlet provied port
     256            config_params.put(servlet_part_name, servlet_prop_val);
     257        }
     258        }
     259        else {
     260        // Regular case => default back to the value provided for 'servlet'
     261        config_params.put(servlet_part_name, servlet_prop_val);
     262        }
     263    }
     264    else {
     265        // Have a non-trival revproxy part val => use that (public facing) value to embed into web browser pages
     266        config_params.put(servlet_part_name, revproxy_prop_val);
     267
     268        if (revproxy_prop_name.equals("revproxy.domain")) {
     269        explicit_revproxy_domain = true;
     270        }
     271    }   
     272    }
     273   
    226274   
    227275    // the receptionist -the servlet will talk to this
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSConstants.java

    r36913 r37136  
    2424    public static final String GSDL3_HOME = "gsdl3_home";
    2525    public static final String INTERFACE_NAME = "interface_name";
    26     public static final String SITE_NAME = "site_name";
    27     public static final String LIBRARY_NAME = "library_name";
    28   public static final String SERVLET_CONTEXT = "servlet_context";
     26    public static final String SITE_NAME      = "site_name";
     27    public static final String LIBRARY_NAME   = "library_name";
     28
     29        public static final String SERVLET_PROTOCOL  = "servlet_protocol";
     30        public static final String SERVLET_DOMAIN    = "servlet_domain";
     31        public static final String SERVLET_OPT_PORT  = "servlet_opt_port";
     32        public static final String SERVLET_CONTEXT   = "servlet_context";
     33
    2934    public static final String BASE_INTERFACES = "base_interfaces";
    3035    public static final String DEFAULT_LANG = "default_lang";
Note: See TracChangeset for help on using the changeset viewer.