@Override
    public Date schedule(Status status, Metadata metadata) {

        int minutesIncrement = 0;

        Optional<Integer> customInterval = Optional.empty();

        // try with a value set in the metadata
        String customInMetadata = metadata.getFirstValue(DELAY_METADATA);
        if (customInMetadata != null) {
            customInterval = Optional.of(Integer.parseInt(customInMetadata));
        }
        // try with the rules from the configuration
        if (!customInterval.isPresent()) {
            customInterval = checkCustomInterval(metadata, status);
        }

        if (customInterval.isPresent()) {
            minutesIncrement = customInterval.get();
        } else {
            switch (status) {
            case FETCHED:
                minutesIncrement = defaultfetchInterval;
                break;
            case FETCH_ERROR:
                minutesIncrement = fetchErrorFetchInterval;
                break;
            case ERROR:
                minutesIncrement = errorFetchInterval;
                break;
            case REDIRECTION:
                minutesIncrement = defaultfetchInterval;
                break;
            default:
                // leave it to now e.g. DISCOVERED
            }
        }

        // a value of -1 means never fetch
        // we use a conventional value
        if (minutesIncrement == -1) {
            return NEVER;
        }

        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MINUTE, minutesIncrement);

        return cal.getTime();
    }
@Override
    public Date schedule(Status status, Metadata metadata) {

        int minutesIncrement = 0;

        Optional<Integer> customInterval = Optional.empty();

        
        String customInMetadata = metadata.getFirstValue(DELAY_METADATA);
        if (customInMetadata != null) {
            customInterval = Optional.of(Integer.parseInt(customInMetadata));
        }
        
        if (!customInterval.isPresent()) {
            customInterval = checkCustomInterval(metadata, status);
        }

        if (customInterval.isPresent()) {
            minutesIncrement = customInterval.get();
        } else {
            switch (status) {
            case FETCHED:
                minutesIncrement = defaultfetchInterval;
                break;
            case FETCH_ERROR:
                minutesIncrement = fetchErrorFetchInterval;
                break;
            case ERROR:
                minutesIncrement = errorFetchInterval;
                break;
            case REDIRECTION:
                minutesIncrement = defaultfetchInterval;
                break;
            default:
                
            }
        }

        
        
        if (minutesIncrement == -1) {
            return NEVER;
        }

        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MINUTE, minutesIncrement);

        return cal.getTime();
    }
@ Override public Date schedule ( Status status , Metadata metadata ) { int minutesIncrement = 0 ; Optional < Integer > customInterval = Optional . empty ( ) ; // try with a value set in the metadata String customInMetadata = metadata . getFirstValue ( DELAY_METADATA ) ; if ( customInMetadata != null ) { customInterval = Optional . of ( Integer . parseInt ( customInMetadata ) ) ; } // try with the rules from the configuration if ( ! customInterval . isPresent ( ) ) { customInterval = checkCustomInterval ( metadata , status ) ; } if ( customInterval . isPresent ( ) ) { minutesIncrement = customInterval . get ( ) ; } else { switch ( status ) { case FETCHED : minutesIncrement = defaultfetchInterval ; break ; case FETCH_ERROR : minutesIncrement = fetchErrorFetchInterval ; break ; case ERROR : minutesIncrement = errorFetchInterval ; break ; case REDIRECTION : minutesIncrement = defaultfetchInterval ; break ; default : // leave it to now e.g. DISCOVERED } } // a value of -1 means never fetch // we use a conventional value if ( minutesIncrement == - 1 ) { return NEVER ; } Calendar cal = Calendar . getInstance ( ) ; cal . add ( Calendar . MINUTE , minutesIncrement ) ; return cal . getTime ( ) ; }
/*
(non-Javadoc)

@see com.digitalpebble.stormcrawler.persistence.Scheduler#schedule(com.
digitalpebble. stormcrawler.persistence .Status,
com.digitalpebble.stormcrawler.Metadata)
/ * ( non - Javadoc )