Skip to content

Commit

Permalink
remove unused TemplateManager.renderServletContextResource method #657
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Jun 13, 2019
1 parent 6c15e10 commit 3544ae1
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/main/java/alfio/util/TemplateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package alfio.util;

import alfio.config.WebSecurityConfig;
import alfio.manager.UploadedResourceManager;
import alfio.manager.system.ConfigurationManager;
import alfio.model.EventAndOrganizationId;
Expand All @@ -32,14 +31,10 @@
import org.springframework.core.io.AbstractResource;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.security.web.csrf.CsrfToken;
import org.springframework.web.context.support.ServletContextResource;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.i18n.MustacheLocalizationMessageInterceptor;
import org.springframework.web.servlet.support.RequestContextUtils;
import org.springframework.web.servlet.view.mustache.jmustache.JMustacheTemplateLoader;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -113,14 +108,6 @@ public String renderString(EventAndOrganizationId event, String template, Map<St
return render(new ByteArrayResource(template.getBytes(StandardCharsets.UTF_8)), modelEnricher(model, Optional.ofNullable(event), locale), locale, templateOutput);
}

//TODO: to be removed when only the rest api will be exposed
public String renderServletContextResource(String servletContextResource, EventAndOrganizationId event, Map<String, Object> model, HttpServletRequest request, TemplateOutput templateOutput) {
model.put("request", request);
model.put(WebSecurityConfig.CSRF_PARAM_NAME, request.getAttribute(CsrfToken.class.getName()));
Locale locale = RequestContextUtils.getLocale(request);
return render(new ServletContextResource(request.getServletContext(), servletContextResource), modelEnricher(model, Optional.ofNullable(event), locale), locale, templateOutput);
}

private Map<String, Object> modelEnricher(Map<String, Object> model, Optional<? extends EventAndOrganizationId> event, Locale locale) {
Map<String, Object> toEnrich = new HashMap<>(model);
event.ifPresent(ev -> toEnrich.put(VAT_TRANSLATION_TEMPLATE_KEY, getVATString(ev, messageSource, locale, configurationManager)));
Expand Down

0 comments on commit 3544ae1

Please sign in to comment.