/** * 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); }
private URI getURI(PageKey pk) { if (route == null || pk == null || uriGenerator == null) { return null; } final Route r = route.toPage(pk); return uriGenerator.getURI(r); }
private static Route route(RenderContext context, PageKey pageKey) { return context.getRoute().toPage(pageKey); }
/** Component execution. */ public ComponentResponse execute() { URI u; final Route route = getRoute(); try { u = new URI(uri); } catch (Exception e) { if (route != null) { u = getUriGenerator().getAbsoluteURI(route.toPage(PageKey.main())); } else { u = URI.create("/"); } } return ComponentResponse.seeOther(u); } }
@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); }
/** Component execution. */ public ComponentResponse execute() { if (destination == null) { // Nothing to do return ComponentResponse.OK; } final PageKey pk = PageKey.special(destination); final Route r = getRoute().toPage(pk); // External if (type != null && type.booleanValue()) { return ComponentResponse.seeOther(replaceQuery(getUriGenerator().getAbsoluteURI(r), query)); } else { return ComponentResponse.internal(r); } } }
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)); } }
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)); } }
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; }
/** Component execution. */ public ComponentResponse execute() { ContentType c = getDestination(); if (c == null) { // Nothing to do return ComponentResponse.OK; } NavigationKey nk = navigationKey; if (nk == null || !keepNavigationKey) { nk = NavigationKey.contentType(c); } else { nk = nk.withContentType(c); } final PageKey pk = PageKey.navigation(nk); final Route r = getRoute().toPage(pk); // External if (type != null && type.booleanValue()) { return ComponentResponse.seeOther(replaceQuery(getUriGenerator().getAbsoluteURI(r), query)); } else { return ComponentResponse.internal(r); } }
contentKey = null; final Route r = getRoute().toPage(pk);
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); }
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; }