private PathSegments segment() { return PathSegments.of(false, name); }
/** * Turns an array of strings into a list of decoded segments. * @param encoded If the segments are encoded. * @param segments String segments. * @return The never {@code null} list of segments. */ public static PathSegments of(boolean encoded, String... segments) { if (segments == null) { return EMPTY; } return of(encoded, Arrays.asList(segments)); }
public PathSegments apply(PathSegments input) { return PathSegments.of(false, Iterables.concat(segments, input)); } };
public PageURI(final PathSegments path, Multimap<String, String> parameters) { this.path = (path != null) ? path : PathSegments.of(); if (parameters != null) { this.parameters = ImmutableMultimap.copyOf(parameters); } else { this.parameters = ImmutableMultimap.of(); } }
public PathSegments apply(PathSegments input) { if (input == null || input.isEmpty()) { return input; } String last = input.last(); if (last == null || last.length() == 0) { return input; } last = new StringBuilder(last).append('.').append(extension).toString(); return PathSegments.of(false, Iterables.concat(input.consumeLast(), ImmutableList.of(last))); }
@GET public Response getPage(@PathParam("path") @Encoded String path) { final PathSegments segments = PathSegments.of(path, true); final HttpSession session = getSession(); final HttpRequestContext requestContext = RequestContexts.http(getCSRFToken(), request, securityContext.isSecure(), HeadersFactory.of(headers), CookiesFactory.of(headers), RequestParamsFactory.of(uri), SessionParamsFactory.of(session)); try { final PageResponse response = getEngine().process(segments, headers, requestContext); for (Entry<String, Object> sp : response.getSession().entrySet()) { final String key = sp.getKey(); final Object value = sp.getValue(); if (value == null) { session.removeAttribute(key); } else { session.setAttribute(key, value); } if (response.getPortal().isSessionCSRF()) { saveCSRFToken(); } } return response.getResponse(); } catch (RuntimeException e) { if (uri != null && uri.getQueryParameters() != null && uri.getQueryParameters().containsKey(PortalManager.MASK_ERROR)) { return Response.ok().type(MediaType.TEXT_HTML).entity("<html></html>").build(); } throw e; } }
/** * @see com.isotrol.impe3.pms.api.portal.PortalsService#isOfflineReady(java.lang.String) */ @Transactional(rollbackFor = Throwable.class) @Authorized(global = GlobalAuthority.PORTAL_GET, portal = PortalAuthority.GET) public boolean isOfflineReady(String portalId) throws PMSException { final PortalEntity portal = load(portalId); try { final EngineModel model = engineLoader.getOffline(getEnvironment().getName()); final DefaultOfflineEngine engine = new DefaultOfflineEngine(model); final PathSegments path = PathSegments.of(false, portal.getId().toString().toLowerCase()); final Response response = engine.process(path, new MockHttpHeaders(), RequestContexts.http()).getResponse(); return response.getStatus() == 200; } catch (Exception e) {} return false; }