public int isValid( SourceValidity newValidity ) { if( newValidity instanceof TimeStampValidity ) { final long timeStamp = ( (TimeStampValidity)newValidity ).getTimeStamp(); return (m_timeStamp == timeStamp ? +1 : -1); } return -1; }
public int isValid( final SourceValidity newValidity ) { if( newValidity instanceof FileTimeStampValidity ) { final long timeStamp = ( (FileTimeStampValidity)newValidity ).getTimeStamp(); return ( m_timeStamp == timeStamp ? 1 : -1); } return -1; }
public SourceValidity getExpiresValidity() { if ( this.expires > 0 && this.validity == null) { this.validity = new ExpiresValidity( this.expires * 1000 ); // milliseconds } return this.validity; }
/** * Generate the validity object. Before this method can be invoked the * generateKey() method must be invoked. * * @return The generated validity object or <code>null</code> if the * component is currently not cacheable. */ public SourceValidity getValidity() { if (this.inputSource.getLastModified()!=0) { AggregatedValidity validity = new AggregatedValidity(); validity.add(new TimeStampValidity(page)); validity.add(this.inputSource.getValidity()); return validity; } else { return null; } }
/** * Generate the validity object. * * @return The generated validity object or <code>null</code> if the * component is currently not cacheable. */ public SourceValidity getValidity() { final long lm = getLastModified(); if(lm > 0) { return new TimeStampValidity(lm); } return null; }
/** * Generate the validity object. * * @return The generated validity object or <code>null</code> if the * component is currently not cacheable. */ public SourceValidity getValidity() { try { AggregatedValidity v = new AggregatedValidity(); for (int i = 0; i < this.parts.size(); i++) { final Source current = ((Part) this.parts.get(i)).source; final SourceValidity sv = current.getValidity(); if (sv == null) { return null; } else { v.add(sv); } } return v; } catch (Exception e) { getLogger().error("Could not getValidity", e); return null; } }
public boolean checkValidity(CachedSourceResponse response, Source source, long expires) { final SourceValidity[] validities = response.getValidityObjects(); boolean valid = true; final ExpiresValidity expiresValidity = (ExpiresValidity) validities[0]; final SourceValidity sourceValidity = validities[1]; if (expiresValidity.isValid() != SourceValidity.VALID) { int validity = sourceValidity != null? sourceValidity.isValid() : SourceValidity.INVALID; if (validity == SourceValidity.INVALID || validity == SourceValidity.UNKNOWN && sourceValidity.isValid(source.getValidity()) != SourceValidity.VALID) { if (logger.isDebugEnabled()) { logger.debug("Response expired, invalid for " + logger); } valid = false; } else { if (logger.isDebugEnabled()) { logger.debug("Response expired, still valid for " + logger); } // set new expiration period validities[0] = new ExpiresValidity(expires); } } else { if (logger.isDebugEnabled()) { logger.debug("Response not expired for " + logger); } } return valid; }
final SourceValidity srcA = this.getValidity(i); int result = srcA.isValid(); if ( result == -1) final SourceValidity srcB = aggregatedValidity.getValidity(i); result = srcA.isValid( srcB ); if ( result < 1)
SourceValidity getValidity(final int index) { final Object o = m_list.get(index); final SourceValidity validity; if (o instanceof SourceValidity) { validity = (SourceValidity)o; } else { validity = ((DeferredValidity)o).getValidity(); m_list.set(index, validity); } return validity; }
/** * Return a validity object based on the file's modification date. * * @see org.apache.excalibur.source.Source#getValidity() */ public SourceValidity getValidity() { if (this.m_file.exists()) { return new FileTimeStampValidity(this.m_file); } else { return null; } }
private void writeObject(java.io.ObjectOutputStream out) throws IOException { // resolve all deferred source validities first for(int i=0; i<m_list.size();i++) { this.getValidity(i); } out.defaultWriteObject(); }
/** * Returns {@link TimeStampValidity} as resources may change in a directory-based classloader. */ public SourceValidity getValidity() { return new TimeStampValidity(getLastModified()); }
/** * Generate the cache validity object. * */ public SourceValidity getValidity() { if (this.validity == null) { long expiry = System.currentTimeMillis() + ConfigurationManager.getLongProperty("websvc.opensearch.validity") * 60 * 60 * 1000; this.validity = new ExpiresValidity(expiry); } return this.validity; }
/** * Check if the component is still valid. * If <code>0</code> is returned the isValid(SourceValidity) must be * called afterwards! * If -1 is returned, the component is not valid anymore and if +1 * is returnd, the component is valid. */ public int isValid() { for( final ListIterator i = m_list.listIterator(); i.hasNext(); ) { final Object o = i.next(); final SourceValidity validity; if (o instanceof SourceValidity) { validity = (SourceValidity)o; } else { validity = ((DeferredValidity)o).getValidity(); i.set(validity); } final int v = validity.isValid(); if( v < 1 ) { return v; } } return 1; }
/** * Get the Validity object. This can either wrap the last modification * date or the expires information or... * If it is currently not possible to calculate such an information * <code>null</code> is returned. */ public SourceValidity getValidity() { long lastModified = getLastModified(); if (lastModified > 0) { return new TimeStampValidity(lastModified); } return null; }
public SourceValidity[] getCacheValidities(CachingSource cachingSource, Source source) { return new SourceValidity[] { new ExpiresValidity(cachingSource.getExpiration()), source.getValidity() }; }
/** * Get the Validity object. This can either wrap the last modification * date or the expires information or... * If it is currently not possible to calculate such an information * <code>null</code> is returned. */ public SourceValidity getValidity() { final long lm = getLastModified(); if (lm > 0) { if (lm == m_cachedLastModificationDate) return m_cachedValidity; m_cachedLastModificationDate = lm; m_cachedValidity = new TimeStampValidity(lm); return m_cachedValidity; } return null; }
validities[0] = new ExpiresValidity(((Long)object[2]).longValue() * 1000); // milliseconds! CachedResponse response = new CachedResponse(validities, (byte[])serializer.getSAXFragment());
/** * Obtain a {@link SourceValidity} object. * * @return a {@link SourceValidity} object, or * <code>null</code> if this is not possible. */ public SourceValidity getValidity() { // Implementation taken from URLSource.java, Kudos :) final long lm = this.getLastModified(); if ( lm > 0 ) { if ( lm == this.m_cachedLastModificationDate ) { return this.m_cachedValidity; } this.m_cachedLastModificationDate = lm; this.m_cachedValidity = new TimeStampValidity( lm ); return this.m_cachedValidity; } return null; }
this.validity = new ExpiresValidity(interval); } else { this.validity = null;