| 
															
																@@ -3,8 +3,10 @@ package co.id.datacomsolusindo.ipphonebridge 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import com.fasterxml.jackson.core.type.TypeReference 
															 | 
															
															 | 
															
																 import com.fasterxml.jackson.core.type.TypeReference 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import com.fasterxml.jackson.databind.ObjectMapper 
															 | 
															
															 | 
															
																 import com.fasterxml.jackson.databind.ObjectMapper 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.apache.commons.io.IOUtils 
															 | 
															
															 | 
															
																 import org.apache.commons.io.IOUtils 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+import org.springframework.context.annotation.Configuration 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.springframework.core.Ordered 
															 | 
															
															 | 
															
																 import org.springframework.core.Ordered 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.springframework.core.annotation.Order 
															 | 
															
															 | 
															
																 import org.springframework.core.annotation.Order 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+import org.springframework.core.io.ResourceLoader 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.springframework.http.HttpMethod 
															 | 
															
															 | 
															
																 import org.springframework.http.HttpMethod 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.springframework.http.HttpStatus 
															 | 
															
															 | 
															
																 import org.springframework.http.HttpStatus 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.springframework.messaging.simp.SimpMessagingTemplate 
															 | 
															
															 | 
															
																 import org.springframework.messaging.simp.SimpMessagingTemplate 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -13,6 +15,10 @@ import org.springframework.web.bind.annotation.GetMapping 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.springframework.web.bind.annotation.PathVariable 
															 | 
															
															 | 
															
																 import org.springframework.web.bind.annotation.PathVariable 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.springframework.web.bind.annotation.PostMapping 
															 | 
															
															 | 
															
																 import org.springframework.web.bind.annotation.PostMapping 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.springframework.web.bind.annotation.RestController 
															 | 
															
															 | 
															
																 import org.springframework.web.bind.annotation.RestController 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+import org.springframework.web.servlet.config.annotation.EnableWebMvc 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+import org.springframework.web.servlet.resource.PathResourceResolver 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import java.io.IOException 
															 | 
															
															 | 
															
																 import java.io.IOException 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import java.io.InputStream 
															 | 
															
															 | 
															
																 import java.io.InputStream 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import java.io.Serializable 
															 | 
															
															 | 
															
																 import java.io.Serializable 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -53,7 +59,7 @@ class SimpleCORSFilter : Filter { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 @Component 
															 | 
															
															 | 
															
																 @Component 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 @Order(1) 
															 | 
															
															 | 
															
																 @Order(1) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-class BridgeFilter(private val template: SimpMessagingTemplate) : Filter { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoader: ResourceLoader) : Filter { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     override fun doFilter(request: ServletRequest, response: ServletResponse, chain: FilterChain) { 
															 | 
															
															 | 
															
																     override fun doFilter(request: ServletRequest, response: ServletResponse, chain: FilterChain) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         val req = request as HttpServletRequest 
															 | 
															
															 | 
															
																         val req = request as HttpServletRequest 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         val splitPath = req.requestURI.split("/") 
															 | 
															
															 | 
															
																         val splitPath = req.requestURI.split("/") 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -111,6 +117,8 @@ class BridgeFilter(private val template: SimpMessagingTemplate) : Filter { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         res.flushBuffer() 
															 | 
															
															 | 
															
																         res.flushBuffer() 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         Singletons.requestInstance.remove(reqId) 
															 | 
															
															 | 
															
																         Singletons.requestInstance.remove(reqId) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         return 
															 | 
															
															 | 
															
																         return 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 } 
															 | 
															
															 | 
															
																 } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -133,7 +141,7 @@ class RequestBuilder(val id: String, val path: String, val method: HttpMethod, v 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     var queryString: MutableMap<String, Array<String>>? = null 
															 | 
															
															 | 
															
																     var queryString: MutableMap<String, Array<String>>? = null 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 } 
															 | 
															
															 | 
															
																 } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																-class Resp(val body: InputStream, val statusCode: Int, val headers: Map<String,Array<String>>? = null) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+class Resp(val body: InputStream, val statusCode: Int, val headers: Map<String, Array<String>>? = null) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 object Singletons { 
															 | 
															
															 | 
															
																 object Singletons { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     val responseQue: MutableMap<String, Resp> by lazy { mutableMapOf<String, Resp>() } 
															 | 
															
															 | 
															
																     val responseQue: MutableMap<String, Resp> by lazy { mutableMapOf<String, Resp>() } 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -148,7 +156,7 @@ class BridgeRestController { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         val typeRef: TypeReference<HashMap<String, Array<String>>> = object : TypeReference<HashMap<String, Array<String>>>() {} 
															 | 
															
															 | 
															
																         val typeRef: TypeReference<HashMap<String, Array<String>>> = object : TypeReference<HashMap<String, Array<String>>>() {} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         Singletons.responseQue[id] = Resp( 
															 | 
															
															 | 
															
																         Singletons.responseQue[id] = Resp( 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 req.getPart("body").inputStream, 
															 | 
															
															 | 
															
																                 req.getPart("body").inputStream, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-               String(IOUtils.toByteArray(req.getPart("status").inputStream)).toInt(), 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                String(IOUtils.toByteArray(req.getPart("status").inputStream)).toInt(), 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 if (req.getPart("header") != null) { 
															 | 
															
															 | 
															
																                 if (req.getPart("header") != null) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                     objectMapper.readValue(String(IOUtils.toByteArray(req.getPart("header").inputStream)), typeRef) 
															 | 
															
															 | 
															
																                     objectMapper.readValue(String(IOUtils.toByteArray(req.getPart("header").inputStream)), typeRef) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 } else { 
															 | 
															
															 | 
															
																                 } else { 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -168,3 +176,16 @@ class BridgeRestController { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 } 
															 | 
															
															 | 
															
																 } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+@Configuration 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+@EnableWebMvc 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+class MvcConfig : WebMvcConfigurer { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    override fun addResourceHandlers(registry: ResourceHandlerRegistry) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        registry 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                .addResourceHandler("/resources/**") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                .addResourceLocations("file:dist/") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                .setCachePeriod(3600 * 24 * 30) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                .resourceChain(true) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                .addResolver(PathResourceResolver()) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 |