Package de.innovationgate.wgpublisher.cache

Examples of de.innovationgate.wgpublisher.cache.FileCache$FileCacheItem


        if (contentType.startsWith("application/")) {
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        }

        // Look if file is cached - If so, send it and exit
        FileCache fileCache = (FileCache) database.getAttribute(WGACore.DBATTRIB_FILECACHE);
        byte[] data = fileCache.getFile(publishingFile, lastModified);
        if (data != null) {
            try {

                // B000041DA
                ByteArrayDataSource dataIn = new ByteArrayDataSource(data, publishingFile.getFileName(), contentType);
                String designEncoding = (String) database.getAttribute(WGACore.DBATTRIB_DESIGN_ENCODING);

                if (designEncoding != null) {
                    writeData(dataIn, request, response, designEncoding, data.length, database.getDbReference(), true);
                }
                else {
                    writeData(dataIn, request, response, null, data.length, database.getDbReference(), true);
                }

            }
            catch (java.net.SocketException exc) {
                _log.warn("Dispatch of cached file request failed bc. of socket error: " + exc.getMessage());
            }
            catch (java.io.IOException exc) {
                if (!exc.getClass().getName().equals("org.apache.catalina.connector.ClientAbortException")) {
                    _log.warn("Dispatch of cached file request failed bc. of IO error: " + exc.getMessage());
                }
            }
            return;
        }

        // In domino native implementations: Change to Master login to retrieve
        // data (Workaround for Domino API Bug)
        String databaseTypeName = database.getTypeName();
        if (databaseTypeName.equals("domino/wgacontentstore/local") || databaseTypeName.equals("domino/custom/local")) {
            WGFactory.getInstance().closeSessions();
            database = _core.openContentDB(path.getDatabaseKey(), null, true);
        }

        long fileSize = publishingFile.getFileSize();

        // Look if file size is below cache threshold - if so, collect data and
        // put into cache, then serve
        long threshold = fileCache.getThreshold();
        if (fileSize != -1 && threshold >= fileSize) {

            // Put into cache
            InputStream inputStream = publishingFile.getInputStream();
            try {
                ByteArrayOutputStream outCache = new ByteArrayOutputStream((int) fileSize);
                WGUtils.inToOut(inputStream, outCache, 2048);
                data = outCache.toByteArray();
                fileCache.putFile(publishingFile, data, lastModified);
            }
            catch (java.net.SocketException exc) {
                _log.warn("Caching of file request failed bc. of socket error: " + exc.getMessage());
            }
            catch (java.io.IOException exc) {
View Full Code Here


        db.setAttribute(DBATTRIB_ITEM_MAPPINGS, new HashMap());
        db.setAttribute(DBATTRIB_PLUGIN_SHORTCUTS, new HashMap());
               
        // Create a file cache object.
        try {
            db.setAttribute(WGACore.DBATTRIB_FILECACHE, new FileCache(db, this));
        }
        catch (CacheException e) {
            getLog().error("Error initializing file cache for database " + db.getDbReference(), e);
        };
       
View Full Code Here

TOP

Related Classes of de.innovationgate.wgpublisher.cache.FileCache$FileCacheItem

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.