[ome-users] NegativeSizeException using getUserDetails

Bernhard Voigt bernhard.voigt at gmail.com
Wed Dec 17 13:49:28 GMT 2008


Dear Mario!

I compiled your code and it works fine for me under Beta 3.1.1.

By the way, you need to adapt the check of the returned map, the map will
always have keys that you've originally passed to the query method. It will
have null pointers or objects as values. The objects need to be casted,
before you have access to the methods - this is Ice-specific:

for(im=m.begin(); im != m.end(); ++im) {
      cout << im->first;
      omero::model::ExperimenterIPtr user =
omero::model::ExperimenterIPtr::dynamicCast(im->second);
      if (user) {
    cout << " id: " << user->getId();
      } else {
    cout << " not found";
      }
      cout << endl;
    }

Best wishes! Bernhard


On Tue, Dec 16, 2008 at 4:13 PM, Mario Valle <mvalle at cscs.ch> wrote:

> I'm expanding the simple client to try to learn OmeroCpp.
> The example below works (and obviously returns no result) if you comment
> the line marked //1
> Otherwise it crashes in the getUserDetails() call with:
> terminate called after throwing an instance of 'Ice::NegativeSizeException'
>   what():  /Users/mvalle/Ice-3.3.0/cpp/include/Ice/BasicStream.h:360:
> Ice::NegativeSizeException:
> protocol error: negative size for sequence, dictionary, etc.
>
> The code is translated (hopefully correctly) from the shoola
> OMEROGateway.java file around
> line 1015.
>
> Anyway, is anyone around that have any OmeroCpp client code to share?
>
> Thanks!
>        mario
>
> #include <omero/client.h>
> #include <iostream>
>
> using namespace std;
>
> int main(int argc, char* argv[])
> {
>     //
>     // Connect to OMERO
>     //
>     cout << "--- Connect ---" << endl;
>     omero::client omero(argc, argv);
>     omero::api::ServiceFactoryPrx sf = omero.createSession();
>     sf->closeOnDestroy();
>
>     //
>     // Try the Pojos services
>     //
>     cout << "--- Pojos ---" << endl;
>
>     omero::api::IPojosPrx pojo = omero.getSession()->getPojosService();
>
>     omero::api::StringSet list;
>     list.push_back("mvalle");  //1
>
>     omero::sys::ParamMap options;
>     omero::api::UserMap m;
>
>     m = pojo->getUserDetails(list, options);
>
>     //
>     // Look at the results
>     //
>     cout << "--- getUserDetails ---" << endl;
>     cout << m.size() << endl;
>
>     omero::api::UserMap::const_iterator im;
>     for(im=m.begin(); im != m.end(); ++im) cout << im->first << endl;
>
>     //
>     // Check the IAdmin interface
>     //
>     cout << "--- Admin ---" << endl;
>
>     // IAdmin is responsible for all user/group creation, password
> changing, etc.
>     omero::api::IAdminPrx  admin = omero.getSession()->getAdminService();
>
>     // Who you are logged in as.
>     cout << admin->getEventContext()->userName << endl;
>
>     return 0;
> }
> ~
>
>
>
> --
> Ing. Mario Valle
> Data Analysis Group                              |
> http://www.cscs.ch/~mvalle <http://www.cscs.ch/%7Emvalle>
> Swiss National Supercomputing Centre (CSCS)      | Tel:  +41 (91) 610.82.60
> v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82
> _______________________________________________
> ome-users mailing list
> ome-users at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-users/attachments/20081217/050f9ff6/attachment.html>


More information about the ome-users mailing list