private void encodeDCP(final DCPDocument.DCP xbDcp, final Map<String, ? extends Collection<DCP>> supportedDcp) throws OwsExceptionReport { final HTTP http = xbDcp.addNewHTTP(); if (supportedDcp.containsKey(HTTPMethods.GET)) { List<DCP> getDcps = Lists.newArrayList(supportedDcp.get(HTTPMethods.GET)); Collections.sort(getDcps); for (DCP dcp : getDcps) { RequestMethodType get = http.addNewGet(); get.setHref(dcp.getUrl()); addConstraints(get, dcp); } } if (supportedDcp.containsKey(HTTPMethods.POST)) { List<DCP> postDcps = Lists.newArrayList(supportedDcp.get(HTTPMethods.POST)); Collections.sort(postDcps); for (DCP dcp : postDcps) { RequestMethodType post = http.addNewPost(); post.setHref(dcp.getUrl()); addConstraints(post, dcp); } } // TODO add if ows supports more than get and post }
private void encodeOwsDCP(OwsDCP dcp, DCP xdcp) { if (dcp.isHTTP()) { HTTP xhttp = xdcp.addNewHTTP(); OwsHttp http = dcp.asHTTP(); SortedSet<OwsRequestMethod> requestMethods = http.getRequestMethods(); requestMethods.forEach(method -> { RequestMethodType xmethod; switch (method.getHttpMethod()) { case HTTPMethods.GET: xmethod = xhttp.addNewGet(); break; case HTTPMethods.POST: xmethod = xhttp.addNewPost(); break; default: return; } encodeOnlineResource(method, xmethod); method.getConstraints().forEach(x -> encodeOwsDomain(x, xmethod.addNewConstraint())); }); } }
/** * @param resource an extension string for a base HTTP binding. * * @return a {@link HTTPDocument} with the given resource */ public HTTPDocument getHttpInfo(String resource) { HTTPDocument httpDocument = HTTPDocument.Factory.newInstance(); HTTP http = httpDocument.addNewHTTP(); RequestMethodType method = (httpMethod == GET) ? http.addNewGet() : http.addNewPost(); String concatenatedUrl = concatenateToDcpUrl(resource); method.setHref(concatenatedUrl); method.setType(Enum.forString("simple")); return httpDocument; }