/** * Iterate over all registered controllers to get the first suitable one. * @param jsonPath built JsonPath object mad from request path * @param requestType type of a HTTP request * @return suitable controller */ public BaseController getController(JsonPath jsonPath, String requestType) { for (BaseController controller : controllers) { if (controller.isAcceptable(jsonPath, requestType)) { return controller; } } throw new MethodNotFoundException(PathBuilder.buildPath(jsonPath), requestType); } }
/** * Parses path provided by the application. The path provided cannot contain neither hostname nor protocol. It * can start or end with slash e.g. <i>/tasks/1/</i> or <i>tasks/1</i>. * * @param path Path to be parsed * @return doubly-linked list which represents path given at the input * @deprecated use build */ public JsonPath buildPath(String path) { JsonPath jsonPath = build(path); if(jsonPath != null){ return jsonPath; }else{ throw new RepositoryNotFoundException(path); } }
JsonPath jsonPath = new PathBuilder(resourceRegistry).buildPath(getRequestPath(request));
JsonPath jsonPath = new PathBuilder(resourceRegistry).build(path); Map<String, Set<String>> parameters = getParameters(uriInfo); String method = requestContext.getMethod();
String[] strings = splitPath(path); if (strings.length == 0 || (strings.length == 1 && "".equals(strings[0]))) { throw new ResourceException("Path is empty"); }else if (currentElementIdx < strings.length && !RELATIONSHIP_MARK.equals(strings[currentElementIdx])) { pathIds = createPathIds(strings[currentElementIdx]); currentElementIdx++; currentJsonPath = getNonResourcePath(previousJsonPath, elementName, relationshipMark); if (pathIds != null) { throw new ResourceException("RelationshipsPath and FieldPath cannot contain ids");
/** * Creates a path using the provided JsonPath structure. * * @param jsonPath JsonPath structure to be parsed * @return String representing structure provided in the input */ public static String buildPath(JsonPath jsonPath) { List<String> urlParts = new LinkedList<>(); JsonPath currentJsonPath = jsonPath; String pathPart; do { if (currentJsonPath instanceof RelationshipsPath) { pathPart = RELATIONSHIP_MARK + SEPARATOR + currentJsonPath.getElementName(); } else if (currentJsonPath instanceof FieldPath) { pathPart = currentJsonPath.getElementName(); } else { pathPart = currentJsonPath.getElementName(); if (currentJsonPath.getIds() != null) { pathPart += SEPARATOR + mergeIds(currentJsonPath.getIds()); } } urlParts.add(pathPart); currentJsonPath = currentJsonPath.getParentResource(); } while (currentJsonPath != null); Collections.reverse(urlParts); return SEPARATOR + StringUtils.join(SEPARATOR, urlParts) + SEPARATOR; }
JsonPath jsonPath = new PathBuilder(resourceRegistry).buildPath(invokerContext.getRequestPath());
ResourceRegistry resourceRegistry = boot.getResourceRegistry(); RequestDispatcher requestDispatcher = boot.getRequestDispatcher(); JsonPath jsonPath = new PathBuilder(resourceRegistry).buildPath(invokerContext.getRequestPath());