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 + "."); } } }
protected boolean canHandle(String viewName, Locale locale) { String uri = viewName; // path corrections if (uri != null) { if (uri.length() != 0 && uri.charAt(0) != '/') { uri = '/' + uri; } } // check the web script registry to see if a web script with this URI exists Match match = container.getRegistry().findWebScript("get", uri); return (match != null); }
@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; }
@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);
match = container.getRegistry().findWebScript(method, scriptUrl); if ((match != null) && (match.getWebScript().getDescription().getRequiredAuthentication().equals(RequiredAuthentication.none))) match = container.getRegistry().findWebScript(method, scriptUrl); if (debug) logger.debug("Agent: " + scriptReq.getAgent()); String reqFormat = scriptReq.getFormat(); String format = (reqFormat == null || reqFormat.length() == 0) ? "[undefined]" : reqFormat; Description desc = scriptReq.getServiceMatch().getWebScript().getDescription(); logger.debug("Invoking Web Script " + description.getId() + " (format " + format + ", style: " + desc.getFormatStyle() + ", default: " + desc.getDefaultFormat() + ")");
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars(); String packagePath = "/" + templateVars.get("package"); Registry registry = getContainer().getRegistry(); Path path = registry.getPackage(packagePath); if (path == null) PackageDescriptionDocument packageDoc = registry.getPackageDescriptionDocument(packagePath); if (packageDoc == null) for (String scriptId : scriptIds) WebScript webscript = registry.getWebScript(scriptId); if (webscript != null)
@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; }
Object content = req.parseContent(); if (content == null || !(content instanceof FormData)) getContainer().reset(); Registry registry = getContainer().getRegistry(); WebScript webscript = registry.getWebScript(scriptId); if (webscript == null)
if (statusTemplate == null) Path path = this.container.getRegistry().getPackage(PathImpl.concatPath("/", getDescription().getScriptPath())); statusTemplate = getPackageStatusTemplate(path, statusCode, format); if (statusTemplate == null)
String scriptId = req.getExtensionPath(); if (scriptId == null || scriptId.length() == 0) WebScript script = getContainer().getRegistry().getWebScript(scriptId); if (script == null) Collection<Store> stores = getContainer().getSearchPath().getStores(); for (Store store : stores)
@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; }
@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; }
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException String scriptId = req.getExtensionPath(); if (scriptId == null || scriptId.length() == 0) WebScript script = getContainer().getRegistry().getWebScript(scriptId); if (script == null)
public void reset() { long startTime = System.nanoTime(); try { scriptProcessorRegistry.reset(); templateProcessorRegistry.reset(); getRegistry().reset(); configService.reset(); } finally { if (logger.isInfoEnabled()) logger.info("Initialised " + getName() + " Web Script Container (in " + (System.nanoTime() - startTime)/1000000f + "ms)"); } }
/** * @throws Exception */ @Test public void testBadWebscriptDescriptionDocuments() throws Exception { Map <String,String> ws = getWebscriptRegistry().getFailures(); assertNotNull (ws); assertEquals(3,ws.size()); } }
for (WebScript webscript : registry.getWebScripts())
/** * @throws Exception */ @Test public void testGetPackageDescriptionDocumentByPath() throws Exception { PackageDescriptionDocument doc = getWebscriptRegistry().getPackageDescriptionDocument("/documents/samples"); assertNotNull(doc); }
public void testWebscriptDescriptionDocument() throws Exception WebScript ws = getWebscriptRegistry().getWebScript("documents/samples/sample1.get"); assertNotNull(ws); Description wsDesc = ws.getDescription();
match = container.getRegistry().findWebScript(method, scriptUrl); if ((match != null) && (match.getWebScript().getDescription().getRequiredAuthentication().equals(RequiredAuthentication.none))) match = container.getRegistry().findWebScript(method, scriptUrl); if (debug) logger.debug("Agent: " + scriptReq.getAgent()); String reqFormat = scriptReq.getFormat(); String format = (reqFormat == null || reqFormat.length() == 0) ? "[undefined]" : reqFormat; Description desc = scriptReq.getServiceMatch().getWebScript().getDescription(); logger.debug("Invoking Web Script " + description.getId() + " (format " + format + ", style: " + desc.getFormatStyle() + ", default: " + desc.getDefaultFormat() + ")");