Class ExpansionDeltaUtil


  • public final class ExpansionDeltaUtil
    extends java.lang.Object

    Utility class providing methods used in ExpansionHandler and DeltaHandler.

    Author:
    https://github.com/mcweba [Marc-Andre Weber]
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String constructRequestUri​(java.lang.String path, io.vertx.core.MultiMap params, java.util.List<java.lang.String> paramsToRemove, java.lang.String subResource, ExpansionDeltaUtil.SlashHandling slashHandling)
      Constructs a Request based on the given path and the given params without the paramsToRemove
      static io.vertx.core.Handler<java.lang.Throwable> createRequestExceptionHandler​(io.vertx.core.http.HttpServerRequest request, java.lang.String uri, java.lang.Class<?> caller)
      Utility method to create a Exception for a HttpServerRequest
      static io.vertx.core.Handler<java.lang.Throwable> createResponseExceptionHandler​(io.vertx.core.http.HttpServerRequest request, java.lang.String uri, java.lang.Class<?> caller)
      Utility method to create a Exception for a HttpServerRequest
      static java.lang.String extractCollectionFromPath​(java.lang.String path)
      Extracts the collection name from the given path.
      static java.util.List<java.lang.String> extractCollectionResourceNames​(io.vertx.core.json.JsonArray collectionArray)
      Extracts the collection resource names from the given JsonArray
      static java.lang.String mapToDelimetedString​(io.vertx.core.MultiMap map, java.lang.String delim)
      Converts the given map to a delimited string based on the given delimiter.
      static java.lang.String removeFromEndOfString​(java.lang.String source, java.lang.String stringToRemove)
      Remove the stringToRemove from source when existing
      static ExpansionDeltaUtil.CollectionResourceContainer verifyCollectionResponse​(io.vertx.core.http.HttpServerRequest request, io.vertx.core.buffer.Buffer data, java.util.Set<java.lang.String> originalParams)
      Verifies the result of the collection request.
      static ExpansionDeltaUtil.CollectionResourceContainer verifyCollectionResponse​(java.lang.String targetPath, io.vertx.core.buffer.Buffer data, java.util.Set<java.lang.String> originalParams)
      Verifies the result of the collection request.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • mapToDelimetedString

        public static java.lang.String mapToDelimetedString​(io.vertx.core.MultiMap map,
                                                            java.lang.String delim)
        Converts the given map to a delimited string based on the given delimiter.
         Example
         Input Map: {k1=v1, k2=v2, k3=v3} Input delim: 
         Result: k1=v1&amp;k2=v2&amp;k3=v3
         
        Parameters:
        map - The map to convert.
        delim - The delimiter to use between key-value pairs.
        Returns:
        The delimited string.
      • removeFromEndOfString

        public static java.lang.String removeFromEndOfString​(java.lang.String source,
                                                             java.lang.String stringToRemove)
        Remove the stringToRemove from source when existing
        Parameters:
        source - the source to remove the stringToRemove from
        stringToRemove - the token to remove from source
        Returns:
        String
      • extractCollectionFromPath

        public static java.lang.String extractCollectionFromPath​(java.lang.String path)
        Extracts the collection name from the given path. The collection name is known to be the last segment of the path
        Parameters:
        path - path
        Returns:
        String
      • extractCollectionResourceNames

        public static java.util.List<java.lang.String> extractCollectionResourceNames​(io.vertx.core.json.JsonArray collectionArray)
                                                                               throws ResourceCollectionException
        Extracts the collection resource names from the given JsonArray
        Parameters:
        collectionArray - collectionArray
        Returns:
        the list of collection names
        Throws:
        ResourceCollectionException - ResourceCollectionException
      • constructRequestUri

        public static java.lang.String constructRequestUri​(java.lang.String path,
                                                           io.vertx.core.MultiMap params,
                                                           java.util.List<java.lang.String> paramsToRemove,
                                                           java.lang.String subResource,
                                                           ExpansionDeltaUtil.SlashHandling slashHandling)
        Constructs a Request based on the given path and the given params without the paramsToRemove
        Parameters:
        path - the original path to modify
        params - the params of the original request
        paramsToRemove - the params which should be removed in the new request
        subResource - additional segment for the new request
        slashHandling - when set to true, the new request will have a / at the end
        Returns:
        String
      • createRequestExceptionHandler

        public static io.vertx.core.Handler<java.lang.Throwable> createRequestExceptionHandler​(io.vertx.core.http.HttpServerRequest request,
                                                                                               java.lang.String uri,
                                                                                               java.lang.Class<?> caller)
        Utility method to create a Exception for a HttpServerRequest
        Parameters:
        request - the request
        uri - an uri
        caller - the caller
        Returns:
        Handler
      • createResponseExceptionHandler

        public static io.vertx.core.Handler<java.lang.Throwable> createResponseExceptionHandler​(io.vertx.core.http.HttpServerRequest request,
                                                                                                java.lang.String uri,
                                                                                                java.lang.Class<?> caller)
        Utility method to create a Exception for a HttpServerRequest
        Parameters:
        request - the request
        uri - an uri
        caller - the caller
        Returns:
        Handler