Package org.geoserver.script

Examples of org.geoserver.script.ScriptManager


        super.setUp();
        scriptMgr = createScriptMgr();
    }

    ScriptManager createScriptMgr() throws Exception {
        ScriptManager mgr = createNiceMock(ScriptManager.class);
        expect(mgr.getWfsTxRoot()).andReturn(Files.createTempDir()).anyTimes();
        replay(mgr);
        return mgr;
    }
View Full Code Here


    }

    protected List<Script> getScripts() {
        List<Script> scripts = new ArrayList<Script>();
        ScriptManager scriptManager = (ScriptManager) GeoServerExtensions.bean("scriptMgr");
        try {
            File[] dirs = { scriptManager.getWpsRoot(), scriptManager.getWfsTxRoot(),
                    scriptManager.getFunctionRoot(), scriptManager.getAppRoot() };
            for (File dir : dirs) {
                File[] files = dir.listFiles();
                for (File file : files) {
                    if (dir.getName().equals("apps")) {
                        if (file.isDirectory()) {
                            File mainFile = scriptManager.findAppMainScript(file);
                            if (mainFile != null) {
                                Script script = new Script(mainFile);
                                scripts.add(script);
                            } else {
                                LOGGER.info("Could not find main app file in " + file.getAbsolutePath());
View Full Code Here

        form.add(cancelLink);
    }

    private List<String> getExtensions() {
        List<String> extensions = Lists.newArrayList();
        ScriptManager scriptManager = (ScriptManager) GeoServerExtensions.bean("scriptMgr");
        for (ScriptPlugin plugin : scriptManager.getPlugins()) {
            extensions.add(plugin.getExtension());
        }
        return extensions;
    }
View Full Code Here

        }
        return extensions;
    }

    private String getModeFromExtension(String ext) {
        ScriptManager scriptManager = (ScriptManager) GeoServerExtensions.bean("scriptMgr");
        String mode = scriptManager.lookupEditorModeByExtension(ext);
        return mode;
    }
View Full Code Here

        form.add(extensionLabel);
        HiddenField extension = new HiddenField("extension", new PropertyModel(scriptModel, "extension"));
        form.add(extension);

        // Content
        ScriptManager scriptManager = (ScriptManager) GeoServerExtensions.bean("scriptMgr");
        String mode = scriptManager.lookupPluginEditorMode(script.getFile());
        CodeMirrorEditor content = new CodeMirrorEditor("contents", mode, new PropertyModel(scriptModel, "contents"));
        content.setRequired(true);
        form.add(content);

        // Dialog
View Full Code Here

            return FilenameUtils.getBaseName(file.getName());
        }
    }

    private File findFile(String name, String type, String extension) {
        ScriptManager scriptManager = (ScriptManager) GeoServerExtensions.bean("scriptMgr");
        try {
            if (name.contains(":")) {
                name = name.replace(":",File.separator);
            }
            File f = scriptManager.findScriptFile(name, ScriptType.getByLabel(type), extension);
            return f;
        } catch (IOException ex) {
            LOGGER.warning(String.format(
                    "Error finding file for name = %s, type = %s extension = %s because ", name,
                    type, extension, ex.getMessage()));
View Full Code Here

        }
        return "";
    }

    private String findType(File file) {
        ScriptManager scriptManager = (ScriptManager) GeoServerExtensions.bean("scriptMgr");
        return scriptManager.getScriptType(file).getLabel();
    }
View Full Code Here

    public List<FunctionName> getFunctionNames() {
        LOGGER.fine("Performing filter lookup");

        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);

        ScriptManager scriptMgr = scriptMgr();
        List<FunctionName> names = new ArrayList<FunctionName>();

        try {
            File filterRoot = scriptMgr.getFunctionRoot();
            for (String file : filterRoot.list()) {
                File f = new File(filterRoot, file);

                FunctionHook hook = scriptMgr.lookupFilterHook(f);
                if (hook == null) {
                    LOGGER.fine("Skipping " + f.getName() + ", no hook found");
                }

                //TODO: support multiple functions in one file
View Full Code Here

        if (function == null) {
            synchronized(this) {
                function = functions.get(name);
                if (function == null) {
                    try {
                        ScriptManager scriptMgr = scriptMgr();

                        File filterRoot = scriptMgr.getFunctionRoot();
                        File f = null;
                        if (name.getNamespaceURI() != null) {
                            f = new File(filterRoot, name.getLocalPart()+"."+name.getNamespaceURI());
                        }
                        else {
View Full Code Here

    }

    public Set<Name> getNames() {
        LOGGER.fine("Performing process lookup");

        ScriptManager scriptMgr = scriptMgr();
        Set<Name> names = new TreeSet<Name>();

        try {
            // load the scripts in the root, the extension is the namespace
            File wpsRoot = scriptMgr.getWpsRoot();
            new CollectProcessNames(wpsRoot, scriptMgr, names) {

                @Override
                String getScriptNamespace(File f) {
                    return getExtension(f.getName());
View Full Code Here

TOP

Related Classes of org.geoserver.script.ScriptManager

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.