@param uri @return Returns a Map containing the organization, module, version and all the query string parameters @throws ParserException
(URI uri)
| 128 | * @throws ParserException |
| 129 | */ |
| 130 | private Map<String, Object> parseUri(URI uri) throws ParserException { |
| 131 | // Parse uri for artifact organization, module and version |
| 132 | Map<String, Object> uriMap = new HashMap<String, Object>(); |
| 133 | String authority = uri.getAuthority(); |
| 134 | if (authority != null) { |
| 135 | String[] tokens = authority.split(":", -1); |
| 136 | if (tokens.length == 3) { |
| 137 | uriMap.put("org", tokens[0]); |
| 138 | if (tokens[1].isEmpty()) { |
| 139 | throw new ParserException("Please specify the artifact module."); |
| 140 | } |
| 141 | uriMap.put("module", tokens[1]); |
| 142 | uriMap.put("version", tokens[2]); |
| 143 | } else { |
| 144 | throw new ParserException("Invalid Artifact. Please specify organization, module and version"); |
| 145 | } |
| 146 | } else { |
| 147 | throw new ParserException("Invalid Artifact. Please specify organization, module and version"); |
| 148 | } |
| 149 | |
| 150 | // Parse query string for exclude list and other parameters |
| 151 | uriMap.putAll(parseQueryString(uri)); |
| 152 | if (uriMap.containsKey("transitive")) { |
| 153 | uriMap.put("transitive", Boolean.parseBoolean(uriMap.get("transitive").toString())); |
| 154 | } |
| 155 | List<Map<String, Object>> excludeList = new LinkedList<Map<String, Object>>(); |
| 156 | if (uriMap.containsKey("exclude")) { |
| 157 | for (String exclude : uriMap.get("exclude").toString().split(",")) { |
| 158 | Map<String, Object> excludeMap = new HashMap<String, Object>(); |
| 159 | String parts[] = exclude.split(":", -1); |
| 160 | if (parts.length == 2) { |
| 161 | excludeMap.put("group", parts[0]); |
| 162 | excludeMap.put("module", parts[1]); |
| 163 | } else { |
| 164 | throw new ParserException("Exclude must contain organization and module separated by a colon."); |
| 165 | } |
| 166 | excludeList.add(excludeMap); |
| 167 | } |
| 168 | } |
| 169 | uriMap.put("excludes", excludeList); |
| 170 | |
| 171 | return uriMap; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * @param uri |
no test coverage detected