use of lucee.runtime.exp.PageException in project Lucee by lucee.
the class Log4jUtil method getLayout.
public static final Layout getLayout(ClassDefinition cd, Map<String, String> layoutArgs) {
if (layoutArgs == null)
layoutArgs = new HashMap<String, String>();
// Layout
Layout layout = null;
if (cd != null && cd.hasClass()) {
// Classic Layout
if (ClassicLayout.class.getName().equalsIgnoreCase(cd.getClassName()))
layout = new ClassicLayout();
else // HTML Layout
if (HTMLLayout.class.getName().equalsIgnoreCase(cd.getClassName())) {
HTMLLayout html = new HTMLLayout();
layout = html;
// Location Info
Boolean locInfo = Caster.toBoolean(layoutArgs.get("locationinfo"), null);
if (locInfo != null)
html.setLocationInfo(locInfo.booleanValue());
else
locInfo = Boolean.FALSE;
layoutArgs.put("locationinfo", locInfo.toString());
// Title
String title = Caster.toString(layoutArgs.get("title"), "");
if (!StringUtil.isEmpty(title, true))
html.setTitle(title);
layoutArgs.put("title", title);
} else // XML Layout
if (XMLLayout.class.getName().equalsIgnoreCase(cd.getClassName())) {
XMLLayout xml = new XMLLayout();
layout = xml;
// Location Info
Boolean locInfo = Caster.toBoolean(layoutArgs.get("locationinfo"), null);
if (locInfo != null)
xml.setLocationInfo(locInfo.booleanValue());
else
locInfo = Boolean.FALSE;
layoutArgs.put("locationinfo", locInfo.toString());
// Properties
Boolean props = Caster.toBoolean(layoutArgs.get("properties"), null);
if (props != null)
xml.setProperties(props.booleanValue());
else
props = Boolean.FALSE;
layoutArgs.put("properties", props.toString());
} else // Pattern Layout
if (PatternLayout.class.getName().equalsIgnoreCase(cd.getClassName())) {
PatternLayout patt = new PatternLayout();
layout = patt;
// pattern
String pattern = Caster.toString(layoutArgs.get("pattern"), null);
if (!StringUtil.isEmpty(pattern, true))
patt.setConversionPattern(pattern);
else {
patt.setConversionPattern(DEFAULT_PATTERN);
layoutArgs.put("pattern", DEFAULT_PATTERN);
}
} else // class defintion
{
Object obj = ClassUtil.loadInstance(cd.getClazz(null), null, null);
if (obj instanceof Layout) {
layout = (Layout) obj;
Iterator<Entry<String, String>> it = layoutArgs.entrySet().iterator();
Entry<String, String> e;
while (it.hasNext()) {
e = it.next();
try {
Reflector.callSetter(obj, e.getKey(), e.getValue());
} catch (PageException e1) {
// TODO log
SystemOut.printDate(e1);
}
}
}
}
}
if (layout != null)
return layout;
return new ClassicLayout();
}
use of lucee.runtime.exp.PageException in project Lucee by lucee.
the class CFMLResourceProvider method callResourceArrayRTE.
Resource[] callResourceArrayRTE(PageContext pc, Component component, String methodName, Object[] args) {
pc = ThreadLocalPageContext.get(pc);
try {
Array arr = Caster.toArray(call(pc, getCFC(pc, component), methodName, args));
Iterator<Object> it = arr.valueIterator();
CFMLResource[] resources = new CFMLResource[arr.size()];
int index = 0;
while (it.hasNext()) {
resources[index++] = new CFMLResource(this, Caster.toComponent(it.next()));
}
return resources;
} catch (PageException pe) {
throw new PageRuntimeException(pe);
}
}
use of lucee.runtime.exp.PageException in project Lucee by lucee.
the class DatasourceResource method listResources.
@Override
public Resource[] listResources() {
if (!attr().isDirectory())
return null;
String path;
if (parent == null)
path = "/";
else
path = parent.concat(name).concat("/");
Attr[] children = null;
try {
children = provider.getAttrs(data, path.hashCode(), path);
} catch (PageException e) {
throw new PageRuntimeException(e);
}
if (children == null)
return new Resource[0];
Resource[] attrs = new Resource[children.length];
for (int i = 0; i < children.length; i++) {
// TODO optimieren, alle attr mitgeben
attrs[i] = new DatasourceResource(provider, data, path + children[i].getName());
}
return attrs;
}
use of lucee.runtime.exp.PageException in project Lucee by lucee.
the class DatasourceResourceProvider method delete.
public void delete(ConnectionData data, int fullPathHash, String path, String name) throws IOException {
Attr attr = getAttr(data, fullPathHash, path, name);
if (attr == null)
throw new IOException("can't delete resource " + path + name + ", resource does not exist");
DatasourceConnection dc = null;
try {
dc = getDatasourceConnection(data);
getCore(data).delete(dc, data.getPrefix(), attr);
} catch (SQLException e) {
throw new IOException(e.getMessage());
} catch (PageException e) {
throw new PageRuntimeException(e);
} finally {
removeFromCache(data, path, name);
release(dc);
// manager.releaseConnection(CONNECTION_ID,dc);
}
}
use of lucee.runtime.exp.PageException in project Lucee by lucee.
the class Admin method doStartTag.
@Override
public int doStartTag() throws PageException {
config = (ConfigImpl) pageContext.getConfig();
// Action
Object objAction = attributes.get(KeyConstants._action);
if (objAction == null)
throw new ApplicationException("missing attrbute action for tag admin");
action = StringUtil.toLowerCase(Caster.toString(objAction)).trim();
// Generals
if (action.equals("buildbundle")) {
doBuildBundle();
return SKIP_BODY;
}
if (action.equals("readbundle")) {
doReadBundle();
return SKIP_BODY;
}
if (action.equals("getlocales")) {
doGetLocales();
return SKIP_BODY;
}
if (action.equals("gettimezones")) {
doGetTimeZones();
return SKIP_BODY;
}
if (action.equals("printdebug")) {
throw new DeprecatedException("action [printdebug] is no longer supported, use instead [getdebugdata]");
}
if (action.equals("getdebugdata")) {
doGetDebugData();
return SKIP_BODY;
}
if (action.equals("adddump")) {
doAddDump();
return SKIP_BODY;
}
if (action.equals("getloginsettings")) {
doGetLoginSettings();
return SKIP_BODY;
}
// Type
type = toType(getString("type", "web"), true);
// has Password
if (action.equals("haspassword")) {
boolean hasPassword = type == TYPE_WEB ? pageContext.getConfig().hasPassword() : pageContext.getConfig().hasServerPassword();
pageContext.setVariable(getString("admin", action, "returnVariable", true), Caster.toBoolean(hasPassword));
return SKIP_BODY;
} else // update Password
if (action.equals("updatepassword")) {
try {
((ConfigWebImpl) pageContext.getConfig()).updatePassword(type != TYPE_WEB, getString("oldPassword", null), getString("admin", action, "newPassword", true));
} catch (Exception e) {
throw Caster.toPageException(e);
}
return SKIP_BODY;
}
try {
_doStartTag();
} catch (IOException e) {
throw Caster.toPageException(e);
}
return Tag.SKIP_BODY;
}
Aggregations