Package org.apache.jetspeed.cache.disk

Examples of org.apache.jetspeed.cache.disk.DiskCacheEntry


    /**
    Save this JCM (hopefully updated JCM) to disk.
    */
    public synchronized void save() throws Exception {

        DiskCacheEntry  pde = JetspeedDiskCache.getInstance()
            .getEntry( this.url );
        Writer filewriter = pde.getWriter();
        this.content.marshal( filewriter );
        filewriter.close();

    }
View Full Code Here


        try {

            //initially set the lastModified data
            if ( this.lastModified == 0 ) {
           
                DiskCacheEntry entry = JetspeedDiskCache.getInstance().getEntry( url );
               
                this.lastModified = entry.getLastModified();

                return false;
           
            }
View Full Code Here

    public void run() {
       
        logger.info("parsing out document store");
        this.setResult( Daemon.RESULT_PROCESSING );
       
        DiskCacheEntry urls[] = JetspeedDiskCache.getInstance().getEntries();
       
        for (int i = 0; i < urls.length; ++i) {

            String url = urls[i].getSourceURL();
           
View Full Code Here

        if(isRealtimeURL(url)) {
            return false;
        }

           
         DiskCacheEntry dce = null;
         if( DiskCacheUtils.isCached(url) ) {
             try {
                 dce = JetspeedDiskCache.getInstance().getEntry( url );
                 if(!dce.hasExpired())
                 {
                         return false;
                 }
                 addRealtimeURL( url );

                 //only update this if the URL on which it is based is newer
                 //than the one on disk.
                 URL sock;
                  
                 // Determine the URL's protocol
                 String protocol = url.substring(0, url.indexOf(":/"));
          
                 // Check if a proxy is set. If no port is set, use the default port (-1)
                 String proxyHost = URLManager.getProxyHost( protocol );
                 if (proxyHost != null)
                 {
                     // Open the URL using a proxy
                     sock = new URL(protocol,
                                    proxyHost,
                                    URLManager.getProxyPort( protocol ),
                                    url);
                 }
                 else
                
                     sock = new URL( url );
                 }

                 URLConnection conn = null;
                 conn = sock.openConnection();

                 File file = dce.getFile();
                 long mod = dce.getLastModified();
                 long filesize = 0;
                 if(file != null)
                 {
                     filesize = file.length();
                 }

                 if(mod > 0 || filesize > 0)
                     conn.setIfModifiedSince(mod);
                  
                 conn.connect();
                 long last = conn.getLastModified();
                 long expires = conn.getExpiration();
                 int clength = conn.getContentLength();
                 int respCode = 200;
                 if(conn instanceof HttpURLConnection) {
                     respCode = ( ( HttpURLConnection )conn ).getResponseCode();
                 }
                  
                 if (respCode != 304 /*NOT MODIFIED*/ &&
                     (clength == -1 || clength > 0) &&
                     last == 0 ||
                       last > dce.getLastModified()) ) {

                     logger.info( "URLFetcher: Found updated URL: " +
                               url +
                               " Modified " + last + " Expires: " + expires +
                               " CLength: " + clength );
               
                     //force this URL to update.

                     JetspeedDiskCache.getInstance().getEntry( url, getReader( conn ) );
                     //Trying to deal with a problem under FreeBSD
                     conn.getInputStream().close();

                     //Set the last modified and expiration times for entry
                     //FIXME: 0 is used in FileWatcher to mean not initialized...
                     if(last > 0)
                         dce.setLastModified(last);   
                     else
                         dce.setLastModified( System.currentTimeMillis() );
                     dce.setExpirationTime(expires);


                     //removeRealtimeURL( url ); (done in finally)
                     return true;
                     //now make sure that the entry that depends on this HREF
                     //is updated in the PortletFactory.
                 } else {

                     if(last > 0)
                         dce.setLastModified(last);   
                     else
                         dce.setLastModified( System.currentTimeMillis() );
                     dce.setExpirationTime(expires);
                          
                      
                     logger.info( "DiskCacheDaemon: URL still valid: " + url +
                               " Modified " + last + " Expires: " + expires +
                               " CLength: " + clength);
View Full Code Here

        try {

            //initially set the lastModified data
            if ( this.lastModified == 0 ) {
           
                DiskCacheEntry entry = JetspeedDiskCache.getInstance().getEntry( url );
               
                this.lastModified = entry.getLastModified();

                return false;
           
            }
View Full Code Here

    /**
    Save this JCM (hopefully updated JCM) to disk.
    */
    public synchronized void save() throws Exception {

        DiskCacheEntry  pde = JetspeedDiskCache.getInstance()
            .getEntry( this.url );
        Writer filewriter = pde.getWriter();
        this.content.marshal( filewriter );
        filewriter.close();

    }
View Full Code Here

    public void run() {
       
        logger.info("parsing out document store");
        this.setResult( Daemon.RESULT_PROCESSING );
       
        DiskCacheEntry urls[] = JetspeedDiskCache.getInstance().getEntries();
       
        for (int i = 0; i < urls.length; ++i) {

            String url = urls[i].getSourceURL();
           
View Full Code Here

        if(isRealtimeURL(url)) {
            return false;
        }

           
         DiskCacheEntry dce = null;
         if( DiskCacheUtils.isCached(url) ) {
             try {
                 dce = JetspeedDiskCache.getInstance().getEntry( url );
                 if(!dce.hasExpired())
                 {
                         return false;
                 }
                 addRealtimeURL( url );

                 //only update this if the URL on which it is based is newer
                 //than the one on disk.
                 URL sock;
                  
                 // Determine the URL's protocol
                 String protocol = url.substring(0, url.indexOf(":/"));
          
                 // Check if a proxy is set. If no port is set, use the default port (-1)
                 String proxyHost = URLManager.getProxyHost( protocol );
                 if (proxyHost != null)
                 {
                     // Open the URL using a proxy
                     sock = new URL(protocol,
                                    proxyHost,
                                    URLManager.getProxyPort( protocol ),
                                    url);
                 }
                 else
                
                     sock = new URL( url );
                 }

                 URLConnection conn = null;
                 conn = sock.openConnection();

                 File file = dce.getFile();
                 long mod = dce.getLastModified();
                 long filesize = 0;
                 if(file != null)
                 {
                     filesize = file.length();
                 }

                 if(mod > 0 || filesize > 0)
                     conn.setIfModifiedSince(mod);
                  
                 conn.connect();
                 long last = conn.getLastModified();
                 long expires = conn.getExpiration();
                 int clength = conn.getContentLength();
                 int respCode = 200;
                 if(conn instanceof HttpURLConnection) {
                     respCode = ( ( HttpURLConnection )conn ).getResponseCode();
                 }
                  
                 if (respCode != 304 /*NOT MODIFIED*/ &&
                     (clength == -1 || clength > 0) &&
                     last == 0 ||
                       last > dce.getLastModified()) ) {

                     logger.info( "URLFetcher: Found updated URL: " +
                               url +
                               " Modified " + last + " Expires: " + expires +
                               " CLength: " + clength );
               
                     //force this URL to update.

                     JetspeedDiskCache.getInstance().getEntry( url, getReader( conn ) );
                     //Trying to deal with a problem under FreeBSD
                     conn.getInputStream().close();

                     //Set the last modified and expiration times for entry
                     //FIXME: 0 is used in FileWatcher to mean not initialized...
                     if(last > 0)
                         dce.setLastModified(last);   
                     else
                         dce.setLastModified( System.currentTimeMillis() );
                     dce.setExpirationTime(expires);


                     //removeRealtimeURL( url ); (done in finally)
                     return true;
                     //now make sure that the entry that depends on this HREF
                     //is updated in the PortletFactory.
                 } else {

                     if(last > 0)
                         dce.setLastModified(last);   
                     else
                         dce.setLastModified( System.currentTimeMillis() );
                     dce.setExpirationTime(expires);
                          
                      
                     logger.info( "DiskCacheDaemon: URL still valid: " + url +
                               " Modified " + last + " Expires: " + expires +
                               " CLength: " + clength);
View Full Code Here

    /**
    Save this JCM (hopefully updated JCM) to disk.
    */
    public synchronized void save() throws Exception {

        DiskCacheEntry  pde = JetspeedDiskCache.getInstance()
            .getEntry( this.url );
        Writer filewriter = pde.getWriter();
        this.content.marshal( filewriter );
        filewriter.close();

    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.cache.disk.DiskCacheEntry

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.