Skip to content

Commit

Permalink
Merge branch 'develop' into fix/allow_null_result_time_db
Browse files Browse the repository at this point in the history
  • Loading branch information
Carsten Hollmann committed May 27, 2020
2 parents 02b581e + 274250e commit 9b575be
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 159 deletions.
22 changes: 14 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,33 @@ FROM jetty:jre8-alpine

USER root
RUN set -ex \
&& apk add --no-cache jq \
&& apk add --no-cache jq gettext \
&& wget -q -P /usr/local/bin https://raw.githubusercontent.com/52North/arctic-sea/master/etc/faroe-entrypoint.sh \
&& chmod +x /usr/local/bin/faroe-entrypoint.sh
USER jetty:jetty

ENV FAROE_CONFIGURATION /etc/sos/configuration.json
ENV WEBAPP ${JETTY_BASE}/webapps/ROOT
ENV HELGOLAND ${WEBAPP}/static/client/helgoland
ENV HELGOLAND_CONFIG ${HELGOLAND}/assets/settings.json

COPY --from=BUILD /usr/src/app/webapp/target/52n-sos-webapp ${WEBAPP}
COPY ./docker/logback.xml ${WEBAPP}/WEB-INF/classes/
COPY ./docker/helgoland.json ${HELGOLAND}/assets/settings.json
COPY ./docker/default-config /etc/sos
COPY --chown=jetty:jetty --from=BUILD /usr/src/app/webapp/target/52n-sos-webapp ${WEBAPP}
COPY --chown=jetty:jetty ./docker/logback.xml ${WEBAPP}/WEB-INF/classes/
COPY --chown=jetty:jetty ./docker/jetty-web.xml ${WEBAPP}/WEB-INF/jetty-web.xml.template
COPY --chown=jetty:jetty ./docker/helgoland.json ${HELGOLAND_CONFIG}
COPY --chown=jetty:jetty ./docker/default-config /etc/sos

USER root
COPY --from=BCRYPT_BUILD /usr/src/app /usr/lib/java-brcypt
COPY docker/bcrypt/bcrypt.sh /usr/local/bin/bcrypt
COPY docker/sos-entrypoint.sh /usr/local/bin


RUN mkdir -p ${WEBAPP}/WEB-INF/tmp \
&& ln -s /etc/sos ${WEBAPP}/WEB-INF/config \
&& chown -R jetty:jetty ${WEBAPP} /etc/sos \
&& chown -R jetty:jetty ${WEBAPP}/WEB-INF/tmp \
${WEBAPP}/WEB-INF/config \
/etc/sos \
&& chmod +x /usr/local/bin/sos-entrypoint.sh \
/usr/local/bin/bcrypt
USER jetty:jetty
Expand All @@ -52,7 +57,7 @@ VOLUME /etc/sos

HEALTHCHECK --start-period=60s --interval=30s \
--timeout=20s --retries=3 \
CMD wget http://localhost:8080/ -q -O - > /dev/null 2>&1
CMD wget http://localhost:8080${SOS_CONTEXT_PATH} -q -O - > /dev/null 2>&1

LABEL maintainer="Carsten Hollmann <c.hollmann@52north.org>" \
org.opencontainers.image.title="52°North SOS" \
Expand All @@ -76,6 +81,7 @@ ENV SOS_ADMIN_USERNAME=admin \
SOS_DATASOURCE_PASSWORD=postgres \
SOS_DATASOURCE_DATABASE=sos \
SOS_DATASOURCE_HOST=db \
SOS_DATASOURCE_PORT=5432
SOS_DATASOURCE_PORT=5432 \
SOS_CONTEXT_PATH=/

CMD [ "java", "-jar", "/usr/local/jetty/start.jar" ]
2 changes: 1 addition & 1 deletion core/api/src/main/java/org/n52/sos/util/SosHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class SosHelper {
/**
* Hide utility constructor
*/
protected SosHelper() {
public SosHelper() {
}

public String getServiceURL() {
Expand Down
3 changes: 3 additions & 0 deletions core/api/src/main/resources/contexts/configured/sos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<bean id="geometryHandler"
class="org.n52.sos.util.GeometryHandler" />

<bean id="sosHelper"
class="org.n52.sos.util.SosHelper" />

<bean id="encoderRepository"
class="org.n52.sos.coding.encode.SosEncoderRepository" />

Expand Down
5 changes: 5 additions & 0 deletions docker/jetty-web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">${SOS_CONTEXT_PATH}</Set>
</Configure>
20 changes: 20 additions & 0 deletions docker/sos-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,24 @@ sos.feature.concept=DEFAULT_FEATURE_CONCEPT
EOF
fi


# set the URL of the API in the Helgoland settings
if [ -n "${EXTERNAL_URL}" ]; then
TEMP="$(mktemp)"
jq --arg value "${EXTERNAL_URL}" \
'(.datasetApis[] | select(.name = "localhost")).url |= $value' \
< ${HELGOLAND_CONFIG} \
> ${TEMP}
mv -f "${TEMP}" "${HELGOLAND_CONFIG}"
fi


# change the context path if required
if [ -n "${SOS_CONTEXT_PATH}" -a ${SOS_CONTEXT_PATH} != "/" ]; then
envsubst '${SOS_CONTEXT_PATH}' \
< "${WEBAPP}/WEB-INF/jetty-web.xml.template" \
> "${WEBAPP}/WEB-INF/jetty-web.xml"
fi


exec "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
package org.n52.sos.inspire.capabilities;

import java.net.MalformedURLException;
import java.net.URI;
import java.util.Collections;
import java.util.Set;

import javax.inject.Inject;

import org.n52.faroe.annotation.Configurable;
import org.n52.iceland.ogc.ows.OwsServiceMetadataRepository;
import org.n52.iceland.ogc.ows.extension.OwsOperationMetadataExtensionProvider;
import org.n52.iceland.ogc.ows.extension.OwsOperationMetadataExtensionProviderKey;
import org.n52.shetland.ogc.ows.service.OwsServiceRequest;
import org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest;
import org.n52.iceland.service.ServiceSettings;
import org.n52.janmayen.http.MediaType;
import org.n52.janmayen.http.MediaTypes;
import org.n52.shetland.inspire.InspireConformity;
import org.n52.shetland.inspire.InspireConformity.InspireDegreeOfConformity;
import org.n52.shetland.inspire.InspireConformityCitation;
import org.n52.shetland.inspire.InspireConstants;
import org.n52.shetland.inspire.InspireDateOfCreation;
Expand All @@ -52,7 +52,6 @@
import org.n52.shetland.inspire.InspireResourceLocator;
import org.n52.shetland.inspire.InspireTemporalReference;
import org.n52.shetland.inspire.InspireUniqueResourceIdentifier;
import org.n52.shetland.inspire.InspireConformity.InspireDegreeOfConformity;
import org.n52.shetland.inspire.dls.FullInspireExtendedCapabilities;
import org.n52.shetland.inspire.dls.MinimalInspireExtendedCapabilities;
import org.n52.shetland.ogc.gml.time.TimeInstant;
Expand All @@ -65,6 +64,8 @@
import org.n52.shetland.ogc.ows.exception.NoApplicableCodeException;
import org.n52.shetland.ogc.ows.exception.OwsExceptionReport;
import org.n52.shetland.ogc.ows.extension.Extension;
import org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest;
import org.n52.shetland.ogc.ows.service.OwsServiceRequest;
import org.n52.shetland.ogc.sos.Sos2Constants;
import org.n52.shetland.ogc.sos.SosConstants;
import org.n52.shetland.ogc.swe.simpleType.SweCount;
Expand All @@ -76,13 +77,6 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;

import org.n52.iceland.ogc.ows.extension.OwsOperationMetadataExtensionProvider;
import org.n52.faroe.ConfigurationError;
import org.n52.faroe.Validation;
import org.n52.faroe.annotation.Configurable;
import org.n52.faroe.annotation.Setting;
import org.n52.iceland.ogc.ows.OwsServiceMetadataRepository;

/**
* Provider for the INSPIRE ExtendedCapabilities
*
Expand All @@ -99,21 +93,16 @@ public class InspireExtendedCapabilitiesProvider extends AbstractInspireProvider

private OwsServiceMetadataRepository serviceMetadataRepository;

private String serviceURL;
private SosHelper sosHelper;

@Inject
public void setServiceMetadataRepository(OwsServiceMetadataRepository repo) {
this.serviceMetadataRepository = repo;
}

@Setting(ServiceSettings.SERVICE_URL)
public void setServiceURL(final URI serviceURL) throws ConfigurationError {
Validation.notNull("Service URL", serviceURL);
String url = serviceURL.toString();
if (url.contains("?")) {
url = url.split("[?]")[0];
}
this.serviceURL = url;
@Inject
public void setSosHelperL(SosHelper sosHelper) {
this.sosHelper = sosHelper;
}

public OwsServiceProvider getOwsServiceProvider() {
Expand Down Expand Up @@ -240,7 +229,8 @@ private void addMetadataUrl(FullInspireExtendedCapabilities fullInspireExtendedC
private InspireResourceLocator getResourceLocator() throws OwsExceptionReport {
try {
InspireResourceLocator resourceLocator =
new InspireResourceLocator(SosHelper.getGetCapabilitiesKVPRequest(serviceURL).toString());
new InspireResourceLocator(SosHelper.getGetCapabilitiesKVPRequest(sosHelper.getServiceURL())
.toString());
resourceLocator.addMediaType(MediaTypes.APPLICATION_XML);
return resourceLocator;
} catch (MalformedURLException ex) {
Expand Down Expand Up @@ -305,7 +295,7 @@ private Set<InspireUniqueResourceIdentifier> getSpatialDataSetIdentifier(String
if (getInspireHelper().isSetNamespace()) {
iuri.setNamespace(getInspireHelper().getNamespace());
} else {
iuri.setNamespace(serviceURL);
iuri.setNamespace(sosHelper.getServiceURL());
}
spatialDataSetIdentifier.add(iuri);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@
*/
package org.n52.sos.inspire.offering;

import java.net.URI;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Stream;

import org.n52.faroe.ConfigurationError;
import org.n52.faroe.Validation;
import javax.inject.Inject;

import org.n52.faroe.annotation.Configurable;
import org.n52.faroe.annotation.Setting;
import org.n52.iceland.service.ServiceSettings;
import org.n52.shetland.inspire.InspireConstants;
import org.n52.shetland.inspire.InspireObject;
import org.n52.shetland.inspire.InspireUniqueResourceIdentifier;
Expand All @@ -49,6 +47,7 @@
import org.n52.sos.inspire.settings.InspireSettings;
import org.n52.sos.ogc.sos.SosObservationOfferingExtensionKey;
import org.n52.sos.ogc.sos.SosObservationOfferingExtensionProvider;
import org.n52.sos.util.SosHelper;

import com.google.common.base.Strings;

Expand All @@ -71,7 +70,7 @@ public class InspireOfferingExtensionProvider extends AbstractInspireProvider

private String namespace;

private String serviceURL;
private SosHelper sosHelper;

@Setting(InspireSettings.INSPIRE_ENABLED_KEY)
public void setEnabled(boolean enabled) {
Expand All @@ -87,16 +86,12 @@ public void setNamespace(String namespace) {
this.namespace = namespace;
}

@Setting(ServiceSettings.SERVICE_URL)
public void setServiceURL(final URI serviceURL) throws ConfigurationError {
Validation.notNull("Service URL", serviceURL);
String url = serviceURL.toString();
if (url.contains("?")) {
url = url.split("[?]")[0];
}
this.serviceURL = url;
@Inject
public void setSosHelperL(SosHelper sosHelper) {
this.sosHelper = sosHelper;
}


@Override
public Set<SosObservationOfferingExtensionKey> getKeys() {
return Collections.unmodifiableSet(KEYS);
Expand All @@ -122,7 +117,7 @@ private InspireUniqueResourceIdentifier getSpatialDataSetIdentifier(String ident
if (!Strings.isNullOrEmpty(namespace)) {
iuri.setNamespace(namespace);
} else {
iuri.setNamespace(serviceURL);
iuri.setNamespace(sosHelper.getServiceURL());
}
return iuri;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
*/
package org.n52.sos.ds.procedure;

import java.net.URI;
import java.util.Locale;

import org.n52.faroe.ConfigurationError;
import org.n52.faroe.Validation;
import javax.inject.Inject;

import org.n52.faroe.annotation.Configurable;
import org.n52.faroe.annotation.Setting;
import org.n52.iceland.binding.BindingRepository;
Expand All @@ -41,14 +40,14 @@
import org.n52.iceland.i18n.I18NDAORepository;
import org.n52.iceland.i18n.I18NSettings;
import org.n52.iceland.ogc.ows.OwsServiceMetadataRepository;
import org.n52.iceland.service.ServiceSettings;
import org.n52.iceland.service.operator.ServiceOperatorRepository;
import org.n52.janmayen.i18n.LocaleHelper;
import org.n52.sos.cache.SosContentCache;
import org.n52.sos.ds.procedure.generator.AbstractProcedureDescriptionGeneratorFactoryRepository;
import org.n52.sos.service.ProcedureDescriptionSettings;
import org.n52.sos.service.SosSettings;
import org.n52.sos.util.GeometryHandler;
import org.n52.sos.util.SosHelper;
import org.n52.svalbard.decode.DecoderRepository;

@Configurable
Expand All @@ -64,7 +63,7 @@ public class AbstractProcedureCreationContext {
private BindingRepository bindingRepository;
private boolean showAllLanguageValues;
private ServiceOperatorRepository serviceOperatorRepository;
private String serviceURL;
private SosHelper sosHelper;
private Locale defaultLocale;
private ContentCacheController contentCacheController;
private ProcedureDescriptionSettings procedureSettings;
Expand Down Expand Up @@ -133,19 +132,13 @@ public Locale getDefaultLocale() {
return defaultLocale;
}

@Setting(ServiceSettings.SERVICE_URL)
public void setServiceURL(final URI serviceURL)
throws ConfigurationError {
Validation.notNull("Service URL", serviceURL);
String url = serviceURL.toString();
if (url.contains("?")) {
url = url.split("[?]")[0];
}
this.serviceURL = url;
@Inject
public void setSosHelperL(SosHelper sosHelper) {
this.sosHelper = sosHelper;
}

public String getServiceURL() {
return serviceURL;
return sosHelper.getServiceURL();
}

/**
Expand Down
Loading

0 comments on commit 9b575be

Please sign in to comment.