<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Monaco;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.apple-style-span
        {mso-style-name:apple-style-span;}
span.apple-tab-span
        {mso-style-name:apple-tab-span;}
span.E-MailFormatvorlage20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=DE link=blue vlink=purple style='word-wrap: break-word;-webkit-nbsp-mode: space;
-webkit-line-break: after-white-space'>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Thanks Jean-Marie,<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>i cannot create my RawFileStore.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I have:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>private void init() throws Exception {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> client
= new omero.client(host);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> ServiceFactoryPrx
sf = client.createSession(user, pass);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> oms
= new OMEROMetadataStoreClient();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> oms.initialize(sf);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> updateService
= sf.getUpdateService();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> queryService
= sf.getQueryService();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> adminService
= sf.getAdminService();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> }<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>and later in the code I do:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>RawFileStorePrx rfs = sf.createRawFileStore();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>which gives me a NullPointerException (without further
information like stack trace etc.)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Please find attached the last lines of master.out.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Cheers<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Matthias<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Von:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> jburel
[mailto:j.burel@dundee.ac.uk] <br>
<b>Gesendet:</b> Freitag, 20. Februar 2009 12:59<br>
<b>An:</b> Matthias Dunda<br>
<b>Cc:</b> ome-devel@lists.openmicroscopy.org.uk<br>
<b>Betreff:</b> Re: [ome-devel] Add a file annotation<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Hi Matthias<o:p></o:p></p>
<div>
<p class=MsoNormal>Follow some code from the OMEROGateway (shoola code base)<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>You need to use the rawfile store<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>File file<o:p></o:p></p>
</div>
<div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>RawFileStorePrx
store = getRawFileService();<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>OriginalFile
save = <span style='color:#0000D1'>null</span>;<o:p></o:p></span></p>
</div>
<div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>Format
f = (Format) getQueryService().findByString(Format.<span style='color:#0000D1'>class</span>.getName(), <span
style='color:#0000D1'>"value"</span>, format);<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>oFile
= <span style='color:#0000D1'>new</span> OriginalFileI();<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>oFile.setName(omero.rtypes.rstring(file.getName()));<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>oFile.setPath(omero.rtypes.rstring(file.getAbsolutePath()));<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>oFile.setSize(omero.rtypes.rlong(file.length()));<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>oFile.setSha1(omero.rtypes.rstring(<span
style='color:#0000D1'>"pending"</span>));<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>oFile.setFormat(f);<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>save
= (OriginalFile) saveAndReturnObject(oFile, <span style='color:#0000D1'>null</span>);<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-style-span><span style='font-size:8.5pt;
font-family:"Monaco","serif";color:black'>store.setFileId(save.getId().getValue());</span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:#018C67'><o:p></o:p></span></p>
</div>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif";
color:#0000D1'>byte</span><span style='font-size:8.5pt;font-family:"Monaco","serif"'>[]
buf = <span style='color:#0000D1'>new</span> <span style='color:#0000D1'>byte</span>[<span
style='color:#0000C0'>INC</span>]; <o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>FileInputStream
stream = <span style='color:#0000D1'>null</span>;<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif";
color:#0000D1'>try</span><span style='font-size:8.5pt;font-family:"Monaco","serif"'>
{<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>stream = <span
style='color:#0000D1'>new</span> FileInputStream(file);<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:#0000D1'>long</span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'> pos = 0;<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:#0000D1'>int</span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'> rlen;<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>ByteBuffer bbuf;<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:#0000D1'>while</span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'> ((rlen =
stream.read(buf)) > 0) {<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>store.write(buf, pos,
rlen);<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>pos += rlen;<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>bbuf =
ByteBuffer.wrap(buf);<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>bbuf.limit(rlen);<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>}<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>stream.close();<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>} <span style='color:#0000D1'>catch</span>
(Exception e) {<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:#0000D1'>try</span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'> {<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:#0000D1'>if</span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'> (stream != <span
style='color:#0000D1'>null</span>) stream.close();<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>} <span style='color:#0000D1'>catch</span>
(Exception ex) {}<o:p></o:p></span></p>
</div>
<p style='margin:0cm;margin-bottom:.0001pt;min-height: 15.0px'><span
class=apple-tab-span><span style='font-size:8.5pt;font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'><o:p></o:p></span></p>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif";color:black'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:#0000D1'>throw</span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:black'> </span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:#0000D1'>new</span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:black'>
DSAccessException(</span><span style='font-size:8.5pt;font-family:"Monaco","serif";
color:#0000D1'>"Cannot upload the file with path "</span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:black'> +</span><span
style='font-size:8.5pt;font-family:"Monaco","serif";color:#0000D1'><o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>file.getAbsolutePath(),
e);<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span class=apple-tab-span><span style='font-size:8.5pt;
font-family:"Monaco","serif"'> </span></span><span
style='font-size:8.5pt;font-family:"Monaco","serif"'>}<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>Then
you link the original file to the file annotation.<o:p></o:p></span></p>
</div>
<div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>FileAnnotation
fa;<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>fa.setFile(of)<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>and
save the file annotation<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'><o:p> </o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>Regards<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Monaco","serif"'>jmarie<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>