/** * */ package vn.mobileid.fms.client; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; /** * @author TRUONG.NNT * @created Jun 29, 2019 */ public class FMSUtils { public String generateKey(String in) { return in; } public static void awaitTerminationAfterShutdown(ExecutorService threadPool) { threadPool.shutdown(); try { if (!threadPool.awaitTermination(30, TimeUnit.SECONDS)) { threadPool.shutdownNow(); } } catch (InterruptedException ex) { ex.printStackTrace(); threadPool.shutdownNow(); Thread.currentThread().interrupt(); } } /** * @param pathSegment * @return escaped path segment, suitable for url * @throws java.io.UnsupportedEncodingException */ public static String encodeUrlPath(String pathSegment) throws UnsupportedEncodingException { String[] paths = pathSegment.split("/"); StringBuilder s = new StringBuilder(); for (String p : paths) { s.append("/").append(URLEncoder.encode(p, StandardCharsets.UTF_8.toString())); } return s.toString(); } }