Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #8351 (closed)

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

Bug: rendering read-only group

Reported by: wmoore Owned by: wmoore
Priority: critical Milestone: OMERO-4.4
Component: OmeroPy Version: n.a.
Keywords: n.a. Cc: cxallan, jamoore, atarkowska, cneves
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: 0.0d
Sprint: 2012-04-10 (12)

Description

Trying to view another user's thumbnail etc from a read-only group (which is not my 'active group') fails when trying to resetDefaults:

2012-03-21 12:59:09,585 ERROR [                           omero.gateway] (proc.87833) getThumbnail:5825 Traceback (most recent call last):
  File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py", line 5780, in getThumbnail
    tb = self._prepareTB()
  File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py", line 5675, in _prepareTB
    tb.resetDefaults(sopts)      # E.g. May throw Missing Pyramid Exception
  File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py", line 3111, in __call__
    return self.handle_exception(e, *args, **kwargs)
  File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/webclient/webclient_gateway.py", line 1671, in handle_exception
    e, *args, **kwargs)
  File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py", line 3108, in __call__
    return self.f(*args, **kwargs)
  File "/Users/will/Desktop/OMERO/dist/lib/python/omero_api_ThumbnailStore_ice.py", line 323, in resetDefaults
    return _M_omero.api.ThumbnailStore._op_resetDefaults.invoke(self, ((), _ctx))
ApiUsageException: exception ::omero::ApiUsageException
{
    serverStackTrace = ome.conditions.ApiUsageException: Unable to reset rendering settings in a read-only group for Pixels set id:2071
	at ome.services.ThumbnailBean.resetDefaults(ThumbnailBean.java:1232)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
	at ome.security.basic.EventHandler.invoke(EventHandler.java:165)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at ome.tools.hibernate.SessionHandler.doStateful(SessionHandler.java:182)
	at ome.tools.hibernate.SessionHandler.invoke(SessionHandler.java:166)

Trying to view image in Image Viewer I get

2012-03-21 13:09:21,428 WARNI [                           omero.gateway] (proc.87833) debug:3090 ApiUsageException on <class 'webclient.webclient_gateway.OmeroWebSafeCallWrapper'> to <43a05464-7e50-4410-a7ce-792122e00cbcomero.api.RenderingEngine> resetDefaults(({'omero.group': '103'},), {})
Traceback (most recent call last):
  File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py", line 3108, in __call__
    return self.f(*args, **kwargs)
  File "/Users/will/Desktop/OMERO/dist/lib/python/omero_api_RenderingEngine_ice.py", line 755, in resetDefaults
    return _M_omero.api.RenderingEngine._op_resetDefaults.invoke(self, ((), _ctx))
ApiUsageException: exception ::omero::ApiUsageException
{
    serverStackTrace = ome.conditions.ApiUsageException: RenderingEngine not ready: renderer is null.
This method can only be called after the renderer is properly initialized (not-null).
Try lookup and/or use methods.
	at ome.services.RenderingBean.errorIfNullRenderer(RenderingBean.java:1576)
	at ome.services.RenderingBean.errorIfInvalidState(RenderingBean.java:1545)
	at ome.services.RenderingBean.resetDefaults(RenderingBean.java:677)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)

Change History (10)

comment:1 Changed 7 years ago by wmoore

  • Summary changed from Bug: to Bug: rendering read-only group

When the read-only group is not my 'active group' this returns false

has_rendering_settings = tb.setPixelsId(pid, self._conn.CONFIG['SERVICE_OPTS'])

even though I have "omero.group":"-1".
When I switch my active group to the read-only group that this image is in, the above line returns True.

comment:2 Changed 7 years ago by wmoore

I'll try to write a test to reproduce this. Try with different values of omero.group. E.g. -1, groupId etc.

comment:3 Changed 7 years ago by wmoore

Failing test: (so far this only has group:-1). https://github.com/will-moore/openmicroscopy/commit/36c98188cccb2dc0a6ccc3f8f268e590b898c265
on branch https://github.com/will-moore/openmicroscopy/tree/thumbs_test_8351

Reproduces the stack track above...

$ python test/integration/thumbnailPerms.py TestThumbnailPerms.testRendering_8351
WARNING:omero.gateway:ApiUsageException on <class 'omero.gateway.OmeroGatewaySafeCallWrapper'> to <0e505f75-5422-43cc-b1c8-751449dffc27omero.api.ThumbnailStore> resetDefaults(({'omero.group': '700'},), {})
Traceback (most recent call last):
  File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py", line 3155, in __call__
    return self.f(*args, **kwargs)
  File "/Users/will/Desktop/OMERO/dist/lib/python/omero_api_ThumbnailStore_ice.py", line 323, in resetDefaults
    return _M_omero.api.ThumbnailStore._op_resetDefaults.invoke(self, ((), _ctx))
ApiUsageException: exception ::omero::ApiUsageException
{
    serverStackTrace = ome.conditions.ApiUsageException: Unable to reset rendering settings in a read-only group for Pixels set id:4418
	at ome.services.ThumbnailBean.resetDefaults(ThumbnailBean.java:1232)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
...
	at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:643)
	at java.lang.Thread.run(Thread.java:680)

    serverExceptionClass = ome.conditions.ApiUsageException
    message = Unable to reset rendering settings in a read-only group for Pixels set id:4418
}

F
======================================================================
FAIL: testRendering_8351 (__main__.TestThumbnailPerms)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/integration/thumbnailPerms.py", line 123, in testRendering_8351
    self.assertNotEquals(None, imageWrapper.getThumbnail())
AssertionError: None == None

----------------------------------------------------------------------
Ran 1 test in 0.981s

FAILED (failures=1)

comment:4 Changed 7 years ago by wmoore

  • Owner changed from wmoore to jmoore

Updated the tests with https://github.com/will-moore/openmicroscopy/commit/c3194bce32785d43946cd9f965d129fbc7b2f691

It seems that using "omero.group": "-1" fails both using the Blitz Gateway and using the thumbnail store directly, whereas using "omero.group":gid works in both cases.

Passing to Josh...

comment:5 Changed 7 years ago by jburel

  • Sprint changed from 2012-03-27 (11) to 2012-04-10 (12)

Moved from sprint 2012-03-27 (11)

comment:6 Changed 7 years ago by jmoore

  • Remaining Time set to 0.25
  • Status changed from new to accepted

Going to try to take a look at this now.

comment:7 Changed 7 years ago by jmoore

Here's the code for the exception being eaten:

5717 	        if rdid is None:
5718 	            if not has_rendering_settings:
5719 	                try:
5720 	                    sopts = dict(self._conn.CONFIG['SERVICE_OPTS'] or {})
5721 	                    sopts['omero.group'] = str(self.getDetails().getGroup().getId())
5722 ->	                    tb.resetDefaults(sopts)      # E.g. May throw Missing Pyramid Exception
5723 	                except omero.ConcurrencyException, ce:
5724 	                    logger.info( "ConcurrencyException: resetDefaults() failed in _prepareTB with backOff: %s" % ce.backOff)
5725 	                    return tb
5726 	                tb.setPixelsId(pid, self._conn.CONFIG['SERVICE_OPTS'])

which gets caught here:

    #@setsessiongroup
    def getThumbnail (self, size=(64,64), z=None, t=None):
...
        except Exception: #pragma: no cover
            logger.error(traceback.format_exc())
            if tb is not None:
                tb.close()
            return None

comment:8 Changed 7 years ago by jmoore

  • Owner changed from jmoore to wmoore

I think what's happening here is that the check for isGraphCritical says whether or not a user is a PI (group-owner):

// CurrentDetails.java
    /**
     * @see SecuritySystem#isGraphCritical()
     * @return
     */
    public boolean isGraphCritical() {
        EventContext ec = getCurrentEventContext();
        long gid = ec.getCurrentGroupId();
        Permissions perms = ec.getCurrentGroupPermissions();

        boolean admin = ec.isCurrentUserAdmin();
        boolean pi = ec.getLeaderOfGroupsList().contains(gid);

        if (perms.isGranted(Role.WORLD, Right.READ)) {
            // Public groups (rwrwrw) are always non-critical
            return false;
        } else if (perms.isGranted(Role.GROUP, Right.READ)) {
            // Since the object will be contained in the group,
            // then it will be readable regardless.
            return false;
        } else {
            // This is a private group. Any form of admin modification is
            // critical.
            return admin || pi;
        }
    }

When the current group is set to -1, it's no longer a PI of the current group, and therefore isGraphCritical is returning false and an attempt is made to create a rdef in a READ-ONLY group.

Options:

  • update isGraphCritical to return true for group=-1. I'm not sure what the total impact of that would be
  • always pass a specific group id for methods that rely on isGraphCritical
  • somehow set the group explicitly based on the image ID in question within the thumb bean/ctx

I'm pushing back to you, Will. If you can't solve this by the second option (explicitly passing the gid) then please see if Chris has a preference for which method we use.

comment:9 Changed 7 years ago by wmoore

  • Remaining Time changed from 0.25 to 0
  • Resolution set to fixed
  • Status changed from accepted to closed

Josh - as suggested, I've used omero.goup:groupId for all method calls in Blitz Gateway _prepareRE and _prepareTB. This fixes the Thumbnail bug above, and a similar problem for the Rendering Engine.

This is in commit https://github.com/will-moore/openmicroscopy/commit/1642514822644e5084960b56aca6c3703bbbc037 in my branch https://github.com/will-moore/openmicroscopy/tree/users_8235

However, as discussed on Friday, this work is likely not to be included in the 4.4 release for web, so we may want to include this commit in a bug-fix branch so that it gets into 4.4?

Closing...

comment:10 Changed 7 years ago by Will Moore <will@…>

(In [aa0c26c9982a5d955c4abb29e0f4438fd90a65bc/ome.git] on branch develop) CHERRY-PICK Use 'omero.group':gid to Blitz _prepareTB & _prepareRE. Close #8351

This allows rendering Engine and Thumbnail Store to be prepared for an image in a read-only group when
the current user is not the owner and is logged in to a different group.

Conflicts:

components/tools/OmeroPy/src/omero/gateway/init.py

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.78384 sec.)

We're Hiring!