{"action":"created","comment":{"url":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/comments/205510426","pull_request_review_id":140794571,"id":205510426,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTUxMDQyNg==","diff_hunk":"@@ -0,0 +1,287 @@\n+/*\n+ * Sleuth Kit Data Model\n+ *\n+ * Copyright 2018 Basis Technology Corp.\n+ * Contact: carrier <at> sleuthkit <dot> org\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *\t http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package org.sleuthkit.datamodel;\n+\n+import java.sql.PreparedStatement;\n+import java.sql.ResultSet;\n+import java.sql.SQLException;\n+import java.sql.Statement;\n+import java.util.logging.Logger;\n+import org.sleuthkit.datamodel.SleuthkitCase.CaseDbConnection;\n+import static org.sleuthkit.datamodel.SleuthkitCase.closeStatement;\n+import org.sleuthkit.datamodel.TskData.DbType;\n+\n+/**\n+ * This class provides modules with access to the case database \n+ * to create custom tables/indexes and to query them.\n+ *\n+ */\n+public final class DBAccessManager {\n+\n+\tprivate static final Logger logger = Logger.getLogger(DBAccessManager.class.getName());\n+\n+\tprivate final SleuthkitCase tskDB;\n+\n+\t/**\n+\t * Constructor\n+\t *\n+\t * @param skCase The SleuthkitCase\n+\t *\n+\t */\n+\tDBAccessManager(SleuthkitCase skCase) {\n+\t\tthis.tskDB = skCase;\n+\t}\n+\n+\t/**\n+\t * Creates a table with the specified name and schema.\n+\t * \n+\t * @param tableName name of the table to create\n+\t * @param tableSchema table schema\n+\t * \n+\t * @throws TskCoreException \n+\t */\n+\tpublic void createTable(final String tableName, final String tableSchema) throws TskCoreException {\n+\n+\t\tvalidateTableName(tableName);\n+\t\tvalidateSQL(tableSchema);\n+\n+\t\tCaseDbConnection connection = tskDB.getConnection();\n+\t\ttskDB.acquireSingleUserCaseReadLock();\n+\n+\t\tStatement statement = null;\n+\t\tString createSQL = \"CREATE TABLE IF NOT EXISTS \" + tableName + \" \" + tableSchema;\n+\t\ttry {\n+\t\t\tstatement = connection.createStatement();\n+\t\t\tstatement.execute(createSQL);\n+\t\t} catch (SQLException ex) {\n+\t\t\tthrow new TskCoreException(\"Error creating table \" + tableName, ex);\n+\t\t} finally {\n+\t\t\tcloseStatement(statement);\n+\t\t\tconnection.close();\n+\t\t\ttskDB.releaseSingleUserCaseReadLock();\n+\t\t}\n+\n+\t}\n+\n+\t/**\n+\t * Creates an index on the specified table, on specified column(s).\n+\t * \n+\t * @param indexName name of index to create\n+\t * @param tableName name of table to create the index on\n+\t * @param colsSQL - columns on which to index\n+\t * \n+\t * @throws TskCoreException \n+\t */\n+\tpublic void createIndex(final String indexName, final String tableName, final String colsSQL) throws TskCoreException {\n+\n+\t\tvalidateTableName(indexName);\n+\t\tvalidateSQL(colsSQL);\n+\n+\t\tCaseDbConnection connection = tskDB.getConnection();\n+\t\ttskDB.acquireSingleUserCaseReadLock();\n+\n+\t\tStatement statement = null;\n+\t\tString indexSQL = \"CREATE INDEX IF NOT EXISTS \" + indexName + \" ON \" + tableName + \" \" + colsSQL; // NON-NLS\n+\t\ttry {\n+\t\t\tstatement = connection.createStatement();\n+\t\t\tstatement.execute(indexSQL);\n+\t\t} catch (SQLException ex) {\n+\t\t\tthrow new TskCoreException(\"Error creating index \" + tableName, ex);\n+\t\t} finally {\n+\t\t\tcloseStatement(statement);\n+\t\t\tconnection.close();\n+\t\t\ttskDB.releaseSingleUserCaseReadLock();\n+\t\t}\n+\t}\n+\n+\t/**\n+\t * Inserts a row in the specified table.\n+\t * If the primary key is duplicate, the existing row is updated.\n+\t * \n+\t * Note: For PostGreSQL, the caller must include the ON CONFLICT clause to handle \n+\t * duplicates\n+\t * \n+\t * @param tableName - table to insert into.\n+\t * @param sql - SQL string specifying column values.\n+\t *\n+\t * @return - rowID of the row inserted/updated\n+\t *\n+\t * @throws TskCoreException\n+\t */\n+\tpublic long insertOrUpdate(final String tableName, final String sql) throws TskCoreException {","path":"bindings/java/src/org/sleuthkit/datamodel/DBAccessManager.java","position":127,"original_position":127,"commit_id":"397afd360c338b9314830e5fc53fa2a80aea9c72","original_commit_id":"397afd360c338b9314830e5fc53fa2a80aea9c72","user":{"login":"rcordovano","id":1713605,"node_id":"MDQ6VXNlcjE3MTM2MDU=","avatar_url":"https://avatars0.githubusercontent.com/u/1713605?v=4","gravatar_id":"","url":"https://api.github.com/users/rcordovano","html_url":"https://github.com/rcordovano","followers_url":"https://api.github.com/users/rcordovano/followers","following_url":"https://api.github.com/users/rcordovano/following{/other_user}","gists_url":"https://api.github.com/users/rcordovano/gists{/gist_id}","starred_url":"https://api.github.com/users/rcordovano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rcordovano/subscriptions","organizations_url":"https://api.github.com/users/rcordovano/orgs","repos_url":"https://api.github.com/users/rcordovano/repos","events_url":"https://api.github.com/users/rcordovano/events{/privacy}","received_events_url":"https://api.github.com/users/rcordovano/received_events","type":"User","site_admin":false},"body":"I am okay with that, as long as we add the method before the next release.","created_at":"2018-07-26T15:53:32Z","updated_at":"2018-07-26T15:53:32Z","html_url":"https://github.com/sleuthkit/sleuthkit/pull/1274#discussion_r205510426","pull_request_url":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/1274","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/comments/205510426"},"html":{"href":"https://github.com/sleuthkit/sleuthkit/pull/1274#discussion_r205510426"},"pull_request":{"href":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/1274"}},"in_reply_to_id":205207230},"pull_request":{"url":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/1274","id":198121751,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4MTIxNzUx","html_url":"https://github.com/sleuthkit/sleuthkit/pull/1274","diff_url":"https://github.com/sleuthkit/sleuthkit/pull/1274.diff","patch_url":"https://github.com/sleuthkit/sleuthkit/pull/1274.patch","issue_url":"https://api.github.com/repos/sleuthkit/sleuthkit/issues/1274","number":1274,"state":"open","locked":false,"title":"Image gallery db migration","user":{"login":"raman-bt","id":4932948,"node_id":"MDQ6VXNlcjQ5MzI5NDg=","avatar_url":"https://avatars3.githubusercontent.com/u/4932948?v=4","gravatar_id":"","url":"https://api.github.com/users/raman-bt","html_url":"https://github.com/raman-bt","followers_url":"https://api.github.com/users/raman-bt/followers","following_url":"https://api.github.com/users/raman-bt/following{/other_user}","gists_url":"https://api.github.com/users/raman-bt/gists{/gist_id}","starred_url":"https://api.github.com/users/raman-bt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raman-bt/subscriptions","organizations_url":"https://api.github.com/users/raman-bt/orgs","repos_url":"https://api.github.com/users/raman-bt/repos","events_url":"https://api.github.com/users/raman-bt/events{/privacy}","received_events_url":"https://api.github.com/users/raman-bt/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-28T18:56:10Z","updated_at":"2018-07-26T15:53:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0f02529a490fec566b4d66a89877f339bc678260","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/1274/commits","review_comments_url":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/1274/comments","review_comment_url":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sleuthkit/sleuthkit/issues/1274/comments","statuses_url":"https://api.github.com/repos/sleuthkit/sleuthkit/statuses/397afd360c338b9314830e5fc53fa2a80aea9c72","head":{"label":"raman-bt:image-gallery-db-migration","ref":"image-gallery-db-migration","sha":"397afd360c338b9314830e5fc53fa2a80aea9c72","user":{"login":"raman-bt","id":4932948,"node_id":"MDQ6VXNlcjQ5MzI5NDg=","avatar_url":"https://avatars3.githubusercontent.com/u/4932948?v=4","gravatar_id":"","url":"https://api.github.com/users/raman-bt","html_url":"https://github.com/raman-bt","followers_url":"https://api.github.com/users/raman-bt/followers","following_url":"https://api.github.com/users/raman-bt/following{/other_user}","gists_url":"https://api.github.com/users/raman-bt/gists{/gist_id}","starred_url":"https://api.github.com/users/raman-bt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raman-bt/subscriptions","organizations_url":"https://api.github.com/users/raman-bt/orgs","repos_url":"https://api.github.com/users/raman-bt/repos","events_url":"https://api.github.com/users/raman-bt/events{/privacy}","received_events_url":"https://api.github.com/users/raman-bt/received_events","type":"User","site_admin":false},"repo":{"id":35565635,"node_id":"MDEwOlJlcG9zaXRvcnkzNTU2NTYzNQ==","name":"sleuthkit","full_name":"raman-bt/sleuthkit","owner":{"login":"raman-bt","id":4932948,"node_id":"MDQ6VXNlcjQ5MzI5NDg=","avatar_url":"https://avatars3.githubusercontent.com/u/4932948?v=4","gravatar_id":"","url":"https://api.github.com/users/raman-bt","html_url":"https://github.com/raman-bt","followers_url":"https://api.github.com/users/raman-bt/followers","following_url":"https://api.github.com/users/raman-bt/following{/other_user}","gists_url":"https://api.github.com/users/raman-bt/gists{/gist_id}","starred_url":"https://api.github.com/users/raman-bt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raman-bt/subscriptions","organizations_url":"https://api.github.com/users/raman-bt/orgs","repos_url":"https://api.github.com/users/raman-bt/repos","events_url":"https://api.github.com/users/raman-bt/events{/privacy}","received_events_url":"https://api.github.com/users/raman-bt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/raman-bt/sleuthkit","description":"The Sleuth Kit® (TSK) is a library and collection of command line digital forensics tools that allow you to investigate volume and file system data. The library can be incorporated into larger digital forensics tools and the command line tools can be directly used to find evidence. ","fork":true,"url":"https://api.github.com/repos/raman-bt/sleuthkit","forks_url":"https://api.github.com/repos/raman-bt/sleuthkit/forks","keys_url":"https://api.github.com/repos/raman-bt/sleuthkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/raman-bt/sleuthkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/raman-bt/sleuthkit/teams","hooks_url":"https://api.github.com/repos/raman-bt/sleuthkit/hooks","issue_events_url":"https://api.github.com/repos/raman-bt/sleuthkit/issues/events{/number}","events_url":"https://api.github.com/repos/raman-bt/sleuthkit/events","assignees_url":"https://api.github.com/repos/raman-bt/sleuthkit/assignees{/user}","branches_url":"https://api.github.com/repos/raman-bt/sleuthkit/branches{/branch}","tags_url":"https://api.github.com/repos/raman-bt/sleuthkit/tags","blobs_url":"https://api.github.com/repos/raman-bt/sleuthkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/raman-bt/sleuthkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/raman-bt/sleuthkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/raman-bt/sleuthkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/raman-bt/sleuthkit/statuses/{sha}","languages_url":"https://api.github.com/repos/raman-bt/sleuthkit/languages","stargazers_url":"https://api.github.com/repos/raman-bt/sleuthkit/stargazers","contributors_url":"https://api.github.com/repos/raman-bt/sleuthkit/contributors","subscribers_url":"https://api.github.com/repos/raman-bt/sleuthkit/subscribers","subscription_url":"https://api.github.com/repos/raman-bt/sleuthkit/subscription","commits_url":"https://api.github.com/repos/raman-bt/sleuthkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/raman-bt/sleuthkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/raman-bt/sleuthkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/raman-bt/sleuthkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/raman-bt/sleuthkit/contents/{+path}","compare_url":"https://api.github.com/repos/raman-bt/sleuthkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/raman-bt/sleuthkit/merges","archive_url":"https://api.github.com/repos/raman-bt/sleuthkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/raman-bt/sleuthkit/downloads","issues_url":"https://api.github.com/repos/raman-bt/sleuthkit/issues{/number}","pulls_url":"https://api.github.com/repos/raman-bt/sleuthkit/pulls{/number}","milestones_url":"https://api.github.com/repos/raman-bt/sleuthkit/milestones{/number}","notifications_url":"https://api.github.com/repos/raman-bt/sleuthkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/raman-bt/sleuthkit/labels{/name}","releases_url":"https://api.github.com/repos/raman-bt/sleuthkit/releases{/id}","deployments_url":"https://api.github.com/repos/raman-bt/sleuthkit/deployments","created_at":"2015-05-13T18:03:08Z","updated_at":"2018-06-25T16:01:15Z","pushed_at":"2018-06-28T18:47:45Z","git_url":"git://github.com/raman-bt/sleuthkit.git","ssh_url":"git@github.com:raman-bt/sleuthkit.git","clone_url":"https://github.com/raman-bt/sleuthkit.git","svn_url":"https://github.com/raman-bt/sleuthkit","homepage":"http://www.sleuthkit.org/sleuthkit/","size":45899,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"sleuthkit:image-gallery-db-migration","ref":"image-gallery-db-migration","sha":"29c4b8951a09723351b2c758e3af1a16dc8b9ea8","user":{"login":"sleuthkit","id":866922,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg2NjkyMg==","avatar_url":"https://avatars2.githubusercontent.com/u/866922?v=4","gravatar_id":"","url":"https://api.github.com/users/sleuthkit","html_url":"https://github.com/sleuthkit","followers_url":"https://api.github.com/users/sleuthkit/followers","following_url":"https://api.github.com/users/sleuthkit/following{/other_user}","gists_url":"https://api.github.com/users/sleuthkit/gists{/gist_id}","starred_url":"https://api.github.com/users/sleuthkit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleuthkit/subscriptions","organizations_url":"https://api.github.com/users/sleuthkit/orgs","repos_url":"https://api.github.com/users/sleuthkit/repos","events_url":"https://api.github.com/users/sleuthkit/events{/privacy}","received_events_url":"https://api.github.com/users/sleuthkit/received_events","type":"Organization","site_admin":false},"repo":{"id":2562873,"node_id":"MDEwOlJlcG9zaXRvcnkyNTYyODcz","name":"sleuthkit","full_name":"sleuthkit/sleuthkit","owner":{"login":"sleuthkit","id":866922,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg2NjkyMg==","avatar_url":"https://avatars2.githubusercontent.com/u/866922?v=4","gravatar_id":"","url":"https://api.github.com/users/sleuthkit","html_url":"https://github.com/sleuthkit","followers_url":"https://api.github.com/users/sleuthkit/followers","following_url":"https://api.github.com/users/sleuthkit/following{/other_user}","gists_url":"https://api.github.com/users/sleuthkit/gists{/gist_id}","starred_url":"https://api.github.com/users/sleuthkit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleuthkit/subscriptions","organizations_url":"https://api.github.com/users/sleuthkit/orgs","repos_url":"https://api.github.com/users/sleuthkit/repos","events_url":"https://api.github.com/users/sleuthkit/events{/privacy}","received_events_url":"https://api.github.com/users/sleuthkit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sleuthkit/sleuthkit","description":"The Sleuth Kit® (TSK) is a library and collection of command line digital forensics tools that allow you to investigate volume and file system data. The library can be incorporated into larger digital forensics tools and the command line tools can be directly used to find evidence. ","fork":false,"url":"https://api.github.com/repos/sleuthkit/sleuthkit","forks_url":"https://api.github.com/repos/sleuthkit/sleuthkit/forks","keys_url":"https://api.github.com/repos/sleuthkit/sleuthkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sleuthkit/sleuthkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sleuthkit/sleuthkit/teams","hooks_url":"https://api.github.com/repos/sleuthkit/sleuthkit/hooks","issue_events_url":"https://api.github.com/repos/sleuthkit/sleuthkit/issues/events{/number}","events_url":"https://api.github.com/repos/sleuthkit/sleuthkit/events","assignees_url":"https://api.github.com/repos/sleuthkit/sleuthkit/assignees{/user}","branches_url":"https://api.github.com/repos/sleuthkit/sleuthkit/branches{/branch}","tags_url":"https://api.github.com/repos/sleuthkit/sleuthkit/tags","blobs_url":"https://api.github.com/repos/sleuthkit/sleuthkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sleuthkit/sleuthkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sleuthkit/sleuthkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/sleuthkit/sleuthkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sleuthkit/sleuthkit/statuses/{sha}","languages_url":"https://api.github.com/repos/sleuthkit/sleuthkit/languages","stargazers_url":"https://api.github.com/repos/sleuthkit/sleuthkit/stargazers","contributors_url":"https://api.github.com/repos/sleuthkit/sleuthkit/contributors","subscribers_url":"https://api.github.com/repos/sleuthkit/sleuthkit/subscribers","subscription_url":"https://api.github.com/repos/sleuthkit/sleuthkit/subscription","commits_url":"https://api.github.com/repos/sleuthkit/sleuthkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/sleuthkit/sleuthkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/sleuthkit/sleuthkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/sleuthkit/sleuthkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/sleuthkit/sleuthkit/contents/{+path}","compare_url":"https://api.github.com/repos/sleuthkit/sleuthkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sleuthkit/sleuthkit/merges","archive_url":"https://api.github.com/repos/sleuthkit/sleuthkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sleuthkit/sleuthkit/downloads","issues_url":"https://api.github.com/repos/sleuthkit/sleuthkit/issues{/number}","pulls_url":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls{/number}","milestones_url":"https://api.github.com/repos/sleuthkit/sleuthkit/milestones{/number}","notifications_url":"https://api.github.com/repos/sleuthkit/sleuthkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sleuthkit/sleuthkit/labels{/name}","releases_url":"https://api.github.com/repos/sleuthkit/sleuthkit/releases{/id}","deployments_url":"https://api.github.com/repos/sleuthkit/sleuthkit/deployments","created_at":"2011-10-12T14:26:49Z","updated_at":"2018-07-24T02:33:40Z","pushed_at":"2018-07-25T20:59:40Z","git_url":"git://github.com/sleuthkit/sleuthkit.git","ssh_url":"git@github.com:sleuthkit/sleuthkit.git","clone_url":"https://github.com/sleuthkit/sleuthkit.git","svn_url":"https://github.com/sleuthkit/sleuthkit","homepage":"http://www.sleuthkit.org/sleuthkit/","size":46291,"stargazers_count":1192,"watchers_count":1192,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":374,"mirror_url":null,"archived":false,"open_issues_count":172,"license":null,"forks":374,"open_issues":172,"watchers":1192,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/1274"},"html":{"href":"https://github.com/sleuthkit/sleuthkit/pull/1274"},"issue":{"href":"https://api.github.com/repos/sleuthkit/sleuthkit/issues/1274"},"comments":{"href":"https://api.github.com/repos/sleuthkit/sleuthkit/issues/1274/comments"},"review_comments":{"href":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/1274/comments"},"review_comment":{"href":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sleuthkit/sleuthkit/pulls/1274/commits"},"statuses":{"href":"https://api.github.com/repos/sleuthkit/sleuthkit/statuses/397afd360c338b9314830e5fc53fa2a80aea9c72"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"rcordovano"}}