Search in sources :

Example 1 with RouteMeta

use of org.webpieces.router.impl.RouteMeta in project webpieces by deanhiller.

the class AbstractDomainBuilder method setInternalSvrErrorRoute.

private void setInternalSvrErrorRoute(Route r) {
    if (!"".equals(this.routerInfo.getPath()))
        throw new UnsupportedOperationException("setInternalSvrErrorRoute can only be called on the root Router, not a scoped router");
    log.info("scope:'" + routerInfo + "' adding INTERNAL_SVR_ERROR route=" + r.getFullPath() + " method=" + r.getControllerMethodString());
    RouteMeta meta = new RouteMeta(r, holder.getInjector(), currentPackage.get(), holder.getUrlEncoding());
    holder.getFinder().loadControllerIntoMetaObject(meta, true);
    domainRoutes.setInternalSvrErrorRoute(meta);
}
Also used : RouteMeta(org.webpieces.router.impl.RouteMeta)

Example 2 with RouteMeta

use of org.webpieces.router.impl.RouteMeta in project webpieces by deanhiller.

the class R1RouterBuilder method loadFilters.

private void loadFilters(L2DomainRoutes domainRoutes) {
    RouteMeta notFound = domainRoutes.getPageNotFoundRoute();
    RouteMeta internalErrorMeta = domainRoutes.getInternalSvrErrorRoute();
    holder.getFinder().loadFiltersIntoMeta(notFound, notFound.getFilters(), true);
    holder.getFinder().loadFiltersIntoMeta(internalErrorMeta, internalErrorMeta.getFilters(), true);
}
Also used : RouteMeta(org.webpieces.router.impl.RouteMeta)

Example 3 with RouteMeta

use of org.webpieces.router.impl.RouteMeta in project webpieces by deanhiller.

the class R1RouterBuilder method addStaticRoute.

private void addStaticRoute(String urlPath, String fileSystemPath, boolean isOnClassPath) {
    if (isOnClassPath)
        throw new UnsupportedOperationException("oops, isOnClassPath not supported yet");
    StaticRoute route = new StaticRoute(new UrlPath(routerInfo, urlPath), fileSystemPath, isOnClassPath, holder.getCachedCompressedDirectory());
    staticRoutes.add(route);
    log.info("scope:'" + routerInfo + "' adding static route=" + route.getFullPath() + " fileSystemPath=" + route.getFileSystemPath());
    RouteMeta meta = new RouteMeta(route, holder.getInjector(), currentPackage.get(), holder.getUrlEncoding());
    allRouting.addStaticRoute(meta);
}
Also used : StaticRoute(org.webpieces.router.impl.StaticRoute) RouteMeta(org.webpieces.router.impl.RouteMeta) UrlPath(org.webpieces.router.impl.UrlPath)

Example 4 with RouteMeta

use of org.webpieces.router.impl.RouteMeta in project webpieces by deanhiller.

the class DevRoutingService method fetchInternalErrorRoute.

public RouteMeta fetchInternalErrorRoute(RouterRequest req) {
    RouteMeta meta = routeLoader.fetchInternalErrorRoute(req.domain);
    if (meta.getControllerInstance() == null) {
        finder.loadControllerIntoMetaObject(meta, false);
        finder.loadFiltersIntoMeta(meta, meta.getFilters(), false);
    }
    return meta;
}
Also used : RouteMeta(org.webpieces.router.impl.RouteMeta)

Example 5 with RouteMeta

use of org.webpieces.router.impl.RouteMeta in project webpieces by deanhiller.

the class DevRoutingService method fetchNotFoundRoute.

public NotFoundInfo fetchNotFoundRoute(NotFoundException e, RouterRequest req) {
    //Production app's notFound route TBD and used in iframe later
    RouteMeta origMeta = routeLoader.fetchNotFoundRoute(req.domain);
    if (req.queryParams.containsKey("webpiecesShowPage")) {
        //This is actually a callback from the below code's iframe!!!
        if (origMeta.getControllerInstance() == null) {
            finder.loadControllerIntoMetaObject(origMeta, false);
            finder.loadFiltersIntoMeta(origMeta, origMeta.getFilters(), false);
        }
        Service<MethodMeta, Action> svc = origMeta.getService222();
        return new NotFoundInfo(origMeta, svc, req);
    }
    log.error("(Development only log message) Route not found!!! Either you(developer) typed the wrong url OR you have a bad route.  Either way,\n" + " something needs a'fixin.  req=" + req, e);
    RouteImpl r = new RouteImpl("/org/webpieces/devrouter/impl/NotFoundController.notFound", RouteType.NOT_FOUND);
    RouteModuleInfo info = new RouteModuleInfo("", null);
    RouteMeta meta = new RouteMeta(r, origMeta.getInjector(), info, config.getUrlEncoding());
    if (meta.getControllerInstance() == null) {
        finder.loadControllerIntoMetaObject(meta, false);
        meta.setService(serviceCreator.create());
    }
    String reason = "Your route was not found in routes table";
    if (e != null)
        reason = e.getMessage();
    RouterRequest newRequest = new RouterRequest();
    newRequest.putMultipart("webpiecesError", "Exception message=" + reason);
    newRequest.putMultipart("url", req.relativePath);
    return new NotFoundInfo(meta, meta.getService222(), newRequest);
}
Also used : MethodMeta(org.webpieces.router.api.dto.MethodMeta) NotFoundInfo(org.webpieces.router.impl.NotFoundInfo) Action(org.webpieces.router.api.actions.Action) RouteImpl(org.webpieces.router.impl.RouteImpl) RouteMeta(org.webpieces.router.impl.RouteMeta) RouteModuleInfo(org.webpieces.router.impl.model.RouteModuleInfo) RouterRequest(org.webpieces.ctx.api.RouterRequest)

Aggregations

RouteMeta (org.webpieces.router.impl.RouteMeta)11 RouterRequest (org.webpieces.ctx.api.RouterRequest)2 Method (java.lang.reflect.Method)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 HttpMethod (org.webpieces.ctx.api.HttpMethod)1 Action (org.webpieces.router.api.actions.Action)1 MethodMeta (org.webpieces.router.api.dto.MethodMeta)1 RedirectResponse (org.webpieces.router.api.dto.RedirectResponse)1 IllegalReturnValueException (org.webpieces.router.api.exceptions.IllegalReturnValueException)1 FilterInfo (org.webpieces.router.impl.FilterInfo)1 NotFoundInfo (org.webpieces.router.impl.NotFoundInfo)1 ReverseRoutes (org.webpieces.router.impl.ReverseRoutes)1 Route (org.webpieces.router.impl.Route)1 RouteImpl (org.webpieces.router.impl.RouteImpl)1 StaticRoute (org.webpieces.router.impl.StaticRoute)1 UrlPath (org.webpieces.router.impl.UrlPath)1 HaveRouteException (org.webpieces.router.impl.loader.HaveRouteException)1 MatchResult (org.webpieces.router.impl.model.MatchResult)1 RouteModuleInfo (org.webpieces.router.impl.model.RouteModuleInfo)1