public synchronized PolicyCollection getDocument(final CacheableYamlSource source) throws PoliciesParseException {
//        cacheTotal++;
        CacheItem entry = cache.get(source.getIdentity());

        long checkTime = System.currentTimeMillis();
        if (null == entry || ((checkTime - entry.cacheTime) > FILE_CHECK_DELAY)) {
            final long lastmod = source.getLastModified().getTime();
            if (null == entry || lastmod > entry.modTime) {
                    if (!source.isValid()) {
                        CacheItem remove = cache.remove(source.getIdentity());
                        entry = null;
//                        cacheRemove++;
                    } else {
//                        cacheMiss++;
                        ValidationSet validation = new ValidationSet();
                        PolicyCollection entry1 = createEntry(source, validation);
                        validation.complete();
                        if (null != entry1) {
                            entry = new CacheItem(entry1, lastmod);
                            cache.put(source.getIdentity(), entry);

                            if(!validation.isValid()){
                                logger.warn(validation.toString());
                                System.err.println(validation.toString());
                            }
                        } else {
                            cache.remove(source.getIdentity());
                            entry = null;

                            if(!validation.isValid()){
                                throw new PoliciesParseException(validation.toString());
                            }
                        }
                    }
            }else{
//                cacheUnmodifiedHit++;
                entry.touch(checkTime);
            }
        }else{
//            cacheHit++;
        }
        return null != entry ? entry.policyCollection : null;
    }
public synchronized PolicyCollection getDocument ( final CacheableYamlSource source ) throws PoliciesParseException { CacheItem entry = cache . get ( source . getIdentity ( ) ) ; long checkTime = System . currentTimeMillis ( ) ; if ( null == entry || ( ( checkTime - entry . cacheTime ) > FILE_CHECK_DELAY ) ) { final long lastmod = source . getLastModified ( ) . getTime ( ) ; if ( null == entry || lastmod > entry . modTime ) { if ( ! source . isValid ( ) ) { CacheItem remove = cache . remove ( source . getIdentity ( ) ) ; entry = null ; } else { ValidationSet validation = new ValidationSet ( ) ; PolicyCollection entry1 = createEntry ( source , validation ) ; validation . complete ( ) ; if ( null != entry1 ) { entry = new CacheItem ( entry1 , lastmod ) ; cache . put ( source . getIdentity ( ) , entry ) ; if ( ! validation . isValid ( ) ) { logger . warn ( validation . toString ( ) ) ; System . err . println ( validation . toString ( ) ) ; } } else { cache . remove ( source . getIdentity ( ) ) ; entry = null ; if ( ! validation . isValid ( ) ) { throw new PoliciesParseException ( validation . toString ( ) ) ; } } } } else { entry . touch ( checkTime ) ; } } else { } return null != entry ? entry . policyCollection : null ; }
@param source source
@return collection
@throws PoliciesParseException