/** * Returns the built portal. * @return The built portal. * @throws IllegalStateException in case of an error. */ protected Portal doGet() { return new Portal(this); }
final Content loadSample() { final FileId sampleFile = moduleConfig.sample(); if (sampleFile == null || (EngineMode.ONLINE == context.getPortal().getMode() && !moduleConfig.sampleOnline())) { return null; } return FreeMarker.loadXMLContent(fileLoader, sampleFile, context.getPortal().getContentTypes(), context .getPortal().getCategories()); }
public ResolvedDevice resolveDevice(DeviceResolutionParams params) { final Portal portal = params.getPortal(); final PathSegments path = params.getPath(); DevicesInPortal dips = portal.getDevices(); if (config != null && !config.includeDefault()) { dips = dips.excludeDevice(portal.getDevice()); } final Device d = portal.getDevices().findDeviceByFirstSegment(path); if (d != null) { return new ResolvedDevice(path.consume(), d, new DefaultDeviceCapabilities(d), params.getParameters()); } return null; } }
/** * @see com.isotrol.impe3.api.DeviceResolver#resolveDevice(com.isotrol.impe3.api.DeviceResolutionParams) */ public ResolvedDevice resolveDevice(DeviceResolutionParams params) { ResolvedDevice rd = DeviceNameUseDeviceResolver.get().resolveDevice(params); if (rd != null) { return rd; } return params.resolve(params.getPortal().getDevice()); }
/** * @see com.isotrol.impe3.api.DeviceResolver#resolveDevice(com.isotrol.impe3.api.DeviceResolutionParams) */ public final ResolvedDevice resolveDevice(DeviceResolutionParams params) { DevicesInPortal dips = params.getPortal().getDevices(); if (!uses) { dips = dips.filterByUse(DeviceNameUse.NONE); } return resolve(params, Iterables.filter(dips.values(), filter)); }
private ResolvedLocale resolve(Portal portal, PathSegments path, HttpHeaders headers, HttpRequestContext request, LocalParams parameters) { final Locale locale = headers.getLanguage(); final List<Locale> acceptables = headers.getAcceptableLanguages(); if (locale == null && (acceptables == null || acceptables.isEmpty())) { return null; } final Set<Locale> locales = portalSupportedLocales( portal.getDefaultLocale(), portal.getLocales()); if (locales.isEmpty()) { return null; } if (locale != null && locales.contains(locale)) { return new ResolvedLocale(path, locale, parameters); } if (acceptables != null) { for (Locale l : acceptables) { if (locales.contains(l)) { return new ResolvedLocale(path, l, parameters); } } } return null; }
/** * @see com.isotrol.impe3.api.LocaleURIGenerator#getTransformer(com.isotrol.impe3.api.Portal, java.util.Locale) */ public Function<PathSegments, PathSegments> getTransformer(Portal portal, Locale locale) { if (useDefaultLocale && Objects.equal(portal.getDefaultLocale(), locale)) { return DefaultLocaleURIGenerator.get().getTransformer(portal, locale); } final ImmutableList<String> segments = ImmutableList.of(locale.toString()); return new Function<PathSegments, PathSegments>() { public PathSegments apply(PathSegments input) { return PathSegments.of(false, Iterables.concat(segments, input)); } }; }
private static Category getCategoryByPath(final ComponentRequestContext context, List<String> args, int i) { final String path = arg(args, i); ; if (path == null) { return null; } return context.getPortal().getCategories().getByPath(path, false, false); }
/** * Returns a portal base. * @param base Base name. * @return The base or {@code null} if not found. */ public URI getBase(String base) { return bases.get(base(base)); }
@Override public ImmutableMap<String, Locale> load(Portal key) throws Exception { return Maps.uniqueIndex(key.getLocales(), Functions.toStringFunction()); } }
private static ContentType getContentType(final ComponentRequestContext context, List<String> args, int i) { final UUID id = getUUID(args, i); if (id == null) { return null; } return context.getPortal().getContentTypes().get(id); }
final Device defaultDevice = devicesModel.get(devices.get().deviceId); Set<DeviceInPortal> dm = ImmutableSet.copyOf(Iterables.transform(devices.get().devices.values(), u2d)); Portal.Builder b = Portal.builder().setId(getId()).setMode(model.getMode()).setDevice(defaultDevice) .setName(name.getDisplayName()).setContentTypes(model.getContentTypes()) .setCategories(model.getCategories()).setBases(ubases).setProperties(getActiveProperties(portals))
@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); }
/** * @see com.isotrol.impe3.api.DeviceURIGenerator#getTransformer(com.isotrol.impe3.api.Portal, * com.isotrol.impe3.api.Device) */ public Function<PathSegments, PathSegments> getTransformer(Portal portal, Device device) { if (portal != null && device != null) { DevicesInPortal dips = portal.getDevices(); if (dips.containsDevice(device)) { return dips.getByDevice(device).getTransformer(); } } return Functions.identity(); } }
/** * @see com.isotrol.impe3.api.LocaleResolver#resolveLocale(com.isotrol.impe3.api.LocaleResolutionParams) */ public ResolvedLocale resolveLocale(LocaleResolutionParams params) { Locale locale = params.getPortal().getDefaultLocale(); return new ResolvedLocale(params.getPath(), firstNonNull(locale, SPANISH), params.getParameters()); }
private static Category getCategory(final ComponentRequestContext context, List<String> args, int i) { final UUID id = getUUID(args, i); if (id == null) { return null; } return context.getPortal().getCategories().get(id); }
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); }
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; }
/** * @see com.isotrol.impe3.api.LocaleResolver#resolveLocale(com.isotrol.impe3.api.LocaleResolutionParams) */ public ResolvedLocale resolveLocale(LocaleResolutionParams params) { Locale locale = null; PathSegments p = params.getPath(); if (p.isEmpty()) { // TODO use fallback return new ResolvedLocale(params.getPath(), params.getPortal().getDefaultLocale(), params.getParameters()); } String segment = p.get(0); locale = cache.getUnchecked(params.getPortal()).get(segment); if (locale == null) { // TODO use fallback return new ResolvedLocale(params.getPath(), params.getPortal().getDefaultLocale(), params.getParameters()); } return new ResolvedLocale(p.consume(), locale, params.getParameters()); }