public SourceValidity getValidity() { if (validity == null) { try { DSpaceValidity validity = new DSpaceValidity(); DSpaceObject dso = HandleUtil.obtainHandle(objectModel); if (dso != null) validity.add(dso); BrowseInfo info = getBrowseInfo(); // Are we browsing items, or unique metadata? if (isItemBrowse(info)) { // Add the browse items to the validity for (BrowseItem item : (java.util.List<BrowseItem>) info.getResults()) { validity.add(item); } } else { // Add the metadata to the validity for (String singleEntry : browseInfo.getStringResults()) { validity.add(singleEntry); } } } catch (Exception e) { // Just ignore all errors and return an invalid cache. } } return this.validity; }
/** * 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 { DSpaceObject dso = HandleUtil.obtainHandle(objectModel); if (dso == null) return null; if (!(dso instanceof Collection)) return null; Collection collection = (Collection) dso; DSpaceValidity validity = new DSpaceValidity(); // Add the actual collection; validity.add(collection); // add reciently submitted items for (BrowseItem item : getRecientlySubmittedIems(collection)) { validity.add(item); } this.validity = validity.complete(); } catch (Exception e) { // Just ignore all errors and return an invalid cache. } } return this.validity; }
/** * Generate the cache validity object. * * <p>This validity object should never "over cache" because it will perform the search, and * serialize the results using the DSpaceValidity object. */ public SourceValidity getValidity() { if (this.validity == null) { try { DSpaceValidity validity = new DSpaceValidity(); DSpaceObject scope = getScope(); validity.add(scope); performSearch(); validity.add("total:" + queryResults.getHitCount()); validity.add("start:" + queryResults.getStart()); @SuppressWarnings("unchecked") // This cast is correct java.util.List<String> handles = queryResults.getHitHandles(); for (String handle : handles) { DSpaceObject resultDSO = HandleManager.resolveToObject(context, handle); validity.add(resultDSO); } this.validity = validity.complete(); } catch (RuntimeException re) { throw re; } catch (Exception e) { this.validity = null; } // add log message that we are viewing the item // done here, as the serialization may not occur if the cache is valid logSearch(); } return this.validity; }
/** * 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; }