Changeset 2643


Ignore:
Timestamp:
03/01/13 11:26:19 (11 years ago)
Author:
oschonef
Message:
  • add compatibility shim for legacy init parameter
File:
1 edited

Legend:

Unmodified
Added
Removed
  • SRUServer/trunk/src/main/java/eu/clarin/sru/server/utils/SRUServerServlet.java

    r2642 r2643  
    8989    private static final String LEGACY_SRU_SERVER_CONFIG_LOCATION_PARAM =
    9090            "sruServerConfigLocation";
    91 
    9291    /**
    9392     * Servlet initialization parameter name for the class that implements the
     
    9695    public static final String SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM =
    9796            "eu.clarin.sru.server.utils.sruServerSearchEngineClass";
     97    /**
     98     * @deprecated use {@link #SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM}
     99     */
     100    @Deprecated
     101    private static final String LEGACY_SRU_SERVER_SERACH_ENGINE_CLASS_PARAM =
     102            "sruServerSerachEngineClass";
    98103    /**
    99104     * @deprecated use {@link #SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM}
     
    102107    private static final String LEGACY_SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM =
    103108            "sruServerSearchEngineClass";
    104 
    105109    /**
    106110     * Default value for the location of the SRU server configuration.
     
    128132                cfg.getInitParameter(SRU_SERVER_CONFIG_LOCATION_PARAM);
    129133        if (sruServerConfigLocation == null) {
    130             sruServerConfigLocation = cfg.getInitParameter(LEGACY_SRU_SERVER_CONFIG_LOCATION_PARAM);
     134            sruServerConfigLocation = cfg.getInitParameter(
     135                    LEGACY_SRU_SERVER_CONFIG_LOCATION_PARAM);
    131136            if (sruServerConfigLocation != null) {
    132137                logger.warn("init parameter '" +
     
    154159        }
    155160
     161        /* get search engine class name from servelet init parameters */
    156162        String sruServerSearchEngineClass =
    157163                cfg.getInitParameter(SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM);
     164
     165        /* legacy compatibility (first try) */
    158166        if (sruServerSearchEngineClass == null) {
    159             sruServerSearchEngineClass = cfg.getInitParameter(LEGACY_SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM);
     167            sruServerSearchEngineClass = cfg.getInitParameter(
     168                    LEGACY_SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM);
    160169            if (sruServerSearchEngineClass != null) {
    161170                logger.warn("init parameter '" +
     
    163172                        "' is deprecated, please use init parameter '" +
    164173                        SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM + "' instead!");
    165             } else {
    166                 throw new ServletException("init parameter '" +
    167                         SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM +
    168                         "' not defined in servlet configuration");
    169             }
     174            }
     175        }
     176
     177        /* legacy compatibility (second try) */
     178        if (sruServerSearchEngineClass == null) {
     179            sruServerSearchEngineClass = cfg.getInitParameter(
     180                    LEGACY_SRU_SERVER_SERACH_ENGINE_CLASS_PARAM);
     181            if (sruServerSearchEngineClass != null) {
     182                logger.warn("init parameter '" +
     183                        LEGACY_SRU_SERVER_SERACH_ENGINE_CLASS_PARAM +
     184                        "' is deprecated, please use init parameter '" +
     185                        SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM + "' instead!");
     186            }
     187        }
     188
     189        /* if still nothing, give up */
     190        if (sruServerSearchEngineClass == null) {
     191            throw new ServletException("init parameter '" +
     192                    SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM +
     193                    "' not defined in servlet configuration");
    170194        }
    171195
Note: See TracChangeset for help on using the changeset viewer.