Search in sources :

Example 1 with GzipResource

use of com.revolsys.spring.resource.GzipResource in project com.revolsys.open by revolsys.

the class IoFactory method getZipResource.

default Resource getZipResource(final Object source) {
    Resource resource = Resource.getResource(source);
    if (isReadFromZipFileSupported()) {
        final String filename = resource.getFilename();
        if (filename.endsWith(".zip")) {
            final String baseName = filename.substring(0, filename.length() - 4);
            final String url = "jar:" + resource.getUri() + "!/" + baseName;
            final UrlResource urlResource = new UrlResource(url);
            if (urlResource.exists()) {
                resource = urlResource;
            } else {
                return null;
            }
        } else if (filename.endsWith(".gz")) {
            return new GzipResource(resource);
        } else if (filename.endsWith(getFileExtensions().get(0) + "z")) {
            return new GzipResource(resource);
        }
    }
    return resource;
}
Also used : GzipResource(com.revolsys.spring.resource.GzipResource) UrlResource(com.revolsys.spring.resource.UrlResource) GzipResource(com.revolsys.spring.resource.GzipResource) UrlResource(com.revolsys.spring.resource.UrlResource) Resource(com.revolsys.spring.resource.Resource)

Aggregations

GzipResource (com.revolsys.spring.resource.GzipResource)1 Resource (com.revolsys.spring.resource.Resource)1 UrlResource (com.revolsys.spring.resource.UrlResource)1