use of lucee.runtime.exp.PageException in project Lucee by lucee.
the class Application method set.
private boolean set(ApplicationContext ac, boolean update) throws PageException {
if (applicationTimeout != null)
ac.setApplicationTimeout(applicationTimeout);
if (sessionTimeout != null)
ac.setSessionTimeout(sessionTimeout);
if (clientTimeout != null)
ac.setClientTimeout(clientTimeout);
if (requestTimeout != null)
ac.setRequestTimeout(requestTimeout);
if (clientstorage != null) {
ac.setClientstorage(clientstorage);
}
if (sessionstorage != null) {
ac.setSessionstorage(sessionstorage);
}
if (customTagMappings != null)
ac.setCustomTagMappings(customTagMappings);
if (componentMappings != null)
ac.setComponentMappings(componentMappings);
if (mappings != null)
ac.setMappings(mappings);
if (loginstorage != Scope.SCOPE_UNDEFINED)
ac.setLoginStorage(loginstorage);
if (!StringUtil.isEmpty(datasource)) {
ac.setDefDataSource(datasource);
ac.setORMDataSource(datasource);
}
if (!StringUtil.isEmpty(defaultdatasource))
ac.setDefDataSource(defaultdatasource);
if (datasources != null) {
try {
ac.setDataSources(AppListenerUtil.toDataSources(pageContext.getConfig(), datasources, pageContext.getConfig().getLog("application")));
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
if (logs != null) {
try {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
acs.setLoggers(ApplicationContextSupport.initLog(logs));
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
if (mails != null) {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
try {
acs.setMailServers(AppListenerUtil.toMailServers(pageContext.getConfig(), mails, null));
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
if (caches != null) {
try {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
Iterator<Entry<Key, Object>> it = caches.entryIterator();
Entry<Key, Object> e;
String name;
Struct sct;
while (it.hasNext()) {
e = it.next();
// default value by name
if (!StringUtil.isEmpty(name = Caster.toString(e.getValue(), null))) {
setDefault(ac, e.getKey(), name);
} else // cache definition
if ((sct = Caster.toStruct(e.getValue(), null)) != null) {
CacheConnection cc = ModernApplicationContext.toCacheConnection(pageContext.getConfig(), e.getKey().getString(), sct);
if (cc != null) {
name = e.getKey().getString();
acs.setCacheConnection(name, cc);
// key is a cache type
setDefault(ac, e.getKey(), name);
// default key
Key def = Caster.toKey(sct.get(KeyConstants._default, null), null);
if (def != null)
setDefault(ac, def, name);
}
}
}
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
if (onmissingtemplate != null && ac instanceof ClassicApplicationContext) {
((ClassicApplicationContext) ac).setOnMissingTemplate(onmissingtemplate);
}
if (scriptrotect != null)
ac.setScriptProtect(AppListenerUtil.translateScriptProtect(scriptrotect));
if (bufferOutput != null)
ac.setBufferOutput(bufferOutput.booleanValue());
if (secureJson != null)
ac.setSecureJson(secureJson.booleanValue());
if (typeChecking != null)
ac.setTypeChecking(typeChecking.booleanValue());
if (suppress != null)
ac.setSuppressContent(suppress.booleanValue());
if (secureJsonPrefix != null)
ac.setSecureJsonPrefix(secureJsonPrefix);
if (setClientCookies != null)
ac.setSetClientCookies(setClientCookies.booleanValue());
if (setClientManagement != null)
ac.setSetClientManagement(setClientManagement.booleanValue());
if (setDomainCookies != null)
ac.setSetDomainCookies(setDomainCookies.booleanValue());
if (setSessionManagement != null)
ac.setSetSessionManagement(setSessionManagement.booleanValue());
if (localMode != -1)
ac.setLocalMode(localMode);
if (mailListener != null)
((ApplicationContextSupport) ac).setMailListener(mailListener);
if (locale != null)
ac.setLocale(locale);
if (timeZone != null)
ac.setTimeZone(timeZone);
if (webCharset != null)
ac.setWebCharset(webCharset.toCharset());
if (resourceCharset != null)
ac.setResourceCharset(resourceCharset.toCharset());
if (sessionType != -1)
ac.setSessionType(sessionType);
if (wsType != -1)
ac.setWSType(wsType);
if (triggerDataMember != null)
ac.setTriggerComponentDataMember(triggerDataMember.booleanValue());
if (compression != null)
ac.setAllowCompression(compression.booleanValue());
if (cacheFunction != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_FUNCTION, cacheFunction);
if (cacheObject != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_OBJECT, cacheObject);
if (cacheQuery != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_QUERY, cacheQuery);
if (cacheResource != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_RESOURCE, cacheResource);
if (cacheTemplate != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_TEMPLATE, cacheTemplate);
if (cacheInclude != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_INCLUDE, cacheInclude);
if (cacheHTTP != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_HTTP, cacheHTTP);
if (cacheFile != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_FILE, cacheFile);
if (cacheWebservice != null)
ac.setDefaultCacheName(Config.CACHE_TYPE_WEBSERVICE, cacheWebservice);
if (antiSamyPolicyResource != null)
((ApplicationContextSupport) ac).setAntiSamyPolicyResource(antiSamyPolicyResource);
if (sessionCookie != null) {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
acs.setSessionCookie(sessionCookie);
}
if (authCookie != null) {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
acs.setAuthCookie(authCookie);
}
if (tag != null)
ac.setTagAttributeDefaultValues(pageContext, tag);
ac.setClientCluster(clientCluster);
ac.setSessionCluster(sessionCluster);
ac.setCGIScopeReadonly(cgiReadOnly);
if (s3 != null)
ac.setS3(AppListenerUtil.toS3(s3));
// Scope cascading
if (scopeCascading != -1)
ac.setScopeCascading(scopeCascading);
// ORM
boolean initORM = false;
if (!update) {
if (ormenabled == null)
ormenabled = false;
if (ormsettings == null)
ormsettings = new StructImpl();
}
if (ormenabled != null)
ac.setORMEnabled(ormenabled);
if (ac.isORMEnabled()) {
initORM = true;
if (ormsettings != null)
AppListenerUtil.setORMConfiguration(pageContext, ac, ormsettings);
}
return initORM;
}
use of lucee.runtime.exp.PageException in project Lucee by lucee.
the class CFTag method _doCFCCatch.
public void _doCFCCatch(Throwable t, String source, boolean throwIfCFCNotExists) throws PageException {
writeEnclosingWriter();
// remove PageServletException wrap
if (t instanceof PageServletException) {
PageServletException pse = (PageServletException) t;
t = pse.getPageException();
}
// abort
try {
if (lucee.runtime.exp.Abort.isAbort(t)) {
if (bodyContent != null) {
bodyContent.writeOut(bodyContent.getEnclosingWriter());
bodyContent.clearBuffer();
}
throw Caster.toPageException(t);
}
} catch (IOException ioe) {
throw Caster.toPageException(ioe);
}
if (throwIfCFCNotExists && cfc == null)
throw Caster.toPageException(t);
try {
if (cfc != null && cfc.contains(pageContext, ON_ERROR)) {
PageException pe = Caster.toPageException(t);
// Object rtn=cfc.call(pageContext, ON_ERROR, new Object[]{pe.getCatchBlock(pageContext),source});
Struct args = new StructImpl(Struct.TYPE_LINKED);
args.set(CFCATCH, pe.getCatchBlock(ThreadLocalPageContext.getConfig(pageContext)));
args.set(SOURCE, source);
Object rtn = cfc.callWithNamedValues(pageContext, ON_ERROR, args);
if (Caster.toBooleanValue(rtn, false))
throw t;
} else
throw t;
} catch (Throwable th) {
ExceptionUtil.rethrowIfNecessary(th);
writeEnclosingWriter();
_doCFCFinally();
throw Caster.toPageException(th);
}
writeEnclosingWriter();
}
use of lucee.runtime.exp.PageException in project Lucee by lucee.
the class CFTag method cfcStartTag.
// CFC
private int cfcStartTag() throws PageException {
callerScope.initialize(pageContext);
try {
cfc = ComponentLoader.loadComponent(pageContext, source.getPageSource(), ResourceUtil.removeExtension(source.getFilename(), source.getFilename()), false, true);
} catch (PageException e) {
Mapping m = source.getPageSource().getMapping();
ConfigWebImpl c = (ConfigWebImpl) pageContext.getConfig();
if (m == c.getTagMapping())
m = c.getServerTagMapping();
else
m = null;
// is te page source from a tag mapping, so perhaps it was moved from server to web context
if (m != null) {
PageSource ps = m.getPageSource(source.getFilename());
try {
cfc = ComponentLoader.loadComponent(pageContext, ps, ResourceUtil.removeExtension(source.getFilename(), source.getFilename()), false, true);
} catch (PageException e1) {
throw e;
}
} else
throw e;
}
validateAttributes(cfc, attributesScope, StringUtil.ucFirst(ListUtil.last(source.getPageSource().getComponentName(), '.')));
boolean exeBody = false;
try {
Object rtn = Boolean.TRUE;
if (cfc.contains(pageContext, KeyConstants._init)) {
Tag parent = getParent();
while (parent != null && !(parent instanceof CFTag && ((CFTag) parent).isCFCBasedCustomTag())) {
parent = parent.getParent();
}
Struct args = new StructImpl(Struct.TYPE_LINKED);
args.set(KeyConstants._HASENDTAG, Caster.toBoolean(hasBody));
if (parent instanceof CFTag) {
args.set(PARENT, ((CFTag) parent).getComponent());
}
rtn = cfc.callWithNamedValues(pageContext, KeyConstants._init, args);
}
if (cfc.contains(pageContext, ON_START_TAG)) {
Struct args = new StructImpl();
args.set(KeyConstants._ATTRIBUTES, attributesScope);
setCaller(pageContext, args);
rtn = cfc.callWithNamedValues(pageContext, ON_START_TAG, args);
}
exeBody = Caster.toBooleanValue(rtn, true);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
_doCFCCatch(t, "start", true);
}
return exeBody ? EVAL_BODY_BUFFERED : SKIP_BODY;
}
use of lucee.runtime.exp.PageException in project Lucee by lucee.
the class CFXTag method doStartTag.
@Override
public int doStartTag() throws PageException {
// RR SerialNumber sn = pageContext.getConfig().getSerialNumber();
// if(sn.getVersion()==SerialNumber.VERSION_COMMUNITY)
// throw new SecurityException("no access to this functionality with the "+sn.getStringVersion()+" version of Lucee");
CFXTagPool pool = pageContext.getConfig().getCFXTagPool();
CustomTag ct;
try {
ct = pool.getCustomTag(appendix);
} catch (CFXTagException e) {
throw Caster.toPageException(e);
}
Request req = new RequestImpl(pageContext, attributes);
Response rsp = new ResponseImpl(pageContext, req.debug());
try {
ct.processRequest(req, rsp);
} catch (Exception e) {
throw Caster.toPageException(e);
}
pool.releaseCustomTag(ct);
return SKIP_BODY;
}
use of lucee.runtime.exp.PageException in project Lucee by lucee.
the class Cache method doStartTag.
@Override
public int doStartTag() throws PageException {
now = new DateTimeImpl(pageContext.getConfig());
if (action == CACHE && hasBody)
action = CONTENT;
try {
if (action == CACHE) {
doClientCache();
doServerCache();
} else if (action == CACHE_CLIENT)
doClientCache();
else if (action == CACHE_SERVER)
doServerCache();
else if (action == FLUSH)
doFlush();
else if (action == CONTENT)
return doContentCache();
else if (action == GET)
doGet();
else if (action == PUT)
doPut();
return EVAL_PAGE;
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
Aggregations