Skip to content

Commit

Permalink
GEOS-6435 - Add INSPIRE extended capabilities section to WCS GetCapab…
Browse files Browse the repository at this point in the history
…ilities response
  • Loading branch information
bgsmase committed Nov 10, 2015
1 parent 829444f commit 0172598
Show file tree
Hide file tree
Showing 6 changed files with 612 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/extension/inspire/pom.xml
Expand Up @@ -35,6 +35,16 @@
<artifactId>gs-wfs</artifactId> <artifactId>gs-wfs</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>gs-wcs</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>gs-wcs2_0</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.geoserver.web</groupId> <groupId>org.geoserver.web</groupId>
<artifactId>gs-web-core</artifactId> <artifactId>gs-web-core</artifactId>
Expand Down
@@ -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;
}

}
Expand Up @@ -35,6 +35,7 @@
import org.geoserver.web.util.MapModel; import org.geoserver.web.util.MapModel;
import org.geoserver.web.util.MetadataMapModel; import org.geoserver.web.util.MetadataMapModel;
import org.geoserver.wfs.WFSInfo; import org.geoserver.wfs.WFSInfo;
import org.geoserver.wcs.WCSInfo;


/** /**
* Panel for the service admin page to set the service INSPIRE extension * Panel for the service admin page to set the service INSPIRE extension
Expand All @@ -53,14 +54,15 @@ public InspireAdminPanel(final String id, final IModel<ServiceInfo> model) {
String metadataURL = (String) serviceMetadata.get(SERVICE_METADATA_URL.key); String metadataURL = (String) serviceMetadata.get(SERVICE_METADATA_URL.key);
String mediaType = (String) serviceMetadata.get(SERVICE_METADATA_TYPE.key); String mediaType = (String) serviceMetadata.get(SERVICE_METADATA_TYPE.key);
String language = (String) serviceMetadata.get(LANGUAGE.key); String language = (String) serviceMetadata.get(LANGUAGE.key);
boolean isWfs = model.getObject() instanceof WFSInfo; boolean isDownloadService = model.getObject() instanceof WFSInfo ||
model.getObject() instanceof WCSInfo;
UniqueResourceIdentifiers ids = null; UniqueResourceIdentifiers ids = null;
if (isWfs) { if (isDownloadService) {
ids = (UniqueResourceIdentifiers) serviceMetadata.get(SPATIAL_DATASET_IDENTIFIER_TYPE.key, UniqueResourceIdentifiers.class); ids = (UniqueResourceIdentifiers) serviceMetadata.get(SPATIAL_DATASET_IDENTIFIER_TYPE.key, UniqueResourceIdentifiers.class);
} }
if (!serviceMetadata.containsKey(CREATE_EXTENDED_CAPABILITIES.key)) { if (!serviceMetadata.containsKey(CREATE_EXTENDED_CAPABILITIES.key)) {
if (metadataURL == null if (metadataURL == null
|| isWfs || isDownloadService
&& (ids == null || ids.isEmpty())) { && (ids == null || ids.isEmpty())) {
serviceMetadata.put(CREATE_EXTENDED_CAPABILITIES.key, false); serviceMetadata.put(CREATE_EXTENDED_CAPABILITIES.key, false);
} else { } else {
Expand Down Expand Up @@ -141,10 +143,11 @@ public String getIdValue(final String key, int index) {


configs.add(serviceMetadataRecordType); configs.add(serviceMetadataRecordType);


// this is WFS specific, will appear only if the service is WFS // this is download service specific, will appear only if the service is
// WFS or WCS
WebMarkupContainer identifiersContainer = new WebMarkupContainer( WebMarkupContainer identifiersContainer = new WebMarkupContainer(
"datasetIdentifiersContainer"); "datasetIdentifiersContainer");
identifiersContainer.setVisible(isWfs); identifiersContainer.setVisible(isDownloadService);
configs.add(identifiersContainer); configs.add(identifiersContainer);
IModel<UniqueResourceIdentifiers> sdiModel = new MetadataMapModel(metadata, SPATIAL_DATASET_IDENTIFIER_TYPE.key, UniqueResourceIdentifiers.class); IModel<UniqueResourceIdentifiers> sdiModel = new MetadataMapModel(metadata, SPATIAL_DATASET_IDENTIFIER_TYPE.key, UniqueResourceIdentifiers.class);
UniqueResourceIdentifiersEditor identifiersEditor = new UniqueResourceIdentifiersEditor( UniqueResourceIdentifiersEditor identifiersEditor = new UniqueResourceIdentifiersEditor(
Expand Down
10 changes: 10 additions & 0 deletions src/extension/inspire/src/main/resources/applicationContext.xml
Expand Up @@ -13,6 +13,9 @@
<bean id="inspireWfsExtendedCapsProvider" class="org.geoserver.inspire.wfs.WFSExtendedCapabilitiesProvider"> <bean id="inspireWfsExtendedCapsProvider" class="org.geoserver.inspire.wfs.WFSExtendedCapabilitiesProvider">
</bean> </bean>


<bean id="inspireWcsExtendedCapsProvider" class="org.geoserver.inspire.wcs.WCSExtendedCapabilitiesProvider">
</bean>

<bean id="inspireWmsAdminPanel" class="org.geoserver.web.services.AdminPagePanelInfo"> <bean id="inspireWmsAdminPanel" class="org.geoserver.web.services.AdminPagePanelInfo">
<description>This bean adds the necessary form fields to Geoserver admin interface</description> <description>This bean adds the necessary form fields to Geoserver admin interface</description>
<property name="id" value="inspireWmsAdminPanel"/> <property name="id" value="inspireWmsAdminPanel"/>
Expand All @@ -27,4 +30,11 @@
<property name="componentClass" value="org.geoserver.inspire.web.InspireAdminPanel"/> <property name="componentClass" value="org.geoserver.inspire.web.InspireAdminPanel"/>
<property name="serviceClass" value="org.geoserver.wfs.WFSInfo"/> <property name="serviceClass" value="org.geoserver.wfs.WFSInfo"/>
</bean> </bean>
<bean id="inspireWcsAdminPanel" class="org.geoserver.web.services.AdminPagePanelInfo">
<description>This bean adds the necessary form fields to Geoserver admin interface</description>
<property name="id" value="inspireWcsAdminPanel"/>
<property name="titleKey" value="inspire"/>
<property name="componentClass" value="org.geoserver.inspire.web.InspireAdminPanel"/>
<property name="serviceClass" value="org.geoserver.wcs.WCSInfo"/>
</bean>
</beans> </beans>

0 comments on commit 0172598

Please sign in to comment.