Examples of SeekableInputStream


Examples of com.volantis.map.common.streams.SeekableInputStream

                public void close() {
                    method.releaseConnection();
                }
            };

            SeekableInputStream seekableStream =
                new DefaultSeekableInputStream(closer, stream, true);

            if(stream != null) {

                // the mimeDiscoverer should not effect the Seekable stream
                // and should restore its position but we mark it just in case.
                String mimeType = null;
                try {
                    seekableStream.mark();
                    mimeType = mimeDiscoverer.discoverMimeType(seekableStream);
                } finally {
                    seekableStream.reset();
                }
                responseInfo = new DefaultRepresentation(
                    method,
                    mimeType,
                    cacheBuilder.build(),
View Full Code Here

Examples of com.volantis.map.common.streams.SeekableInputStream

    private static Representation getLocalImage(String sourceURL)
        throws IOException {


        URL url = new URL(sourceURL);
        final SeekableInputStream sis;
        if (url.getProtocol().equals("file")) {
            sis = new DefaultSeekableInputStream(new File(url.getFile()));
        } else {
            sis = new DefaultSeekableInputStream(null, url.openStream(), false);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Loading local file: " + url);
        }


        final String mimeType = DISCOVERER.discoverMimeType(sis);

        CachedHttpContentStateBuilder builder =
            new CachedHttpContentStateBuilder();


        final Map responses = new HashMap();
        Date now = new Date();
        // formaters are NOT thread safe so we must create a new one
        DateFormat format = DateFormats.RFC_1123_GMT.create();
        responses.put("date",  format.format(now));

        responses.put("cache-control", "max-age=" + LOCAL_FILE_MAX_AGE);
        responses.put("expires", format.format(
            new Date(now.getTime() + LOCAL_FILE_MAX_AGE * 1000)));

        // create a "fake" accessor
        HttpResponseHeaderAccessor accessor = new HttpResponseHeaderAccessor() {

            // javadoc inherited
            public String getProtocol() {
                return "HTTP";
            }

            // javadoc inherited
            public String getResponseHeaderValue(String s) {
                s = s.toLowerCase(Locale.ENGLISH);
                // get returns null if the entry does not exist. This meets the
                // specification for getResponseHeaderValue
                return (String) responses.get(s);
            }
        };

        builder.setMethodAccessor(accessor);

        Time t = Time.inMilliSeconds(System.currentTimeMillis());
        builder.setRequestTime(t);
        builder.setResponseTime(t);
        final CachedHttpContentState state = builder.build();

        // A mock Representation that adds a "default" timeout to local and
        // non-http image sources.
        return new Representation() {

            public void close() {
                try {
                    sis.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

View Full Code Here

Examples of org.apache.pig.backend.datastorage.SeekableInputStream

        if (elem.exists() && (!elem.getDataStorage().isContainer(elem.toString()))) {
            try {
                if (elem.systemElement())
                    throw new IOException ("Attempt is made to open system file " + elem.toString());
               
                SeekableInputStream sis = elem.sopen();
                sis.seek(offset, FLAGS.SEEK_SET);
                return sis;
            }
            catch (DataStorageException e) {
                throw new IOException("Failed to determine if elem=" + elem + " is container", e);
            }
View Full Code Here

Examples of org.apache.pig.backend.datastorage.SeekableInputStream

        if (elem.exists() && (!elem.getDataStorage().isContainer(elem.toString()))) {
            try {
                if (elem.systemElement())
                    throw new IOException ("Attempt is made to open system file " + elem.toString());
               
                SeekableInputStream sis = elem.sopen();
                sis.seek(offset, FLAGS.SEEK_SET);
                return sis;
            }
            catch (DataStorageException e) {
                throw new IOException("Failed to determine if elem=" + elem + " is container", e);
            }
View Full Code Here

Examples of org.apache.pig.backend.datastorage.SeekableInputStream

        if (elem.exists() && (!elem.getDataStorage().isContainer(elem.toString()))) {
            try {
                if (elem.systemElement())
                    throw new IOException ("Attempt is made to open system file " + elem.toString());
               
                SeekableInputStream sis = elem.sopen();
                sis.seek(offset, FLAGS.SEEK_SET);
                return sis;
            }
            catch (DataStorageException e) {
                throw WrappedIOException.wrap("Failed to determine if elem=" + elem + " is container", e);
            }
View Full Code Here

Examples of org.apache.pig.backend.datastorage.SeekableInputStream

        if (elem.exists() && (!elem.getDataStorage().isContainer(elem.toString()))) {
            try {
                if (elem.systemElement())
                    throw new IOException ("Attempt is made to open system file " + elem.toString());
               
                SeekableInputStream sis = elem.sopen();
                sis.seek(offset, FLAGS.SEEK_SET);
                return sis;
            }
            catch (DataStorageException e) {
                throw WrappedIOException.wrap("Failed to determine if elem=" + elem + " is container", e);
            }
View Full Code Here

Examples of org.apache.pig.backend.datastorage.SeekableInputStream

        if (elem.exists() && (!elem.getDataStorage().isContainer(elem.toString()))) {
            try {
                if (elem.systemElement())
                    throw new IOException ("Attempt is made to open system file " + elem.toString());
               
                SeekableInputStream sis = elem.sopen();
                sis.seek(offset, FLAGS.SEEK_SET);
                return sis;
            }
            catch (DataStorageException e) {
                throw new IOException("Failed to determine if elem=" + elem + " is container", e);
            }
View Full Code Here

Examples of org.apache.pig.backend.datastorage.SeekableInputStream

        if (elem.exists() && (!elem.getDataStorage().isContainer(elem.toString()))) {
            try {
                if (elem.systemElement())
                    throw new IOException ("Attempt is made to open system file " + elem.toString());

                SeekableInputStream sis = elem.sopen();
                sis.seek(offset, FLAGS.SEEK_SET);
                return sis;
            }
            catch (DataStorageException e) {
                throw new IOException("Failed to determine if elem=" + elem + " is container", e);
            }
View Full Code Here

Examples of org.apache.pig.backend.datastorage.SeekableInputStream

        if (elem.exists() && (!elem.getDataStorage().isContainer(elem.toString()))) {
            try {
                if (elem.systemElement())
                    throw new IOException ("Attempt is made to open system file " + elem.toString());

                SeekableInputStream sis = elem.sopen();
                sis.seek(offset, FLAGS.SEEK_SET);
                return sis;
            }
            catch (DataStorageException e) {
                throw new IOException("Failed to determine if elem=" + elem + " is container", e);
            }
View Full Code Here

Examples of org.apache.pig.backend.datastorage.SeekableInputStream

        if (elem.exists() && (!elem.getDataStorage().isContainer(elem.toString()))) {
            try {
                if (elem.systemElement())
                    throw new IOException ("Attempt is made to open system file " + elem.toString());
               
                SeekableInputStream sis = elem.sopen();
                sis.seek(offset, FLAGS.SEEK_SET);
                return sis;
            }
            catch (DataStorageException e) {
                throw new IOException("Failed to determine if elem=" + elem + " is container", e);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.