package at.gv.egiz.eidas.specific.connector.gui; import java.io.InputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import at.gv.egiz.eaaf.core.api.gui.IGUIBuilderConfiguration; import at.gv.egiz.eaaf.core.api.gui.IGUIFormBuilder; import at.gv.egiz.eaaf.core.exceptions.GUIBuildException; import at.gv.egiz.eaaf.core.impl.gui.AbstractGUIFormBuilderImpl; @Service("DefaultGUIBuilderImpl") public class DefaultGUIBuilderImpl extends AbstractGUIFormBuilderImpl implements IGUIFormBuilder { private static final Logger log = LoggerFactory.getLogger(DefaultGUIBuilderImpl.class); private static final String CLASSPATH_HTMLTEMPLATES_DIR = "templates/"; public DefaultGUIBuilderImpl() throws GUIBuildException { super(); } @Override protected InputStream getInternalTemplate(IGUIBuilderConfiguration config) throws GUIBuildException { String viewName = config.getViewName(); log.debug("GUI template:" + viewName + " is not found in configuration directory. " + " Load template from project library ... "); String pathLocation = getInternalClasspathTemplateDir(config, CLASSPATH_HTMLTEMPLATES_DIR) + viewName; try { InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(pathLocation); return is; } catch (Exception e1) { log.error("GUI template:" + pathLocation + " is NOT loadable from classpath!", e1); throw new GUIBuildException("GUI template:" + pathLocation + " is NOT loadable from classpath!", e1); } } }