protected void doOrderBefore(QPath srcPath, QPath destPath) throws RepositoryException
{
if (!getPrimaryNodeType().hasOrderableChildNodes())
{
throw new UnsupportedRepositoryOperationException("child node ordering not supported on node " + getPath());
}
if (srcPath.equals(destPath))
{
return;
}
// check existence
if (dataManager.getItemData(srcPath) == null)
{
throw new ItemNotFoundException(getPath() + " has no child node with name " + srcPath.getName().getAsString());
}
if (destPath != null && dataManager.getItemData(destPath) == null)
{
throw new ItemNotFoundException(getPath() + " has no child node with name " + destPath.getName().getAsString());
}
if (!checkedOut())
{
throw new VersionException(" cannot change child node ordering of a checked-in node ");
}
if (destPath != null && srcPath.getDepth() != destPath.getDepth())
{
throw new ItemNotFoundException("Source and destenation is not relative paths of depth one, "
+ "i.e. is not a childs of same parent node");
}
List<NodeData> siblings = new ArrayList<NodeData>(dataManager.getChildNodesData(nodeData()));
if (siblings.size() < 2)
{
throw new UnsupportedRepositoryOperationException("Nothing to order Count of child nodes " + siblings.size());
}
Collections.sort(siblings, new NodeDataOrderComparator());
// calculating source and destination position