protected boolean loadRelativePathResource(ResourceView resultComponent, Element element) { Element relativePath = element.element("relativePath"); if (relativePath == null) return false; String path = relativePath.attributeValue("path"); if (StringUtils.isEmpty(path)) { throw new GuiDevelopmentException("No path provided for the RelativePathResource", context.getFullFrameId()); } RelativePathResource resource = resultComponent.createResource(RelativePathResource.class); resource.setPath(path); loadMimeType(resource, relativePath); resultComponent.setSource(resource); return true; }
protected boolean loadClasspathResource(ResourceView resultComponent, Element element) { Element classpathResource = element.element("classpath"); if (classpathResource == null) return false; String classpathPath = classpathResource.attributeValue("path"); if (StringUtils.isEmpty(classpathPath)) { throw new GuiDevelopmentException("No path provided for the ClasspathResource", context.getFullFrameId()); } ClasspathResource resource = resultComponent.createResource(ClasspathResource.class); resource.setPath(classpathPath); loadMimeType(resource, classpathResource); loadStreamSettings(resource, classpathResource); resultComponent.setSource(resource); return true; }
protected void loadUrlResource(ResourceView resultComponent, Element element) { Element urlResource = element.element("url"); if (urlResource == null) return; String url = urlResource.attributeValue("url"); if (StringUtils.isEmpty(url)) { throw new GuiDevelopmentException("No url provided for the UrlResource", context.getFullFrameId()); } UrlResource resource = resultComponent.createResource(UrlResource.class); try { resource.setUrl(new URL(url)); loadMimeType(resource, urlResource); resultComponent.setSource(resource); } catch (MalformedURLException e) { String msg = String.format("An error occurred while creating UrlResource with the given url: %s", url); throw new GuiDevelopmentException(msg, context.getFullFrameId()); } }