Пример #1
0
 /**
  * Checks for an existing route that matches the {@link er.rest.routes.ERXRoute.Method} and {@link
  * er.rest.routes.ERXRoute#routePattern()} of <code>route</code> and yet has a different
  * controller or action mapping.
  *
  * @param route
  */
 protected void verifyRoute(ERXRoute route) {
   ERXRoute duplicateRoute =
       routeForMethodAndPattern(route.method(), route.routePattern().pattern());
   if (duplicateRoute != null) {
     boolean isDifferentController =
         ObjectUtils.notEqual(duplicateRoute.controller(), route.controller());
     boolean isDifferentAction = ObjectUtils.notEqual(duplicateRoute.action(), route.action());
     if (isDifferentController || isDifferentAction) {
       // We have a problem whereby two routes with same url pattern and http method map to
       // different direct actions
       StringBuilder message = new StringBuilder();
       message.append("The route <");
       message.append(route);
       message.append("> conflicts with existing route <");
       message.append(duplicateRoute);
       message.append(">.");
       if (isDifferentController) {
         message.append(" The controller class <");
         message.append(route.controller());
         message.append("> is different to <");
         message.append(duplicateRoute.controller());
         message.append(">.");
       }
       if (isDifferentAction) {
         message.append(" The action <");
         message.append(route.action());
         message.append("> is different to <");
         message.append(duplicateRoute.action());
         message.append(">.");
       }
       throw new IllegalStateException(message.toString());
     }
   }
 }
Пример #2
0
 /**
  * Returns the routes for the given controller class.
  *
  * @param routeController the controller class
  * @return the routes for the given controller class
  */
 public NSArray<ERXRoute> routesForControllerClass(
     Class<? extends ERXRouteController> routeController) {
   NSMutableArray<ERXRoute> routes = new NSMutableArray<ERXRoute>();
   for (ERXRoute route : _routes) {
     if (route.controller() == routeController) {
       routes.add(route);
     }
   }
   return routes;
 }