String owner = IPermission.PORTAL_FRAMEWORK;
String target = IPermission.CHANNEL_PREFIX + channelPublishId;
// retrieve the indicated channel from the channel registry store and
// determine its current lifecycle state
IChannelDefinition channel = this.channelRegistryStore
.getChannelDefinition(channelPublishId);
if (channel == null){
return doesPrincipalHavePermission(principal, owner,
IPermission.CHANNEL_MANAGER_APPROVED_ACTIVITY, target);
// throw new AuthorizationException("Unable to locate channel " + channelPublishId);
}
ChannelLifecycleState state = channel.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 all = IPermission.ALL_CHANNELS_TARGET;
String activity = IPermission.CHANNEL_MANAGER_EXPIRED_ACTIVITY;
if ((order <= ChannelLifecycleState.EXPIRED.getOrder()
|| channel.getExpirationDate() != null)
&& (doesPrincipalHavePermission(principal, owner, activity, all)
|| doesPrincipalHavePermission(principal, owner,
activity, target))) {
return true;
}
activity = IPermission.CHANNEL_MANAGER_ACTIVITY;
if ((order <= ChannelLifecycleState.PUBLISHED.getOrder()
|| channel.getPublishDate() != null)
&& (doesPrincipalHavePermission(principal, owner, activity, all)
|| doesPrincipalHavePermission(principal, owner,
activity, target))) {
return true;
}