use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.
the class GenericServiceOperator method receiveRequest.
/**
* {@inheritDoc}
*
* @throws OperationNotSupportedException if no matching
* {@link RequestOperator} could be
* found or if the operator returned
* a {@code null}-response.
*/
@Override
public OwsServiceResponse receiveRequest(OwsServiceRequest request) throws OwsExceptionReport {
String operationName = request.getOperationName();
RequestOperator operator = this.requestOperatorRepository.getRequestOperator(this.key, operationName);
if (operator == null) {
throw new OperationNotSupportedException(operationName);
}
OwsServiceResponse response = operator.receiveRequest(request);
if (response == null) {
throw new OperationNotSupportedException(operationName);
}
return response;
}
use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.
the class GenericRequestOperator method receiveRequest.
@Override
public OwsServiceResponse receiveRequest(final OwsServiceRequest abstractRequest) throws OwsExceptionReport {
this.eventBus.submit(new RequestEvent(abstractRequest));
if (requestType.isAssignableFrom(abstractRequest.getClass())) {
Q request = requestType.cast(abstractRequest);
checkForModifierAndProcess(request);
this.validator.validate(request);
A response = receive(request);
this.eventBus.submit(new ResponseEvent(response));
checkForModifierAndProcess(request, response);
return response;
} else {
throw new OperationNotSupportedException(abstractRequest.getOperationName());
}
}
use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.
the class GenericRequestOperator method checkForModifierAndProcess.
private void checkForModifierAndProcess(OwsServiceRequest request) throws OwsExceptionReport {
if (!this.modifierRepository.hasRequestResponseModifier(request)) {
return;
}
List<RequestResponseModifier> splitter = new LinkedList<>();
List<RequestResponseModifier> remover = new LinkedList<>();
List<RequestResponseModifier> defaultModifier = new LinkedList<>();
this.modifierRepository.getRequestResponseModifier(request).stream().forEach(modifier -> {
if (modifier.getFacilitator().isSplitter()) {
splitter.add(modifier);
} else if (modifier.getFacilitator().isAdderRemover()) {
remover.add(modifier);
} else {
defaultModifier.add(modifier);
}
});
// execute adder/remover
for (RequestResponseModifier modifier : remover) {
modifier.modifyRequest(request);
}
// execute default
for (RequestResponseModifier modifier : defaultModifier) {
modifier.modifyRequest(request);
}
// execute splitter
for (RequestResponseModifier modifier : splitter) {
modifier.modifyRequest(request);
}
}
use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.
the class EXIBinding method parseRequest.
/**
* Parse and decode the incoming EXI encoded {@link InputStream}
*
* @param request
* {@link HttpServletRequest} with EXI encoded
* {@link InputStream}
* @return {@link OwsServiceRequest} from EXI encoded {@link InputStream}
* @throws OwsExceptionReport
* If an error occurs during parsing
*/
protected OwsServiceRequest parseRequest(HttpServletRequest request) throws OwsExceptionReport {
XmlObject doc = decode(request);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("EXI-REQUEST: {}", doc.xmlText());
}
Decoder<OwsServiceRequest, XmlObject> decoder = getDecoder(CodingHelper.getDecoderKey(doc));
try {
return decoder.decode(doc).setRequestContext(getRequestContext(request));
} catch (OwsDecodingException ex) {
throw ex.getCause();
} catch (DecodingException ex) {
throw new InvalidParameterValueException().withMessage(ex.getMessage()).causedBy(ex).at(ex.getLocation().orElse(null));
}
}
use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.
the class JSONBinding method doPostOperation.
@Override
public void doPostOperation(HttpServletRequest req, HttpServletResponse res) throws HTTPException, IOException {
OwsServiceRequest request = null;
try {
request = parseRequest(req);
checkServiceOperatorKeyTypes(request);
OwsServiceResponse response = getServiceOperator(request).receiveRequest(request);
writeResponse(req, res, response);
} catch (OwsExceptionReport oer) {
oer.setVersion(request != null ? request.getVersion() : null);
LOG.warn("Unexpected error", oer);
writeOwsExceptionReport(req, res, oer);
}
}
Aggregations