private static void exportComplexInput( XMLStreamWriter writer, ComplexInput input ) throws XMLStreamException { if ( input instanceof EmbeddedComplexInput ) { writer.writeStartElement( WPS_NS, "Data" ); XMLStreamReader reader = ( (EmbeddedComplexInput) input ).getComplexDataAsXMLStream(); // copy "wps:ComplexData" element writeElement( writer, reader ); writer.writeEndElement(); } else if ( input instanceof ReferencedComplexInput ) { writer.writeStartElement( WPS_NS, "Reference" ); ReferencedComplexInput referencedInput = (ReferencedComplexInput) input; // "mimeType" attribute (optional) if ( referencedInput.getMimeType() != null ) { writer.writeAttribute( "mimeType", referencedInput.getMimeType() ); } // "encoding" attribute (optional) if ( referencedInput.getEncoding() != null ) { writer.writeAttribute( "encoding", referencedInput.getEncoding() ); } // "schema" attribute (optional) if ( referencedInput.getSchema() != null ) { writer.writeAttribute( "schema", referencedInput.getSchema() ); } // "xlink:href" attribute (required) writer.writeAttribute( XLN_NS, "href", "" + referencedInput.getURL() ); writer.writeEndElement(); } }
@Override public XMLStreamReader getValueAsXMLStream() throws IOException { XMLStreamReader reader = null; try { reader = XMLInputFactory.newInstance().createXMLStreamReader( getValueAsBinaryStream() ); reader.next(); } catch ( Exception e ) { throw new IOException( e.getMessage(), e ); } return new XMLStreamReaderWrapper( reader, XMLAdapter.DEFAULT_URL ); }
@Override public String toString() { return super.toString() + " (ReferencedComplexInput/Reference), inputReference=" + reference + ", mimeType='" + getMimeType() + "', encoding='" + getEncoding() + "', schema='" + getSchema() + "'"; } }
private static ComplexInput parseComplexInput( CodeType inputId, ComplexInputDefinition definition, AttributedParameter parameter, ExceptionCustomizer exceptionCustomizer ) throws OWSException { if ( parameter.getHref() == null ) { throw exceptionCustomizer.inputEvalutationNotSupported( inputId, new Pair<String, String>( "xlink:href", null ), "Inline complex values are not supported for KVP execute requests" ); } URL url = null; try { url = new URL( parameter.getHref() ); } catch ( MalformedURLException e ) { throw exceptionCustomizer.inputInvalidParameter( inputId, new Pair<String, String>( "xlink:href", parameter.getHref() ) ); } ComplexFormatType format = new ComplexFormatType(); format.setMimeType( parameter.getMimeType() ); format.setEncoding( parameter.getEncoding() ); format.setSchema( parameter.getSchema() ); ComplexFormatType augmentedFormat = validateAndAugmentFormat( format, definition, exceptionCustomizer ); InputReference reference = new InputReference( url, new HashMap<String, String>() ); return new ReferencedComplexInput( definition, null, null, augmentedFormat, reference ); }
return new ReferencedComplexInput( definition, title, summary, format, inputReference );