use of lucee.runtime.type.scope.Scope in project Lucee by lucee.
the class Exit method doEndTag.
@Override
public int doEndTag() throws TemplateException {
Scope variables = pageContext.variablesScope();
Object thistagObj = variables.get("thistag", null);
boolean insideCT = (thistagObj != null) && (thistagObj instanceof lucee.runtime.type.Collection);
// Inside Custom Tag
if (insideCT) {
lucee.runtime.type.Collection thistag = (lucee.runtime.type.Collection) thistagObj;
// executionmode
Object exeModeObj = thistag.get("executionmode", null);
boolean isEndMode = (exeModeObj != null) && (exeModeObj instanceof String) && exeModeObj.toString().equalsIgnoreCase("end");
// Start
if (!isEndMode) {
if (method == MODE_LOOP) {
throw new TemplateException("invalid context for the tag exit, method loop can only be used in the end tag of a custom tag");
} else if (method == MODE_EXIT_TAG) {
thistag.setEL("executebody", Boolean.FALSE);
return SKIP_PAGE;
}
} else // End
if (method == MODE_LOOP) {
thistag.setEL("executebody", Boolean.TRUE);
return SKIP_PAGE;
}
return SKIP_PAGE;
}
// OUTside Custom Tag
if (method == MODE_LOOP)
throw new TemplateException("invalid context for the tag exit, method loop can only be used inside a custom tag");
return SKIP_PAGE;
}
use of lucee.runtime.type.scope.Scope in project Lucee by lucee.
the class Props method call.
@Override
public Object call(PageContext pc) throws PageException {
// remote persistent (only type server is supported)
// Caster.toString(pc.urlFormScope().get(REMOTE_PERSISTENT_ID,null),null);
String strRemotePersisId = Caster.toString(getURLorForm(pc, REMOTE_PERSISTENT_ID, null), null);
if (!StringUtil.isEmpty(strRemotePersisId, true)) {
strRemotePersisId = strRemotePersisId.trim();
} else
strRemotePersisId = null;
HttpServletRequest req = pc.getHttpServletRequest();
// client
String client = Caster.toString(req.getAttribute("client"), null);
// call type (invocation, store-only)
String callType = Caster.toString(req.getAttribute("call-type"), null);
boolean internalCall = "lucee-gateway-1-0".equals(client) || "lucee-listener-1-0".equals(client);
boolean fromRest = "lucee-rest-1-0".equals(client);
Component component;
try {
pc.setSilent();
// load the cfc
try {
if (internalCall && strRemotePersisId != null) {
ConfigWebImpl config = (ConfigWebImpl) pc.getConfig();
GatewayEngineImpl engine = config.getGatewayEngine();
component = engine.getPersistentRemoteCFC(strRemotePersisId);
if (component == null) {
component = newInstance(pc, getComponentName(), false, false, true);
if (!internalCall)
component = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_REMOTE, component);
engine.setPersistentRemoteCFC(strRemotePersisId, component);
}
} else {
component = newInstance(pc, getComponentName(), false, false, true);
if (!internalCall)
component = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_REMOTE, component);
}
} finally {
pc.unsetSilent();
}
// Only get the Component, no invocation
if ("store-only".equals(callType)) {
req.setAttribute("component", component);
return null;
}
// METHOD INVOCATION
String qs = ReqRspUtil.getQueryString(pc.getHttpServletRequest());
if (pc.getBasePageSource() == this.getPageSource() && pc.getConfig().debug())
pc.getDebugger().setOutput(false);
boolean isPost = pc.getHttpServletRequest().getMethod().equalsIgnoreCase("POST");
boolean suppressContent = pc.getRequestDialect() == CFMLEngine.DIALECT_LUCEE || ((PageContextImpl) pc).getSuppressContent();
if (suppressContent)
pc.clear();
Object method;
if (fromRest) {
callRest(pc, component, Caster.toString(req.getAttribute("rest-path"), ""), (Result) req.getAttribute("rest-result"), suppressContent);
return null;
}
// POST
if (isPost) {
// Soap
if (isSoap(pc)) {
callWebservice(pc, component);
// close(pc);
return null;
} else // WDDX
if ((method = getURLorForm(pc, KeyConstants._method, null)) != null) {
callWDDX(pc, component, KeyImpl.toKey(method), suppressContent);
// close(pc);
return null;
}
} else // GET
{
// WSDL
if (qs != null && (qs.trim().equalsIgnoreCase("wsdl") || qs.trim().startsWith("wsdl&"))) {
callWSDL(pc, component);
// close(pc);
return null;
} else // WDDX
if ((method = getURLorForm(pc, KeyConstants._method, null)) != null) {
callWDDX(pc, component, KeyImpl.toKey(method), suppressContent);
// close(pc);
return null;
}
if (qs != null) {
int rf = UDFUtil.toReturnFormat(qs.trim(), -1);
if (rf != -1)
callCFCMetaData(pc, component, rf);
// close(pc);
return null;
}
}
// Include MUST
Array path = pc.getTemplatePath();
// if(path.size()>1 ) {
if (path.size() > 1 && !(path.size() == 3 && ListUtil.last(path.getE(2).toString(), "/\\", true).equalsIgnoreCase(pc.getRequestDialect() == CFMLEngine.DIALECT_CFML ? lucee.runtime.config.Constants.CFML_APPLICATION_EVENT_HANDLER : lucee.runtime.config.Constants.LUCEE_APPLICATION_EVENT_HANDLER))) {
// MUSTMUST bad impl -> check with and without application . cfc
ComponentSpecificAccess c = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE, component);
Key[] keys = c.keys();
Object el;
Scope var = pc.variablesScope();
for (int i = 0; i < keys.length; i++) {
el = c.get(keys[i], null);
if (el instanceof UDF)
var.set(keys[i], el);
}
return null;
}
// DUMP
// TODO component.setAccess(pc,Component.ACCESS_PUBLIC);
String cdf = pc.getConfig().getComponentDumpTemplate();
if (cdf != null && cdf.trim().length() > 0) {
pc.variablesScope().set(KeyConstants._component, component);
pc.doInclude(cdf, false);
} else
pc.write(pc.getConfig().getDefaultDumpWriter(DumpWriter.DEFAULT_RICH).toString(pc, component.toDumpData(pc, 9999, DumpUtil.toDumpProperties()), true));
} catch (Throwable t) {
// Exception Handler.castAnd Stack(t, this, pc);
throw Caster.toPageException(t);
}
return null;
}
Aggregations