@ Override @ RequestCache public boolean canPrincipalSubscribe ( IAuthorizationPrincipal principal , String portletDefinitionId ) { String owner = IPermission . PORTAL_SUBSCRIBE ; // retrieve the indicated channel from the channel registry store and // determine its current lifecycle state IPortletDefinition portlet = this . portletDefinitionRegistry . getPortletDefinition ( portletDefinitionId ) ; if ( portlet == null ) { return false ; } String target = PermissionHelper . permissionTargetIdForPortletDefinition ( portlet ) ; PortletLifecycleState state = portlet . getLifecycleState ( ) ; /* * Each channel lifecycle state now has its own subscribe permission. The * following logic checks the appropriate permission for the lifecycle. */ String permission ; if ( state . equals ( PortletLifecycleState . PUBLISHED ) || state . equals ( PortletLifecycleState . MAINTENANCE ) ) { // NB: There is no separate SUBSCRIBE permission for MAINTENANCE // mode; everyone simply sees the 'out of service' message permission = IPermission . PORTLET_SUBSCRIBER_ACTIVITY ; } else if ( state . equals ( PortletLifecycleState . APPROVED ) ) { permission = IPermission . PORTLET_SUBSCRIBER_APPROVED_ACTIVITY ; } else if ( state . equals ( PortletLifecycleState . CREATED ) ) { permission = IPermission . PORTLET_SUBSCRIBER_CREATED_ACTIVITY ; } else if ( state . equals ( PortletLifecycleState . EXPIRED ) ) { permission = IPermission . PORTLET_SUBSCRIBER_EXPIRED_ACTIVITY ; } else { throw new AuthorizationException ( "Unrecognized lifecycle state for channel " + portletDefinitionId ) ; } // Test the appropriate permission. return doesPrincipalHavePermission ( principal , owner , permission , target ) ; }
Answers if the principal has permission to SUBSCRIBE to this Channel .