Search in sources :

Example 71 with StructImpl

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

the class InterfaceImpl method _getMetaData.

private static Struct _getMetaData(PageContext pc, InterfaceImpl icfc, boolean ignoreCache) throws PageException {
    Page page = MetadataUtil.getPageWhenMetaDataStillValid(pc, icfc, ignoreCache);
    if (page != null && page.metaData != null && page.metaData.get() != null)
        return page.metaData.get();
    long creationTime = System.currentTimeMillis();
    Struct sct = new StructImpl();
    ArrayImpl arr = new ArrayImpl();
    {
        Iterator<UDF> it = icfc.udfs.values().iterator();
        while (it.hasNext()) {
            arr.append(it.next().getMetaData(pc));
        }
    }
    if (icfc.meta != null) {
        Iterator it = icfc.meta.entrySet().iterator();
        Map.Entry entry;
        while (it.hasNext()) {
            entry = (Entry) it.next();
            sct.setEL(KeyImpl.toKey(entry.getKey()), entry.getValue());
        }
    }
    if (!StringUtil.isEmpty(icfc.hint, true))
        sct.set(KeyConstants._hint, icfc.hint);
    if (!StringUtil.isEmpty(icfc.dspName, true))
        sct.set(KeyConstants._displayname, icfc.dspName);
    // init(pc,icfc);
    if (!ArrayUtil.isEmpty(icfc.extend)) {
        Set<String> _set = lucee.runtime.type.util.ListUtil.listToSet(icfc.strExtend, ',', true);
        Struct ex = new StructImpl();
        sct.set(KeyConstants._extends, ex);
        Iterator<InterfaceImpl> it = icfc.extend.iterator();
        InterfaceImpl inter;
        while (it.hasNext()) {
            inter = it.next();
            if (!_set.contains(inter.getCallPath()))
                continue;
            ex.setEL(KeyImpl.init(inter.getCallPath()), _getMetaData(pc, inter, true));
        }
    }
    if (arr.size() != 0)
        sct.set(KeyConstants._functions, arr);
    PageSource ps = icfc.pageSource;
    sct.set(KeyConstants._name, ps.getComponentName());
    sct.set(KeyConstants._fullname, ps.getComponentName());
    sct.set(KeyConstants._path, ps.getDisplayPath());
    sct.set(KeyConstants._type, "interface");
    page.metaData = new MetaDataSoftReference<Struct>(sct, creationTime);
    return sct;
}
Also used : Entry(java.util.Map.Entry) ArrayImpl(lucee.runtime.type.ArrayImpl) Struct(lucee.runtime.type.Struct) StructImpl(lucee.runtime.type.StructImpl) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

Example 72 with StructImpl

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

the class PageContextImpl method executeRest.

@Override
public void executeRest(String realPath, boolean throwExcpetion) throws PageException {
    initallog();
    // config.get ApplicationListener();
    ApplicationListener listener = null;
    try {
        String pathInfo = req.getPathInfo();
        // charset
        try {
            String charset = HTTPUtil.splitMimeTypeAndCharset(req.getContentType(), new String[] { "", "" })[1];
            if (StringUtil.isEmpty(charset))
                charset = getWebCharset().name();
            java.net.URL reqURL = new java.net.URL(req.getRequestURL().toString());
            String path = ReqRspUtil.decode(reqURL.getPath(), charset, true);
            String srvPath = req.getServletPath();
            if (path.startsWith(srvPath)) {
                pathInfo = path.substring(srvPath.length());
            }
        } catch (Exception e) {
        }
        // Service mapping
        if (StringUtil.isEmpty(pathInfo) || pathInfo.equals("/")) {
            // list available services (if enabled in admin)
            if (config.getRestList()) {
                try {
                    HttpServletRequest _req = getHttpServletRequest();
                    write("Available sevice mappings are:<ul>");
                    lucee.runtime.rest.Mapping[] mappings = config.getRestMappings();
                    lucee.runtime.rest.Mapping _mapping;
                    String path;
                    for (int i = 0; i < mappings.length; i++) {
                        _mapping = mappings[i];
                        Resource p = _mapping.getPhysical();
                        path = _req.getContextPath() + ReqRspUtil.getScriptName(this, _req) + _mapping.getVirtual();
                        write("<li " + (p == null || !p.isDirectory() ? " style=\"color:red\"" : "") + ">" + path + "</li>");
                    }
                    write("</ul>");
                } catch (IOException e) {
                    throw Caster.toPageException(e);
                }
            } else
                RestUtil.setStatus(this, 404, null);
            return;
        }
        // check for matrix
        int index;
        String entry;
        Struct matrix = new StructImpl();
        while ((index = pathInfo.lastIndexOf(';')) != -1) {
            entry = pathInfo.substring(index + 1);
            pathInfo = pathInfo.substring(0, index);
            if (StringUtil.isEmpty(entry, true))
                continue;
            index = entry.indexOf('=');
            if (index != -1)
                matrix.setEL(KeyImpl.init(entry.substring(0, index).trim()), entry.substring(index + 1).trim());
            else
                matrix.setEL(KeyImpl.init(entry.trim()), "");
        }
        // get accept
        List<MimeType> accept = ReqRspUtil.getAccept(this);
        MimeType contentType = ReqRspUtil.getContentType(this);
        // check for format extension
        // int format = getApplicationContext().getRestSettings().getReturnFormat();
        int format;
        boolean hasFormatExtension = false;
        if (StringUtil.endsWithIgnoreCase(pathInfo, ".json")) {
            pathInfo = pathInfo.substring(0, pathInfo.length() - 5);
            format = UDF.RETURN_FORMAT_JSON;
            accept.clear();
            accept.add(MimeType.APPLICATION_JSON);
            hasFormatExtension = true;
        } else if (StringUtil.endsWithIgnoreCase(pathInfo, ".wddx")) {
            pathInfo = pathInfo.substring(0, pathInfo.length() - 5);
            format = UDF.RETURN_FORMAT_WDDX;
            accept.clear();
            accept.add(MimeType.APPLICATION_WDDX);
            hasFormatExtension = true;
        } else if (StringUtil.endsWithIgnoreCase(pathInfo, ".cfml")) {
            pathInfo = pathInfo.substring(0, pathInfo.length() - 5);
            format = UDF.RETURN_FORMAT_SERIALIZE;
            accept.clear();
            accept.add(MimeType.APPLICATION_CFML);
            hasFormatExtension = true;
        } else if (StringUtil.endsWithIgnoreCase(pathInfo, ".serialize")) {
            pathInfo = pathInfo.substring(0, pathInfo.length() - 10);
            format = UDF.RETURN_FORMAT_SERIALIZE;
            accept.clear();
            accept.add(MimeType.APPLICATION_CFML);
            hasFormatExtension = true;
        } else if (StringUtil.endsWithIgnoreCase(pathInfo, ".xml")) {
            pathInfo = pathInfo.substring(0, pathInfo.length() - 4);
            format = UDF.RETURN_FORMAT_XML;
            accept.clear();
            accept.add(MimeType.APPLICATION_XML);
            hasFormatExtension = true;
        } else if (StringUtil.endsWithIgnoreCase(pathInfo, ".java")) {
            pathInfo = pathInfo.substring(0, pathInfo.length() - 5);
            format = UDFPlus.RETURN_FORMAT_JAVA;
            accept.clear();
            accept.add(MimeType.APPLICATION_JAVA);
            hasFormatExtension = true;
        } else {
            format = getApplicationContext() == null ? null : getApplicationContext().getRestSettings().getReturnFormat();
        // MimeType mt=MimeType.toMimetype(format);
        // if(mt!=null)accept.add(mt);
        }
        if (accept.size() == 0)
            accept.add(MimeType.ALL);
        // loop all mappings
        // lucee.runtime.rest.Result result = null;//config.getRestSource(pathInfo, null);
        RestRequestListener rl = null;
        lucee.runtime.rest.Mapping[] restMappings = config.getRestMappings();
        lucee.runtime.rest.Mapping m, mapping = null, defaultMapping = null;
        // String callerPath=null;
        if (restMappings != null)
            for (int i = 0; i < restMappings.length; i++) {
                m = restMappings[i];
                if (m.isDefault())
                    defaultMapping = m;
                if (pathInfo.startsWith(m.getVirtualWithSlash(), 0) && m.getPhysical() != null) {
                    mapping = m;
                    // result = m.getResult(this,callerPath=pathInfo.substring(m.getVirtual().length()),format,matrix,null);
                    rl = new RestRequestListener(m, pathInfo.substring(m.getVirtual().length()), matrix, format, hasFormatExtension, accept, contentType, null);
                    break;
                }
            }
        // default mapping
        if (mapping == null && defaultMapping != null && defaultMapping.getPhysical() != null) {
            mapping = defaultMapping;
            // result = mapping.getResult(this,callerPath=pathInfo,format,matrix,null);
            rl = new RestRequestListener(mapping, pathInfo, matrix, format, hasFormatExtension, accept, contentType, null);
        }
        if (mapping == null || mapping.getPhysical() == null) {
            RestUtil.setStatus(this, 404, "no rest service for [" + pathInfo + "] found");
            getConfig().getLog("rest").error("REST", "no rest service for [" + pathInfo + "] found");
        } else {
            base = config.toPageSource(null, mapping.getPhysical(), null);
            listener = ((MappingImpl) base.getMapping()).getApplicationListener();
            listener.onRequest(this, base, rl);
        }
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
        PageException pe = Caster.toPageException(t);
        if (!Abort.isSilentAbort(pe)) {
            log(true);
            if (fdEnabled) {
                FDSignal.signal(pe, false);
            }
            if (listener == null) {
                if (base == null)
                    listener = config.getApplicationListener();
                else
                    listener = ((MappingImpl) base.getMapping()).getApplicationListener();
            }
            listener.onError(this, pe);
        } else
            log(false);
        if (throwExcpetion)
            throw pe;
    } finally {
        if (enablecfoutputonly > 0) {
            setCFOutputOnly((short) 0);
        }
        base = null;
    }
}
Also used : URL(lucee.runtime.type.scope.URL) MimeType(lucee.commons.lang.mimetype.MimeType) Struct(lucee.runtime.type.Struct) HttpServletRequest(javax.servlet.http.HttpServletRequest) PageException(lucee.runtime.exp.PageException) RestRequestListener(lucee.runtime.rest.RestRequestListener) Resource(lucee.commons.io.res.Resource) IOException(java.io.IOException) PageException(lucee.runtime.exp.PageException) CasterException(lucee.runtime.exp.CasterException) MissingIncludeException(lucee.runtime.exp.MissingIncludeException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) CacheException(lucee.commons.io.cache.exp.CacheException) DatabaseException(lucee.runtime.exp.DatabaseException) ServletException(javax.servlet.ServletException) ModernAppListenerException(lucee.runtime.listener.ModernAppListenerException) RequestTimeoutException(lucee.runtime.exp.RequestTimeoutException) ExpressionException(lucee.runtime.exp.ExpressionException) ApplicationException(lucee.runtime.exp.ApplicationException) StructImpl(lucee.runtime.type.StructImpl) ApplicationListener(lucee.runtime.listener.ApplicationListener)

Example 73 with StructImpl

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

the class XMLConverter method _deserializeStruct.

/**
 * Desirialize a Struct Object
 * @param elStruct Struct Object as XML Element
 * @return Struct Object
 * @throws ConverterException
 */
private Object _deserializeStruct(Element elStruct) throws ConverterException {
    String type = elStruct.getAttribute("type");
    Struct struct = new StructImpl();
    NodeList list = elStruct.getChildNodes();
    int len = list.getLength();
    for (int i = 0; i < len; i++) {
        // print.ln(i);
        Node node = list.item(i);
        if (node instanceof Element) {
            Element var = (Element) node;
            Element value = getChildElement((Element) node);
            if (value != null) {
                struct.setEL(var.getAttribute("name"), _deserialize(value));
            }
        }
    }
    if (struct.size() == 0 && type != null && type.length() > 0) {
        return "";
    }
    return struct;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) Struct(lucee.runtime.type.Struct)

Example 74 with StructImpl

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

the class DebugEntryTemplatePartComparator method writeOut.

@Override
public void writeOut(PageContext pc) throws IOException {
    // stop();
    if (!output)
        return;
    String addr = pc.getHttpServletRequest().getRemoteAddr();
    lucee.runtime.config.DebugEntry debugEntry = ((ConfigImpl) pc.getConfig()).getDebugEntry(addr, null);
    if (debugEntry == null) {
        // pc.forceWrite(pc.getConfig().getDefaultDumpWriter().toString(pc,toDumpData(pc, 9999,DumpUtil.toDumpProperties()),true));
        return;
    }
    Struct args = new StructImpl();
    args.setEL(KeyConstants._custom, debugEntry.getCustom());
    try {
        args.setEL(KeyConstants._debugging, pc.getDebugger().getDebuggingData(pc));
    } catch (PageException e1) {
    }
    try {
        String path = debugEntry.getPath();
        PageSource[] arr = ((PageContextImpl) pc).getPageSources(path);
        Page p = PageSourceImpl.loadPage(pc, arr, null);
        // patch for old path
        String fullname = debugEntry.getFullname();
        if (p == null) {
            if (path != null) {
                boolean changed = false;
                if (path.endsWith("/Modern.cfc") || path.endsWith("\\Modern.cfc")) {
                    path = "/lucee-server-context/admin/debug/Modern.cfc";
                    fullname = "lucee-server-context.admin.debug.Modern";
                    changed = true;
                } else if (path.endsWith("/Classic.cfc") || path.endsWith("\\Classic.cfc")) {
                    path = "/lucee-server-context/admin/debug/Classic.cfc";
                    fullname = "lucee-server-context.admin.debug.Classic";
                    changed = true;
                } else if (path.endsWith("/Comment.cfc") || path.endsWith("\\Comment.cfc")) {
                    path = "/lucee-server-context/admin/debug/Comment.cfc";
                    fullname = "lucee-server-context.admin.debug.Comment";
                    changed = true;
                }
                if (changed)
                    pc.write("<span style='color:red'>Please update your debug template defintions in the Lucee admin by going into the detail view and hit the \"update\" button.</span>");
            }
            arr = ((PageContextImpl) pc).getPageSources(path);
            p = PageSourceImpl.loadPage(pc, arr);
        }
        pc.addPageSource(p.getPageSource(), true);
        try {
            Component c = pc.loadComponent(fullname);
            c.callWithNamedValues(pc, "output", args);
        } finally {
            pc.removeLastPageSource(true);
        }
    } catch (PageException e) {
        pc.handlePageException(e);
    }
}
Also used : PageException(lucee.runtime.exp.PageException) Page(lucee.runtime.Page) PageContextImpl(lucee.runtime.PageContextImpl) Struct(lucee.runtime.type.Struct) PageSource(lucee.runtime.PageSource) StructImpl(lucee.runtime.type.StructImpl) Component(lucee.runtime.Component) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 75 with StructImpl

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

the class DebugEntryTemplatePartComparator method getDebuggingData.

@Override
public Struct getDebuggingData(PageContext pc, boolean addAddionalInfo) throws DatabaseException {
    Struct debugging = new StructImpl();
    // datasources
    debugging.setEL(KeyConstants._datasources, ((ConfigImpl) pc.getConfig()).getDatasourceConnectionPool().meta());
    // queries
    List<QueryEntry> queries = getQueries();
    Struct qryExe = new StructImpl();
    ListIterator<QueryEntry> qryIt = queries.listIterator();
    Collection.Key[] cols = new Collection.Key[] { KeyConstants._name, KeyConstants._time, KeyConstants._sql, KeyConstants._src, KeyConstants._count, KeyConstants._datasource, KeyConstants._usage, CACHE_TYPE };
    String[] types = new String[] { "VARCHAR", "DOUBLE", "VARCHAR", "VARCHAR", "DOUBLE", "VARCHAR", "ANY", "VARCHAR" };
    Query qryQueries = null;
    try {
        qryQueries = new QueryImpl(cols, types, queries.size(), "query");
    } catch (DatabaseException e) {
        qryQueries = new QueryImpl(cols, queries.size(), "query");
    }
    int row = 0;
    try {
        QueryEntry qe;
        while (qryIt.hasNext()) {
            row++;
            qe = qryIt.next();
            qryQueries.setAt(KeyConstants._name, row, qe.getName() == null ? "" : qe.getName());
            qryQueries.setAt(KeyConstants._time, row, Long.valueOf(qe.getExecutionTime()));
            qryQueries.setAt(KeyConstants._sql, row, qe.getSQL().toString());
            qryQueries.setAt(KeyConstants._src, row, qe.getSrc());
            qryQueries.setAt(KeyConstants._count, row, Integer.valueOf(qe.getRecordcount()));
            qryQueries.setAt(KeyConstants._datasource, row, qe.getDatasource());
            qryQueries.setAt(CACHE_TYPE, row, qe.getCacheType());
            Struct usage = getUsage(qe);
            if (usage != null)
                qryQueries.setAt(KeyConstants._usage, row, usage);
            Object o = qryExe.get(KeyImpl.init(qe.getSrc()), null);
            if (o == null)
                qryExe.setEL(KeyImpl.init(qe.getSrc()), Long.valueOf(qe.getExecutionTime()));
            else
                qryExe.setEL(KeyImpl.init(qe.getSrc()), Long.valueOf(((Long) o).longValue() + qe.getExecutionTime()));
        }
    } catch (PageException dbe) {
    }
    // Pages
    // src,load,app,query,total
    row = 0;
    ArrayList<DebugEntryTemplate> arrPages = toArray();
    int len = arrPages.size();
    Query qryPage = new QueryImpl(new Collection.Key[] { KeyConstants._id, KeyConstants._count, KeyConstants._min, KeyConstants._max, KeyConstants._avg, KeyConstants._app, KeyConstants._load, KeyConstants._query, KeyConstants._total, KeyConstants._src }, len, "query");
    try {
        DebugEntryTemplate de;
        // PageSource ps;
        for (int i = 0; i < len; i++) {
            row++;
            de = arrPages.get(i);
            // ps = de.getPageSource();
            qryPage.setAt(KeyConstants._id, row, de.getId());
            qryPage.setAt(KeyConstants._count, row, _toString(de.getCount()));
            qryPage.setAt(KeyConstants._min, row, _toString(de.getMin()));
            qryPage.setAt(KeyConstants._max, row, _toString(de.getMax()));
            qryPage.setAt(KeyConstants._avg, row, _toString(de.getExeTime() / de.getCount()));
            qryPage.setAt(KeyConstants._app, row, _toString(de.getExeTime() - de.getQueryTime()));
            qryPage.setAt(KeyConstants._load, row, _toString(de.getFileLoadTime()));
            qryPage.setAt(KeyConstants._query, row, _toString(de.getQueryTime()));
            qryPage.setAt(KeyConstants._total, row, _toString(de.getFileLoadTime() + de.getExeTime()));
            qryPage.setAt(KeyConstants._src, row, de.getSrc());
        }
    } catch (PageException dbe) {
    }
    // Pages Parts
    List<DebugEntryTemplatePart> filteredPartEntries = null;
    boolean hasParts = partEntries != null && !partEntries.isEmpty() && !arrPages.isEmpty();
    int qrySize = 0;
    if (hasParts) {
        String slowestTemplate = arrPages.get(0).getPath();
        filteredPartEntries = new ArrayList();
        java.util.Collection<DebugEntryTemplatePartImpl> col = partEntries.values();
        for (DebugEntryTemplatePart detp : col) {
            if (detp.getPath().equals(slowestTemplate))
                filteredPartEntries.add(detp);
        }
        qrySize = Math.min(filteredPartEntries.size(), MAX_PARTS);
    }
    Query qryPart = new QueryImpl(new Collection.Key[] { KeyConstants._id, KeyConstants._count, KeyConstants._min, KeyConstants._max, KeyConstants._avg, KeyConstants._total, KeyConstants._path, KeyConstants._start, KeyConstants._end, KeyConstants._startLine, KeyConstants._endLine, KeyConstants._snippet }, qrySize, "query");
    if (hasParts) {
        row = 0;
        Collections.sort(filteredPartEntries, DEBUG_ENTRY_TEMPLATE_PART_COMPARATOR);
        DebugEntryTemplatePart[] parts = new DebugEntryTemplatePart[qrySize];
        if (filteredPartEntries.size() > MAX_PARTS)
            parts = filteredPartEntries.subList(0, MAX_PARTS).toArray(parts);
        else
            parts = filteredPartEntries.toArray(parts);
        try {
            DebugEntryTemplatePart de;
            // PageSource ps;
            for (int i = 0; i < parts.length; i++) {
                row++;
                de = parts[i];
                qryPart.setAt(KeyConstants._id, row, de.getId());
                qryPart.setAt(KeyConstants._count, row, _toString(de.getCount()));
                qryPart.setAt(KeyConstants._min, row, _toString(de.getMin()));
                qryPart.setAt(KeyConstants._max, row, _toString(de.getMax()));
                qryPart.setAt(KeyConstants._avg, row, _toString(de.getExeTime() / de.getCount()));
                qryPart.setAt(KeyConstants._start, row, _toString(de.getStartPosition()));
                qryPart.setAt(KeyConstants._end, row, _toString(de.getEndPosition()));
                qryPart.setAt(KeyConstants._total, row, _toString(de.getExeTime()));
                qryPart.setAt(KeyConstants._path, row, de.getPath());
                if (de instanceof DebugEntryTemplatePartImpl) {
                    qryPart.setAt(KeyConstants._startLine, row, _toString(((DebugEntryTemplatePartImpl) de).getStartLine()));
                    qryPart.setAt(KeyConstants._endLine, row, _toString(((DebugEntryTemplatePartImpl) de).getEndLine()));
                    qryPart.setAt(KeyConstants._snippet, row, ((DebugEntryTemplatePartImpl) de).getSnippet());
                }
            }
        } catch (PageException dbe) {
        }
    }
    // exceptions
    len = exceptions == null ? 0 : exceptions.size();
    Array arrExceptions = new ArrayImpl();
    if (len > 0) {
        Iterator<CatchBlock> it = exceptions.iterator();
        row = 0;
        while (it.hasNext()) {
            arrExceptions.appendEL(it.next());
        }
    }
    // output log
    // Query qryOutputLog=getOutputText();
    // timers
    len = timers == null ? 0 : timers.size();
    Query qryTimers = new QueryImpl(new Collection.Key[] { KeyConstants._label, KeyConstants._time, KeyConstants._template }, len, "timers");
    if (len > 0) {
        try {
            Iterator<DebugTimerImpl> it = timers.iterator();
            DebugTimer timer;
            row = 0;
            while (it.hasNext()) {
                timer = it.next();
                row++;
                qryTimers.setAt(KeyConstants._label, row, timer.getLabel());
                qryTimers.setAt(KeyConstants._template, row, timer.getTemplate());
                qryTimers.setAt(KeyConstants._time, row, Caster.toDouble(timer.getTime()));
            }
        } catch (PageException dbe) {
        }
    }
    // dumps
    len = dumps == null ? 0 : dumps.size();
    if (!((ConfigImpl) pc.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_DUMP))
        len = 0;
    Query qryDumps = new QueryImpl(new Collection.Key[] { KeyConstants._output, KeyConstants._template, KeyConstants._line }, len, "dumps");
    if (len > 0) {
        try {
            Iterator<DebugDump> it = dumps.iterator();
            DebugDump dd;
            row = 0;
            while (it.hasNext()) {
                dd = it.next();
                row++;
                qryDumps.setAt(KeyConstants._output, row, dd.getOutput());
                if (!StringUtil.isEmpty(dd.getTemplate()))
                    qryDumps.setAt(KeyConstants._template, row, dd.getTemplate());
                if (dd.getLine() > 0)
                    qryDumps.setAt(KeyConstants._line, row, new Double(dd.getLine()));
            }
        } catch (PageException dbe) {
        }
    }
    // traces
    len = traces == null ? 0 : traces.size();
    if (!((ConfigImpl) pc.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_TRACING))
        len = 0;
    Query qryTraces = new QueryImpl(new Collection.Key[] { KeyConstants._type, KeyConstants._category, KeyConstants._text, KeyConstants._template, KeyConstants._line, KeyConstants._action, KeyConstants._varname, KeyConstants._varvalue, KeyConstants._time }, len, "traces");
    if (len > 0) {
        try {
            Iterator<DebugTraceImpl> it = traces.iterator();
            DebugTraceImpl trace;
            row = 0;
            while (it.hasNext()) {
                trace = it.next();
                row++;
                qryTraces.setAt(KeyConstants._type, row, DebugTraceImpl.toType(trace.getType(), "INFO"));
                if (!StringUtil.isEmpty(trace.getCategory()))
                    qryTraces.setAt(KeyConstants._category, row, trace.getCategory());
                if (!StringUtil.isEmpty(trace.getText()))
                    qryTraces.setAt(KeyConstants._text, row, trace.getText());
                if (!StringUtil.isEmpty(trace.getTemplate()))
                    qryTraces.setAt(KeyConstants._template, row, trace.getTemplate());
                if (trace.getLine() > 0)
                    qryTraces.setAt(KeyConstants._line, row, new Double(trace.getLine()));
                if (!StringUtil.isEmpty(trace.getAction()))
                    qryTraces.setAt(KeyConstants._action, row, trace.getAction());
                if (!StringUtil.isEmpty(trace.getVarName()))
                    qryTraces.setAt(KeyImpl.init("varname"), row, trace.getVarName());
                if (!StringUtil.isEmpty(trace.getVarValue()))
                    qryTraces.setAt(KeyImpl.init("varvalue"), row, trace.getVarValue());
                qryTraces.setAt(KeyConstants._time, row, new Double(trace.getTime()));
            }
        } catch (PageException dbe) {
        }
    }
    // scope access
    len = implicitAccesses == null ? 0 : implicitAccesses.size();
    Query qryImplicitAccesseses = new QueryImpl(new Collection.Key[] { KeyConstants._template, KeyConstants._line, KeyConstants._scope, KeyConstants._count, KeyConstants._name }, len, "implicitAccess");
    if (len > 0) {
        try {
            Iterator<ImplicitAccessImpl> it = implicitAccesses.values().iterator();
            ImplicitAccessImpl das;
            row = 0;
            while (it.hasNext()) {
                das = it.next();
                row++;
                qryImplicitAccesseses.setAt(KeyConstants._template, row, das.getTemplate());
                qryImplicitAccesseses.setAt(KeyConstants._line, row, new Double(das.getLine()));
                qryImplicitAccesseses.setAt(KeyConstants._scope, row, das.getScope());
                qryImplicitAccesseses.setAt(KeyConstants._count, row, new Double(das.getCount()));
                qryImplicitAccesseses.setAt(KeyConstants._name, row, das.getName());
            }
        } catch (PageException dbe) {
        }
    }
    Query history = new QueryImpl(new Collection.Key[] {}, 0, "history");
    try {
        history.addColumn(KeyConstants._id, historyId);
        history.addColumn(KeyConstants._level, historyLevel);
    } catch (PageException e) {
    }
    if (addAddionalInfo) {
        debugging.setEL(KeyConstants._cgi, pc.cgiScope());
        debugging.setEL(KeyImpl.init("starttime"), new DateTimeImpl(starttime, false));
        debugging.setEL(KeyConstants._id, pc.getId());
    }
    debugging.setEL(KeyConstants._pages, qryPage);
    debugging.setEL(PAGE_PARTS, qryPart);
    debugging.setEL(KeyConstants._queries, qryQueries);
    debugging.setEL(KeyConstants._timers, qryTimers);
    debugging.setEL(KeyConstants._traces, qryTraces);
    debugging.setEL("dumps", qryDumps);
    debugging.setEL(IMPLICIT_ACCESS, qryImplicitAccesseses);
    // debugging.setEL(OUTPUT_LOG,qryOutputLog);
    debugging.setEL(KeyConstants._history, history);
    debugging.setEL(KeyConstants._exceptions, arrExceptions);
    return debugging;
}
Also used : Query(lucee.runtime.type.Query) ArrayImpl(lucee.runtime.type.ArrayImpl) ArrayList(java.util.ArrayList) Struct(lucee.runtime.type.Struct) QueryImpl(lucee.runtime.type.QueryImpl) DateTimeImpl(lucee.runtime.type.dt.DateTimeImpl) PageException(lucee.runtime.exp.PageException) Array(lucee.runtime.type.Array) StructImpl(lucee.runtime.type.StructImpl) CatchBlock(lucee.runtime.exp.CatchBlock) Collection(lucee.runtime.type.Collection) DatabaseException(lucee.runtime.exp.DatabaseException) ConfigImpl(lucee.runtime.config.ConfigImpl) Key(lucee.runtime.type.Collection.Key)

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