Changeset 32335


Ignore:
Timestamp:
2018-08-14T16:29:38+12:00 (6 years ago)
Author:
ak19
Message:

Simplifying the code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/util/GlobalProperties.java

    r32334 r32335  
    153153
    154154            //protocol
    155             if (properties.getProperty("server.protocol") == null || properties.getProperty("server.protocol").equals(""))
     155            protocolSpecifier = properties.getProperty("server.protocol");
     156            if (protocolSpecifier == null || protocolSpecifier.equals(""))
    156157            {
    157158                protocolSpecifier = "http://";
    158159            }
     160            else if (!protocolSpecifier.endsWith("://"))
     161            {               
     162                protocolSpecifier = protocolSpecifier + "://";             
     163            }
     164
     165            //hostname
     166            hostSpecifier = properties.getProperty("tomcat.server");
     167            if (hostSpecifier == null)
     168            {
     169                hostSpecifier = "localhost";
     170            }
    159171            else
    160             {
    161                 if (properties.getProperty("server.protocol").endsWith("://"))
    162                 {
    163                     protocolSpecifier = properties.getProperty("server.protocol");
    164                 }
    165                 else
    166                 {
    167                     protocolSpecifier = properties.getProperty("server.protocol") + "://";
    168                 }
    169             }
    170 
    171             //hostname
    172             if (properties.getProperty("tomcat.server") == null)
    173             {
    174                 hostSpecifier = "localhost";
    175             }
    176             else
    177             {
    178                 hostSpecifier = properties.getProperty("tomcat.server");
     172            {               
    179173                while (hostSpecifier.endsWith("/"))
    180174                {
     
    184178
    185179            //port
    186             if (properties.getProperty("tomcat.port") == null || properties.getProperty("tomcat.port").equals("") || (protocolSpecifier.equals("http://") && properties.getProperty("tomcat.port").equals("80")) || (protocolSpecifier.equals("https://") && properties.getProperty("tomcat.port").equals("443")))
     180            portSpecifier = properties.getProperty("tomcat.port");
     181            if (portSpecifier == null || portSpecifier.equals("")
     182                || (protocolSpecifier.equals("http://") && portSpecifier.equals("80"))
     183                || (protocolSpecifier.equals("https://") && portSpecifier.equals("443")))
    187184            {
    188185                portSpecifier = "";
     
    190187            else
    191188            {
    192                 portSpecifier = ":" + properties.getProperty("tomcat.port");
     189                portSpecifier = ":" + portSpecifier;
    193190            }
    194191
    195192            //context path
    196             if (properties.getProperty("tomcat.context") == null || properties.getProperty("tomcat.context").equals("") || properties.getProperty("tomcat.context").equals("/"))
     193            contextSpecifier = properties.getProperty("tomcat.context");
     194            if (contextPath == null || contextPath.equals("") || contextPath.equals("/"))
    197195            {
    198196                contextSpecifier = "";
    199197            }
    200198            else
    201             {
    202                 contextSpecifier = properties.getProperty("tomcat.context");
     199            {               
    203200                if (!contextSpecifier.startsWith("/"))
    204201                {
Note: See TracChangeset for help on using the changeset viewer.