Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEOS-6435 - Add INSPIRE extended capabilities section to WCS GetCapab…
…ilities response
- Loading branch information
Showing
6 changed files
with
612 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
...sion/inspire/src/main/java/org/geoserver/inspire/wcs/WCSExtendedCapabilitiesProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,126 @@ | |||
/* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved | |||
* (c) 2001 - 2013 OpenPlans | |||
* This code is licensed under the GPL 2.0 license, available at the root | |||
* application directory. | |||
*/ | |||
package org.geoserver.inspire.wcs; | |||
|
|||
import static org.geoserver.inspire.InspireMetadata.CREATE_EXTENDED_CAPABILITIES; | |||
import static org.geoserver.inspire.InspireMetadata.SERVICE_METADATA_TYPE; | |||
import static org.geoserver.inspire.InspireMetadata.SERVICE_METADATA_URL; | |||
import static org.geoserver.inspire.InspireMetadata.LANGUAGE; | |||
import static org.geoserver.inspire.InspireMetadata.SPATIAL_DATASET_IDENTIFIER_TYPE; | |||
import static org.geoserver.inspire.InspireSchema.COMMON_NAMESPACE; | |||
import static org.geoserver.inspire.InspireSchema.DLS_NAMESPACE; | |||
import static org.geoserver.inspire.InspireSchema.DLS_SCHEMA; | |||
|
|||
import org.geoserver.inspire.UniqueResourceIdentifier; | |||
import org.geoserver.inspire.UniqueResourceIdentifiers; | |||
|
|||
import net.opengis.wcs20.GetCapabilitiesType; | |||
import org.geoserver.wcs.WCSInfo; | |||
import org.geoserver.catalog.CoverageInfo; | |||
import org.geoserver.catalog.MetadataMap; | |||
|
|||
import org.xml.sax.Attributes; | |||
import org.xml.sax.helpers.AttributesImpl; | |||
import org.xml.sax.helpers.NamespaceSupport; | |||
|
|||
import java.io.IOException; | |||
import java.util.List; | |||
|
|||
public class WCSExtendedCapabilitiesProvider extends | |||
org.geoserver.wcs2_0.response.WCSExtendedCapabilitiesProvider { | |||
|
|||
@Override | |||
public String[] getSchemaLocations(String schemaBaseURL) { | |||
return new String[]{DLS_NAMESPACE, DLS_SCHEMA}; | |||
} | |||
|
|||
@Override | |||
public void registerNamespaces(NamespaceSupport namespaces) { | |||
// IGN : We add another xmlns for inspire_common | |||
namespaces.declarePrefix("inspire_common", COMMON_NAMESPACE); | |||
// IGN : We add another xmlns for inspire_dls | |||
namespaces.declarePrefix("inspire_dls", DLS_NAMESPACE); | |||
} | |||
|
|||
@Override | |||
public void encodeExtendedOperations(Translator tx, WCSInfo wcs, GetCapabilitiesType request) throws IOException { | |||
//INSPIRE has nothing to add to operations section | |||
} | |||
|
|||
@Override | |||
public void encodeExtendedContents(Translator tx, WCSInfo wcs, List<CoverageInfo> coverages, GetCapabilitiesType request) | |||
throws IOException { | |||
MetadataMap serviceMetadata = wcs.getMetadata(); | |||
Boolean createExtendedCapabilities = serviceMetadata.get(CREATE_EXTENDED_CAPABILITIES.key, Boolean.class); | |||
String metadataURL = (String) serviceMetadata.get(SERVICE_METADATA_URL.key); | |||
String mediaType = (String) serviceMetadata.get(SERVICE_METADATA_TYPE.key); | |||
String language = (String) serviceMetadata.get(LANGUAGE.key); | |||
UniqueResourceIdentifiers ids = (UniqueResourceIdentifiers) serviceMetadata.get(SPATIAL_DATASET_IDENTIFIER_TYPE.key, UniqueResourceIdentifiers.class); | |||
//Don't create extended capabilities element if mandatory content not present | |||
//or turned off | |||
if (metadataURL == null | |||
|| ids == null | |||
|| ids.isEmpty() | |||
|| createExtendedCapabilities != null | |||
&& !createExtendedCapabilities) { | |||
return; | |||
} | |||
|
|||
// IGN : INSPIRE SCENARIO 1 | |||
tx.start("ows:ExtendedCapabilities"); | |||
tx.start("inspire_dls:ExtendedCapabilities"); | |||
tx.start("inspire_common:MetadataUrl"); | |||
tx.start("inspire_common:URL"); | |||
tx.chars(metadataURL); | |||
tx.end("inspire_common:URL"); | |||
if (mediaType != null) { | |||
tx.start("inspire_common:MediaType"); | |||
tx.chars(mediaType); | |||
tx.end("inspire_common:MediaType"); | |||
} | |||
tx.end("inspire_common:MetadataUrl"); | |||
tx.start("inspire_common:SupportedLanguages"); | |||
language = language != null ? language : "eng"; | |||
tx.start("inspire_common:DefaultLanguage"); | |||
tx.start("inspire_common:Language"); | |||
tx.chars(language); | |||
tx.end("inspire_common:Language"); | |||
tx.end("inspire_common:DefaultLanguage"); | |||
tx.end("inspire_common:SupportedLanguages"); | |||
tx.start("inspire_common:ResponseLanguage"); | |||
tx.start("inspire_common:Language"); | |||
tx.chars(language); | |||
tx.end("inspire_common:Language"); | |||
tx.end("inspire_common:ResponseLanguage"); | |||
for (UniqueResourceIdentifier id : ids) { | |||
if (id.getMetadataURL() != null) { | |||
tx.start("inspire_dls:SpatialDataSetIdentifier", atts("metadataURL", id.getMetadataURL())); | |||
} else { | |||
tx.start("inspire_dls:SpatialDataSetIdentifier"); | |||
} | |||
tx.start("inspire_common:Code"); | |||
tx.chars(id.getCode()); | |||
tx.end("inspire_common:Code"); | |||
if (id.getNamespace() != null) { | |||
tx.start("inspire_common:Namespace"); | |||
tx.chars(id.getNamespace()); | |||
tx.end("inspire_common:Namespace"); | |||
} | |||
tx.end("inspire_dls:SpatialDataSetIdentifier"); | |||
} | |||
tx.end("inspire_dls:ExtendedCapabilities"); | |||
tx.end("ows:ExtendedCapabilities"); | |||
} | |||
|
|||
Attributes atts(String... atts) { | |||
AttributesImpl attributes = new AttributesImpl(); | |||
for (int i = 0; i < atts.length; i += 2) { | |||
attributes.addAttribute(null, atts[i], atts[i], null, atts[i + 1]); | |||
} | |||
return attributes; | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.