*
* @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.DeleteBranchRequest)
*/
@Override
public void process( DeleteBranchRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
// Check the projection first ...
if (checkErrorOrCancel(request, federatedRequest)) return;
// Do an initial check to make sure that there was no error on the source that prevented projection
Request projectedSource = projected.getRequest();
if (checkErrorOrCancel(request, projectedSource)) return;
// Go through the projected requests, and look for the top-most node ...
Location highest = null;
while (projected != null) {
// The projected request should either be a DeleteChildrenRequest (if the node being deleted is
// at the top of a projection and therefore required to exist) or a DeleteBranchRequest (in all
// other cases)...
Location actual = null;
Request sourceRequest = projected.getRequest();
if (sourceRequest instanceof DeleteBranchRequest) {
DeleteBranchRequest source = (DeleteBranchRequest)projected.getRequest();
actual = source.getActualLocationOfNode();
} else {
DeleteChildrenRequest source = (DeleteChildrenRequest)projected.getRequest();
actual = source.getActualLocationOfNode();
}
if (checkErrorOrCancel(request, sourceRequest)) return;
if (!projected.isSameLocation() && projected.getProjection() != null) {
actual = projectToFederated(request.at(), projected.getProjection(), actual, request);
}
if (highest == null) highest = actual;
else if (highest.getPath().isDecendantOf(actual.getPath())) highest = actual;
projected = projected.next();
}
assert highest != null;
request.setActualLocationOfNode(highest);
}