private NodeLocationWithParentImpl(Node node,String id,String path,Node cachedParent,String cachedParentId,boolean cacheIfPossible,ClientDocumentStfulImpl clientDoc)
{
super(clientDoc);
if (node == null) throw new ItsNatException("INTERNAL ERROR");
this.nodeLocationDeleg = getNodeLocationNotParent(node, id, path, clientDoc);
this.cachedParent = cachedParent;
this.cachedParentId = cachedParentId;
NodeCacheRegistryImpl nodeCache = clientDoc.getNodeCacheRegistry();
if ((nodeCache != null) && cacheIfPossible) // Aunque est� cacheado el nodo principal aprovechamos para cachear los padres.
{
// Cacheamos unos cuantos padres inmediatos para que los nodos "adyacentes" (de la zona en general)
// puedan encontrarse m�s r�pidamente, sobre todo si el cachedParent no se encontr� o est� muy arriba.
int maxParents = 3; // Un valor razonable para evitar cachear en exceso nodos padre (y enviar demasiado JavaScript)
// que a lo mejor no se usan nunca ni para el c�lculo de paths
Node currParent = node.getParentNode();
for(int i = 0; (currParent != null) && (currParent != cachedParent) && (i < maxParents); i++)
{
String parentId = nodeCache.getId(currParent);
if (parentId == null) // No cacheado
{
parentId = nodeCache.addNode(currParent);
if (parentId != null)
{
// Hemos cacheado un nuevo nodo, DEBEMOS LLAMAR toJSArray y enviar al cliente
// de otra manera el cliente NO se enterar� de este cacheado.
if (newCachedParentIds == null)
this.newCachedParentIds = new ArrayList<String>(maxParents);
newCachedParentIds.add(parentId);
currParent = currParent.getParentNode();
i++;
}
else currParent = null; // No se puede cachear, paramos
}
else currParent = null; // Ya cacheado, paramos
}
}
if ((nodeLocationDeleg instanceof NodeLocationAlreadyCachedNotParentImpl) && !isNull(cachedParentId)) throw new ItsNatException("INTERNAL ERROR");
}