@Override protected void executeImpl(Action action, NodeRef actionedUponNodeRef) { if (condition) { // Do something } else { throw new WebScriptException("Action is failed"); } }
public void afterPropertiesSet() throws Exception { if (defaultWebScript == null || defaultWebScript.length() == 0 || !applicationContext.containsBean(defaultWebScript)) { throw new WebScriptException("Default Web Script implementation '" + (defaultWebScript == null ? "<undefined>" : defaultWebScript) + "' does not exist."); } }
public void afterPropertiesSet() throws Exception { if (defaultWebScript == null || defaultWebScript.length() == 0 || !applicationContext.containsBean(defaultWebScript)) { throw new WebScriptException("Default Web Script implementation '" + (defaultWebScript == null ? "<undefined>" : defaultWebScript) + "' does not exist."); } }
public boolean hasTemplate(String templatePath) { boolean hasTemplate = false; try { Template template = templateConfig.getTemplate(templatePath); hasTemplate = (template != null); } catch(FileNotFoundException e) { // NOTE: return false as template is not found } catch(IOException e) { throw new WebScriptException("Failed to retrieve template " + templatePath, e); } return hasTemplate; }
public void afterPropertiesSet() throws Exception { if (defaultWebScript == null || defaultWebScript.length() == 0 || !applicationContext.containsBean(defaultWebScript)) { throw new WebScriptException("Default Web Script implementation '" + (defaultWebScript == null ? "<undefined>" : defaultWebScript) + "' does not exist."); } }
public InputStream getInputStream() { try { return this.location.getInputStream(); } catch (IOException e) { throw new WebScriptException("Unable to retrieve input stream for script " + getPathDescription()); } }
public InputStream getInputStream() { try { return this.location.getInputStream(); } catch (IOException e) { throw new WebScriptException("Unable to retrieve input stream for script " + getPathDescription()); } }
public InputStream getInputStream() { try { return this.location.getInputStream(); } catch (IOException e) { throw new WebScriptException("Unable to retrieve input stream for script " + getPathDescription()); } }
public Content getContent() { // ensure we only try to read the content once - as this method may be called several times // but the underlying inputstream itself can only be processed a single time if (content == null) { try { content = new InputStreamContent(req.getInputStream(), getContentType(), req.getCharacterEncoding()); } catch(IOException e) { throw new WebScriptException("Failed to retrieve request content", e); } } return content; }
public Content getContent() { // ensure we only try to read the content once - as this method may be called several times // but the underlying inputstream itself can only be processed a single time if (content == null) { try { content = new InputStreamContent(req.getInputStream(), getContentType(), req.getCharacterEncoding()); } catch(IOException e) { throw new WebScriptException("Failed to retrieve request content", e); } } return content; }
public Object executeScript(String path, Map<String, Object> model) { // locate script within web script stores ScriptContent scriptLocation = findScript(path); if (scriptLocation == null) { throw new WebScriptException("Unable to locate script " + path); } // execute script return executeScript(scriptLocation, model); }
public Object executeScript(String path, Map<String, Object> model) { // locate script within web script stores ScriptContent scriptLocation = findScript(path); if (scriptLocation == null) { throw new WebScriptException("Unable to locate script " + path); } // execute script return executeScript(scriptLocation, model); }
public FormData read(WebScriptRequest req) { if (!(req instanceof WebScriptServletRequest)) { throw new WebScriptException("Failed to convert request to FormData"); } return new FormData(((WebScriptServletRequest)req).getHttpServletRequest()); }
public FormData read(WebScriptRequest req) { if (!(req instanceof WebScriptServletRequest)) { throw new WebScriptException("Failed to convert request to FormData"); } return new FormData(((WebScriptServletRequest)req).getHttpServletRequest()); }
public Object executeScript(String path, Map<String, Object> model) { // locate script within web script stores ScriptContent scriptLocation = findScript(path); if (scriptLocation == null) { throw new WebScriptException("Unable to locate script " + path); } // execute script return executeScript(scriptLocation, model); }
public FormData read(WebScriptRequest req) { if (!(req instanceof WebScriptServletRequest)) { throw new WebScriptException("Failed to convert request to FormData"); } return new FormData(((WebScriptServletRequest)req).getHttpServletRequest()); }
/** * Initializes the script loaders */ protected void initLoaders() { List<ScriptLoader> loaders = new ArrayList<ScriptLoader>(searchPath.getStores().size()); for (Store apiStore : searchPath.getStores()) { ScriptLoader loader = apiStore.getScriptLoader(); if (loader == null) { throw new WebScriptException("Unable to retrieve script loader for Web Script store " + apiStore.getBasePath()); } loaders.add(loader); } this.scriptLoader = new MultiScriptLoader(loaders.toArray(new ScriptLoader[loaders.size()])); }
/** * Initializes the script loaders */ protected void initLoaders() { List<ScriptLoader> loaders = new ArrayList<ScriptLoader>(searchPath.getStores().size()); for (Store apiStore : searchPath.getStores()) { ScriptLoader loader = apiStore.getScriptLoader(); if (loader == null) { throw new WebScriptException("Unable to retrieve script loader for Web Script store " + apiStore.getBasePath()); } loaders.add(loader); } this.scriptLoader = new MultiScriptLoader(loaders.toArray(new ScriptLoader[loaders.size()])); }
/** * Initializes the script loaders */ protected void initLoaders() { List<ScriptLoader> loaders = new ArrayList<ScriptLoader>(searchPath.getStores().size()); for (Store apiStore : searchPath.getStores()) { ScriptLoader loader = apiStore.getScriptLoader(); if (loader == null) { throw new WebScriptException("Unable to retrieve script loader for Web Script store " + apiStore.getBasePath()); } loaders.add(loader); } this.scriptLoader = new MultiScriptLoader(loaders.toArray(new ScriptLoader[loaders.size()])); }
/** * Render a template (contents as string) * * @param template the template * @param model model * @param writer output writer * @param extension optional template extension type (i.e. ftl, php) */ final protected void renderString(String template, Map<String, Object> model, Writer writer, String extension) { TemplateProcessor processor = container.getTemplateProcessorRegistry().getTemplateProcessorByExtension(extension); if (processor != null) { processor.processString(template, model, writer); } else { throw new WebScriptException("No processor found for extension " + extension); } }