@Test(expected = IllegalArgumentException.class) public void testGetUriParametersIllegalArgumentException() { AtlasUtil.getUriParameters("atlas:?%%XX"); }
public static Map<String, String> getUriParameters(String atlasUri) { if (atlasUri == null) { return null; } Map<String, String> params = new HashMap<String, String>(); if (AtlasUtil.isEmpty(atlasUri)) { return params; } validateUri(atlasUri); String[] pass1 = null; if (atlasUri.contains("?")) { pass1 = atlasUri.split("\\?", 2); } if (pass1 == null || pass1.length < 2 || pass1[1] == null || pass1[1].length() < 1) { return params; } String allParams = null; try { allParams = URLDecoder.decode(pass1[1], "UTF-8"); } catch (UnsupportedEncodingException e) { LOG.error("Unable to parse uri" + atlasUri + " for configuration parameters", e); return params; } if (allParams == null) { return null; } String[] configs = allParams.split("&", SPLIT_LIMIT); if (configs == null || configs.length < 1) { return params; } for (int i = 0; i < configs.length; i++) { if (!configs[i].contains("=")) { LOG.warn("Invalid configuration parameter: " + configs[i] + " for uri: '" + atlasUri + "'"); continue; } String[] cfgs = configs[i].split("="); if (cfgs == null || cfgs.length != 2) { LOG.warn("Invalid configuration parameter: " + configs[i] + " for uri: '" + atlasUri + "'"); continue; } params.put(cfgs[0], cfgs[1]); } return params; }
AtlasUtil { public static Map<String, String> getUriParameters(String atlasUri) { if (atlasUri == null) { return null; } Map<String, String> params = new HashMap<String, String>(); if (AtlasUtil.isEmpty(atlasUri)) { return params; } validateUri(atlasUri); String[] pass1 = null; if (atlasUri.contains("?")) { pass1 = atlasUri.split("\\?", 2); } if (pass1 == null || pass1.length < 2 || pass1[1] == null || pass1[1].length() < 1) { return params; } String allParams = null; try { allParams = URLDecoder.decode(pass1[1], "UTF-8"); } catch (UnsupportedEncodingException e) { LOG.error("Unable to parse uri" + atlasUri + " for configuration parameters", e); return params; } if (allParams == null) { return null; } String[] configs = allParams.split("&", SPLIT_LIMIT); if (configs == null || configs.length < 1) { return params; } for (int i = 0; i < configs.length; i++) { if (!configs[i].contains("=")) { LOG.warn("Invalid configuration parameter: " + configs[i] + " for uri: '" + atlasUri + "'"); continue; } String[] cfgs = configs[i].split("="); if (cfgs == null || cfgs.length != 2) { LOG.warn("Invalid configuration parameter: " + configs[i] + " for uri: '" + atlasUri + "'"); continue; } params.put(cfgs[0], cfgs[1]); } return params; } }
AtlasUtil { public static Map<String, String> getUriParameters(String atlasUri) { if (atlasUri == null) { return null; } Map<String, String> params = new HashMap<String, String>(); if (AtlasUtil.isEmpty(atlasUri)) { return params; } validateUri(atlasUri); String[] pass1 = null; if (atlasUri.contains("?")) { pass1 = atlasUri.split("\\?", 2); } if (pass1 == null || pass1.length < 2 || pass1[1] == null || pass1[1].length() < 1) { return params; } String allParams = null; try { allParams = URLDecoder.decode(pass1[1], "UTF-8"); } catch (UnsupportedEncodingException e) { LOG.error("Unable to parse uri" + atlasUri + " for configuration parameters", e); return params; } if (allParams == null) { return null; } String[] configs = allParams.split("&", SPLIT_LIMIT); if (configs == null || configs.length < 1) { return params; } for (int i = 0; i < configs.length; i++) { if (!configs[i].contains("=")) { LOG.warn("Invalid configuration parameter: " + configs[i] + " for uri: '" + atlasUri + "'"); continue; } String[] cfgs = configs[i].split("="); if (cfgs == null || cfgs.length != 2) { LOG.warn("Invalid configuration parameter: " + configs[i] + " for uri: '" + atlasUri + "'"); continue; } params.put(cfgs[0], cfgs[1]); } return params; }  }
AtlasUtil { public static Map<String, String> getUriParameters(String atlasUri) { if (atlasUri == null) { return null; } Map<String, String> params = new HashMap<String, String>(); if (AtlasUtil.isEmpty(atlasUri)) { return params; } validateUri(atlasUri); String[] pass1 = null; if (atlasUri.contains("?")) { pass1 = atlasUri.split("\\?", 2); } if (pass1 == null || pass1.length < 2 || pass1[1] == null || pass1[1].length() < 1) { return params; } String allParams = null; try { allParams = URLDecoder.decode(pass1[1], "UTF-8"); } catch (UnsupportedEncodingException e) { LOG.error("Unable to parse uri" + atlasUri + " for configuration parameters", e); return params; } if (allParams == null) { return null; } String[] configs = allParams.split("&", SPLIT_LIMIT); if (configs == null || configs.length < 1) { return params; } for (int i = 0; i < configs.length; i++) { if (!configs[i].contains("=")) { LOG.warn("Invalid configuration parameter: " + configs[i] + " for uri: '" + atlasUri + "'"); continue; } String[] cfgs = configs[i].split("="); if (cfgs == null || cfgs.length != 2) { LOG.warn("Invalid configuration parameter: " + configs[i] + " for uri: '" + atlasUri + "'"); continue; } params.put(cfgs[0], cfgs[1]); } return params; }  static Properties loadPropertiesFromURL(URL url); static boolean isEmpty(String string); static boolean matchUriModule(String uriA, String uriB); static String getUriScheme(String atlasUri); static String getUriModule(String atlasUri); static String getUriDataType(String atlasUri); static String getUriModuleVersion(String atlasUri); static String getUriParameterValue(String atlasUri, String key); static Map<String, String> getUriParameters(String atlasUri); static int countCharacters(String text, char match); static List<Class<?>> findClassesForPackage(String scannedPackage); static void addAudit(AtlasSession session, String docId, String message, String path, AuditStatus status,
            String value); static Audit createAudit(AuditStatus status, String docId, String docName, String path, String value, String message); static void addAudit(AtlasSession session, Validation validation); static void addAudits(AtlasInternalSession session, String docId, List<Audit> audits); static AuditStatus toAuditStatus(ValidationStatus vstatus); static String getDocumentNameById(AtlasMapping mapping, String docId); static String getChainedMessage(Throwable t); static String escapeForUri(String source); static String unescapeFromUri(String uri); static void deleteDirectory(File targetDir); static void deleteDirectoryContents(File targetDir); static void copyFile(Path sourcePath, Path destPath); }
AtlasUtil { public static Map<String, String> getUriParameters(String atlasUri) { if (atlasUri == null) { return null; } Map<String, String> params = new HashMap<String, String>(); if (AtlasUtil.isEmpty(atlasUri)) { return params; } validateUri(atlasUri); String[] pass1 = null; if (atlasUri.contains("?")) { pass1 = atlasUri.split("\\?", 2); } if (pass1 == null || pass1.length < 2 || pass1[1] == null || pass1[1].length() < 1) { return params; } String allParams = null; try { allParams = URLDecoder.decode(pass1[1], "UTF-8"); } catch (UnsupportedEncodingException e) { LOG.error("Unable to parse uri" + atlasUri + " for configuration parameters", e); return params; } if (allParams == null) { return null; } String[] configs = allParams.split("&", SPLIT_LIMIT); if (configs == null || configs.length < 1) { return params; } for (int i = 0; i < configs.length; i++) { if (!configs[i].contains("=")) { LOG.warn("Invalid configuration parameter: " + configs[i] + " for uri: '" + atlasUri + "'"); continue; } String[] cfgs = configs[i].split("="); if (cfgs == null || cfgs.length != 2) { LOG.warn("Invalid configuration parameter: " + configs[i] + " for uri: '" + atlasUri + "'"); continue; } params.put(cfgs[0], cfgs[1]); } return params; }  static Properties loadPropertiesFromURL(URL url); static boolean isEmpty(String string); static boolean matchUriModule(String uriA, String uriB); static String getUriScheme(String atlasUri); static String getUriModule(String atlasUri); static String getUriDataType(String atlasUri); static String getUriModuleVersion(String atlasUri); static String getUriParameterValue(String atlasUri, String key); static Map<String, String> getUriParameters(String atlasUri); static int countCharacters(String text, char match); static List<Class<?>> findClassesForPackage(String scannedPackage); static void addAudit(AtlasSession session, String docId, String message, String path, AuditStatus status,
            String value); static Audit createAudit(AuditStatus status, String docId, String docName, String path, String value, String message); static void addAudit(AtlasSession session, Validation validation); static void addAudits(AtlasInternalSession session, String docId, List<Audit> audits); static AuditStatus toAuditStatus(ValidationStatus vstatus); static String getDocumentNameById(AtlasMapping mapping, String docId); static String getChainedMessage(Throwable t); static String escapeForUri(String source); static String unescapeFromUri(String uri); static void deleteDirectory(File targetDir); static void deleteDirectoryContents(File targetDir); static void copyFile(Path sourcePath, Path destPath); static final int SPLIT_LIMIT; static final String NEW_LINE_CHARS; }