/** * Generate the cache validity object. * * <p>The validity object will include the collection being viewed and all recently submitted * items. This does not include the community / collection hierarch, when this changes they will * not be reflected in the cache. */ public SourceValidity getValidity() { if (this.validity == null) { try { DSpaceValidity validity = new DSpaceValidity(); DSpaceObject dso = HandleUtil.obtainHandle(objectModel); if (dso != null) { // Add the actual collection; validity.add(dso); } // add recently submitted items, serialize solr query contents. DiscoverResult response = getQueryResponse(dso); validity.add("numFound:" + response.getDspaceObjects().size()); for (DSpaceObject resultDso : response.getDspaceObjects()) { validity.add(resultDso); } for (String facetField : response.getFacetResults().keySet()) { validity.add(facetField); List<DiscoverResult.FacetResult> facetValues = response.getFacetResults().get(facetField); for (DiscoverResult.FacetResult facetValue : facetValues) { validity.add(facetValue.getAsFilterQuery() + facetValue.getCount()); } } this.validity = validity.complete(); } catch (Exception e) { // Just ignore all errors and return an invalid cache. } // TODO: dependent on tags as well :) } return this.validity; }