String adminRole = getServiceLocator().getPortalConfiguration().getString(PortalConfigurationConstants.ROLES_DEFAULT_ADMIN);
admin = getPortletRequest().isUserInRole(adminRole);
if (!admin && !principal.getType().getName().equals(JetspeedPrincipalType.USER))
{
// no non-user type principal modification is allowed if the current user itself doesn't have this principal
UserSubjectPrincipal currentUser = (UserSubjectPrincipal)getPortletRequest().getUserPrincipal();
if (!hasPrincipal(currentUser.getSubject(), principal))
{
modificationAllowed = false;
}
}
refreshList();
ListView commentListView = new ListView("comments",
new PropertyModel(this, "associations"))
{
public void populateItem(final ListItem listItem)
{
final JetspeedPrincipal principal = (JetspeedPrincipal) listItem
.getModelObject();
listItem.add(new Label("Name", principal.getName()));
boolean deleteAllowed = modificationAllowed;
Link deleteLink = new Link("delete")
{
@Override
public void onClick()
{
try
{
if (!associationsFrom)
{
getManager().removeAssociation(principal,
getPrincipal(), assoctionName);
} else
{
getManager().removeAssociation(
getPrincipal(), principal,
assoctionName);
}
refreshList();
} catch (Exception e)
{
// TODO: handle exception
}
}
};
deleteLink.add(new Label("deleteLabel", new ResourceModel(
"common.delete")));
if (!admin && deleteAllowed && !principal.getType().getName().equals(JetspeedPrincipalType.USER))
{
// restrict deleting non-user type principals to only those the current user itself has
UserSubjectPrincipal currentUser = (UserSubjectPrincipal)getPortletRequest().getUserPrincipal();
if (!hasPrincipal(currentUser.getSubject(), principal))
{
deleteAllowed = false;
}
}
if (!deleteAllowed || !modificationAllowed)