@Override public String getContributionId(Resource contrib) { return contrib.getName(); }
public static String getUri(Resource resource) { return Resource.PREFIX + resource.getName(); }
protected ro.isdc.wro.model.resource.Resource toWroResource(String bundle, Resource resource) { ro.isdc.wro.model.resource.ResourceType type = toWroResourceType(resource.getType()); if (type == null) { if (log.isDebugEnabled()) { log.debug("Cannot handle resource type '" + resource.getType() + "' for resource '" + resource.getName() + "'"); } return null; } String uri = NuxeoUriLocator.getUri(resource); if (uri == null) { log.error( "Cannot handle resource '" + resource.getName() + "' for bundle '" + bundle + "': no uri resolved"); return null; } ro.isdc.wro.model.resource.Resource res = ro.isdc.wro.model.resource.Resource.create(uri, type); res.setMinimize(resource.isShrinkable()); return res; }
protected Map<String, Resource> getSubResources(DAG graph, Resource r, String type) { Map<String, Resource> res = new HashMap<>(); List<String> deps = r.getDependencies(); if (deps != null) { for (String dn : deps) { Resource d = getResource(dn); if (d == null) { log.error("Unknown resource dependency named '" + dn + "'"); continue; } if (!ResourceType.matches(type, d)) { continue; } res.put(dn, d); try { graph.addEdge(r.getName(), dn); } catch (CycleDetectedException e) { log.error("Cycle detected in resource dependencies: ", e); break; } res.putAll(getSubResources(graph, d, type)); } } return res; }
@Override public InputStream locate(String uri) throws IOException { Resource resource = getResource(uri); if (resource != null) { String ruri = resource.getURI(); if (ruri == null) { log.error("Cannot handle resource '" + resource.getName() + "': no resolved uri"); return null; } final UriLocator uriLocator = uriLocatorFactory.getInstance(ruri); if (uriLocator != null) { return uriLocator.locate(ruri); } } return null; }
protected void includeXHTML(FaceletContext ctx, UIComponent parent, List<Resource> rs, FaceletHandler leaf) throws IOException { if (rs != null && !rs.isEmpty()) { for (Resource r : rs) { String uri = r.getURI(); if (StringUtils.isBlank(uri)) { log.error("Invalid resource '" + r.getName() + "': no uri defined at " + tag.getLocation()); continue; } TagAttributeImpl srcAttr = getTagAttribute("src", uri); TagAttributesImpl attributes = new TagAttributesImpl(new TagAttribute[] { srcAttr }); TagConfig xconfig = TagConfigFactory.createTagConfig(config, tagId, attributes, leaf); new IncludeHandler(xconfig).apply(ctx, parent); } } }
protected String resolveNuxeoResourcePath(org.nuxeo.ecm.web.resources.api.Resource resource) { if (resource == null) { return null; } String name = resource.getName(); if (ResourceType.css.matches(resource)) { String suffixed = name; if (!suffixed.endsWith(ResourceType.css.getSuffix())) { suffixed += ResourceType.css.getSuffix(); } return BUNDLE_ENDPOINT_PATH + suffixed; } else if (ResourceType.js.matches(resource)) { String suffixed = name; if (!suffixed.endsWith(ResourceType.js.getSuffix())) { suffixed += ResourceType.js.getSuffix(); } return BUNDLE_ENDPOINT_PATH + suffixed; } else if (ResourceType.html.matches(resource)) { // assume html resources are copied to the war "components" sub-directory for now return COMPONENTS_PATH + resource.getPath(); } // fallback on URI return resource.getURI(); }