String owner = IPermission.PORTAL_PUBLISH;
String target = IPermission.PORTLET_PREFIX + portletDefinitionId;
// 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 doesPrincipalHavePermission(principal, owner,
IPermission.PORTLET_MANAGER_APPROVED_ACTIVITY, target);
// throw new AuthorizationException("Unable to locate channel " + channelPublishId);
}
PortletLifecycleState state = portlet.getLifecycleState();
int order = state.getOrder();
/*
* 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.
*/
String activity = IPermission.PORTLET_MANAGER_MAINTENANCE_ACTIVITY;
if (order <= PortletLifecycleState.MAINTENANCE.getOrder()
&& doesPrincipalHavePermission(principal, owner, activity, target)) {
return true;
}
activity = IPermission.PORTLET_MANAGER_EXPIRED_ACTIVITY;
if ((order <= PortletLifecycleState.EXPIRED.getOrder()
|| portlet.getExpirationDate() != null)
&& doesPrincipalHavePermission(principal, owner, activity, target)) {
return true;
}
activity = IPermission.PORTLET_MANAGER_ACTIVITY;
if ((order <= PortletLifecycleState.PUBLISHED.getOrder()
|| portlet.getPublishDate() != null)
&& doesPrincipalHavePermission(principal, owner, activity, target)) {
return true;
}
activity = IPermission.PORTLET_MANAGER_APPROVED_ACTIVITY;