@Override public String getContributionId(Resource contrib) { return contrib.getName(); }
@Override public String getContributionId(ResourceBundle contrib) { return contrib.getName(); }
@Override public void merge(ResourceBundle src, ResourceBundle dst) { dst.merge(src); }
@Override public WroModel create() { WroModel model = new WroModel(); WebResourceManager service = Framework.getService(WebResourceManager.class); ResourceContextImpl rcontext = new ResourceContextImpl(); List<ResourceBundle> bundles = service.getResourceBundles(); for (ResourceBundle bundle : bundles) { String groupName = bundle.getName(); Group group = new Group(groupName); List<Resource> resources = service.getResources(rcontext, groupName, ResourceType.any.name()); if (resources != null) { for (Resource resource : resources) { ro.isdc.wro.model.resource.Resource wr = toWroResource(groupName, resource); if (wr != null) { group.addResource(wr); } } } model.addGroup(group); } return model; }
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(); }
protected List<Resource> retrieveResources(WebResourceManager wrm, String bundle, ResourceType type) { return wrm.getResources(new ResourceContextImpl(), bundle, type.name()); }
public String getSuffix() { return "." + name(); }
protected List<String> resolveProcessorNames(String type) { List<String> res = new ArrayList<String>(); List<Processor> procs = NuxeoConfigurableProvider.resolveProcessors(type); for (Processor proc : procs) { res.add(proc.getName()); } return res; }
@Override protected String resolveUrl(FacesContext context, UIComponent component) throws IOException { Map<String, Object> attributes = component.getAttributes(); String name = (String) attributes.get("name"); if (name != null) { Resource r = resolveNuxeoResource(context, component, name); if (r != null) { String url = getUrlWithParams(context, component, r.getURI()); url = resolveUrlWithTimestamp(component, url); return url; } } return null; }
@Override public ResourceBundle clone(ResourceBundle orig) { return orig.clone(); }
protected ResourceType resolveType(String type) { if (StringUtils.isBlank(type)) { return ResourceType.any; } ResourceType parsed = ResourceType.parse(type); if (parsed != null) { List<ResourceType> handled = Arrays.asList(handledTypesArray); if (handled.contains(parsed)) { return parsed; } } return null; }
public static boolean isProcessorEnabled(String alias, String uri) { Resource res = getResource(uri); if (res != null) { return res.getProcessors().contains(alias); } return false; }
public static final boolean matches(String type, Resource r) { if (StringUtils.isBlank(type) || ResourceType.any.name().equals(type.toLowerCase())) { return true; } String rt = r.getType(); if (StringUtils.isBlank(rt)) { return true; } if (type.toLowerCase().equals(rt.toLowerCase())) { return true; } return false; }
/** * @since 7.4 */ public final boolean equals(String type) { if (name().equalsIgnoreCase(type)) { return true; } return false; }
public static String getUri(Resource resource) { return Resource.PREFIX + resource.getName(); }
protected ro.isdc.wro.model.resource.ResourceType toWroResourceType(String type) { if (StringUtils.isBlank(type)) { return null; } if (ResourceType.js.name().equals(type.toLowerCase())) { return ro.isdc.wro.model.resource.ResourceType.JS; } if (ResourceType.css.name().equals(type.toLowerCase())) { return ro.isdc.wro.model.resource.ResourceType.CSS; } return null; }