Package de.innovationgate.utils.io

Examples of de.innovationgate.utils.io.ByteArrayDataSource


                        monitor.worked(1);

                        monitor.setTaskName("updating remote server configuration");
                        ByteArrayOutputStream out = new ByteArrayOutputStream();
                        WGAConfiguration.write(_remoteWGAConfiguration, out);
                        DataSource configDataSource = new ByteArrayDataSource(out.toByteArray(), "WGAConfiguration", "text/xml");
                        _remoteServer.getServices().updateWGAConfiguration(_remoteServer.getSession(), configDataSource);
                        monitor.worked(1);

                        monitor.setTaskName("waiting for remote content store to get available");
                        List<String> dbkeys = new ArrayList<String>();
View Full Code Here


        }
       
        try {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            WGAConfiguration.write(_core.getWgaConfiguration(), out);
            return new ByteArrayDataSource(out.toByteArray(), WGAConfiguration.class.getName(), "text/xml");
        }
        catch (Exception e) {
            throw new WGAServiceException("Cannot serialize wga configuration.", e);
        }
       
View Full Code Here

        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) {
                if (!exc.getClass().getName().equals("org.apache.catalina.connector.ClientAbortException")) {
                    _log.warn("Caching of file request failed bc. of IO error: " + exc.getMessage());
                }
            }
            finally {
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    }
                    catch (Exception e) {
                    }
                }
            }

            // Writing from cache to out
            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 {
View Full Code Here

TOP

Related Classes of de.innovationgate.utils.io.ByteArrayDataSource

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.