X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=org.argeo.publishing.ui%2Fsrc%2Forg%2Fargeo%2Fpublishing%2Fservlet%2FFontsServlet.java;fp=org.argeo.publishing.ui%2Fsrc%2Forg%2Fargeo%2Fpublishing%2Fservlet%2FFontsServlet.java;h=0000000000000000000000000000000000000000;hp=5bc6d0cc642d1536c55a235a810314bff151624d;hb=6e56ffa34cb02ab04d028423aea342e3dfed4358;hpb=c285180bece610b2c2921d44fe14b6dde2123efa diff --git a/org.argeo.publishing.ui/src/org/argeo/publishing/servlet/FontsServlet.java b/org.argeo.publishing.ui/src/org/argeo/publishing/servlet/FontsServlet.java deleted file mode 100644 index 5bc6d0c..0000000 --- a/org.argeo.publishing.ui/src/org/argeo/publishing/servlet/FontsServlet.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.argeo.publishing.servlet; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.io.IOUtils; -import org.argeo.cms.ui.CmsTheme; - -/** Serves fonts locally. */ -public class FontsServlet extends HttpServlet { - private static final long serialVersionUID = 6009572962850708537L; - private Map themes = Collections.synchronizedMap(new HashMap<>()); - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - String font = req.getPathInfo(); - font = font.substring(1, font.length()); - for (CmsTheme theme : themes.values()) { - for (String fontPath : theme.getFontsPaths()) { - if (fontPath.endsWith(font)) { - if (font.endsWith(".woff")) - resp.setContentType("font/woff"); - else if (font.endsWith(".woff2")) - resp.setContentType("font/woff2"); - try (InputStream in = theme.loadPath(fontPath)) { - IOUtils.copy(in, resp.getOutputStream()); - return; - } - } - } - } - resp.setStatus(404); - } - - public void addTheme(CmsTheme theme, Map properties) { - themes.put(theme.getThemeId(), theme); - } - - public void removeTheme(CmsTheme theme, Map properties) { - themes.remove(theme.getThemeId()); - } - -}