public static NodeSet checkAccess(NodeSet nodes, String actions)
{
if ((nodes != null) && !nodes.isEmpty())
{
// check permissions and constraints, filter nodes as required
NodeSetImpl filteredNodes = null;
Iterator checkAccessIter = nodes.iterator();
while (checkAccessIter.hasNext())
{
AbstractBaseElement node = (AbstractBaseElement)checkAccessIter.next();
try
{
// check access
node.checkAccess(actions);
// add to filteredNodes nodes if copying
if (filteredNodes != null)
{
// permitted, add to filteredNodes nodes
filteredNodes.add((Node)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(null, ((NodeSetImpl) nodes).getComparator());
Iterator copyIter = nodes.iterator();
while (copyIter.hasNext())
{
Node copyNode = (Node)copyIter.next();
if (copyNode != node)
{
filteredNodes.add(copyNode);
}
else
{
break;
}