use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class SosDecoderv100 method parseGetObservationById.
private OwsServiceRequest parseGetObservationById(GetObservationByIdDocument getObsByIdDoc) throws DecodingException {
GetObservationByIdRequest getObsByIdRequest = new GetObservationByIdRequest();
GetObservationById getObsById = getObsByIdDoc.getGetObservationById();
getObsByIdRequest.setService(getObsById.getService());
getObsByIdRequest.setVersion(getObsById.getVersion());
if (getObsById.isSetResponseFormat()) {
getObsByIdRequest.setResponseFormat(decodeResponseFormat(getObsById.getResponseFormat()));
} else {
getObsByIdRequest.setResponseFormat(OmConstants.CONTENT_TYPE_OM.toString());
}
net.opengis.sos.x10.ResponseModeType.Enum responseMode = getObsById.getResponseMode();
if (responseMode != null && responseMode.toString().equalsIgnoreCase(SosConstants.RESPONSE_MODE_INLINE)) {
getObsByIdRequest.setResponseMode(SosConstants.RESPONSE_MODE_INLINE);
}
if (getObsById.isSetResultModel()) {
getObsByIdRequest.setResultModel(OMHelper.getObservationTypeFor(getObsById.getResultModel()));
}
getObsByIdRequest.setObservationIdentifier(Arrays.asList(getObsById.getObservationId()));
return getObsByIdRequest;
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class SosDecoderv20 method parseInsertObservation.
private OwsServiceRequest parseInsertObservation(final InsertObservationDocument insertObservationDoc) throws DecodingException {
// set namespace for default XML type (e.g. xs:string, xs:integer,
// xs:boolean, ...)
// Fix for problem with XmlBeans: namespace is not set in child elements
// when defined in root of request (SOAP)
final XmlCursor cursor = insertObservationDoc.newCursor();
if (cursor.toFirstChild() && cursor.namespaceForPrefix(W3CConstants.NS_XS_PREFIX) == null) {
cursor.prefixForNamespace(W3CConstants.NS_XS);
}
cursor.dispose();
final InsertObservationRequest insertObservationRequest = new InsertObservationRequest();
final InsertObservationType insertObservationType = insertObservationDoc.getInsertObservation();
insertObservationRequest.setService(insertObservationType.getService());
insertObservationRequest.setVersion(insertObservationType.getVersion());
if (insertObservationDoc.getInsertObservation().getOfferingArray() != null) {
insertObservationRequest.setOfferings(Arrays.asList(insertObservationType.getOfferingArray()));
}
insertObservationRequest.setExtensions(parseExtensibleRequest(insertObservationType));
if (insertObservationType.getObservationArray() != null) {
final int length = insertObservationType.getObservationArray().length;
final Map<String, Time> phenomenonTimes = new HashMap<>(length);
final Map<String, TimeInstant> resultTimes = new HashMap<>(length);
final Map<String, AbstractFeature> features = new HashMap<>(length);
CompositeException exceptions = new CompositeException();
for (final Observation observation : insertObservationType.getObservationArray()) {
final Object decodedObject = decodeXmlElement(observation.getOMObservation());
if (decodedObject instanceof OmObservation) {
final OmObservation sosObservation = (OmObservation) decodedObject;
checkAndAddPhenomenonTime(sosObservation.getPhenomenonTime(), phenomenonTimes);
checkAndAddResultTime(sosObservation.getResultTime(), resultTimes);
checkAndAddFeatures(sosObservation.getObservationConstellation().getFeatureOfInterest(), features);
insertObservationRequest.addObservation(sosObservation);
} else {
exceptions.add(new DecodingException(Sos2Constants.InsertObservationParams.observation, "The requested observation type (%s) is not supported by this server!", observation.getOMObservation().getDomNode().getNodeName()));
}
}
checkReferencedElements(insertObservationRequest.getObservations(), phenomenonTimes, resultTimes, features);
try {
exceptions.throwIfNotEmpty();
} catch (CompositeException ex) {
throw new DecodingException(ex, Sos2Constants.InsertObservationParams.observation);
}
} else {
// TODO MissingMandatoryParameterException?
throw new DecodingException(Sos2Constants.InsertObservationParams.observation, "The request does not contain an observation");
}
return insertObservationRequest;
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class SosDecoderv20 method parseGetResultResponse.
private OwsServiceResponse parseGetResultResponse(final GetResultResponseDocument getResultResponseDoc) throws DecodingException {
final GetResultResponse sosGetResultResponse = new GetResultResponse();
final GetResultResponseType getResultResponse = getResultResponseDoc.getGetResultResponse();
final String resultValues = parseResultValues(getResultResponse.getResultValues());
sosGetResultResponse.setResultValues(resultValues);
return sosGetResultResponse;
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class SosDecoderv20 method parseGetResultTemplate.
private OwsServiceRequest parseGetResultTemplate(final GetResultTemplateDocument getResultTemplateDoc) throws DecodingException {
final GetResultTemplateType getResultTemplate = getResultTemplateDoc.getGetResultTemplate();
final GetResultTemplateRequest sosGetResultTemplateRequest = new GetResultTemplateRequest();
sosGetResultTemplateRequest.setService(getResultTemplate.getService());
sosGetResultTemplateRequest.setVersion(getResultTemplate.getVersion());
sosGetResultTemplateRequest.setOffering(getResultTemplate.getOffering());
sosGetResultTemplateRequest.setObservedProperty(getResultTemplate.getObservedProperty());
sosGetResultTemplateRequest.setExtensions(parseExtensibleRequest(getResultTemplate));
return sosGetResultTemplateRequest;
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class SosDecoderv20 method parseGetResultTemplateResponse.
private OwsServiceResponse parseGetResultTemplateResponse(final GetResultTemplateResponseDocument getResultTemplateResponseDoc) throws DecodingException {
final GetResultTemplateResponse sosGetResultTemplateResponse = new GetResultTemplateResponse();
final GetResultTemplateResponseType getResultTemplateResponse = getResultTemplateResponseDoc.getGetResultTemplateResponse();
final SosResultEncoding resultEncoding = parseResultEncoding(getResultTemplateResponse.getResultEncoding().getAbstractEncoding());
final SosResultStructure resultStructure = parseResultStructure(getResultTemplateResponse.getResultStructure().getAbstractDataComponent());
sosGetResultTemplateResponse.setResultEncoding(resultEncoding);
sosGetResultTemplateResponse.setResultStructure(resultStructure);
return sosGetResultTemplateResponse;
}
Aggregations