/** * Creates a route with the same parameters of this one but with a different destination page. * @param secure Whether this route is through a secure channel, such as HTTPS. * @param toPage New destination page. * @return The new route. */ public Route toPage(boolean secure, PageKey toPage) { return of(secure, toPage, device, locale); }
/** * Creates a route with the same parameters of this one but with a different destination page. * @param toPage New destination page. * @return The new route. */ public Route toPage(PageKey toPage) { return toPage(secure, toPage); }
/** * Returns a route to the specified destination. * @param secure Whether this route is through a secure channel, such as HTTPS. * @param page Destination page. * @param device Device performing the request. * @param locale Desired locale. * @return The requested route. */ public static Route of(boolean secure, PageKey page, Device device, Locale locale) { return new Route(secure, page, device, locale); }
private CloudItem createItem(Category category, int hits, int totalHits) { final NavigationKey nk = NavigationKey.category(category); final PageKey pk = PageKey.navigation(nk); final Route r = (route != null) ? route.toPage(pk) : Route.of(false, pk, null, null); final URI uri = uriGenerator.getURI(r); final Name name = (locale != null) ? category.getName().get(locale) : category.getDefaultName(); return new CloudItem(name.getDisplayName(), uri, Math.ceil(hits / totalHits)); } }
@Renderer public SitemapRenderer sitemap(final RenderContext context) { final List<URLEntry> entries = Lists.newLinkedList(); if (page != null) { Route r = context.getRoute(); r = r.toDevice(context.getPortal().getDevice()); for (Content c : page) { PageKey pk = PageKey.content(c.getContentKey()); URI u = context.getAbsoluteURI(r.toPage(pk)); entries.add(URLEntry.of(u)); } } return SitemapRenderers.set(entries); }
static Route toDevice(RenderContext context, Route route, String deviceName) { if (deviceName == null) { return route; } final DevicesInPortal dips = context.getPortal().getDevices(); if (dips.containsName(deviceName)) { final DeviceInPortal dip = dips.getByName(deviceName); return route.toDevice(dip.getDevice()); } return route; }
@Inject public void setRoute(Route route) { this.route = route; this.locale = (route != null) ? route.getLocale() : null; }
static Route toLocale(RenderContext context, Route route, String localeString) { final Locale locale = Locales.safeFromString(localeString); if (locale == null) { return route; } return route.toLocale(locale); }
private Category getSelected() { if (componentConfig != null && componentConfig.selected() != null) { return componentConfig.selected(); } else if (config != null && config.selected() != null) { return config.selected(); } if (config != null && config.decoupledSelection()) { final PageKey p = route.getPage(); if(p instanceof WithNavigation) { final NavigationKey navigationKey = ((WithNavigation)p).getNavigationKey(); if (navigationKey != null && navigationKey.isCategory()) { Category c = navigationKey.getCategory(); if (categories.containsValue(c)) { return c; } } } } return getCurrent(); }
private CloudItem createItem(ContentType contentType, int hits, int totalHits) { final NavigationKey nk = NavigationKey.contentType(contentType); final PageKey pk = PageKey.navigation(nk); final Route r = (route != null) ? route.toPage(pk) : Route.of(false, pk, null, null); final URI uri = uriGenerator.getURI(r); final Name name = (locale != null) ? contentType.getName().get(locale) : contentType.getDefaultName(); return new CloudItem(name.getDisplayName(), uri, Math.ceil(hits / totalHits)); } }
public SyndEntry apply(Content c) { final ContentKey key = c.getContentKey(); NavigationKey nk = null; if (config != null && config.keepNavigation()) { nk = context.getNavigationKey(); if (nk != null) { nk = nk.withoutContentType(); } } final PageKey pageKey = PageKey.content(nk, key); Route route = context.getRoute().toPage(pageKey); if (config != null && config.toDefaultDevice()) { route = route.toDevice(context.getPortal().getDevice()); } final URI link = context.getAbsoluteURI(route); return ATOMFactory.entry(c, link, config); }
@Inject public void setRoute(Route route) { this.route = route; this.locale = (route != null) ? route.getLocale() : null; }
protected MenuItem createItem(Category category, Predicate<Category> selected) { URI uri = null; if(category.isRoutable()) { final NavigationKey nk = NavigationKey.category(category); final PageKey pk = PageKey.navigation(nk); final Route r = (route != null) ? route.toPage(pk) : Route.of(false, pk, null, null); uri = uriGenerator.getURI(r); } final Name name = (locale != null) ? category.getName().get(locale) : category.getDefaultName(); final MenuItem item = new MenuItem(name.getDisplayName(), uri, selected.apply(category)); return item; }
private URI getURI(PageKey pk) { if (route == null || pk == null || uriGenerator == null) { return null; } final Route r = route.toPage(pk); return uriGenerator.getURI(r); }
/** * Returns a route to the specified destination. * @param secure Whether this route is through a secure channel, such as HTTPS. * @param context Client context. * @param page Destination page. * @return The requested route. */ public static Route of(boolean secure, ClientRequestContext context, final PageKey page) { return of(secure, page, context.getDevice(), context.getLocale()); }
/** * Creates a route with the same parameters of this one but with a different destination page. * @param locale New destination locale. * @return The new route. */ public Route toLocale(Locale locale) { checkNotNull(locale, "The destination locale must be provided."); if (locale.equals(this.locale)) { return this; } return new Route(this.secure, this.page, this.device, locale); }
protected MenuItem createItem(ContentType contentType) { final NavigationKey nk; if (config.navigation() && context.getNavigationKey() != null && context.getNavigationKey().isCategory()) { nk = NavigationKey.category(context.getNavigationKey().getCategory(), contentType); } else { nk = NavigationKey.contentType(contentType); } final PageKey pk = PageKey.navigation(nk); final Route r = (route != null) ? route.toPage(pk) : Route.of(false, pk, null, null); final URI uri = uriGenerator.getURI(r); final Name name = (locale != null) ? contentType.getName().get(locale) : contentType.getDefaultName(); final MenuItem item = new MenuItem(name.getDisplayName(), uri); return item; }
private static Route route(RenderContext context, PageKey pageKey) { return context.getRoute().toPage(pageKey); }
/** * Returns a route to the specified destination. * @param context Request context. * @param page Destination page. * @param device Device performing the request. * @param locale Desired locale. * @return The requested route. */ public static Route of(RequestContext context, final PageKey page) { return of(context.isSecure(), page, context.getDevice(), context.getLocale()); }
/** * Creates a route with the same parameters of this one but with a different destination device. * @param locale New destination locale. * @return The new route. */ public Route toDevice(Device device) { checkNotNull(device, "The destination device must be provided."); if (device.equals(this.device)) { return this; } return new Route(this.secure, this.page, device, this.locale); }