private Resource check(Resource resource, String name) { Resource result = resource.getRelativeResource(name); if (_log.isDebugEnabled()) _log.debug("Checking for existence of " + result); if (result.getResourceURL() != null) { _log.debug("Found " + result); return result; } return null; }
Resource localizeResource(Resource resource, Locale locale) { if (locale == null) return resource; Resource localized = resource.getLocalization(locale); if (localized != null && localized.getResourceURL() != null) return localized; return resource; }
String extractBaseName(Resource baseResourceLocation) { String fileName = baseResourceLocation.getName(); int dotx = fileName.lastIndexOf('.'); return dotx > -1 ? fileName.substring(0, dotx) : fileName; }
public InputStream getResourceAsStream() { Resource location = getResourceLocation(); try { URL url = location.getResourceURL(); return url.openStream(); } catch (Exception ex) { throw new ApplicationRuntimeException(AssetMessages.noSuchResource(location.getPath())); } }
/** * Initialize site map from a url (xml document). * @throws DocumentException on error * @throws IllegalStateException If no resource has been set. */ public void initialize() throws DocumentException { if (resource == null) throw new IllegalStateException( "No resource set, call setResource(..) before initialize()"); if (resource.getResourceURL() == null) throw new IllegalStateException( "No valid resource URL could be resolved:" + resource); log.debug("Sitemap resource: " + resource.getResourceURL()); SAXReader reader = new SAXReader(); document = reader.read(resource.getResourceURL()); Element main = (Element)document.selectSingleNode("/sitemap"); String val = main.attributeValue("compact"); if (val != null && !val.trim().equals("")) compact = Boolean.valueOf(val).booleanValue(); }
public void initializeService() { _webInfLocation = _contextRoot.getRelativeResource("WEB-INF/"); _webInfAppLocation = _webInfLocation.getRelativeResource(_applicationId + "/"); }
if (templateAsset != null && templateAsset.getResourceLocation() != null && templateAsset.getResourceLocation().getResourceURL() != null) return readTemplateFromAsset(cycle, component, templateAsset.getResourceLocation()); String name = resource.getName(); int dotx = name.lastIndexOf('.'); String templateExtension = getTemplateExtension(component); if (template != null && template.getResourceURL() != null) return readTemplateFromAsset(cycle, component, template);
/** * Finds the resource. If the inputValue is blank, then returns null. * Interprets the inputValue as a relative path from the contributing module's descriptor. * In addition, a localized resource will be returned if avaiable (localized to * the {@link org.apache.hivemind.Registry#getLocale() registry's locale}. * */ public Object translate( Module contributingModule, Class propertyType, String inputValue, Location location) { if (HiveMind.isBlank(inputValue)) return null; Locale locale = contributingModule.getLocale(); Resource descriptor = contributingModule.getLocation().getResource(); Resource baseResource = descriptor.getRelativeResource(inputValue); Resource result = baseResource.getLocalization(locale); if (result == null) throw new ApplicationRuntimeException( RulesMessages.resourceLocalizationError(inputValue, contributingModule)); return result; }
/** * Generates a URL for the client to retrieve the asset. The context path is prepended to the * asset path, which means that assets deployed inside web applications will still work (if * things are configured properly). */ public String buildURL() { if (_resolvedURL == null) _resolvedURL = _contextPath + getResourceLocation().getPath(); return _resolvedURL; }
/** * Invokes {@link Resource#getLocalization(java.util.Locale)}. */ public Resource findLocalization(Resource rootResource, Locale locale) { return rootResource.getLocalization(locale); }
/** * Reads the template for the given resource; returns null if the resource doesn't exist. Note * that this method is only invoked from a synchronized block, so there shouldn't be threading * issues here. */ private ComponentTemplate parseTemplate(IRequestCycle cycle, Resource resource, IComponent component) { String encoding = getTemplateEncoding(component, resource.getLocale()); char[] templateData = readTemplate(resource, encoding); if (templateData == null) return null; return constructTemplateInstance(cycle, templateData, resource, component); }
/** * Returns the properties, reading them if necessary. Properties may have been previously read * for this locale, in which case the cached value is returned. Also, if the resource doesn't * exist, then the parent is returned as is. Updates the propertiesMap cache. */ private Properties readProperties(Locale locale, Resource propertiesResource, Properties parent) { Properties result = (Properties) _propertiesMap.get(locale); if (result != null) return result; URL url = propertiesResource.getResourceURL(); if (url == null) result = parent; else result = readPropertiesFile(url, parent); _propertiesMap.put(locale, result); return result; }
/** * Called by hivemind automatically. */ public void initializeService() { _webInfLocation = _contextRoot.getRelativeResource(WEB_INF); _webInfAppLocation = _webInfLocation.getRelativeResource(_applicationId + "/"); }
public InputStream getResourceAsStream() { Resource location = getResourceLocation(); try { URL url = location.getResourceURL(); return url.openStream(); } catch (Exception ex) { throw new ApplicationRuntimeException(AssetMessages.noSuchResource(location.getPath())); } }
if (templateAsset != null && templateAsset.getResourceLocation() != null && templateAsset.getResourceLocation().getResourceURL() != null) return readTemplateFromAsset(cycle, component, templateAsset.getResourceLocation()); String name = resource.getName(); int dotx = name.lastIndexOf('.'); String templateExtension = getTemplateExtension(component); if (template != null && template.getResourceURL() != null) return readTemplateFromAsset(cycle, component, template);
/** * Generates a URL for the client to retrieve the asset. The context path is prepended to the * asset path, which means that assets deployed inside web applications will still work (if * things are configured properly). */ public String buildURL() { if (_resolvedURL == null) _resolvedURL = _contextPath + getResourceLocation().getPath(); return _resolvedURL; }
/** * Invokes {@link Resource#getLocalization(java.util.Locale)}. */ public Resource findLocalization(Resource rootResource, Locale locale) { return rootResource.getLocalization(locale); }
/** * Reads the template for the given resource; returns null if the resource doesn't exist. Note * that this method is only invoked from a synchronized block, so there shouldn't be threading * issues here. */ private ComponentTemplate parseTemplate(IRequestCycle cycle, Resource resource, IComponent component) { String encoding = getTemplateEncoding(component, resource.getLocale()); char[] templateData = readTemplate(resource, encoding); if (templateData == null) return null; return constructTemplateInstance(cycle, templateData, resource, component); }
private Resource check(Resource resource, String name) { Resource result = resource.getRelativeResource(name); if (_log.isDebugEnabled()) _log.debug("Checking for existence of " + result); if (result.getResourceURL() != null) { _log.debug("Found " + result); return result; } return null; }
private IComponentSpecification check(Resource resource) { if (_log.isDebugEnabled()) _log.debug("Checking: " + resource); if (resource.getResourceURL() == null) return null; return getSpecificationSource().getComponentSpecification(resource); }