use of lucee.runtime.type.Array in project Lucee by lucee.
the class CredentialImpl method toRole.
/**
* convert a Object to a String Array of Roles
* @param oRoles
* @return roles
* @throws PageException
*/
public static String[] toRole(Object oRoles) throws PageException {
if (oRoles instanceof String) {
oRoles = ListUtil.listToArrayRemoveEmpty(oRoles.toString(), ",");
}
if (oRoles instanceof Array) {
Array arrRoles = (Array) oRoles;
String[] roles = new String[arrRoles.size()];
for (int i = 0; i < roles.length; i++) {
roles[i] = Caster.toString(arrRoles.get(i + 1, ""));
}
return roles;
}
throw new ApplicationException("invalid roles definition for tag loginuser");
}
use of lucee.runtime.type.Array in project Lucee by lucee.
the class DataSourceServiceImpl method getNames.
@Override
public Array getNames() throws SecurityException {
checkReadAccess();
lucee.runtime.db.DataSource[] sources = config().getDataSources();
Array names = new ArrayImpl();
for (int i = 0; i < sources.length; i++) {
names.appendEL(sources[i].getName());
}
return names;
}
use of lucee.runtime.type.Array 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);
}
use of lucee.runtime.type.Array in project Lucee by lucee.
the class XMLConfigAdmin method getResourceProviders.
private void getResourceProviders(ResourceProvider[] providers, Query qry, Element p, int row, Boolean def) throws PageException {
Array support = new ArrayImpl();
String cn = p.getAttribute("class");
String name = p.getAttribute("bundle-name");
String version = p.getAttribute("bundle-version");
ClassDefinition cd = new ClassDefinitionImpl(cn, name, version, ThreadLocalPageContext.getConfig().getIdentification());
qry.setAt("scheme", row, p.getAttribute("scheme"));
qry.setAt("arguments", row, p.getAttribute("arguments"));
qry.setAt("class", row, cd.getClassName());
qry.setAt("bundleName", row, cd.getName());
qry.setAt("bundleVersion", row, cd.getVersionAsString());
for (int i = 0; i < providers.length; i++) {
if (providers[i].getClass().getName().equals(cd.getClassName())) {
if (providers[i].isAttributesSupported())
support.append("attributes");
if (providers[i].isModeSupported())
support.append("mode");
qry.setAt("support", row, ListUtil.arrayToList(support, ","));
qry.setAt("scheme", row, providers[i].getScheme());
qry.setAt("caseSensitive", row, Caster.toBoolean(providers[i].isCaseSensitive()));
qry.setAt("default", row, def);
break;
}
}
}
use of lucee.runtime.type.Array in project Lucee by lucee.
the class ArrayFindAll method find.
public static Array find(PageContext pc, Array array, UDF udf) throws PageException {
Array rtn = new ArrayImpl();
int len = array.size();
Object[] arr = new Object[1];
Object res;
Boolean b;
for (int i = 1; i <= len; i++) {
arr[0] = array.get(i, null);
if (arr[0] != null) {
res = udf.call(pc, arr, false);
b = Caster.toBoolean(res, null);
if (b == null)
throw new FunctionException(pc, "ArrayFindAll", 2, "function", "return value of the " + (udf instanceof Closure ? "closure" : "function [" + udf.getFunctionName() + "]") + " cannot be casted to a boolean value.", CasterException.createMessage(res, "boolean"));
if (b.booleanValue()) {
rtn.appendEL(Caster.toDouble(i));
}
}
}
return rtn;
}
Aggregations