Class ComponentRoute

java.lang.Object
com.broadleafcommerce.metadata.route.ComponentRoute
All Implemented Interfaces:
Serializable, org.springframework.core.Ordered

public class ComponentRoute extends Object implements Serializable, org.springframework.core.Ordered

Domain used for representing a "route" in the admin application. This route can be tied to a metadata Component using componentId, or this route can be tied to a non-metadata named component using componentName.

 
 // a route to a metadata component by ID
 ComponentRoute.builder().path("/products").componentId("catalog:products:list").build();

 // a route to a non-metadata component by name
 ComponentRoute.builder().path("/workflow").componentName("MY_CHANGES").build();
 
 
Author:
Nick Crum (ncrum)
See Also:
  • Constructor Details

    • ComponentRoute

      public ComponentRoute(String path, String componentId, String componentName, List<String> scopes, boolean exact, int order, Predicate<org.springframework.web.context.request.WebRequest> predicate)
    • ComponentRoute

      public ComponentRoute(String path, String componentId, String componentName, List<String> scopes, boolean exact, String scopeMatchType, int order, Predicate<org.springframework.web.context.request.WebRequest> predicate)
      Creates a new ComponentRoute instance.
      Parameters:
      path - The path for this route in the admin application, e.g. "/products".

      This supports any valid URL path that https://github.com/pillarjs/path-to-regexp/tree/v1.7.0 understands, e.g. "/products", "/products/:id", and "/categories/:id?" are all valid URL paths. Must start with a slash, and optionally may include any path parameters as necessary.

      componentId - The Component.id(java.lang.String) of the Component that will be rendered for this route.
      componentName - The name of the component that will be rendered for this route. This can be used as an alternative to using componentId for non-metadata-driven components like "not found" views. This should not be used if componentId is provided.
      scopes - The scopes that the user must have at least one with "READ" access for this route to render. If none are provided, it will be assumed the user has access.
      exact -

      Whether or not the route requires an exact match to render. This is typically true, but can be set to false when you have a component that needs support for sub-routes.

      Setting this to Boolean.FALSE will allow partial matching of the url. See the table below for how exact and non-exact routes work.

      path location.pathname exact matches?
      /one /one/two true no
      /one /one/two false yes
      ;

      Refer to https://reacttraining.com/react-router/web/api/Route/exact-bool for more details.

      scopeMatchType - Controls how the scopes are used to filter the route's accessibility. The default is DefaultRouteScopeMatchType.ANY.
      order -

      The order of this route. This can be used to ensure that routes are returned in a certain order. The ordering of routes can matter as a route that is provided earlier takes precedence over a route provided later.

      As an example, take a route with a path of "/products/create" and one with a path of "/products/:id". If "/products/create" comes after "/products/:id", then it will never be matched, because they are equal precedence and "/products/:id" will match first.

      predicate - A Predicate for this route. This will be used to evaluate whether or not this route should be returned for a given WebRequest.
      Since:
      Metadata 2.0.7, Release Train 2.1.5
      See Also:
  • Method Details

    • test

      public boolean test(org.springframework.web.context.request.WebRequest request)
      Evaluates the predicate on the given WebRequest.
      Parameters:
      request - the web request
      Returns:
      whether or not this route is a match for the web request
    • builder

      public static ComponentRoute.ComponentRouteBuilder builder()
    • getPath

      public String getPath()
      The path for this route in the admin application, e.g. "/products".

      This supports any valid URL path that https://github.com/pillarjs/path-to-regexp/tree/v1.7.0 understands, e.g. "/products", "/products/:id", and "/categories/:id?" are all valid URL paths. Must start with a slash, and optionally may include any path parameters as necessary.

    • getComponentId

      public String getComponentId()
      The Component.id(java.lang.String) of the Component that will be rendered for this route.
    • getComponentName

      public String getComponentName()
      The name of the component that will be rendered for this route. This can be used as an alternative to using componentId for non-metadata-driven components like "not found" views. This should not be used if componentId is provided.
    • getScopes

      public List<String> getScopes()
      The scopes that the user must have at least one with "READ" access for this route to render. If none are provided, it will be assumed the user has access.
    • isExact

      public boolean isExact()

      Whether or not the route requires an exact match to render. This is typically true, but can be set to false when you have a component that needs support for sub-routes.

      Setting this to Boolean.FALSE will allow partial matching of the url. See the table below for how exact and non-exact routes work.

      path location.pathname exact matches?
      /one /one/two true no
      /one /one/two false yes
      ;

      Refer to https://reacttraining.com/react-router/web/api/Route/exact-bool for more details.

    • getScopeMatchType

      public String getScopeMatchType()
      Controls how the scopes are used to filter the route's accessibility. The default is DefaultRouteScopeMatchType.ANY.
      Since:
      Metadata 2.0.7, Release Train 2.1.5
      See Also:
    • getOrder

      public int getOrder()

      The order of this route. This can be used to ensure that routes are returned in a certain order. The ordering of routes can matter as a route that is provided earlier takes precedence over a route provided later.

      As an example, take a route with a path of "/products/create" and one with a path of "/products/:id". If "/products/create" comes after "/products/:id", then it will never be matched, because they are equal precedence and "/products/:id" will match first.

      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • getPredicate

      public Predicate<org.springframework.web.context.request.WebRequest> getPredicate()
      A Predicate for this route. This will be used to evaluate whether or not this route should be returned for a given WebRequest.
    • setPath

      public void setPath(String path)
      The path for this route in the admin application, e.g. "/products".

      This supports any valid URL path that https://github.com/pillarjs/path-to-regexp/tree/v1.7.0 understands, e.g. "/products", "/products/:id", and "/categories/:id?" are all valid URL paths. Must start with a slash, and optionally may include any path parameters as necessary.

    • setComponentId

      public void setComponentId(String componentId)
      The Component.id(java.lang.String) of the Component that will be rendered for this route.
    • setComponentName

      public void setComponentName(String componentName)
      The name of the component that will be rendered for this route. This can be used as an alternative to using componentId for non-metadata-driven components like "not found" views. This should not be used if componentId is provided.
    • setScopes

      public void setScopes(List<String> scopes)
      The scopes that the user must have at least one with "READ" access for this route to render. If none are provided, it will be assumed the user has access.
    • setExact

      public void setExact(boolean exact)

      Whether or not the route requires an exact match to render. This is typically true, but can be set to false when you have a component that needs support for sub-routes.

      Setting this to Boolean.FALSE will allow partial matching of the url. See the table below for how exact and non-exact routes work.

      path location.pathname exact matches?
      /one /one/two true no
      /one /one/two false yes
      ;

      Refer to https://reacttraining.com/react-router/web/api/Route/exact-bool for more details.

    • setScopeMatchType

      public void setScopeMatchType(String scopeMatchType)
      Controls how the scopes are used to filter the route's accessibility. The default is DefaultRouteScopeMatchType.ANY.
      Since:
      Metadata 2.0.7, Release Train 2.1.5
      See Also:
    • setOrder

      public void setOrder(int order)

      The order of this route. This can be used to ensure that routes are returned in a certain order. The ordering of routes can matter as a route that is provided earlier takes precedence over a route provided later.

      As an example, take a route with a path of "/products/create" and one with a path of "/products/:id". If "/products/create" comes after "/products/:id", then it will never be matched, because they are equal precedence and "/products/:id" will match first.

    • setPredicate

      public void setPredicate(Predicate<org.springframework.web.context.request.WebRequest> predicate)
      A Predicate for this route. This will be used to evaluate whether or not this route should be returned for a given WebRequest.