@ Override @ RequestCache public boolean canPrincipalManage ( IAuthorizationPrincipal principal , String portletDefinitionId ) throws AuthorizationException { final String owner = IPermission . PORTAL_PUBLISH ; final String target = IPermission . PORTLET_PREFIX + portletDefinitionId ; // Retrieve the indicated portlet from the portlet registry store and // determine its current lifecycle state. IPortletDefinition portlet = this . portletDefinitionRegistry . getPortletDefinition ( portletDefinitionId ) ; if ( portlet == null ) { /* * Is this what happens when a portlet is new? Shouldn't we * be checking PORTLET_MANAGER_CREATED_ACTIVITY in that case? */ return doesPrincipalHavePermission ( principal , owner , IPermission . PORTLET_MANAGER_APPROVED_ACTIVITY , target ) ; } /* * The following code assumes that later lifecycle states imply permission * for earlier lifecycle states. For example, if a user has permission to * manage an expired channel, we assume s/he also has permission to * create, approve, and publish channels. The following code counts * channels with auto-publish or auto-expiration dates set as requiring * publish or expiration permissions for management, even though the channel * may not yet be published or expired. */ final IPortletLifecycleEntry highestLifecycleEntryDefined = portlet . getLifecycle ( ) . get ( portlet . getLifecycle ( ) . size ( ) - 1 ) ; String activity ; switch ( highestLifecycleEntryDefined . getLifecycleState ( ) ) { case CREATED : activity = IPermission . PORTLET_MANAGER_CREATED_ACTIVITY ; break ; case APPROVED : activity = IPermission . PORTLET_MANAGER_APPROVED_ACTIVITY ; break ; case PUBLISHED : activity = IPermission . PORTLET_MANAGER_ACTIVITY ; break ; case EXPIRED : activity = IPermission . PORTLET_MANAGER_EXPIRED_ACTIVITY ; break ; case MAINTENANCE : activity = IPermission . PORTLET_MANAGER_MAINTENANCE_ACTIVITY ; break ; default : final String msg = "Unrecognized portlet lifecycle state: " + highestLifecycleEntryDefined . getLifecycleState ( ) ; throw new IllegalStateException ( msg ) ; } return doesPrincipalHavePermission ( principal , owner , activity , target ) ; }
Answers if the principal has permission to MANAGE this Channel .