<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-family: Tahoma,Arial,Helvetica,sans-serif'>
<p>For now, the code below is working as expected:</p>
<p>1) MidPoint "stamp" (image) attribute in schema extension with "xsd:base64Binary" type.</p>
<p>2) SchemaScript.groovy:</p>
<p>account.addAttributeInfo(AttributeInfoBuilder.build("stamp", byte[].class));</p>
<p>3) SearchScript.groovy (read the stamp from database):</p>
<p>def stampquery = "select stamp from users" + where;<br />stamp_blob = sql.firstRow(stampquery).stamp;<br />if ( stamp_blob ) { stamp_in = stamp_blob.getBinaryStream().getBytes(); } else { stamp_in = null }</p>
<p>and set the attribute: stamp:stamp_in,</p>
<p>4) UpdateScript.groovy (write the stamp to datablase)</p>
<p>case "stamp":<br /> // oracle "blob" is an interface, write to the blob can be done using BinaryOutputStream.<br /> // first, we need to lock the blob in the database by running "select for update" query:<br /> blob_out = (oracle.sql.BLOB) sql.firstRow("select stamp from users where id = ? for update",[uid]).stamp;<br /> // now we have to define binary output stream to write the blob:<br /> outstream = ((BLOB)blob_out).getBinaryOutputStream();<br /> // and write the attribute received as a byte array to this stream:<br /> stamp_out = attributes?.get("stamp")?.get(0);<br /> outstream.write(stamp_out);<br /> // at the end we close the stream.<br /> outstream.close();<br /> break;</p>
<p>---------<br />Have fun.<br />Regards!<br />WS</p>
</body></html>