On Thu, Jun 5, 2014 at 4:01 PM, Justin Deoliveira <[email protected]
> wrote:
> What does the WPS spec say that binary encoded data is supposed to look
> like? Hard to visualize this one without some context but my first
> impression is that we could implement the encode() method for the binding
> and insert the binary/cdata encoded content directly into the dom element
> that is provided.
>
>
So had a look around and found this example of direct encoding, in
SimpleContentComplexEMFBinding:
/**
* Calls getValue() and appends the result as child text of
<tt>value</tt>.
*/
public Element encode(Object object, Document document, Element value)
throws Exception {
EObject eobject = (EObject) object;
if ( EMFUtils.has( eobject, "value") ) {
Object v = EMFUtils.get( ((EObject)object), "value" );
if ( v != null ) {
value.appendChild( document.createTextNode( v.toString() )
);
}
}
return value;
}
I guess the binding has to either implement encode, or to return the
properties, right?
One thing that bothers me about the above example is that it's memory
bound, if I have
a large binary to put in the output module, I'd rather go with a
ContentHandler instead,
which is what the binary delegates expect anyways, for example:
public class RawDataEncoderDelegate implements EncoderDelegate {
private RawData rawData;
public RawDataEncoderDelegate(RawData rawData) {
this.rawData = rawData;
}
* public void encode(ContentHandler output) throws Exception {*
InputStream is = null;
try {
is = rawData.getInputStream();
byte[] buffer = new byte[4096];
int read = 0;
while ((read = is.read(buffer)) > 0) {
char[] chars;
if (read == 4096) {
chars = new
String(Base64.encodeBase64(buffer)).toCharArray();
} else {
byte[] reducedBuffer = new byte[read];
System.arraycopy(buffer, 0, reducedBuffer, 0, read);
chars = new
String(Base64.encodeBase64(reducedBuffer)).toCharArray();
}
output.characters(chars, 0, chars.length);
}
} finally {
IOUtils.closeQuietly(is);
}
}
public void encode(OutputStream os) throws IOException {
IOUtils.copy(rawData.getInputStream(), os);
}
Is this possible?
Cheers
Andrea
--
==
GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.
==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
-------------------------------------------------------
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel