HttpResponse httpResponse = httpClient.executePost(url, request, ContentType.TEXT_XML); HttpEntity responseEntity = httpResponse.getEntity(); result = new OperationResult(responseEntity.getContent(), parameters, request); } catch (Exception e) { LOGGER.error("Error occured, while sending GetDataAvailability.", e); result = super.doOperation(operation, parameters); ByteArrayInputStream resultStream = result.getIncomingResultAsStream(); try { XmlObject result_xb = XmlObject.Factory.parse(resultStream); document = SoapUtil.readBodyNodeFrom(envelopeDoc, null); return new OperationResult(new ByteArrayInputStream(document.xmlText().getBytes()), result.getUsedParameters(), result.getSendedRequest());
/** * @deprecated use instead {@link #SOSObservationStore(OperationResult)} and {@link #unmarshalFeatures()} */ @Deprecated protected OXFFeatureCollection unmarshalFeatures100(OperationResult operationResult) throws OXFException { try { this.xmlObject = XMLBeansParser.parse(operationResult.getIncomingResultAsAutoCloseStream()); return unmarshalFeatures(operationResult); } catch (XMLHandlingException e) { throw new OXFException("Could not parse OperationResult.", e); } }
private ExceptionReport parseExceptionReport_100(OperationResult result) throws XmlException { String requestResult = new String(result.getIncomingResult()); ExceptionReportDocument exceptionReportDocument = ExceptionReportDocument.Factory.parse(requestResult); String language = exceptionReportDocument.getExceptionReport().getLang(); String version = exceptionReportDocument.getExceptionReport().getVersion(); ExceptionReport exceptionReport = new ExceptionReport(version, language); ExceptionType[] exceptions = exceptionReportDocument.getExceptionReport().getExceptionArray(); for (ExceptionType exceptionType : exceptions) { String exceptionCode = exceptionType.getExceptionCode(); String[] exceptionMessages = exceptionType.getExceptionTextArray(); if ("ResponseExceedsSizeLimit".equalsIgnoreCase(exceptionCode)) { String errorMsg = Arrays.toString(exceptionMessages); errorMsg = errorMsg.replace("[", "").replace("]", ""); throw new ResponseExceedsSizeLimitException(errorMsg); } String locator = exceptionType.getLocator(); String sentRequest = result.getSendedRequest(); OWSException owsException = new OWSException(exceptionMessages, exceptionCode, sentRequest, locator); exceptionReport.addException(owsException); } return exceptionReport; }
public StaticVisualization renderLayer(OperationResult operationResult) throws OXFException { PlanarImage resultImage = null; String format = (String) operationResult.getUsedParameters().getParameterShellWithCommonName(Parameter.COMMON_NAME_FORMAT).getSpecifiedValue(); SeekableStream seekableStream = SeekableStream.wrapInputStream(operationResult.getIncomingResultAsStream(), true); ParameterBlock pb = new ParameterBlock(); pb.add(seekableStream); if (format.toLowerCase().contains("png")) { resultImage = JAI.create("PNG", pb); } else if (format.toLowerCase().contains("gif")) { resultImage = JAI.create("GIF", pb); } else if (format.toLowerCase().contains("tif")) { resultImage = JAI.create("TIFF", pb); } else if (format.toLowerCase().contains("jpeg") || format.toLowerCase().contains("jpg")) { resultImage = JAI.create("JPEG", pb); } else { throw new OXFException("Format '" + format + "' is not supported by this WMSRenderer."); } return new StaticVisualization(resultImage.getAsBufferedImage()); }
private GetFeatureOfInterestResponseDocument getFOIResponseOfOpResult(OperationResult opRes) throws XmlException, IOException, OXFException { XmlObject foiResponse = XmlObject.Factory.parse(opRes.getIncomingResultAsStream()); if (foiResponse instanceof GetFeatureOfInterestResponseDocument) { return (GetFeatureOfInterestResponseDocument) foiResponse; } else { throw new OXFException("No valid GetFeatureOfInterestREsponse"); } }
HttpResponse httpResponse = httpClient.executePost(this.sosUrl.trim(), getDataAvailability, ContentType.TEXT_XML); HttpEntity responseEntity = httpResponse.getEntity(); OperationResult result = new OperationResult(responseEntity.getContent(), parameters, getDataAvailability); XmlObject result_xb = XmlObject.Factory.parse(result.getIncomingResultAsStream()); String resultStr = result_xb.xmlText(); String timeString = resultStr.substring(resultStr.indexOf("<gml:beginPosition>") + 19, resultStr.indexOf("</gml:beginPosition>"));
sendedRequest = new URL(operationResult.getSendedRequest()); String incomingFormat = paramMap.getParameterValue("FORMAT"); SeekableStream seekableStream = SeekableStream.wrapInputStream(operationResult.getIncomingResultAsStream(), true); ParameterBlock pb = new ParameterBlock(); pb.add(seekableStream);
result = new OperationResult(responseEntity.getContent(), parameters, request); final XmlObject result_xb = XmlObject.Factory.parse(result.getIncomingResultAsAutoCloseStream()); if (result_xb.schemaType() == ExceptionReportDocument.type) { throw parseOws110ExceptionReport(result);
URL requestURL = new URL(requestURLString); LOGGER.info("Following operation requested: " + requestURLString); return new OperationResult(requestURL.openStream(), parameterContainer, requestURLString);
private ExceptionReport parseOws110ExceptionReport(final OperationResult result) throws IOException, XmlException { final ExceptionReportDocument xb_execRepDoc = ExceptionReportDocument.Factory.parse(result.getIncomingResultAsAutoCloseStream()); final net.opengis.ows.x11.ExceptionType[] xb_exceptions = xb_execRepDoc.getExceptionReport().getExceptionArray(); final String language = xb_execRepDoc.getExceptionReport().getLang(); final String version = xb_execRepDoc.getExceptionReport().getVersion(); final ExceptionReport oxf_execReport = new ExceptionReport(version, language); for (final ExceptionType xb_exec : xb_exceptions) { final String execCode = xb_exec.getExceptionCode(); final String[] execMsgs = xb_exec.getExceptionTextArray(); final String locator = xb_exec.getLocator(); final OWSException owsExec = new OWSException(execMsgs, execCode, result.getSendedRequest(), locator); oxf_execReport.addException(owsExec); } return oxf_execReport; }
protected String getVersion(OperationResult operationResult) { ParameterContainer parameters = operationResult.getUsedParameters(); ParameterShell shell = parameters.getParameterShellWithCommonName(COMMON_NAME_VERSION); return (String) shell.getSpecifiedValue(); }
private Collection<SosTimeseries> executeGDATasks( Map<SosTimeseries, FutureTask<OperationResult>> getDataAvailabilityTasks) throws InterruptedException, ExecutionException, TimeoutException, XmlException, IOException { int counter = getDataAvailabilityTasks.size(); LOGGER.debug("Sending " + counter + " GetDataAvailability requests"); Collection<SosTimeseries> timeseries = new ArrayList<SosTimeseries>(); for (SosTimeseries timeserie : getDataAvailabilityTasks.keySet()) { LOGGER.debug("Sending #{} GetDataAvailability request for procedure " + timeserie.getProcedure(), counter--); FutureTask<OperationResult> futureTask = getDataAvailabilityTasks.get(timeserie); AccessorThreadPool.execute(futureTask); OperationResult result = futureTask.get(SERVER_TIMEOUT, MILLISECONDS); if (result == null) { LOGGER.error("Get no result for GetDataAvailability with parameter constellation: " + timeserie + "!"); } XmlObject result_xb = XmlObject.Factory.parse(result.getIncomingResultAsStream()); timeseries.addAll(getAvailableTimeseries(result_xb, timeserie)); } return timeseries; }
@Override public OperationResult doOperation(Operation operation, ParameterContainer parameters) throws ExceptionReport, OXFException { try { String httpGETRequest = createHttpGETRequest(operation, parameters); LOGGER.debug("Send GET request '{}'", httpGETRequest); HttpResponse httpResponse = httpClient.executeGet(httpGETRequest); HttpEntity responseEntity = httpResponse.getEntity(); String responseString = inputStreamToString(responseEntity.getContent()); XmlObject response = parseToXmlObject(responseString); OperationResult result = new OperationResult(response.newInputStream(), parameters, httpGETRequest); checkForExceptionReport(result, response); return result; } catch (IOException e) { throw new OXFException("Error while reading operation result.", e); } catch (XmlException e) { throw new OXFException("Could not parse response to XML.", e); } catch (HttpClientException e) { throw new OXFException("Could not send request.", e); } }
incomingResultAsStream = opResult.getIncomingResultAsStream(); DescribeSensorParser parser = new DescribeSensorParser(incomingResultAsStream, metadata);
HttpEntity responseEntity = httpResponse.getEntity(); if (httpResponse.getStatusLine().getStatusCode() != 204 && responseEntity.getContent() != null) { return new OperationResult(responseEntity.getContent(), parameterContainer, request);
protected OperationResultStore(OperationResult operationResult) throws OXFException { try { this.xmlObject = XMLBeansParser.parse(operationResult.getIncomingResultAsAutoCloseStream(), false); this.version = getVersion(operationResult); } catch (XMLHandlingException e) { throw new OXFException("Could not parse OperationResult.", e); } }
protected Map<Feature, Point> performGetFeatureOfInterest(TimeseriesParametersLookup lookup) throws OXFException, ExceptionReport { HashMap<Feature, Point> features = new HashMap<Feature, Point>(); for (Network network : networks.values()) { ParameterContainer paramCon = new ParameterContainer(); paramCon.addParameterShell(GET_FOI_SERVICE_PARAMETER, "SOS"); paramCon.addParameterShell(GET_FOI_VERSION_PARAMETER, getServiceVersion()); paramCon.addParameterShell("procedure", network.getNetwork()); Operation operation = new Operation("GetFeatureOfInterest", getServiceUrl(), getServiceUrl()); try { OperationResult result = getSosAdapter().doOperation(operation, paramCon); FeatureParser parser = new FeatureParser(getServiceUrl(), createEpsgStrictAxisOrder()); features.putAll(parser.parseFeatures(result.getIncomingResultAsStream())); } catch (OXFException e) { LOGGER.warn("Exception in OXF layer while executing operation", e); } catch (ExceptionReport e) { // TODO probably we do have to handle an ExceedsSizeLimitException here LOGGER.warn("Service returned an ExceptionReport", e); } } for (Feature feature : features.keySet()) { lookup.addFeature(feature); } return features; }
/** * @deprecated Use {@link SOSSensorStore#SOSSensorStore(OperationResult)} with {@link SOSSensorStore#unmarshalFeatures(OperationResult)} */ public OXFFeatureCollection unmarshalFeatures(OperationResult operationResult) throws OXFException { try { this.xmlObject = XMLBeansParser.parse(operationResult.getIncomingResultAsAutoCloseStream()); this.version = getVersion(operationResult); } catch (XMLHandlingException e) { throw new OXFException("Could not parse OperationResult", e); } return unmarshalFeatures(); }
return XmlObject.Factory.parse(result.getIncomingResultAsStream());
private boolean requestCapabilities() { SESAdapter adapter = new SESAdapter("0.0.0"); Operation op = new Operation(SESAdapter.GET_CAPABILITIES, null, host.toExternalForm()); ParameterContainer parameter = new ParameterContainer(); try { parameter.addParameterShell(ISESRequestBuilder.GET_CAPABILITIES_SES_URL, host.toExternalForm()); OperationResult opResult = adapter.doOperation(op, parameter); if (opResult == null) return false; XmlObject response = XmlObject.Factory.parse(opResult.getIncomingResultAsAutoCloseStream()); if (response instanceof EnvelopeDocument) { if (((EnvelopeDocument) response).getEnvelope().getBody().xmlText().contains("Capabilities")) { return true; } } } catch (OXFException e) { logger.warn(e.getMessage()); } catch (XmlException e) { logger.warn(e.getMessage()); } catch (IOException e) { logger.warn(e.getMessage()); } catch (ExceptionReport e) { logger.warn(e.getMessage()); } return false; } }).start();