@Test public void testBBoxRawDataOutput(){ IData envelope = new BoundingBoxData( new double[] { 46, 102 }, new double[] { 47, 103 }, null); InputStream is; try { RawData bboxRawData = new RawData(envelope, "BBOXOutputData", null, null, null, identifier, processDescription); is = bboxRawData.getAsStream(); XmlObject bboxXMLObject = XmlObject.Factory.parse(is); assertTrue(bboxXMLObject != null); assertTrue(bboxXMLObject.getDomNode().getFirstChild().getNodeName().equals("wps:BoundingBoxData")); } catch (Exception e) { fail(e.getMessage()); } }
public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); }
RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } }
RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } RawData(IData obj, String id, String schema, String encoding,
                   String mimeType, String algorithmIdentifier,
                   ProcessDescriptionType description); }
RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } RawData(IData obj, String id, String schema, String encoding,
                   String mimeType, String algorithmIdentifier,
                   ProcessDescriptionType description); InputStream getAsStream(); }
RawData extends ResponseData { public InputStream getAsStream() throws ExceptionReport { try { if(obj instanceof ILiteralData){ return new ByteArrayInputStream(String.valueOf(obj.getPayload()).getBytes(Charsets.UTF_8)); } if(obj instanceof IBBOXData){ IBBOXData bbox = (IBBOXData) obj; StringBuilder builder = new StringBuilder(); builder.append("<wps:BoundingBoxData"); appendAttr(builder, "xmlns:ows", XMLBeansHelper.NS_OWS_1_1); appendAttr(builder, "xmlns:wps", XMLBeansHelper.NS_WPS_1_0_0); if (bbox.getCRS() != null) { appendAttr(builder, "crs", escape(bbox.getCRS())); } appendAttr(builder, "dimensions", bbox.getDimension()); builder.append(">"); builder.append("\n\t"); builder.append("<ows:LowerCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getLowerCorner())); builder.append("</ows:LowerCorner>"); builder.append("\n\t"); builder.append("<ows:UpperCorner>"); SPACE_JOINER.appendTo(builder, Doubles.asList(bbox.getUpperCorner())); builder.append("</ows:UpperCorner>"); builder.append("\n"); builder.append("</wps:BoundingBoxData>"); return new ByteArrayInputStream(builder.toString().getBytes(Charsets.UTF_8)); } if(encoding == null || "".equals(encoding) || encoding.equalsIgnoreCase(IOHandler.DEFAULT_ENCODING)){ return generator.generateStream(obj, mimeType, schema); } else if(encoding.equalsIgnoreCase(IOHandler.ENCODING_BASE64)){ return generator.generateBase64Stream(obj, mimeType, schema); } } catch (IOException e) { throw new ExceptionReport("Error while generating Complex Data out of the process result", ExceptionReport.NO_APPLICABLE_CODE, e); } throw new ExceptionReport("Could not determine encoding. Use default (=not set) or base64", ExceptionReport.NO_APPLICABLE_CODE); } RawData(IData obj, String id, String schema, String encoding,
                   String mimeType, String algorithmIdentifier,
                   ProcessDescriptionType description); InputStream getAsStream(); static final Joiner SPACE_JOINER; }