use of org.n52.shetland.ogc.ows.OwsServiceIdentification in project arctic-sea by 52North.
the class AbstractCapabilitiesBaseTypeDecoder method parseServiceIdentification.
private OwsServiceIdentification parseServiceIdentification(ServiceIdentification serviceIdentification) {
if (serviceIdentification == null) {
return null;
}
OwsCode serviceType = parseCode(serviceIdentification.getServiceType());
Set<String> serviceTypeVersion = Optional.ofNullable(serviceIdentification.getServiceTypeVersionArray()).map(Arrays::stream).orElseGet(Stream::empty).collect(toSet());
Set<String> fees = Optional.ofNullable(serviceIdentification.getFees()).map(Collections::singleton).orElseGet(Collections::emptySet);
Set<URI> profiles = Optional.ofNullable(serviceIdentification.getProfileArray()).map(Arrays::stream).orElseGet(Stream::empty).map(URI::create).collect(toSet());
Set<String> accessConstraints = Optional.ofNullable(serviceIdentification.getAccessConstraintsArray()).map(Arrays::stream).orElseGet(Stream::empty).collect(toSet());
MultilingualString title = new MultilingualString();
MultilingualString abstrakt = new MultilingualString();
Optional.ofNullable(serviceIdentification.getTitleArray()).map(Arrays::stream).orElseGet(Stream::empty).map(this::parseLanguageString).forEach(title::addLocalization);
Optional.ofNullable(serviceIdentification.getAbstractArray()).map(Arrays::stream).orElseGet(Stream::empty).map(this::parseLanguageString).forEach(abstrakt::addLocalization);
Set<OwsKeyword> keywords = Optional.ofNullable(serviceIdentification.getKeywordsArray()).map(Arrays::stream).orElseGet(Stream::empty).flatMap(this::parseKeyword).filter(Objects::nonNull).collect(toSet());
return new OwsServiceIdentification(serviceType, serviceTypeVersion, profiles, fees, accessConstraints, title, abstrakt, keywords);
}
use of org.n52.shetland.ogc.ows.OwsServiceIdentification in project arctic-sea by 52North.
the class OwsEncoderv110Test method should_encode_service_identification_without_service_type_codespace.
@Test
public void should_encode_service_identification_without_service_type_codespace() throws EncodingException {
String serviceTypeValue = "serviceType";
OwsServiceIdentification serviceId = new OwsServiceIdentification(new OwsCode(serviceTypeValue), null, null, null, null, null, null, null);
XmlObject xbEncoded = encodeObjectToXml(OWSConstants.NS_OWS, serviceId);
assertThat(xbEncoded, instanceOf(ServiceIdentification.class));
ServiceIdentification xbServiceId = (ServiceIdentification) xbEncoded;
assertThat(xbServiceId.getServiceType().getStringValue(), equalTo(serviceTypeValue));
assertThat(xbServiceId.getServiceType().getCodeSpace(), nullValue());
}
use of org.n52.shetland.ogc.ows.OwsServiceIdentification in project arctic-sea by 52North.
the class AbstractGetCapabilitiesHandler method createCapabilities.
private OwsCapabilities createCapabilities(GetCapabilitiesRequest request, String service, String version) throws OwsExceptionReport {
Set<CapabilitiesSection> sections = getRequestedSections(request);
Locale requestedLocale = getRequestedLocale(request);
String updateSequence = null;
OwsServiceIdentification serviceIdentification = null;
if (sections.contains(CapabilitiesSection.ServiceIdentification)) {
serviceIdentification = getServiceIdentification(service, requestedLocale);
}
OwsServiceProvider serviceProvider = null;
if (sections.contains(CapabilitiesSection.ServiceProvider)) {
serviceProvider = getServiceProvider(service, requestedLocale);
}
OwsOperationsMetadata operationsMetadata = null;
if (sections.contains(CapabilitiesSection.OperationsMetadata)) {
operationsMetadata = getOperations(service, version);
}
Set<String> languages = null;
if (sections.contains(CapabilitiesSection.Languages)) {
languages = getLanguages();
}
T contents = null;
if (sections.contains(CapabilitiesSection.Contents)) {
contents = createContents(service, version);
}
Collection<OwsCapabilitiesExtension> extensions = getExtensions(request, service, version);
OwsCapabilities capabilities = new OwsCapabilities(service, version, updateSequence, serviceIdentification, serviceProvider, operationsMetadata, languages, extensions);
return createCapabilities(capabilities, contents);
}
use of org.n52.shetland.ogc.ows.OwsServiceIdentification in project arctic-sea by 52North.
the class OwsEncoderv110 method encodeServiceIdentification.
private XmlObject encodeServiceIdentification(OwsServiceIdentification serviceIdentification) throws EncodingException {
ServiceIdentification serviceIdent;
/* TODO check for required fields and fail on missing ones */
serviceIdent = ServiceIdentification.Factory.newInstance();
serviceIdentification.getAccessConstraints().forEach(serviceIdent::addAccessConstraints);
if (!serviceIdentification.getFees().isEmpty()) {
serviceIdent.setFees(serviceIdentification.getFees().iterator().next());
}
CodeType xbServiceType = serviceIdent.addNewServiceType();
xbServiceType.setStringValue(serviceIdentification.getServiceType().getValue());
if (serviceIdentification.getServiceType().getCodeSpace().isPresent()) {
xbServiceType.setCodeSpace(serviceIdentification.getServiceType().getCodeSpace().get().toString());
}
encodeMultilingualString(serviceIdentification.getTitle(), serviceIdent::addNewTitle);
encodeMultilingualString(serviceIdentification.getAbstract(), serviceIdent::addNewAbstract);
serviceIdentification.getServiceTypeVersion().stream().forEach(serviceIdent::addServiceTypeVersion);
serviceIdentification.getProfiles().stream().map(URI::toString).forEach(serviceIdent::addProfile);
serviceIdentification.getKeywords().stream().collect(groupingBy(OwsKeyword::getType, mapping(OwsKeyword::getKeyword, toList()))).forEach((type, keywords) -> encodeOwsKeywords(type, keywords, serviceIdent.addNewKeywords()));
return serviceIdent;
}
use of org.n52.shetland.ogc.ows.OwsServiceIdentification in project arctic-sea by 52North.
the class OwsEncoderv110 method encode.
@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
if (element instanceof OwsServiceIdentification) {
return encodeServiceIdentification((OwsServiceIdentification) element);
} else if (element instanceof OwsServiceProvider) {
return encodeServiceProvider((OwsServiceProvider) element);
} else if (element instanceof OwsOperationsMetadata) {
return encodeOperationsMetadata((OwsOperationsMetadata) element);
} else if (element instanceof OwsExceptionReport) {
if (isEncodeExceptionsOnly(additionalValues) && !((OwsExceptionReport) element).getExceptions().isEmpty()) {
return encodeOwsException(((OwsExceptionReport) element).getExceptions().get(0));
}
return encodeOwsExceptionReport((OwsExceptionReport) element);
} else if (element instanceof OwsMetadata) {
MetadataType metadataType = MetadataType.Factory.newInstance(getXmlOptions());
encodeOwsMetadata((OwsMetadata) element, metadataType);
return metadataType;
} else if (element instanceof OwsDomain) {
DomainType domainType = DomainType.Factory.newInstance(getXmlOptions());
encodeOwsDomain((OwsDomain) element, domainType);
return domainType;
} else if (element instanceof OwsAcceptVersions) {
return encodeAcceptVersions((OwsAcceptVersions) element);
} else if (element instanceof OwsSections) {
return encodeSections((OwsSections) element);
}
throw new UnsupportedEncoderInputException(this, element);
}
Aggregations