Helper that strips the api and optional version from the URI array since api calls only care about what comes after. E.g. if the URI is "/api/v1/uid/assign" this method will return the {"uid", "assign"} @return An array with 1 or more components, note the first item may be an empty string if given j
()
| 155 | * @since 2.0 |
| 156 | */ |
| 157 | public String[] explodeAPIPath() { |
| 158 | final String[] split = this.explodePath(); |
| 159 | int index = 1; |
| 160 | if (split.length < 1 || !split[0].toLowerCase().equals("api")) { |
| 161 | throw new IllegalArgumentException("The URI does not start with \"/api\""); |
| 162 | } |
| 163 | if (split.length < 2) { |
| 164 | // given "/api" |
| 165 | final String[] root = { "" }; |
| 166 | return root; |
| 167 | } |
| 168 | if (split[1].toLowerCase().startsWith("v") && split[1].length() > 1 && |
| 169 | Character.isDigit(split[1].charAt(1))) { |
| 170 | index = 2; |
| 171 | } |
| 172 | |
| 173 | if (split.length - index == 0) { |
| 174 | // given "/api/v#" |
| 175 | final String[] root = { "" }; |
| 176 | return root; |
| 177 | } |
| 178 | |
| 179 | final String[] path = new String[split.length - index]; |
| 180 | int path_idx = 0; |
| 181 | for (int i = index; i < split.length; i++) { |
| 182 | path[path_idx] = split[i]; |
| 183 | path_idx++; |
| 184 | } |
| 185 | return path; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * This method splits the query path component and returns a string suitable |