Class WMMultipartUtils


  • public class WMMultipartUtils
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String BLOB  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.wavemaker.runtime.commons.file.model.DownloadResponse buildDownloadResponse​(javax.servlet.http.HttpServletRequest request, java.io.InputStream is, boolean download)  
      static <T> com.wavemaker.runtime.commons.file.model.DownloadResponse buildDownloadResponseForBlob​(T instance, java.lang.String fieldName, javax.servlet.http.HttpServletRequest httpServletRequest, boolean download)  
      static <T> void buildHttpResponseForBlob​(T instance, java.lang.String fieldName, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)
      Generate Http response for a field in any Instance
      static java.lang.String guessContentType​(byte[] data)
      get a match from a stream of data
      static byte[] toByteArray​(org.springframework.web.multipart.MultipartFile file)  
      static <T> T toObject​(java.lang.String json, java.lang.Class<T> instance)  
      static <T> T toObject​(org.springframework.web.multipart.MultipartFile multipartFile, java.lang.Class<T> instance)  
      static <T> T toObject​(org.springframework.web.multipart.MultipartHttpServletRequest multipartHttpServletRequest, java.lang.Class<T> instance)  
      static <T> T toObject​(org.springframework.web.multipart.MultipartHttpServletRequest multipartHttpServletRequest, java.lang.Class<T> instance, java.lang.String serviceId)  
      static <T> T updateLobsContent​(T oldInstance, T newInstance)
      This Api is used to update blob content from old instance to new instance when blob type content is NULL in the new instance
      • Methods inherited from class java.lang.Object

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

      • WMMultipartUtils

        public WMMultipartUtils()
    • Method Detail

      • toObject

        public static <T> T toObject​(org.springframework.web.multipart.MultipartHttpServletRequest multipartHttpServletRequest,
                                     java.lang.Class<T> instance)
      • toObject

        public static <T> T toObject​(org.springframework.web.multipart.MultipartHttpServletRequest multipartHttpServletRequest,
                                     java.lang.Class<T> instance,
                                     java.lang.String serviceId)
      • toObject

        public static <T> T toObject​(org.springframework.web.multipart.MultipartFile multipartFile,
                                     java.lang.Class<T> instance)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • toObject

        public static <T> T toObject​(java.lang.String json,
                                     java.lang.Class<T> instance)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • updateLobsContent

        public static <T> T updateLobsContent​(T oldInstance,
                                              T newInstance)
        This Api is used to update blob content from old instance to new instance when blob type content is NULL in the new instance
        Parameters:
        oldInstance - : persisted instance.
        newInstance - : changes in the persisted instance.
        Returns:
        returns newInstance with updated blob content
      • toByteArray

        public static byte[] toByteArray​(org.springframework.web.multipart.MultipartFile file)
      • guessContentType

        public static java.lang.String guessContentType​(byte[] data)
        get a match from a stream of data
        Parameters:
        data - bytes of data
        Returns:
        Guessed content type of given bytes
      • buildHttpResponseForBlob

        public static <T> void buildHttpResponseForBlob​(T instance,
                                                        java.lang.String fieldName,
                                                        javax.servlet.http.HttpServletRequest httpServletRequest,
                                                        javax.servlet.http.HttpServletResponse httpServletResponse)
        Generate Http response for a field in any Instance
        Parameters:
        instance - any Instance
        fieldName - name of the field
        httpServletRequest - to prepare content type
        httpServletResponse - to generate response for the given field
      • buildDownloadResponseForBlob

        public static <T> com.wavemaker.runtime.commons.file.model.DownloadResponse buildDownloadResponseForBlob​(T instance,
                                                                                                                 java.lang.String fieldName,
                                                                                                                 javax.servlet.http.HttpServletRequest httpServletRequest,
                                                                                                                 boolean download)
      • buildDownloadResponse

        public static com.wavemaker.runtime.commons.file.model.DownloadResponse buildDownloadResponse​(javax.servlet.http.HttpServletRequest request,
                                                                                                      java.io.InputStream is,
                                                                                                      boolean download)