19 package org.turro.parser;
21 import freemarker.ext.dom.NodeModel;
23 import java.io.IOException;
24 import java.util.Date;
25 import java.util.Random;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
28 import javax.servlet.ServletException;
29 import javax.servlet.http.Cookie;
30 import javax.xml.parsers.ParserConfigurationException;
31 import org.amic.util.date.DateFormats;
32 import org.turro.collections.parser.ParserException;
33 import org.turro.string.ObjectString;
34 import org.turro.string.Strings;
35 import org.turro.action.ContentService;
36 import org.turro.action.IEntityCtrl;
37 import org.turro.action.Plugins;
38 import org.turro.action.UserSummaries;
39 import org.turro.annotation.ExternalParser;
40 import org.turro.collections.KeyObjectMap;
41 import org.turro.elephant.context.ElephantContext;
42 import org.turro.elephant.impl.feed.FeedMacro;
43 import org.turro.elephant.impl.util.CookieUtil;
44 import org.turro.elephant.impl.util.FileUtil;
45 import org.turro.elephant.impl.util.Files;
46 import org.turro.elephant.impl.util.Parser;
47 import org.turro.elephant.impl.util.StringParser;
48 import org.turro.elephant.security.IUser;
49 import org.turro.entities.Entities;
50 import org.turro.entities.IElephantEntity;
51 import org.turro.html.HTMLHelper;
52 import org.turro.i18n.I_;
53 import org.turro.indicator.IndicatorResult;
54 import org.turro.indicator.Indicators;
55 import org.turro.json.JsonSearch;
56 import org.turro.marker.ElephantMarker;
57 import org.turro.plugin.contacts.IContact;
58 import org.turro.reflection.Reflections;
59 import org.turro.user.content.UserContents;
60 import org.xml.sax.SAXException;
87 out.write(
"_" +
I_.
api().used().getLanguage());
102 }
catch (ServletException | IOException ex) {
108 if(!Strings.isBlank(value)) {
115 }
catch (ServletException | IOException ex) {
120 Date now =
new Date();
123 }
else if(
"time".equals(
getToken(1))) {
125 }
else if(
"all".equals(
getToken(1))) {
135 marker.
put(
"json", JsonSearch.of(file));
144 marker.
put(
"doc", NodeModel.parse(file));
146 }
catch (SAXException | ParserConfigurationException | IOException ex) {
157 }
catch (IOException ex) {
167 }
catch (ParserException ex) {
175 }
else if(
"shuffle".equals(
tokens[3])) {
184 if(path.startsWith(
"/")) {
187 hh.
startTag(
"iframe",
"src=\"" + path +
188 "\" style=\"border:0;margin:0;padding:0;width:" +
195 out.write(Strings.transform(res, ((Integer)ObjectString.parseString(
getToken(2), Integer.class,
true)).intValue()));
201 out.write(Strings.transform(res, ((Integer)ObjectString.parseString(
getToken(2), Integer.class,
true)).intValue()));
205 Random random =
new Random();
206 int v = random.nextInt(Integer.valueOf(
getToken(1)));
207 out.write(Integer.toString(v));
211 int i = Integer.valueOf(
getToken(1));
225 else if(
"email".equals(
getToken(1))) {
253 out.write(obj.toString());
261 if(!Strings.isBlank(format)) {
262 out.format(
I_.
api().used(), format, obj);
264 out.write(obj.toString());
287 if(Strings.isBlank(value)) {
289 if(cookie !=
null)
out.write(cookie.getValue());
296 String indicator =
null;
300 out.write(ObjectString.formatObject(Double.valueOf(ir.
getValue()),
"#,##0.00",
true));
static String createEntryPoint(IConstructor constructor, String entryPoint, String valueStr)
static< T > T loadImplementation(Class< T > jclass)
static void initSummaries(IConstructor constructor)
static String parseSummaries(IConstructor constructor)
static String getSiteName()
static String getRootWebPath()
static String logMsg(String msg)
static void writeFeed(IConstructor constructor, String feeds)
static Cookie getCookie(HttpServletRequest request, String name)
static void setCookie(HttpServletResponse response, String name, String value, String path, int age)
static Properties getOrderedProperties(File file)
static String getJsonFiles(final String path, final String pattern)
static String getJsonSortedFiles(final String path, final String pattern)
static String getJsonShuffledFiles(final String path, final String pattern)
static File file(IConstructor constructor, String file)
static Object getValueFrom(String pathToValue, Object object)
static IElephantEntity getController(String path)
HTMLGenerator startTag(String tag)
static String get(String msg)
static I18nApiWrapper api()
static I18nCompatibilityWrapper compatibility()
static IndicatorResult readIndicator(String indicator)
void process(String rootTmpl, String tmpl)
Object put(Object key, Object value)
String getToken(String name)
void explainMacros(ParserMacroSet macros)
ParserMacro addMacro(String macroName)
ParserMacro addPossibleValue(String value)
ParserMacro addParameter(String name, boolean optional)
static String parseContents(IConstructor constructor)
void setEntityPath(String entityPath)
String parse(IConstructor constructor)
void setTemplate(String template)
Object findAttribute(String key)
HttpServletResponse getResponse()
ElContext getCurrentContext()
HttpServletRequest getRequest()
String getParameter(String param)
void includeContent(String path)
void renderContext(String path, String stopper)
ElContext getRenderingContext()
boolean isInRole(String role)
static final String CONNECTOR_EMAIL
String getProperty(String key)