Search in sources :

Example 26 with Array

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");
}
Also used : Array(lucee.runtime.type.Array) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 27 with Array

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;
}
Also used : Array(lucee.runtime.type.Array) ArrayImpl(lucee.runtime.type.ArrayImpl) DataSource(coldfusion.sql.DataSource)

Example 28 with Array

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);
}
Also used : Array(lucee.runtime.type.Array) StructImpl(lucee.runtime.type.StructImpl) ApplicationException(lucee.runtime.exp.ApplicationException) Iterator(java.util.Iterator) ORMConfiguration(lucee.runtime.orm.ORMConfiguration) Struct(lucee.runtime.type.Struct)

Example 29 with Array

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;
        }
    }
}
Also used : Array(lucee.runtime.type.Array) ClassDefinitionImpl(lucee.transformer.library.ClassDefinitionImpl) ArrayImpl(lucee.runtime.type.ArrayImpl) ClassDefinition(lucee.runtime.db.ClassDefinition)

Example 30 with Array

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;
}
Also used : Array(lucee.runtime.type.Array) Closure(lucee.runtime.type.Closure) ArrayImpl(lucee.runtime.type.ArrayImpl) FunctionException(lucee.runtime.exp.FunctionException)

Aggregations

Array (lucee.runtime.type.Array)169 ArrayImpl (lucee.runtime.type.ArrayImpl)79 Struct (lucee.runtime.type.Struct)49 StructImpl (lucee.runtime.type.StructImpl)25 Iterator (java.util.Iterator)24 PageException (lucee.runtime.exp.PageException)23 Entry (java.util.Map.Entry)22 ArrayList (java.util.ArrayList)20 Key (lucee.runtime.type.Collection.Key)20 ListIterator (java.util.ListIterator)16 Query (lucee.runtime.type.Query)16 List (java.util.List)14 ApplicationException (lucee.runtime.exp.ApplicationException)14 FunctionException (lucee.runtime.exp.FunctionException)14 ForEachQueryIterator (lucee.runtime.type.it.ForEachQueryIterator)14 Resource (lucee.commons.io.res.Resource)13 IOException (java.io.IOException)12 Collection (lucee.runtime.type.Collection)10 QueryImpl (lucee.runtime.type.QueryImpl)10 JavaObject (lucee.runtime.java.JavaObject)8