/** * Gets the base URL of the server, this value is retrieved from the current HTTP request. If no * HTTP request is in progress NULL is returned. Only the use cases where an OWS service or a * REST end-point was target are handled. */ private static String baseUrl() { // let's see if a OWS service was targeted Request owsRequest = Dispatcher.REQUEST.get(); if (owsRequest != null) { // retrieve the base URL from the dispatcher request return RequestUtils.baseURL(Dispatcher.REQUEST.get().getHttpRequest()); } // let's see if a REST end-point was targeted RequestInfo restRequest = RequestInfo.get(); if (restRequest != null) { // retrieve the base URL from REST request return restRequest.getBaseURL(); } // no HTTP request is in progress return null; } }
protected String href(String link) { final RequestInfo pg = RequestInfo.get(); link += ".html"; // encode as relative or absolute depending on the link type if (link.startsWith("/")) { // absolute, encode from "root" return pg.servletURI(link); } else { // encode as relative return pg.pageURI(link); } } }
if (template == null) template = tryLoadTemplate(configuration, templateName + ".ftl"); final RequestInfo requestInfo = RequestInfo.get();
protected String href(String link) { final RequestInfo pg = RequestInfo.get(); String ext = getExtension(); if (ext != null && ext.length() > 0) link = link + "." + ext; // encode as relative or absolute depending on the link type if (link.startsWith("/")) { // absolute, encode from "root" return pg.servletURI(link); } else { // encode as relative return pg.pageURI(link); } }
public void marshal( Object source, HierarchicalStreamWriter writer, MarshallingContext context) { String ref; // Special case for layer list, to handle the non-workspace-specific // endpoint for layers if (clazz.equals(LayerInfo.class) && OwsUtils.getter(clazz, "prefixedName", String.class) != null && RequestInfo.get() != null && !RequestInfo.get().getPagePath().contains("/workspaces/")) { ref = (String) OwsUtils.get(source, "prefixedName"); } else if (OwsUtils.getter(clazz, "name", String.class) != null) { ref = (String) OwsUtils.get(source, "name"); } else if (OwsUtils.getter(clazz, "id", String.class) != null) { ref = (String) OwsUtils.get(source, "id"); } else if (OwsUtils.getter(clazz, "id", Long.class) != null) { // For some reason Importer objects have Long ids so this catches that // case ref = OwsUtils.get(source, "id").toString(); } else { throw new RuntimeException( "Could not determine identifier for: " + clazz.getName()); } writer.startNode("name"); writer.setValue(ref); writer.endNode(); encodeLink(encode(ref), writer); }
/** * Add {@link RequestInfo} to the freemarker model * * @param model * @throws TemplateModelException */ protected void setRequestInfo(SimpleHash model) throws TemplateModelException { final RequestInfo requestInfo = RequestInfo.get(); if (model.get("page") == null) { if (requestInfo != null) { model.put("page", requestInfo); } } }
protected static String href(String path) { return ResponseUtils.buildURL( RequestInfo.get().servletURI("resource/"), ResponseUtils.urlEncode(path, '/'), null, URLMangler.URLType.RESOURCE); }
@GetMapping( value = {"", "index"}, produces = {MediaType.TEXT_HTML_VALUE} ) public RestWrapper get() { SimpleHash model = new SimpleHash(); model.put("links", getLinks()); model.put("page", RequestInfo.get()); return wrapObject(model, SimpleHash.class); }