ALNode node = getLayoutNode(nodeId);
// Checking restrictions on the node
Collection restrictions = node.getRestrictionsByPath(IUserLayoutRestriction.LOCAL_RESTRICTION_PATH);
for ( Iterator i = restrictions.iterator(); i.hasNext(); ) {
IUserLayoutRestriction restriction = (IUserLayoutRestriction) i.next();
// check other restrictions except priority and depth
if ( !restriction.getName().equals(RestrictionTypes.DEPTH_RESTRICTION) &&
!restriction.getName().equals(RestrictionTypes.PRIORITY_RESTRICTION) &&
!restriction.checkRestriction(node) ) {
moveNodeToLostFolder(nodeId);
break;
}
}
// Checking the depth restriction
if ( !restrictionManager.checkRestriction(nodeId,RestrictionTypes.DEPTH_RESTRICTION,depth+"") ) {
moveNodeToLostFolder(nodeId);
}
// Checking children related restrictions on the children if they exist
restrictions = node.getRestrictionsByPath(IUserLayoutRestriction.CHILDREN_RESTRICTION_PATH);
boolean isFolder = (node.getNodeType() == IUserLayoutNodeDescription.FOLDER );
if ( isFolder ) {
for ( Iterator i = restrictions.iterator(); i.hasNext(); ) {
IUserLayoutRestriction restriction = (IUserLayoutRestriction) i.next();
for ( String nextId = ((ALFolder)node).getFirstChildNodeId(); nextId != null; ) {
ALNode nextNode = getLayoutNode(nextId);
String tmpNodeId = nextNode.getNextNodeId();
if ( !restriction.getName().equals(RestrictionTypes.DEPTH_RESTRICTION) &&
!restriction.checkRestriction(nextNode) ) {
moveNodeToLostFolder(nextId);
}
nextId = tmpNodeId;
}
}
}
// Checking parent related restrictions on the parent if it exists
String parentNodeId = node.getParentNodeId();
if ( parentNodeId != null ) {
restrictions = node.getRestrictionsByPath(IUserLayoutRestriction.PARENT_RESTRICTION_PATH);
ALNode parentNode = getLayoutNode(parentNodeId);
for ( Iterator i = restrictions.iterator(); i.hasNext(); ) {
IUserLayoutRestriction restriction = (IUserLayoutRestriction) i.next();
if ( !restriction.getName().equals(RestrictionTypes.DEPTH_RESTRICTION) &&
!restriction.checkRestriction(parentNode) ) {
moveNodeToLostFolder(nodeId);
break;
}
}
}