// Otherwise, if the final path does not have a Cell directory,
// this is ok. It just means that Cell has no children, so we
// return an empty list.
LOGGER.fine("Did not find a WFS Cell directory for path " +
path + ". This is ok, returning empty list.");
CellList children = new CellList(path, new Cell[] {});
return Response.ok(children).build();
}
}
// If we have reached here, we have 'dir' with the directory in which
// the cells should be. Create a WFSCellChildren object which is used
// to serialize the result.
String names[] = dir.getCellNames();
if (names == null) {
// If the directory exists, yet there are no children, this is ok.
// Just return an empty list.
LOGGER.fine("Did not find WFS Cell children for path " + path +
". This is ok, returning empty list.");
CellList children = new CellList(path, new Cell[]{});
return Response.ok(children).build();
}
LOGGER.fine("For WFS Cell " + path + " # Children " + names.length);
// Loop through and create the WFSCellChildren object, we need to
// include the last modified time so that the client can check whether
// the cell has been modified or not.
LinkedList<Cell> list = new LinkedList<Cell>();
for (String name : names) {
WFSCell cell = dir.getCellByName(name);
if (cell == null) {
LOGGER.warning("No WFS cell exists with name " + name);
continue;
}
LOGGER.fine("Found WFS child " + name + " in path " + path);
list.add(new Cell(name, cell.getLastModified()));
}
// Convert the list of CellChilds to an array, form into a CellList and
// send the CellList directly to the client.
Cell[] childs = list.toArray(new Cell[] {});
LOGGER.fine("For WFS Cell " + path + " setting children array " +
childs);
CellList children = new CellList(path, childs);
return Response.ok(children).build();
}