/** * Registers a template under a given name. * * @param templateName name to register the template under * @param template template to register */ public void registerTemplate(String templateName, String template) { try { StringResourceRepository repository = VelocityStringResourceRepositoryAdaptor.getRepository(velocity); repository.putStringResource(templateName, template); } catch (VelocityException e) { log.error("Unable to register template into Velocity string repository", e); } }
/** * Overrides superclass for better performance. * @since 1.6 */ public boolean resourceExists(final String name) { if (name == null) { return false; } return (this.repository.getStringResource(name) != null); }
@Override public boolean registerTemplate(String name, String template) { StringResourceRepository repo = StringResourceLoader.getRepository(); //(StringResourceRepository) velocityEngine.getApplicationAttribute(StringResourceLoader.REPOSITORY_NAME_DEFAULT); repo.removeStringResource(name); repo.putStringResource(name, template); return getTemplate(name).isPresent(); }
repo.setEncoding(encoding); repo.setEncoding(RuntimeConstants.ENCODING_DEFAULT); log.debug("Default repository encoding is {}", repo.getEncoding()); return repo;
repo.putStringResource("alert_template", ""); repo.putStringResource("alert_template", templateString); Assert.assertEquals(templateString, repo.getStringResource("alert_template").getBody());
@Override public synchronized void unregister(String policyId) { LOG.info("Unregistering {}", policyId); stringResourceRepository.removeStringResource(getAlertBodyTemplateName(policyId)); stringResourceRepository.removeStringResource(getAlertSubjectTemplateName(policyId)); policyDefinitionRepository.remove(policyId); }
!this.repository.getEncoding().equals(encoding)) repoName, this.repository.getEncoding(), encoding); this.repository.setEncoding(encoding);
@Override public void removeTemplate(String name) { StringResourceRepository repo = StringResourceLoader.getRepository(); //(StringResourceRepository) velocityEngine.getApplicationAttribute(StringResourceLoader.REPOSITORY_NAME_DEFAULT); repo.removeStringResource(name); }
public static void putStringResource(String templateName, String templateCode){ StringResourceLoader.getRepository().putStringResource(templateName, templateCode); }
/** * Overrides superclass for better performance. * @since 1.6 */ public boolean resourceExists(final String name) { if (name == null) { return false; } return (this.repository.getStringResource(name) != null); }
repo.setEncoding(encoding); } else { repo.setEncoding(REPOSITORY_ENCODING_DEFAULT); log.debug("Default repository encoding is " + repo.getEncoding());
/** * Registers the template with template engine. */ protected void registerTemplate() { try { StringResourceRepository repository = VelocityStringResourceRepositoryAdaptor.getRepository(velocity); templateName = "shibboleth.resolver.ad." + getId(); repository.putStringResource(templateName, attributeTemplate.trim()); } catch (VelocityException e) { log.error("Unable to register template into Velocity string repository", e); } }
/** * Overrides superclass for better performance. * @since 1.6 */ public boolean resourceExists(final String name) { if (name == null) { return false; } return (this.repository.getStringResource(name) != null); }
repo.setEncoding(encoding); repo.setEncoding(REPOSITORY_ENCODING_DEFAULT); log.debug("Default repository encoding is " + repo.getEncoding());
@Override protected Template loadInlineTemplate(String s) { stringResourceRepository().putStringResource(s, s); org.apache.velocity.Template template = stringEngine.getTemplate(s); return new VelocityTemplate(template); }
/** * @see ResourceLoader#getLastModified(org.apache.velocity.runtime.resource.Resource) */ public long getLastModified(final Resource resource) { StringResource original = null; original = this.repository.getStringResource(resource.getName()); return (original != null) ? original.getLastModified() : 0; }
repo.setEncoding(encoding); repo.setEncoding(REPOSITORY_ENCODING_DEFAULT); log.debug("Default repository encoding is " + repo.getEncoding());
protected void cache(String name, String template) { try { getRepository().putStringResource(name, template); } catch (Exception cnfe) { getVelocityView().getLog() .error("Could not cache body in a StringResourceRepository", cnfe); cache = false; } }
/** * @see org.apache.velocity.runtime.resource.loader.ResourceLoader#getLastModified(org.apache.velocity.runtime.resource.Resource) */ public long getLastModified(final Resource resource) { StringResource original = null; original = this.repository.getStringResource(resource.getName()); return (original != null) ? original.getLastModified() : 0; }
if (encoding != null && !repository.getEncoding().equals(encoding)) { if (log.isInfoEnabled()) { log.info("Changing the default encoding of string repository '" + repoName + "' from " + repository.getEncoding() + " to " + encoding); repository.setEncoding(encoding);