Search in sources :

Example 36 with StructImpl

use of lucee.runtime.type.StructImpl in project Lucee by lucee.

the class Mapping method getResult.

public Result getResult(PageContext pc, String path, Struct matrix, int format, boolean hasFormatExtension, List<MimeType> accept, MimeType contentType, Result defaultValue) throws PageException {
    List<Source> sources = init(pc, false);
    Iterator<Source> it = sources.iterator();
    Source src;
    String[] arrPath, subPath;
    int index;
    while (it.hasNext()) {
        src = it.next();
        Struct variables = new StructImpl();
        arrPath = RestUtil.splitPath(path);
        index = RestUtil.matchPath(variables, src.getPath(), arrPath);
        if (index != -1) {
            subPath = new String[(arrPath.length - 1) - index];
            System.arraycopy(arrPath, index + 1, subPath, 0, subPath.length);
            return new Result(src, variables, subPath, matrix, format, hasFormatExtension, accept, contentType);
        }
    }
    return defaultValue;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) PageSource(lucee.runtime.PageSource) Struct(lucee.runtime.type.Struct)

Example 37 with StructImpl

use of lucee.runtime.type.StructImpl in project Lucee by lucee.

the class Caster method toStruct.

public static Struct toStruct(Query qry, int row) {
    Key[] names = qry.getColumnNames();
    Struct sct = new StructImpl();
    for (int i = 0; i < names.length; i++) {
        sct.setEL(names[i], qry.getAt(names[i], row, null));
    }
    return sct;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) Key(lucee.runtime.type.Collection.Key) XMLMultiElementStruct(lucee.runtime.text.xml.struct.XMLMultiElementStruct) XMLStruct(lucee.runtime.text.xml.struct.XMLStruct) ObjectStruct(lucee.runtime.type.scope.ObjectStruct) MapAsStruct(lucee.runtime.type.wrap.MapAsStruct) Struct(lucee.runtime.type.Struct) CollectionStruct(lucee.runtime.type.CollectionStruct)

Example 38 with StructImpl

use of lucee.runtime.type.StructImpl in project Lucee by lucee.

the class DatSourceDefImpl method getAllowedSQL.

@Override
public Struct getAllowedSQL() {
    Struct allow = new StructImpl();
    allow.setEL(KeyConstants._alter, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_ALTER)));
    allow.setEL(KeyConstants._create, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_CREATE)));
    allow.setEL(KeyConstants._delete, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_DELETE)));
    allow.setEL(KeyConstants._drop, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_DROP)));
    allow.setEL(KeyConstants._grant, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_GRANT)));
    allow.setEL(KeyConstants._insert, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_INSERT)));
    allow.setEL(KeyConstants._revoke, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_REVOKE)));
    allow.setEL(KeyConstants._select, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_SELECT)));
    // TODO
    allow.setEL("storedproc", Caster.toBoolean(true));
    allow.setEL(KeyConstants._update, Caster.toBoolean(ds.hasAllow(DataSource.ALLOW_UPDATE)));
    return allow;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) Struct(lucee.runtime.type.Struct)

Example 39 with StructImpl

use of lucee.runtime.type.StructImpl in project Lucee by lucee.

the class DataSourceServiceImpl method getDrivers.

@Override
public Struct getDrivers() throws ServiceException, SecurityException {
    checkReadAccess();
    Struct rtn = new StructImpl();
    Struct driver;
    try {
        Resource luceeContext = ResourceUtil.toResourceExisting(pc(), "/lucee/admin/dbdriver/");
        Resource[] children = luceeContext.listResources(new ExtensionResourceFilter(Constants.getComponentExtensions()));
        String name;
        for (int i = 0; i < children.length; i++) {
            driver = new StructImpl();
            name = ListFirst.call(pc(), children[i].getName(), ".");
            driver.setEL(KeyConstants._name, name);
            driver.setEL("handler", children[i].getName());
            rtn.setEL(name, driver);
        }
    } catch (ExpressionException e) {
        throw new ServiceException(e.getMessage());
    }
    return rtn;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) ServiceException(coldfusion.server.ServiceException) Resource(lucee.commons.io.res.Resource) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter) ExpressionException(lucee.runtime.exp.ExpressionException) Struct(lucee.runtime.type.Struct)

Example 40 with StructImpl

use of lucee.runtime.type.StructImpl in project Lucee by lucee.

the class DataSourceServiceImpl method getDatasources.

@Override
public Struct getDatasources() throws SecurityException {
    // MUST muss struct of struct zurueckgeben!!!
    checkReadAccess();
    lucee.runtime.db.DataSource[] sources = config().getDataSources();
    Struct rtn = new StructImpl();
    for (int i = 0; i < sources.length; i++) {
        rtn.setEL(sources[i].getName(), new DataSourceImpl(sources[i]));
    }
    return rtn;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) DataSource(coldfusion.sql.DataSource) Struct(lucee.runtime.type.Struct)

Aggregations

StructImpl (lucee.runtime.type.StructImpl)251 Struct (lucee.runtime.type.Struct)216 PageException (lucee.runtime.exp.PageException)40 Entry (java.util.Map.Entry)34 Key (lucee.runtime.type.Collection.Key)28 Array (lucee.runtime.type.Array)25 ArrayImpl (lucee.runtime.type.ArrayImpl)24 ApplicationException (lucee.runtime.exp.ApplicationException)21 IOException (java.io.IOException)19 Map (java.util.Map)19 Resource (lucee.commons.io.res.Resource)18 Iterator (java.util.Iterator)17 PageContextImpl (lucee.runtime.PageContextImpl)14 QueryImpl (lucee.runtime.type.QueryImpl)13 Collection (lucee.runtime.type.Collection)11 Query (lucee.runtime.type.Query)11 DateTimeImpl (lucee.runtime.type.dt.DateTimeImpl)11 HashMap (java.util.HashMap)9 PageSource (lucee.runtime.PageSource)8 Element (org.w3c.dom.Element)8