refactoring
This commit is contained in:
		
							parent
							
								
									b758a1c7d0
								
							
						
					
					
						commit
						0270bc9b88
					
				@ -201,7 +201,7 @@ public class DeviceConnectivityServiceImpl implements DeviceConnectivityService
 | 
				
			|||||||
                    pemContentBuilder.append("-----END CERTIFICATE-----\n");
 | 
					                    pemContentBuilder.append("-----END CERTIFICATE-----\n");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            String msg = String.format("Failed to read %s server certificate!", path);
 | 
					            String msg = String.format("Failed to read %s server certificate!", path);
 | 
				
			||||||
            log.warn(msg);
 | 
					            log.warn(msg);
 | 
				
			||||||
            throw new RuntimeException(msg, e);
 | 
					            throw new RuntimeException(msg, e);
 | 
				
			||||||
 | 
				
			|||||||
@ -214,24 +214,24 @@ public class DeviceConnectivityUtil {
 | 
				
			|||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        StringBuilder mqttDockerCommand = new StringBuilder();
 | 
					        StringBuilder coapDockerCommand = new StringBuilder();
 | 
				
			||||||
        mqttDockerCommand.append(DOCKER_RUN).append(isLocalhost(host) ? ADD_DOCKER_INTERNAL_HOST : "").append(COAP_IMAGE);
 | 
					        coapDockerCommand.append(DOCKER_RUN).append(isLocalhost(host) ? ADD_DOCKER_INTERNAL_HOST : "").append(COAP_IMAGE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (isLocalhost(host)) {
 | 
					        if (isLocalhost(host)) {
 | 
				
			||||||
            coapCommand = coapCommand.replace(host, HOST_DOCKER_INTERNAL);
 | 
					            coapCommand = coapCommand.replace(host, HOST_DOCKER_INTERNAL);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (COAPS.equals(protocol)) {
 | 
					        if (COAPS.equals(protocol)) {
 | 
				
			||||||
            mqttDockerCommand.append("/bin/sh -c \"")
 | 
					            coapDockerCommand.append("/bin/sh -c \"")
 | 
				
			||||||
                    .append(getCurlPemCertCommand(baseUrl, protocol))
 | 
					                    .append(getCurlPemCertCommand(baseUrl, protocol))
 | 
				
			||||||
                    .append(" && ")
 | 
					                    .append(" && ")
 | 
				
			||||||
                    .append(coapCommand)
 | 
					                    .append(coapCommand)
 | 
				
			||||||
                    .append("\"");
 | 
					                    .append("\"");
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            mqttDockerCommand.append(coapCommand);
 | 
					            coapDockerCommand.append(coapCommand);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return mqttDockerCommand.toString();
 | 
					        return coapDockerCommand.toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static String getHost(String baseUrl, DeviceConnectivityInfo properties, String protocol) throws URISyntaxException {
 | 
					    public static String getHost(String baseUrl, DeviceConnectivityInfo properties, String protocol) throws URISyntaxException {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user