// -- super --// protected Object parse(String path, File file, Object extra) throws Exception { Boolean disable = (Boolean) ConfigurationHolder.getFlatConfig().get(CONFIG_ZKGRAILS_TAGLIB_DISABLE); if (disable != null) { if (disable) { final Locator locator = extra != null ? (Locator) extra : PageDefinitions.getLocator(_wapp, path); return new Parser(_wapp, locator).parse(file, path); } } Locator locator = null; if (extra != null) locator = (Locator) extra; else locator = PageDefinitions.getLocator(_wapp, path); GroovyPagesTemplateEngine gsp = (GroovyPagesTemplateEngine) _ctx.getBean("groovyPagesTemplateEngine"); byte[] buffer = new byte[(int) file.length()]; BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); bis.read(buffer); String encoding = (String) ConfigurationHolder.getFlatConfig().get(CONFIG_OPTION_GSP_ENCODING); if (encoding == null) encoding = UTF_8_ENCODING; String bufferStr = new String(buffer, encoding); bufferStr = bufferStr.replaceAll("@\\{", "\\$\\{'@'\\}\\{"); // checked Template template = gsp.createTemplate(new ByteArrayResource(bufferStr.getBytes(encoding))); // // Issue 113 is between here // Do not need to do anything, just correct encoding in Config.groovy // Writable w = template.make(); StringWriter sw = new StringWriter(); w.writeTo(new PrintWriter(sw)); // checked String zulSrc = sw.toString().replaceAll("\\#\\{", "\\$\\{"); // checked StringReader reader = new StringReader(zulSrc); PageDefinition pgdef = new Parser(_wapp, locator).parse(reader, null); pgdef.setRequestPath(path); return pgdef; }
/** * Invokes {@link Initiator#doInit}, if any, and returns an instance of{@link Initiators}. * * @param sysinits the system-level initiators */ @SuppressWarnings("unchecked") public static final Initiators doInit(PageDefinition pagedef, Page page, Initiator[] sysinits) { if (sysinits != null) try { for (int j = 0; j < sysinits.length; ++j) sysinits[j].doInit(page, Collections.EMPTY_MAP); } catch (Throwable ex) { throw UiException.Aide.wrap(ex); } final List<Initiator> inits = pagedef != null ? pagedef.doInit(page) : null; boolean sysinitEx = false; if (sysinits != null) for (int j = 0; j < sysinits.length; ++j) if (sysinits[j] instanceof InitiatorExt) { sysinitEx = true; break; } boolean initEx = false; if (inits != null) for (Initiator init : inits) if (init instanceof InitiatorExt) { initEx = true; break; } if (!sysinitEx && !initEx) return new Initiators(); return new RealInits(sysinits, inits, sysinitEx, initEx); }