use of org.parosproxy.paros.db.RecordStructure in project zaproxy by zaproxy.
the class SessionStructure method addStructure.
private static RecordStructure addStructure(Session session, String host, HttpMessage msg, List<String> paths, int size, int historyId) throws DatabaseException, URIException {
//String nodeUrl = pathsToUrl(host, paths, size);
String nodeName = getNodeName(session, host, msg, paths, size);
String parentName = pathsToUrl(host, paths, size - 1);
String url = "";
if (msg != null) {
url = msg.getRequestHeader().getURI().toString();
String params = getParams(session, msg);
if (params.length() > 0) {
nodeName = nodeName + " " + params;
}
}
String method = HttpRequestHeader.GET;
if (msg != null) {
method = msg.getRequestHeader().getMethod();
}
RecordStructure msgRs = Model.getSingleton().getDb().getTableStructure().find(session.getSessionId(), nodeName, method);
if (msgRs == null) {
long parentId = -1;
if (!nodeName.equals("Root")) {
HttpMessage tmpMsg = null;
int parentHistoryId = -1;
if (!parentName.equals("Root")) {
tmpMsg = getTempHttpMessage(session, parentName, msg);
parentHistoryId = tmpMsg.getHistoryRef().getHistoryId();
}
RecordStructure parentRs = addStructure(session, host, tmpMsg, paths, size - 1, parentHistoryId);
parentId = parentRs.getStructureId();
}
msgRs = Model.getSingleton().getDb().getTableStructure().insert(session.getSessionId(), parentId, historyId, nodeName, url, method);
}
return msgRs;
}
use of org.parosproxy.paros.db.RecordStructure in project zaproxy by zaproxy.
the class ParosTableStructure method read.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableParam#read(long)
*/
@Override
public synchronized RecordStructure read(long sessionId, long urlId) throws DatabaseException {
try {
psRead.setLong(1, sessionId);
psRead.setLong(2, urlId);
try (ResultSet rs = psRead.executeQuery()) {
RecordStructure result = build(rs);
return result;
}
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.RecordStructure in project zaproxy by zaproxy.
the class ParosTableStructure method getChildren.
@Override
public List<RecordStructure> getChildren(long sessionId, long parentId) throws DatabaseException {
try {
psGetChildren.setLong(1, sessionId);
psGetChildren.setLong(2, parentId);
List<RecordStructure> result = new ArrayList<>();
try (ResultSet rs = psGetChildren.executeQuery()) {
while (rs.next()) {
result.add(build(rs));
}
}
return result;
} catch (SQLException e) {
throw new DatabaseException(e);
}
}
use of org.parosproxy.paros.db.RecordStructure in project zaproxy by zaproxy.
the class SqlTableStructure method getChildren.
@Override
public List<RecordStructure> getChildren(long sessionId, long parentId) throws DatabaseException {
SqlPreparedStatementWrapper psGetChildren = null;
try {
psGetChildren = DbSQL.getSingleton().getPreparedStatement("structure.ps.getchildren");
psGetChildren.getPs().setLong(1, sessionId);
psGetChildren.getPs().setLong(2, parentId);
List<RecordStructure> result = new ArrayList<>();
try (ResultSet rs = psGetChildren.getPs().executeQuery()) {
while (rs.next()) {
result.add(build(rs));
}
}
return result;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psGetChildren);
}
}
use of org.parosproxy.paros.db.RecordStructure in project zaproxy by zaproxy.
the class SqlTableStructure method read.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableParam#read(long)
*/
@Override
public synchronized RecordStructure read(long sessionId, long urlId) throws DatabaseException {
SqlPreparedStatementWrapper psRead = null;
try {
psRead = DbSQL.getSingleton().getPreparedStatement("structure.ps.read");
psRead.getPs().setLong(1, sessionId);
psRead.getPs().setLong(2, urlId);
try (ResultSet rs = psRead.getPs().executeQuery()) {
RecordStructure result = null;
if (rs.next()) {
result = build(rs);
}
return result;
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psRead);
}
}
Aggregations