We're Hiring!

permission issue on annotation in matlab

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Re: permission issue on annotation in matlab

Postby jacques2020 » Fri Sep 09, 2016 4:27 am

Hi Josh,

I had a try of your python code but was not successfull (my code attached below). I cannot make the setSecurityContext to work either with
Code: Select all
self.sf=conn.getSession()
or
Code: Select all
self.sf=conn. secSecurityContext
is not a known method in all case. I went through the API doc for BlitzGateway and omero.model.session and it indeed appears nowhere. I tried to find my way in test_permission.py within the source code that appear to do what I tried to do but the test class definition through Pytest etc. are likely beyond my knowledge of python. Anyway, it was just to help and test your code. On my side, the issue in matlab is solved.

Cheers

Jacques



Code: Select all
from omero.gateway import *
from omero.model import *
class RootConn:
    def __init__(self):
      conn = BlitzGateway('root', '**********' host='host', port=4064)
      conn.connect()
      self.sf=conn.getSession()

class MyClass:
    def __init__(self):
      conn = BlitzGateway('J', '*****************', host='host', port=4064)
      connected = conn.connect()
      self.sf=conn
      self.root=RootConn()

    def testUserGroupLinkage(self):
            admin = self.sf.getAdminService()
            update = self.sf.getUpdateService()
            ugid = admin.getSecurityRoles().userGroupId
            ogid = admin.getEventContext().groupId

            # (1) We start off by assuming ogid == 3 as in your example
            # -------------------------------------------------------------------

            # (2) Then create a file annotation in the user's current group
            # -------------------------------------------------------------------
            fa = FileAnnotationI()
            fa = update.saveAndReturnObject(fa)
            assert fa.details.group.id.val == ogid

            # (3) Then we create a dataset in the "user" group (id=1)
            # -------------------------------------------------------------------
            ds = DatasetI()
            ds.setName(rstring("testUserGroupLinkage"))
            ds = update.saveAndReturnObject(ds)
            assert ds.details.group.id.val == ogid
            self.root.sf.setSecurityContext(ExperimenterGroupI(ogid, False))
            self.root.sf.getAdminService().moveToCommonSpace([ds])

            # (4) Now we link the two together.
            # -------------------------------------------------------------------
            dal = DatasetAnnotationLinkI()
            dal.parent = ds.proxy()
            dal.child = fa.proxy()
            dal = update.saveAndReturnObject(dal)

c = MyClass()
c.testUserGroupLinkage()
jacques2020
 
Posts: 102
Joined: Fri Jul 15, 2011 7:46 am

Re: permission issue on annotation in matlab

Postby jmoore » Fri Sep 09, 2016 6:47 am

Hi Jacques,

in my code, `self` was the ITest class. It has fields:

  • self.client of type omero.client.BaseClient and
  • self.sf of type omero.api.ServiceFactoryPrx

BaseClient has the field self.sf as well.

Your `conn` object is of type omero.gateway.BlitzGateway and has a field `self.c` of type BaseClient. In short, to get to the `sf` field, you need:

Code: Select all
self.conn.c.sf


Hope that helps.
~Josh.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: permission issue on annotation in matlab

Postby jacques2020 » Fri Sep 09, 2016 7:34 am

Great ! thank you.
With the suggested correction, the python code run smoothly. It does not reproduce the matlab bug.

Cheers

Jacques
jacques2020
 
Posts: 102
Joined: Fri Jul 15, 2011 7:46 am

Previous

Return to Developer Discussion

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron