static NodeSet filterNodeSetByAccess(NodeSet nodes)
{
if ((nodes != null) && !nodes.isEmpty())
{
// check permissions and constraints, filter nodes as required
NodeSetImpl filteredNodes = null;
Iterator checkAccessIter = nodes.iterator();
while (checkAccessIter.hasNext())
{
Node node = (Node)checkAccessIter.next();
try
{
// check access
node.checkAccess(JetspeedActions.VIEW);
// add to filteredNodes nodes if copying
if (filteredNodes != null)
{
// permitted, add to filteredNodes nodes
filteredNodes.add(node);
}
}
catch (SecurityException se)
{
// create filteredNodes nodes if not already copying
if (filteredNodes == null)
{
// not permitted, copy previously permitted nodes
// to new filteredNodes node set with same comparator
filteredNodes = new NodeSetImpl(nodes);
Iterator copyIter = nodes.iterator();
while (copyIter.hasNext())
{
Node copyNode = (Node)copyIter.next();
if (copyNode != node)
{
filteredNodes.add(copyNode);
}
else
{
break;
}