Class ExtDirectSpringUtil

java.lang.Object
ch.ralscha.extdirectspring.util.ExtDirectSpringUtil

public final class ExtDirectSpringUtil extends Object
Utility class
  • Field Details

    • UTF8_CHARSET

      public static final Charset UTF8_CHARSET
  • Method Details

    • equal

      public static boolean equal(Object a, Object b)
      Checks if two objects are equal. Returns true if both objects are null
      Parameters:
      a - object one
      b - object two
      Returns:
      true if objects are equal
    • isMultipart

      public static boolean isMultipart(jakarta.servlet.http.HttpServletRequest request)
      Checks if the request is a multipart request
      Parameters:
      request - the HTTP servlet request
      Returns:
      true if request is a Multipart request (file upload)
    • invoke

      public static Object invoke(org.springframework.context.ApplicationContext context, String beanName, MethodInfo methodInfo, Object[] params) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
      Invokes a method on a Spring managed bean.
      Parameters:
      context - a Spring application context
      beanName - the name of the bean
      methodInfo - the methodInfo object
      params - the parameters
      Returns:
      the result of the method invocation
      Throws:
      IllegalArgumentException - if there is no bean in the context
      IllegalAccessException
      InvocationTargetException
    • invoke

      public static Object invoke(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Locale locale, org.springframework.context.ApplicationContext context, ExtDirectRequest directRequest, ParametersResolver parametersResolver, MethodInfoCache cache) throws Exception
      Throws:
      Exception
    • getStackTrace

      public static String getStackTrace(Throwable t)
      Converts a stacktrace into a String
      Parameters:
      t - a Throwable
      Returns:
      the whole stacktrace in a String
    • addCacheHeaders

      public static void addCacheHeaders(jakarta.servlet.http.HttpServletResponse response, String etag, Integer month)
      Adds Expires, ETag and Cache-Control response headers.
      Parameters:
      response - the HTTP servlet response
      etag - the calculated etag (md5) of the response
      month - number of months the response can be cached. Added to the Expires and Cache-Control header. If null defaults to 6 months.
    • handleCacheableResponse

      public static void handleCacheableResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, byte[] data, String contentType) throws IOException
      Checks etag and sends back HTTP status 304 if not modified. If modified sets content type and content length, adds cache headers ( addCacheHeaders(HttpServletResponse, String, Integer)), writes the data into the ServletResponse.getOutputStream() and flushes it.
      Parameters:
      request - the HTTP servlet request
      response - the HTTP servlet response
      data - the response data
      contentType - the content type of the data (i.e. "application/javascript;charset=utf-8")
      Throws:
      IOException
    • generateApiString

      public static String generateApiString(org.springframework.context.ApplicationContext ctx) throws com.fasterxml.jackson.core.JsonProcessingException
      Returns the api configuration as a String. Uses "REMOTING_API" and "POLLING_URLS" for the variable names
      Parameters:
      ctx - The spring applicationcontext
      Returns:
      the api configuration
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • generateApiString

      public static String generateApiString(org.springframework.context.ApplicationContext ctx, String remotingVarName, String pollingApiVarName) throws com.fasterxml.jackson.core.JsonProcessingException
      Returns the api configuration as a String
      Parameters:
      ctx - The spring applicationcontext
      remotingVarName - name of the variable for the remoting configuration (e.g. REMOTING_API)
      pollingApiVarName - name of the variable for the polling configuration (e.g. POLLING_URLS)
      Returns:
      the api configuration
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException