protected Map<Path, String> discoverUiResources(Path path, Service s) throws Throwable { Map<Path, String> pathToURIPath = new HashMap<>(); Path baseUriPath = Paths.get(getSelfLink()); String prefix = path.toString().replace('\\', '/'); if (getHost().getState().resourceSandboxFileReference != null) { discoverFileResources(s, pathToURIPath, baseUriPath, prefix); } if (pathToURIPath.isEmpty()) { discoverJarResources(path, s, pathToURIPath, baseUriPath, prefix); } return pathToURIPath; }
protected void startUiFileContentServices() throws Throwable { Map<Path, String> pathToURIPath = new HashMap<>(); Path baseResourcePath = Utils.getServiceUiResourcePath(this); try { pathToURIPath = discoverUiResources(baseResourcePath, this); } catch (Throwable e) { log(Level.WARNING, "Error enumerating UI resources for %s: %s", this.getSelfLink(), Utils.toString(e)); } if (pathToURIPath.isEmpty()) { log(Level.WARNING, "No custom UI resources found for %s", this.getClass().getName()); return; } for (Entry<Path, String> e : pathToURIPath.entrySet()) { String value = e.getValue(); if (value.contains("/META-INF/")) { continue; } Operation post = Operation .createPost(UriUtils.buildUri(getHost(), value)); RestrictiveFileContentService fcs = new RestrictiveFileContentService( e.getKey().toFile()); getHost().startService(post, fcs); } }
@Override public void handleGet(Operation get) { URI uri = get.getUri(); String selfLink = getSelfLink(); String requestUri = uri.getPath();