use of lucee.runtime.type.StructImpl in project Lucee by lucee.
the class Admin method doGetDatasource.
/**
* @throws PageException
*/
private void doGetDatasource() throws PageException {
String name = getString("admin", action, "name");
Map ds = config.getDataSourcesAsMap();
Iterator it = ds.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
if (key.equalsIgnoreCase(name)) {
DataSource d = (DataSource) ds.get(key);
Struct sct = new StructImpl();
ClassDefinition cd = d.getClassDefinition();
sct.setEL(KeyConstants._name, key);
sct.setEL(KeyConstants._host, d.getHost());
sct.setEL("classname", cd.getClassName());
sct.setEL("class", cd.getClassName());
sct.setEL("bundleName", cd.getName());
sct.setEL("bundleVersion", cd.getVersionAsString());
sct.setEL("dsn", d.getDsnOriginal());
sct.setEL("database", d.getDatabase());
sct.setEL("port", d.getPort() < 1 ? "" : Caster.toString(d.getPort()));
sct.setEL("dsnTranslated", d.getDsnTranslated());
sct.setEL("timezone", toStringTimeZone(d.getTimeZone()));
sct.setEL("password", d.getPassword());
sct.setEL("passwordEncrypted", ConfigWebUtil.encrypt(d.getPassword()));
sct.setEL("username", d.getUsername());
sct.setEL("readonly", Caster.toBoolean(d.isReadOnly()));
sct.setEL("select", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_SELECT)));
sct.setEL("delete", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DELETE)));
sct.setEL("update", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_UPDATE)));
sct.setEL("insert", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_INSERT)));
sct.setEL("create", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_CREATE)));
sct.setEL("insert", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_INSERT)));
sct.setEL("drop", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DROP)));
sct.setEL("grant", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_GRANT)));
sct.setEL("revoke", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_REVOKE)));
sct.setEL("alter", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_ALTER)));
sct.setEL("connectionLimit", d.getConnectionLimit() < 1 ? "" : Caster.toString(d.getConnectionLimit()));
sct.setEL("connectionTimeout", d.getConnectionTimeout() < 1 ? "" : Caster.toString(d.getConnectionTimeout()));
sct.setEL("metaCacheTimeout", Caster.toDouble(d.getMetaCacheTimeout()));
sct.setEL("custom", d.getCustoms());
sct.setEL("blob", Boolean.valueOf(d.isBlob()));
sct.setEL("clob", Boolean.valueOf(d.isClob()));
sct.setEL("validate", Boolean.valueOf(d.validate()));
sct.setEL("storage", Boolean.valueOf(d.isStorage()));
if (d instanceof DataSourceImpl) {
DataSourceImpl di = ((DataSourceImpl) d);
sct.setEL("literalTimestampWithTSOffset", Boolean.valueOf(di.getLiteralTimestampWithTSOffset()));
sct.setEL("alwaysSetTimeout", Boolean.valueOf(di.getAlwaysSetTimeout()));
sct.setEL("dbdriver", Caster.toString(di.getDbDriver(), ""));
}
pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
return;
}
}
throw new ApplicationException("there is no datasource with name [" + name + "]");
}
use of lucee.runtime.type.StructImpl in project Lucee by lucee.
the class Admin method doGetMapping.
/**
* @throws PageException
*/
private void doGetMapping() throws PageException {
Mapping[] mappings = config.getMappings();
Struct sct = new StructImpl();
String virtual = getString("admin", action, "virtual");
for (int i = 0; i < mappings.length; i++) {
MappingImpl m = (MappingImpl) mappings[i];
if (!m.getVirtual().equals(virtual))
continue;
sct.set("archive", m.getArchive());
sct.set("strarchive", m.getStrArchive());
sct.set("physical", m.getPhysical());
sct.set("strphysical", m.getStrPhysical());
sct.set("virtual", m.getVirtual());
sct.set(KeyConstants._hidden, Caster.toBoolean(m.isHidden()));
sct.set("physicalFirst", Caster.toBoolean(m.isPhysicalFirst()));
sct.set("readonly", Caster.toBoolean(m.isReadonly()));
sct.set("inspect", ConfigWebUtil.inspectTemplate(m.getInspectTemplateRaw(), ""));
sct.set("toplevel", Caster.toBoolean(m.isTopLevel()));
pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
return;
}
throw new ApplicationException("there is no mapping with virtual [" + virtual + "]");
}
use of lucee.runtime.type.StructImpl in project Lucee by lucee.
the class Admin method doGetCharset.
private void doGetCharset() throws PageException {
Struct sct = new StructImpl();
pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
sct.set("resourceCharset", config.getResourceCharset().name());
sct.set("templateCharset", config.getTemplateCharset().name());
sct.set("webCharset", ((PageContextImpl) pageContext).getWebCharset().name());
sct.set("jreCharset", SystemUtil.getCharset().name());
}
use of lucee.runtime.type.StructImpl in project Lucee by lucee.
the class Admin method doGetExecutionLog.
private void doGetExecutionLog() throws PageException {
ExecutionLogFactory factory = config.getExecutionLogFactory();
Struct sct = new StructImpl();
sct.set(KeyConstants._enabled, Caster.toBoolean(config.getExecutionLogEnabled()));
Class clazz = factory.getClazz();
sct.set(KeyConstants._class, clazz != null ? clazz.getName() : "");
sct.set(KeyConstants._arguments, factory.getArgumentsAsStruct());
pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
}
use of lucee.runtime.type.StructImpl in project Lucee by lucee.
the class Admin method doUpdateORMSetting.
private void doUpdateORMSetting() throws SecurityException, PageException {
ORMConfiguration oc = config.getORMConfig();
Struct settings = new StructImpl();
settings.set(ORMConfigurationImpl.AUTO_GEN_MAP, getBool("admin", action, "autogenmap"));
settings.set(ORMConfigurationImpl.EVENT_HANDLING, getBool("admin", action, "eventHandling"));
settings.set(ORMConfigurationImpl.FLUSH_AT_REQUEST_END, getBool("admin", action, "flushatrequestend"));
settings.set(ORMConfigurationImpl.LOG_SQL, getBool("admin", action, "logSQL"));
settings.set(ORMConfigurationImpl.SAVE_MAPPING, getBool("admin", action, "savemapping"));
settings.set(ORMConfigurationImpl.USE_DB_FOR_MAPPING, getBool("admin", action, "useDBForMapping"));
settings.set(ORMConfigurationImpl.SECONDARY_CACHE_ENABLED, getBool("admin", action, "secondarycacheenabled"));
settings.set(ORMConfigurationImpl.CATALOG, getString("admin", action, "catalog"));
settings.set(ORMConfigurationImpl.SCHEMA, getString("admin", action, "schema"));
settings.set(ORMConfigurationImpl.SQL_SCRIPT, getString("admin", action, "sqlscript"));
settings.set(ORMConfigurationImpl.CACHE_CONFIG, getString("admin", action, "cacheconfig"));
settings.set(ORMConfigurationImpl.CACHE_PROVIDER, getString("admin", action, "cacheProvider"));
settings.set(ORMConfigurationImpl.ORM_CONFIG, getString("admin", action, "ormConfig"));
// dbcreate
String strDbcreate = getString("admin", action, "dbcreate");
String dbcreate = "none";
if ("none".equals(strDbcreate))
dbcreate = "none";
else if ("update".equals(strDbcreate))
dbcreate = "update";
else if ("dropcreate".equals(strDbcreate))
dbcreate = "dropcreate";
else
throw new ApplicationException("invalid dbcreate definition [" + strDbcreate + "], valid dbcreate definitions are [none,update,dropcreate]");
settings.set(ORMConfigurationImpl.DB_CREATE, dbcreate);
// cfclocation
String strCfclocation = getString("admin", action, "cfclocation");
Array arrCfclocation = lucee.runtime.type.util.ListUtil.listToArray(strCfclocation, ",\n");
Iterator it = arrCfclocation.valueIterator();
String path;
while (it.hasNext()) {
path = (String) it.next();
ResourceUtil.toResourceExisting(config, path);
}
settings.set(KeyConstants._cfcLocation, arrCfclocation);
admin.updateORMSetting(ORMConfigurationImpl.load(config, null, settings, null, oc));
store();
adminSync.broadcast(attributes, config);
}
Aggregations