[ome-devel] Add a file annotation

Matthias Dunda Matthias.Dunda at carus-it.com
Fri Feb 20 13:45:51 GMT 2009


Thanks Jean-Marie,

i cannot create my RawFileStore.

I have:

private void init() throws Exception {
                               client = new omero.client(host);
                               ServiceFactoryPrx sf = client.createSession(user, pass);
                               oms = new OMEROMetadataStoreClient();
                               oms.initialize(sf);
                               updateService = sf.getUpdateService();
                               queryService = sf.getQueryService();
                               adminService = sf.getAdminService();
                }

and later in the code I do:

RawFileStorePrx rfs = sf.createRawFileStore();

which gives me a NullPointerException (without further information like stack trace etc.)

Please find attached the last lines of master.out.

Cheers
Matthias

Von: jburel [mailto:j.burel at dundee.ac.uk]
Gesendet: Freitag, 20. Februar 2009 12:59
An: Matthias Dunda
Cc: ome-devel at lists.openmicroscopy.org.uk
Betreff: Re: [ome-devel] Add a file annotation

Hi Matthias
Follow some code from the OMEROGateway (shoola code base)
You need to use the rawfile store
File file
RawFileStorePrx store = getRawFileService();
OriginalFile save = null;
Format f = (Format) getQueryService().findByString(Format.class.getName(), "value", format);
oFile = new OriginalFileI();
oFile.setName(omero.rtypes.rstring(file.getName()));
oFile.setPath(omero.rtypes.rstring(file.getAbsolutePath()));
oFile.setSize(omero.rtypes.rlong(file.length()));
oFile.setSha1(omero.rtypes.rstring("pending"));
oFile.setFormat(f);
save = (OriginalFile) saveAndReturnObject(oFile, null);
store.setFileId(save.getId().getValue());
byte[] buf = new byte[INC];
FileInputStream stream = null;
try {
                   stream = new FileInputStream(file);
                   long pos = 0;
                   int rlen;
                   ByteBuffer bbuf;
                   while ((rlen = stream.read(buf)) > 0) {
                          store.write(buf, pos, rlen);
                          pos += rlen;
                          bbuf = ByteBuffer.wrap(buf);
                          bbuf.limit(rlen);
                   }
                   stream.close();
            } catch (Exception e) {
                   try {
                          if (stream != null) stream.close();
                   } catch (Exception ex) {}


                   throw new DSAccessException("Cannot upload the file with path " +
                                 file.getAbsolutePath(), e);
            }
Then you link the original file to the file annotation.
FileAnnotation fa;
fa.setFile(of)
and save the file annotation

Regards
jmarie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20090220/499c3c8e/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: master.out
Type: application/octet-stream
Size: 9127 bytes
Desc: master.out
Url : http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20090220/499c3c8e/attachment-0001.obj 


More information about the ome-devel mailing list