long requestedUpdateSequence = -1;
if (request.getUpdateSequence() != null) {
try {
requestedUpdateSequence = Long.parseLong(request.getUpdateSequence());
} catch (NumberFormatException e) {
throw new WcsException("Invalid update sequence number format, "
+ "should be an integer", WcsExceptionCode.InvalidUpdateSequence,
"updateSequence");
}
if (requestedUpdateSequence > updateSequence) {
throw new WcsException("Invalid update sequence value, it's higher "
+ "than the current value, " + updateSequence,
WcsExceptionCode.InvalidUpdateSequence, "updateSequence");
}
}
final AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute("", "version", "version", "", CUR_VERSION);
attributes.addAttribute("", "xmlns:wcs", "xmlns:wcs", "", WCS_URI);
attributes.addAttribute("", "xmlns:xlink", "xmlns:xlink", "",
"http://www.w3.org/1999/xlink");
attributes.addAttribute("", "xmlns:ogc", "xmlns:ogc", "", "http://www.opengis.net/ogc");
attributes.addAttribute("", "xmlns:ows", "xmlns:ows", "",
"http://www.opengis.net/ows/1.1");
attributes.addAttribute("", "xmlns:gml", "xmlns:gml", "", "http://www.opengis.net/gml");
final String prefixDef = new StringBuffer("xmlns:").append(XSI_PREFIX).toString();
attributes.addAttribute("", prefixDef, prefixDef, "", XSI_URI);
final String locationAtt = new StringBuffer(XSI_PREFIX).append(":schemaLocation")
.toString();
final String locationDef = buildSchemaURL(request.getBaseUrl(), "wcs/1.1.1/wcsGetCapabilities.xsd");
attributes.addAttribute("", locationAtt, locationAtt, "", locationDef);
attributes.addAttribute("", "updateSequence", "updateSequence", "", String
.valueOf(updateSequence));
start("wcs:Capabilities", attributes);
// handle the sections directive
boolean allSections;
List<String> sections;
if (request.getSections() == null) {
allSections = true;
sections = Collections.emptyList();
} else {
sections = request.getSections().getSection();
allSections = sections.contains("All");
}
final Set<String> knownSections = new HashSet<String>(Arrays.asList(
"ServiceIdentification", "ServiceProvider", "OperationsMetadata", "Contents",
"All"));
for (String section : sections) {
if(!knownSections.contains(section))
throw new WcsException("Unknown section " + section,
WcsExceptionCode.InvalidParameterValue, "Sections");
}
// encode the actual capabilities contents taking into consideration
// the sections