Search in sources :

Example 46 with PageException

use of lucee.runtime.exp.PageException in project Lucee by lucee.

the class XMLConverter method _deserializeQuery.

/**
 * Desirialize a Query Object
 * @param recordset Query Object as XML Element
 * @return Query Object
 * @throws ConverterException
 */
private Object _deserializeQuery(Element recordset) throws ConverterException {
    try {
        // create Query Object
        Query query = new QueryImpl(lucee.runtime.type.util.ListUtil.listToArray(recordset.getAttribute("fieldNames"), ','), Caster.toIntValue(recordset.getAttribute("rowCount")), "query");
        NodeList list = recordset.getChildNodes();
        int len = list.getLength();
        for (int i = 0; i < len; i++) {
            Node node = list.item(i);
            if (node instanceof Element) {
                _deserializeQueryField(query, (Element) node);
            }
        }
        return query;
    } catch (PageException e) {
        throw toConverterException(e);
    }
}
Also used : PageException(lucee.runtime.exp.PageException) QueryImpl(lucee.runtime.type.QueryImpl) Query(lucee.runtime.type.Query) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element)

Example 47 with PageException

use of lucee.runtime.exp.PageException in project Lucee by lucee.

the class SQLCaster method setValue.

public static void setValue(PageContext pc, TimeZone tz, PreparedStatement stat, int parameterIndex, SQLItem item) throws PageException, SQLException, DatabaseException {
    pc = ThreadLocalPageContext.get(pc);
    Object value = item.getValue();
    if (item.isNulls() || value == null) {
        stat.setNull(parameterIndex, item.getType());
        return;
    }
    int type = item.getType();
    switch(type) {
        /*
			 * case Types.ARRAY: stat.setArray(parameterIndex,toArray(item.getValue())); return;
			 */
        case Types.BIGINT:
            try {
                stat.setLong(parameterIndex, Caster.toLongValue(value));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.BIT:
            try {
                stat.setBoolean(parameterIndex, Caster.toBooleanValue(value));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.BLOB:
            try {
                stat.setBlob(parameterIndex, SQLUtil.toBlob(stat.getConnection(), value));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.CLOB:
            try {
                stat.setClob(parameterIndex, SQLUtil.toClob(stat.getConnection(), value));
            /*
					 * if(value instanceof String) { try{ stat.setString(parameterIndex,Caster.toString(value)); } catch(Throwable
					 * t){ExceptionUtil.rethrowIfNecessary(t); stat.setClob(parameterIndex,SQLUtil.toClob(stat.getConnection(),value)); }
					 * 
					 * } else stat.setClob(parameterIndex,SQLUtil.toClob(stat.getConnection(),value));
					 */
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.CHAR:
            String str = Caster.toString(value);
            // if(str!=null && str.length()==0) str=null;
            stat.setObject(parameterIndex, str, type);
            // // stat.setString(parameterIndex,str);
            return;
        case Types.DECIMAL:
        case Types.NUMERIC:
            try {
                stat.setDouble(parameterIndex, (Caster.toDoubleValue(value)));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.DOUBLE:
        case Types.FLOAT:
            try {
                if (type == Types.FLOAT)
                    stat.setFloat(parameterIndex, Caster.toFloatValue(value));
                else if (type == Types.DOUBLE)
                    stat.setDouble(parameterIndex, Caster.toDoubleValue(value));
                else
                    stat.setObject(parameterIndex, Caster.toDouble(value), type);
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
        case Types.BINARY:
            try {
                stat.setObject(parameterIndex, Caster.toBinary(value), type);
            // // stat.setBytes(parameterIndex,Caster.toBinary(value));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.REAL:
            try {
                stat.setObject(parameterIndex, Caster.toFloat(value), type);
            // // stat.setFloat(parameterIndex,Caster.toFloatValue(value));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.TINYINT:
            try {
                stat.setObject(parameterIndex, Caster.toByte(value), type);
            // // stat.setByte(parameterIndex,Caster.toByteValue(value));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.SMALLINT:
            try {
                stat.setObject(parameterIndex, Caster.toShort(value), type);
            // // stat.setShort(parameterIndex,Caster.toShortValue(value));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.INTEGER:
            try {
                stat.setObject(parameterIndex, Caster.toInteger(value), type);
            // // stat.setInt(parameterIndex,Caster.toIntValue(value));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.VARCHAR:
        case Types.LONGVARCHAR:
        case CFTypes.VARCHAR2:
            stat.setObject(parameterIndex, Caster.toString(value), type);
            // // stat.setString(parameterIndex,Caster.toString(value));
            return;
        case Types.DATE:
            try {
                stat.setDate(parameterIndex, new Date(Caster.toDate(value, tz).getTime()), JREDateTimeUtil.getThreadCalendar(tz));
            // stat.setDate(parameterIndex,new Date((Caster.toDate(value,null).getTime())));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.TIME:
            try {
                // stat.setObject(parameterIndex, new Time((Caster.toDate(value,null).getTime())), type);
                stat.setTime(parameterIndex, new Time(Caster.toDate(value, tz).getTime()), JREDateTimeUtil.getThreadCalendar(tz));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.TIMESTAMP:
            try {
                // stat.setObject(parameterIndex, new Timestamp((Caster.toDate(value,null).getTime())), type);
                // stat.setObject(parameterIndex, value, type);
                stat.setTimestamp(parameterIndex, new Timestamp(Caster.toDate(value, tz).getTime()), JREDateTimeUtil.getThreadCalendar(tz));
            } catch (PageException pe) {
                if (!NullSupportHelper.full(pc) && value instanceof String && StringUtil.isEmpty((String) value))
                    stat.setNull(parameterIndex, item.getType());
                else
                    throw pe;
            }
            return;
        case Types.OTHER:
            stat.setObject(parameterIndex, value, Types.OTHER);
            return;
        /*
			 * case CF_SQL_STRUCT: case CF_SQL_REFCURSOR: case CF_SQL_NULL: case CF_SQL_ARRAY: case CF_SQL_DISTINCT:
			 */
        default:
            stat.setObject(parameterIndex, value, type);
    }
}
Also used : PageException(lucee.runtime.exp.PageException) DateTime(lucee.runtime.type.dt.DateTime) Time(java.sql.Time) Timestamp(java.sql.Timestamp) Date(java.sql.Date)

Example 48 with PageException

use of lucee.runtime.exp.PageException in project Lucee by lucee.

the class SQLPrettyfier method prettyfie.

public static String prettyfie(String sql, boolean validZql) {
    ParserString ps = new ParserString(sql.trim());
    boolean insideString = false;
    // short insideKlammer=0;
    StringBuilder sb = new StringBuilder(sql.length());
    outer: while (!ps.isAfterLast()) {
        if (insideString) {
            if (ps.isCurrent('\'')) {
                if (!ps.hasNext() || !ps.isNext('\''))
                    insideString = false;
            }
        } else {
            if (ps.isCurrent('\''))
                insideString = true;
            else if (ps.isCurrent('?')) {
                sb.append(" " + PLACEHOLDER_QUESTION + " ");
                ps.next();
                continue;
            } else if (ps.isCurrent('{')) {
                StringBuilder date = new StringBuilder();
                int pos = ps.getPos();
                while (true) {
                    if (ps.isAfterLast()) {
                        ps.setPos(pos);
                        break;
                    } else if (ps.isCurrent('}')) {
                        date.append('}');
                        DateTime d;
                        try {
                            d = DateCaster.toDateAdvanced(date.toString(), null);
                        } catch (PageException e) {
                            ps.setPos(pos);
                            break;
                        }
                        sb.append('\'');
                        sb.append(new DateFormat(Locale.US).format(d, "yyyy-mm-dd"));
                        sb.append(' ');
                        sb.append(new TimeFormat(Locale.US).format(d, "HH:mm:ss"));
                        sb.append('\'');
                        ps.next();
                        continue outer;
                    } else {
                        date.append(ps.getCurrent());
                        ps.next();
                    }
                }
            } else if (ps.isCurrent('*')) {
                sb.append(" " + PLACEHOLDER_ASTERIX + " ");
                ps.next();
                // last=ps.getCurrent();
                continue;
            } else if (validZql && ps.isCurrent('a')) {
                if (ps.isPreviousWhiteSpace() && ps.isNext('s') && ps.isNextNextWhiteSpace()) {
                    ps.next();
                    ps.next();
                    ps.removeSpace();
                    continue;
                }
            }
        /*for(int i=0;i<reseved_words.length;i++) {
		        	if(ps.isCurrent(reseved_words[i])) {
			        	int pos=ps.getPos();
			        	ps.setPos(pos+4);
			        	if(ps.isCurrentWhiteSpace()) {
			        		sb.append(" placeholder_"+reseved_words[i]+" ");
			        		continue;
			        	}
			        	if(ps.isCurrent(',')) {
			        		sb.append(" placeholder_"+reseved_words[i]+",");
			        		continue;
			        	}
			        	ps.setPos(pos);
			        }
		        }*/
        /*if(ps.isCurrent("char")) {
		        	int pos=ps.getPos();
		        	ps.setPos(pos+4);
		        	if(ps.isCurrentWhiteSpace()) {
		        		sb.append(" "+PLACEHOLDER_CHAR+" ");
		        		continue;
		        	}
		        	if(ps.isCurrent(',')) {
		        		sb.append(" "+PLACEHOLDER_CHAR+",");
		        		continue;
		        	}
		        	ps.setPos(pos);
		        }*/
        }
        sb.append(ps.getCurrent());
        ps.next();
    }
    ;
    if (!ps.isLast(';'))
        sb.append(';');
    // print.err("---------------------------------------------------------------------------------");
    return sb.toString();
}
Also used : PageException(lucee.runtime.exp.PageException) TimeFormat(lucee.runtime.format.TimeFormat) ParserString(lucee.commons.lang.ParserString) DateFormat(lucee.runtime.format.DateFormat) DateTime(lucee.runtime.type.dt.DateTime)

Example 49 with PageException

use of lucee.runtime.exp.PageException 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 50 with PageException

use of lucee.runtime.exp.PageException 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

PageException (lucee.runtime.exp.PageException)200 ApplicationException (lucee.runtime.exp.ApplicationException)56 IOException (java.io.IOException)54 Struct (lucee.runtime.type.Struct)49 StructImpl (lucee.runtime.type.StructImpl)37 ExpressionException (lucee.runtime.exp.ExpressionException)32 Resource (lucee.commons.io.res.Resource)30 SecurityException (lucee.runtime.exp.SecurityException)26 BundleException (org.osgi.framework.BundleException)26 MalformedURLException (java.net.MalformedURLException)25 Array (lucee.runtime.type.Array)21 Key (lucee.runtime.type.Collection.Key)17 PageRuntimeException (lucee.runtime.exp.PageRuntimeException)15 SAXException (org.xml.sax.SAXException)15 Entry (java.util.Map.Entry)14 ClassException (lucee.commons.lang.ClassException)14 DeprecatedException (lucee.runtime.exp.DeprecatedException)14 SMTPException (lucee.runtime.net.mail.SMTPException)13 ArrayImpl (lucee.runtime.type.ArrayImpl)13 Query (lucee.runtime.type.Query)13