Package org.geoserver.platform

Examples of org.geoserver.platform.GeoServerResourceLoader.url()

@param url File URL or path relative to data directory @return File indicated by provided URL @see Files#url(File,String)

*/
public class DSFinderRepository extends org.geotools.data.gen.DSFinderRepository {

    protected URL getURLForLocation(String location) throws IOException {
        GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class);
        File f = loader.url(location);       
        URL url = null;
        if (f.exists()) {
            url = f.toURI().toURL();
        } else {
            url = new URL(location);
View Full Code Here


        if (source instanceof String) {
            String path = (String) source;
           
            GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class);
            File f = loader.url(path);
            URL url = null;
            if (f!= null && f.exists()) {
                url = f.toURI().toURL();
            } else {
                url = new URL(path);
View Full Code Here

        // find under which root the selection should be placed
        File selection = (File) file.getObject();
       
        // first check if the file is a relative reference into the data dir
        if(selection != null) {
            File relativeToDataDir = loader.url(selection.getPath());
            if(relativeToDataDir != null) {
                selection = relativeToDataDir;
            }
        }
       
View Full Code Here

                    // Getting coverage reader using the format and the real path.
                    //
                    // /////////////////////////////////////////////////////////
                    final String url = info.getURL();
                    GeoServerResourceLoader loader = catalog.getResourceLoader();
                    final File obj = loader.url(url);

                    // In case no File is returned, provide the original String url
                    final Object input = obj != null ? obj : url; 

                    // readers might change the provided hints, pass down a defensive copy
View Full Code Here

    @Override
    public String getMimeType(CoverageInfo cInfo) throws IOException {
        // no mapping let's go with the ImageIO reader code
        GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class);
       
        final File sourceFile = loader.url(cInfo.getStore().getURL());
        if (sourceFile == null) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine("Original source is null");
            }
            return null;
View Full Code Here

        try {
            url = new URL(imageURL);
            if (url.getProtocol() == null || url.getProtocol().equals("file")) {
                GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class);
                File file = loader.url(imageURL);
                if (file.exists()){
                    url = DataUtilities.fileToURL(file);
                }
            }
        } catch (MalformedURLException e) {
View Full Code Here

            // local to provided baseDirectory
            relFile = Files.url(baseDirectory, uriSpec);
        }
        else if( loader != null ){
            // local to data directory?
            relFile = loader.url(uriSpec);
        }

        if (relFile == null || !relFile.exists()) {
            error(validatable, "FileExistsValidator.fileNotFoundError",
                    Collections.singletonMap("file", uriSpec));
View Full Code Here

    }

    @Test
    public void testFindDataFile() throws IOException {
        GeoServerResourceLoader loader = getResourceLoader();
        final File file = loader.url("file:" + RAIN_DATA_PATH);
        assertNotNull(file);
    }

    @Test
    public void testFindDataFileForAbsolutePath() throws IOException {
View Full Code Here

    @Test
    public void testFindDataFileForAbsolutePath() throws IOException {
        GeoServerResourceLoader loader = getResourceLoader();      
        final File dataDir = loader.getBaseDirectory();
        final String absolutePath = dataDir.getCanonicalPath() + SEPARATOR_CHAR + RAIN_DATA_PATH;
        final File file = loader.url(absolutePath);
        assertNotNull(file);
    }

    @Test
    public void testFindDataFileForCustomUrl() throws IOException {
View Full Code Here

    }

    @Test
    public void testFindDataFileForCustomUrl() throws IOException {
        GeoServerResourceLoader loader = getResourceLoader();
        final File file = loader.url("sde://user:password@server:port");
        assertNull(file); // Before GEOS-5931 it would have been returned a file again
    }
}
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.