Package org.apache.excalibur.source

Examples of org.apache.excalibur.source.SourceValidity


        try {
            AggregatedValidity v = new AggregatedValidity();
            Source current;
            for (int i = 0; i < this.parts.size(); i++) {
                current = ((Part)this.parts.get(i)).source;
                SourceValidity sv = current.getValidity();
                if (sv == null) {
                    return null;
                } else {
                    v.add(sv);
                }
View Full Code Here


        public synchronized Document getDocument(ComponentManager manager,
                                                 SourceResolver resolver,
                                                 Logger logger) throws Exception {

            Source src = null;
            SourceValidity valid = null;
            Document dom = null;

            if (this.document == null) {
                if (logger.isDebugEnabled())
                    logger.debug("document not cached... reloading uri "+this.uri);
View Full Code Here

                this.toCacheSourceValidities = new SourceValidity[this.toCacheKey.size()];
                int len = this.toCacheSourceValidities.length;
                int i = 0;
                while (i < len) {
                    final SourceValidity validity = this.getValidityForInternalPipeline(i);

                    if (validity == null) {
                        if (i > 0
                            && (this.fromCacheKey == null || i > this.fromCacheKey.size())) {
                            // shorten key
View Full Code Here

                int i = 0;
                while (responseIsValid && i < fromCacheValidityObjects.length) {
                    boolean isValid = false;
                    // BH check if validities[i] is null, may happen
                    // if exception was thrown due to malformed content
                    SourceValidity validity = fromCacheValidityObjects[i];
                    int valid = validity != null ? validity.isValid() : -1;
                    if ( valid == 0) { // don't know if valid, make second test
                      
                        validity = this.getValidityForInternalPipeline(i);

                        if (validity != null) {
View Full Code Here

    protected boolean processReader(Environment  environment)
    throws ProcessingException {
        try {
            boolean usedCache = false;
            OutputStream outputStream = null;
            SourceValidity readerValidity = null;
            PipelineCacheKey pcKey = null;

            // test if reader is cacheable
            Serializable readerKey = null;
            boolean isCacheableProcessingComponent = false;
            if (super.reader instanceof CacheableProcessingComponent) {
                readerKey = ((CacheableProcessingComponent)super.reader).getKey();
                isCacheableProcessingComponent = true;
            } else if (super.reader instanceof Cacheable) {
                readerKey = new Long(((Cacheable)super.reader).generateKey());
            }

            if ( readerKey != null) {
                // response is cacheable, build the key
                pcKey = new PipelineCacheKey();
                pcKey.addKey(new ComponentCacheKey(ComponentCacheKey.ComponentType_Reader,
                                                   this.readerRole,
                                                   readerKey)
                            );

                // now we have the key to get the cached object
                CachedResponse cachedObject = (CachedResponse)this.cache.get( pcKey );

                if (cachedObject != null) {
                    if (this.getLogger().isDebugEnabled()) {
                        this.getLogger().debug(
                            "Found cached response for '" + environment.getURI() +
                            "' using key: " + pcKey
                        );
                    }
                    SourceValidity[] validities = cachedObject.getValidityObjects();
                    if (validities == null || validities.length != 1) {
                        throw new ProcessingException("Cached response is not correct.");
                    }
                    SourceValidity cachedValidity = validities[0];
                    int result = cachedValidity.isValid();
                    boolean valid = false;
                    if ( result == 0 ) {
                        // get reader validity and compare
                        if (isCacheableProcessingComponent) {
                            readerValidity = ((CacheableProcessingComponent)super.reader).getValidity();
                        } else {
                            CacheValidity cv = ((Cacheable)super.reader).generateValidity();
                            if ( cv != null ) {
                                readerValidity = CacheValidityToSourceValidity.createValidity( cv );
                            }
                        }
                        if (readerValidity != null) {
                            result = cachedValidity.isValid(readerValidity);
                            if ( result == 0 ) {
                                readerValidity = null;
                            } else {
                                valid = (result == 1);
                            }
View Full Code Here

    /**
     *
     * @see org.apache.cocoon.components.pipeline.ProcessingPipeline#getValidityForInternalPipeline(int)
     */
    SourceValidity getValidityForInternalPipeline(int index) {
        final SourceValidity validity;
        if (index == 0) {
            // test generator
            if (this.generatorIsCacheableProcessingComponent) {
                validity = ((CacheableProcessingComponent)super.generator).getValidity();
            } else {
View Full Code Here

        String key = sourceUri;
        Object value = null;

        CachedObject cachedObject = (CachedObject) getCache().get(key);
        boolean usedCache = false;
        SourceValidity sourceValidity = null;

        try {

            if (cachedObject != null) {
                if (getLogger().isDebugEnabled()){
                    getLogger().debug("Found cached object [" + cachedObject + "]");
                }
                SourceValidity cachedValidity = cachedObject.getValidityObject();

                int result = cachedValidity.isValid();
                boolean valid = false;
                if (result == 0) {

                    // get source validity and compare

                    sourceValidity = getSourceValidity(sourceUri);

                    if (sourceValidity != null) {
                        result = cachedValidity.isValid(sourceValidity);
                        if (result == 0) {
                            sourceValidity = null;
                        } else {
                            valid = (result == 1);
                        }
View Full Code Here

     * @throws MalformedURLException when an error occurs.
     * @throws IOException when an error occurs.
     */
    protected SourceValidity getSourceValidity(String sourceUri)
        throws MalformedURLException, IOException {
        SourceValidity sourceValidity;
        Source source = null;
        try {
            source = getResolver().resolveURI(sourceUri);
            sourceValidity = source.getValidity();
        } finally {
View Full Code Here

        this.delay = delay;
    }
   
    public void addSource(Source src) {
        if (this.data != null) {
            SourceValidity validity = src.getValidity();
            if (validity == null) {
                // one of the sources has no validity : this object will always be invalid
                this.data = null;
            } else {
                // Add the validity and URI to the list
View Full Code Here

        }
    }
   
    private int computeStatus(SourceResolver resolver) {
        for (int i = 0; i < data.size(); i+=2) {
            SourceValidity validity = (SourceValidity)data.get(i);
            switch(validity.isValid()) {
                case -1:
                    // invalid : stop examining
                    return -1;
                case 1:
                    // valid : just continue to next source
                    break;
                case 0:
                    // don't know : check with the new source
                    if (resolver == null) {
                        // we have no resolver : definitely don't know (need to have one)
                        return 0;
                    }
                    try {
                        Source newSrc = resolver.resolveURI((String)data.get(i+1));
                        int value = validity.isValid(newSrc.getValidity());
                        resolver.release(newSrc);
                        if (value != 1) {
                            return -1;
                        }
                    } catch(IOException ioe) {
View Full Code Here

TOP

Related Classes of org.apache.excalibur.source.SourceValidity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.