/** {@inheritDoc} */ public ContentCollection getCollection(String id) { ContentCollection cc = storage.getCollection(id); if (cc != null) { return cc; } ContentEntity rp = getRealParent(id); if (rp == null) { return null; } ContentEntity ce = getVirtualChild(id, rp, true); if (ce instanceof ContentCollection) { return (ContentCollection) ce; } return null; }
/** * Find the closest real ancestor to the requested id, this recurses into itself * * @param id * @return the closest ancestor or null if not found (bit unlikely) */ public ContentEntity getRealParent(String id) { ContentEntity ce = storage.getCollection(id); if (ce == null) { try { ce = storage.getResource(id); } catch (TypeException e) { log.debug("Type Exception ", e); } } if (ce == null) { if (id.equals(Entity.SEPARATOR)) { // If the entity is the root and we didint get anything, there is nothing we can do // no root, no content, no point in trying to get annother one log.fatal("Unable to get Root node of the repository"); throw new AssertionError("Unable to Get Root repository " + Entity.SEPARATOR); } int lastSlash = id.lastIndexOf(Entity.SEPARATOR, id.length() - 2); if (lastSlash > 0) { String parentId = id.substring(0, lastSlash + 1 /* [email protected] wanted a "- 1" here */); ce = getRealParent(parentId); } } return ce; }