Class RequestUtils


  • public class RequestUtils
    extends Object
    Utils class containing request-specific static utility methods.
    • Method Detail

      • extractRequestUrl

        public static String extractRequestUrl​(javax.servlet.http.HttpServletRequest request)
        Extracts the request URL from the given HttpServletRequest object.
        Parameters:
        request - sent HttpServletRequest object
        Returns:
        String that contains the received request URL
      • cacheNotAllowed

        public static boolean cacheNotAllowed​(String url,
                                              String[] timeParameter)
        Checks, if caching will be allowed for the given query, or not.
        Parameters:
        url - the URL of the request to check
        timeParameter - the "time" parameter of the request to check
        Returns:
        whether caching is allowed, or not
      • isDataExtraction

        public static boolean isDataExtraction​(String url)
        Checks if the given request is requesting a data extraction that can potentially return a bigger amount of GeoJSON data. This can either be through using the /elements/geometry|bbox|centroid, or the /elementsFullHistory endpoint.
        Parameters:
        url - the url of the request to check
        Returns:
        whether it is a data-extraction request, or not
      • isContributionsExtraction

        public static boolean isContributionsExtraction​(String url)
        Checks if the given request is requesting a contributions extraction that can potentially return a bigger amount of GeoJSON data. This can be through using the /contributions/(latest)/geometry|bbox|centroid endpoint.
        Parameters:
        url - the url of the request to check
        Returns:
        whether it is a contributions-extraction request, or not
      • usesCsvFormat

        public static boolean usesCsvFormat​(javax.servlet.http.HttpServletRequest request)
        Checks if the given request uses the csv format.
        Parameters:
        request - HttpServletRequest object used to check
        Returns:
        whether it uses the csv format, or not
      • extractOSHDBMetadata

        public static void extractOSHDBMetadata()
                                         throws IOException
        Extracts some metadata from the OSHDB keytables or db and adds it to the corresponding objects.
        Throws:
        DatabaseAccessException - if the keytables are missing
        RuntimeException - if the timerange metadata cannot be retrieved from the db
        IOException - thrown by #readTree(String) readTree