Refine search
/** * Helper function to reset all web scripts in the web framework * web scripts container */ public void resetWebScripts() { if (this.webFrameworkContainer != null) { int previousCount = this.webFrameworkContainer.getRegistry().getWebScripts().size(); int previousFailures = this.webFrameworkContainer.getRegistry().getFailures().size(); this.webFrameworkContainer.reset(); // debug out logger.info("Reset Web Scripts Registry; registered " + this.webFrameworkContainer.getRegistry().getWebScripts().size() + " Web Scripts. Previously, there were " + previousCount + "."); int newFailures = this.webFrameworkContainer.getRegistry().getFailures().size(); if (newFailures != 0 || previousFailures != 0) { logger.info("Warning: found " + newFailures + " broken Web Scripts. Previously, there were " + previousFailures + "."); } } }
/** * Helper to retrieve a ResourceBundle wrapper from a store path. * * @param path String * @return ResourceBundle * @throws IOException */ private ResourceBundle getBundleFromPath(String path) throws IOException { ResourceBundle result = null; if (container.getSearchPath().hasDocument(path)) { InputStream is = container.getSearchPath().getDocument(path); try { result = new WebScriptPropertyResourceBundle(is, path); } finally { is.close(); } } return result; }
throw new WebScriptException("WebScript " + description.getId() + " already associated with the '" + this.container.getName() + "' container");
final public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException String format = req.getFormat(); String mimetype = getContainer().getFormatRegistry().getMimeType(req.getAgent(), format); if (mimetype == null) throw new WebScriptException("Web Script format '" + format + "' is not registered"); ScriptDetails script = getExecuteScript(req.getContentType()); if (script != null) if (getContainer().allowCallbacks()) callback = req.getJSONCallback();
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) { Map<String, Object> model = new HashMap<String, Object>(7, 1.0f); model.put("webscripts", getContainer().getRegistry().getWebScripts()); model.put("failures", getContainer().getRegistry().getFailures()); model.put("rooturl", getContainer().getRegistry().getUri("/")); model.put("rootpackage", getContainer().getRegistry().getPackage("/")); model.put("rootfamily", getContainer().getRegistry().getFamily("/")); model.put("rootlifecycle", getContainer().getRegistry().getLifecycle("/")); return model; }
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars(); String packagePath = "/" + templateVars.get("package"); Registry registry = getContainer().getRegistry(); Path path = registry.getPackage(packagePath); if (path == null) throw new WebScriptException(Status.STATUS_NOT_FOUND, "Web Script Package '" + packagePath + "' not found"); PackageDescriptionDocument packageDoc = registry.getPackageDescriptionDocument(packagePath); if (packageDoc == null) throw new WebScriptException(Status.STATUS_NOT_FOUND, "Web Script documentation for package '" + packagePath + "' not found"); for (String scriptId : scriptIds) WebScript webscript = registry.getWebScript(scriptId); if (webscript != null)
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException String scriptId = req.getExtensionPath(); if (scriptId == null || scriptId.length() == 0) throw new WebScriptException("Web Script Id not provided"); WebScript script = getContainer().getRegistry().getWebScript(scriptId); if (script == null) throw new WebScriptException("Web Script Id '" + scriptId + "' not found"); throw new WebScriptException("Failed to read Web Script description document for '" + scriptId + "'", e);
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) String packageFilter = req.getParameter("package") != null ? req.getParameter("package") : "/"; String urlFilter = req.getParameter("url") != null ? req.getParameter("url") : "/"; String familyFilter = req.getParameter("family") != null ? req.getParameter("family") : "/"; String lifecycleFilter = req.getParameter("lifecycle") != null ? req.getParameter("lifecycle") : "/"; Collection<WebScript> scripts = getContainer().getRegistry().getWebScripts(); Collection<WebScript> filteredWebScripts = new ArrayList<WebScript>(); for (WebScript script : scripts) Path rootPackage = getContainer().getRegistry().getPackage("/"); Path filteredPackage = filterPath(null, rootPackage, packageFilter, urlFilter, familyFilter);
params.put("webscript", req.getServiceMatch().getWebScript().getDescription()); params.put("format", new FormatModel(container.getFormatRegistry(), req.getFormat())); params.put("args", createArgs(req)); params.put("argsM", createArgsM(req)); params.put("headers", createHeaders(req)); params.put("headersM", createHeadersM(req)); params.put("guest", req.isGuest()); params.put("url", createURLModel(req)); params.put("msg", getScriptMessage()); if (script != null) FormatReader<Object> reader = container.getFormatRegistry().getReader(script.getRequestType()); if (!(WebScriptRequestImpl.MULTIPART_FORM_DATA.equals(contentType) && getDescription().getMultipartProcessing() == false)) params.putAll(req.getRuntime().getScriptParameters()); params.putAll(container.getScriptParameters());
params.putAll(req.getRuntime().getTemplateParameters()); params.putAll(container.getTemplateParameters()); params.put("webscript", req.getServiceMatch().getWebScript().getDescription()); params.put("format", new FormatModel(container.getFormatRegistry(), req.getFormat())); params.put("args", createArgs(req)); params.put("argsM", createArgsM(req)); params.put("formatwrite", new FormatWriterMethod(container.getFormatRegistry(), req.getFormat())); params.put("message", getMessageMethod()); // for compatibility with repo templates params.put("msg", getMessageMethod()); // short form for presentation webscripts
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) { // extract web script package String packagePath = req.getExtensionPath(); if (packagePath == null || packagePath.length() == 0) { packagePath = "/"; } if (!packagePath.startsWith("/")) { packagePath = "/" + packagePath; } // locate web script package Path path = getContainer().getRegistry().getPackage(packagePath); if (path == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Web Script Package '" + packagePath + "' not found"); } Map<String, Object> model = new HashMap<String, Object>(7, 1.0f); model.put("package", path); return model; }
throw new WebScriptException("Web Script install only supported via HTTP Servlet"); Object content = req.parseContent(); if (content == null || !(content instanceof FormData)) throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Web Script install request is not multipart/form-data"); throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Web Script install request expects only one file upload"); getContainer().reset(); Registry registry = getContainer().getRegistry(); WebScript webscript = registry.getWebScript(scriptId); if (webscript == null)
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) { // extract web script package String uriPath = req.getExtensionPath(); if (uriPath == null || uriPath.length() == 0) { uriPath = "/"; } if (!uriPath.startsWith("/")) { uriPath = "/" + uriPath; } // locate web script package Path path = getContainer().getRegistry().getUri(uriPath); if (path == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Web Script URI '" + uriPath + "' not found"); } Map<String, Object> model = new HashMap<String, Object>(7, 1.0f); model.put("uri", path); return model; }
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) { // extract web script package String uriPath = req.getExtensionPath(); if (uriPath == null || uriPath.length() == 0) { uriPath = "/"; } if (!uriPath.startsWith("/")) { uriPath = "/" + uriPath; } // locate web script package Path path = getContainer().getRegistry().getLifecycle(uriPath); if (path == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Web Script URI '" + uriPath + "' not found"); } Map<String, Object> model = new HashMap<String, Object>(7, 1.0f); model.put("lifecycle", path); return model; }
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) { // extract web script package String familyPath = req.getExtensionPath(); if (familyPath == null || familyPath.length() == 0) { familyPath = "/"; } if (!familyPath.startsWith("/")) { familyPath = "/" + familyPath; } // locate web script package Path path = getContainer().getRegistry().getFamily(familyPath); if (path == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Web Script Family '" + familyPath + "' not found"); } Map<String, Object> model = new HashMap<String, Object>(7, 1.0f); model.put("family", path); return model; }
String mimetype = container.getFormatRegistry().getMimeType(req.getAgent(), template.getFormat()); if (mimetype == null) throw new WebScriptException("Web Script format '" + template.getFormat() + "' is not registered"); logger.debug("Force success status header in response: " + req.forceSuccessStatus()); logger.debug("Sending status " + statusCode + " (Template: " + template.getPath() + ")"); logger.debug("Rendering response: content type=" + mimetype); res.setStatus(req.forceSuccessStatus() ? HttpServletResponse.SC_OK : statusCode); String location = status.getLocation(); if (location != null && location.length() > 0)
input = this.container.getSearchPath().getDocument(configPath); if (input != null) throw new WebScriptException("Failed to read script configuration file", ioe); this.scriptConfigModel = new ScriptConfigModel(this.container.getConfigService(), this.xmlConfig); this.templateConfigModel = new TemplateConfigModel(this.container.getConfigService(), this.xmlConfig);
FormatRegistry formatRegistry = getContainer().getFormatRegistry(); if (format != null) String validScriptPath = getContainer().getScriptProcessorRegistry().findValidScriptPath(basePath + "." + format); if (validScriptPath != null) ScriptProcessor scriptProcessor = getContainer().getScriptProcessorRegistry().getScriptProcessor(validScriptPath); scriptContent = scriptProcessor.findScript(validScriptPath); break; String validScriptPath = getContainer().getScriptProcessorRegistry().findValidScriptPath(basePath); if (validScriptPath != null) ScriptProcessor scriptProcessor = getContainer().getScriptProcessorRegistry().getScriptProcessor(validScriptPath); scriptContent = scriptProcessor.findScript(validScriptPath); throw new WebScriptException("No reader registered for \"" + generalizedMimetype + "\"");
if (statusTemplate == null) Path path = this.container.getRegistry().getPackage(PathImpl.concatPath("/", getDescription().getScriptPath())); statusTemplate = getPackageStatusTemplate(path, statusCode, format); if (statusTemplate == null)
if (methodIdx == -1 || (methodIdx == id.length() - 1)) throw new WebScriptException("Unable to establish HTTP Method from web script description: naming convention must be <name>.<method>.desc.xml"); if (defaultFormat != null) defaultFormatMimetype = container.getFormatRegistry().getMimeType(null, defaultFormat); if (defaultFormatMimetype == null) throw new WebScriptException("Default format '" + defaultFormat + "' is unknown"); throw new WebScriptException("Invalid schema type reference " + requestType.getId());