Package org.geoserver.platform.resource

Examples of org.geoserver.platform.resource.Resource


                                   HttpServletResponse response) throws IOException {

        WorkspaceInfo ws = findWorkspace(wsName, catalog());

        GeoServerResourceLoader rl = geoServer.getCatalog().getResourceLoader();
        Resource resource = rl.get(Paths.path("workspaces",ws.getName(),"styles",icon));

        if( resource.getType() != Type.RESOURCE ){
            throw new NotFoundException("Icon "+icon+" not found");
        }
        String ext = fileExt(icon);
        if( !ICON_FORMATS.containsKey(ext)){
            throw new NotFoundException("Icon "+icon+" format unsupported");
        }
        String mimeType = ICON_FORMATS.get(ext.toLowerCase());

        response.setContentType(mimeType);
        //response.setStatus(HttpServletResponse.SC_OK);
        response.setDateHeader("Last-Modified", resource.lastmodified() );
        //IOUtils.copy(resource.in(), response.getOutputStream());

        try (
            InputStream in = resource.in();
        ) {
            return IOUtils.toByteArray(in);
        }
    }
View Full Code Here


    public boolean delete(@PathVariable String wsName, @PathVariable String icon) throws IOException {

        WorkspaceInfo ws = findWorkspace(wsName, catalog());

        GeoServerResourceLoader rl = geoServer.getCatalog().getResourceLoader();
        Resource resource = rl.get(Paths.path("workspaces",ws.getName(),"styles",icon));
        if( resource.getType() != Type.RESOURCE ){
            throw new NotFoundException("Icon "+icon+" not found");
        }
        String ext = fileExt(icon);
        if( !ICON_FORMATS.containsKey(ext)){
            throw new NotFoundException("Icon "+icon+" format unsupported");
        }
        return resource.delete();
    }
View Full Code Here

                path = Paths.path("styles",s.getFilename());
            }
            else {
                path = Paths.path("workspaces",s.getWorkspace().getName(),"styles",s.getFilename());
            }
            final Resource r = rl.get(path);
           
            // Similar to s.getStyle() and GeoServerDataDirectory.parsedStyle(s)
            // But avoid resolving external graphics to absolute file references
            if ( r == null || r.getType() == Type.UNDEFINED ){
                throw new IOException( "No such resource: " + s.getFilename());
            }
            // Force use of unmodified URI, avoiding absolute file references
            ResourceLocator locator = new ResourceLocator(){
                public URL locateResource(String spec) {
View Full Code Here

    }

    JSONObj layer(JSONObj obj, LayerInfo l, HttpServletRequest req) {
        IO.layer(obj, l, req);
        if (!obj.has("modified")) {
            Resource r = dataDir().config(l);
            if (r.getType() != Type.UNDEFINED) {
                IO.date(obj.putObject("modified"), new Date(r.lastmodified()));
            }
        }
        return obj;
    }
View Full Code Here

        IO.bounds(obj.putObject("bbox"), bounds);
        obj.put("layer_count", map.getLayers().size());

        IO.metadata(obj, map);
        if (!obj.has("modified")) {
            Resource r = dataDir().config(map);
            if (r.getType() != Type.UNDEFINED) {
                IO.date(obj.putObject("modified"), new Date(r.lastmodified()));
            }
        }

        return obj;
    }
View Full Code Here

       
        if (configFileName == null) {
            configFileName = "DEFAULT_LOGGING.properties";
            LoggingInitializer.LOGGER.warning("No log4jConfigFile defined in services.xml:  using 'DEFAULT_LOGGING.properties'");
        }
        Resource resource = resourceLoader.get( Paths.path("logs", configFileName) );
        if( resource == null || resource.getType() == Type.UNDEFINED ){
            //hmm, well, we don't have a log4j config file and this could be due to the fact
            //that this is a data-dir upgrade.  We can count on the DEFAULT_LOGGING.properties file
            //being present on the classpath, so we'll upgrade their data_dir and then use the
            //default DEFAULT_LOGGING.properties configuration.
            LoggingInitializer.LOGGER.warning("log4jConfigFile '" + configFileName + "' couldn't be found in the data dir, so GeoServer will " +
            "install the various logging config file into the data dir, and then try to find it again.");
           
            Resource logs = resourceLoader.get( "logs" );           
            File lcdir = logs.dir();
           
            //now we copy in the various logging config files from the base repo location on the classpath
            final String[] lcfiles = new String[] {
                    "DEFAULT_LOGGING.properties",
                    "GEOSERVER_DEVELOPER_LOGGING.properties",
View Full Code Here

    long timeout = -1;

    /** Default watches controlflow.properties */
    public DefaultControlFlowConfigurator() {
        GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class);
        Resource controlflow = loader.get(PROPERTYFILENAME);
        configFile = new PropertyFileWatcher(controlflow);       
    }
View Full Code Here

            IOUtils.closeQuietly(is);
        }
        // override settings from datadir
        try {
            // datadir search
            Resource resource = loader.get( PROPERTIES_FILE );
            if (resource.getType() == Type.RESOURCE) {
                is = resource.in();
                props.load(is);
            }
        } catch (IOException e2) {
            LOGGER.log(Level.FINER, e2.getMessage(), e2);
        } finally {
View Full Code Here

    /**
     * Returns a file under the {@link #root()} directory, if the file does not exist null is returned.
     */
    public File findFile(String... location) throws IOException {
        Resource resource = get(Paths.path(location));
        return Resources.find(resource);
    }
View Full Code Here

     * <p>
     * This directory is called 'data', and is located directly under {@link #root()}
     * </p>
     */
    public File findDataRoot() throws IOException {
        Resource directory = get("data");
        return Resources.directory(directory);
    }
View Full Code Here

TOP

Related Classes of org.geoserver.platform.resource.Resource

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.