{"action":"created","comment":{"url":"https://api.github.com/repos/dimagi/commcare-core/pulls/comments/80491221","id":80491221,"diff_hunk":"@@ -0,0 +1,58 @@\n+package org.commcare.resources.model.installers;\n+\n+import org.commcare.resources.model.Resource;\n+import org.commcare.resources.model.ResourceInitializationException;\n+import org.commcare.resources.model.ResourceLocation;\n+import org.commcare.resources.model.ResourceTable;\n+import org.commcare.resources.model.UnresolvedResourceException;\n+import org.commcare.suite.model.OfflineUserRestore;\n+import org.commcare.util.CommCareInstance;\n+import org.javarosa.core.reference.Reference;\n+import org.javarosa.xml.util.UnfullfilledRequirementsException;\n+\n+import java.io.IOException;\n+\n+/**\n+ * Install user restore xml file present in app for use in offline logins.\n+ * Used for providing a demo user restore.\n+ *\n+ * @author Phillip Mates (pmates@dimagi.com)\n+ */\n+public class OfflineUserRestoreInstaller extends CacheInstaller<OfflineUserRestore> {\n+    @Override\n+    protected String getCacheKey() {\n+        return OfflineUserRestore.STORAGE_KEY;\n+    }\n+\n+    @Override\n+    public boolean initialize(CommCareInstance instance, boolean isUpgrade)\n+            throws ResourceInitializationException {\n+        instance.registerDemoUserRestore(storage().read(cacheLocation));\n+        return true;\n+    }\n+\n+    @Override\n+    public boolean requiresRuntimeInitialization() {\n+        return true;\n+    }\n+\n+    @Override\n+    public boolean install(Resource r, ResourceLocation location,\n+                           Reference ref, ResourceTable table,\n+                           CommCareInstance instance, boolean upgrade)\n+            throws UnresolvedResourceException, UnfullfilledRequirementsException {\n+        try {\n+            OfflineUserRestore offlineUserRestore = OfflineUserRestore.buildInMemoryUserRestore(ref.getStream());","path":"backend/src/org/commcare/resources/model/installers/OfflineUserRestoreInstaller.java","position":45,"original_position":45,"commit_id":"0db0ed1f92cb14fa9e63c40b86626820f13ed6ee","original_commit_id":"28285d5e6a6286c82d219523536a235ce140d86d","user":{"login":"amstone326","id":3723143,"avatar_url":"https://avatars.githubusercontent.com/u/3723143?v=3","gravatar_id":"","url":"https://api.github.com/users/amstone326","html_url":"https://github.com/amstone326","followers_url":"https://api.github.com/users/amstone326/followers","following_url":"https://api.github.com/users/amstone326/following{/other_user}","gists_url":"https://api.github.com/users/amstone326/gists{/gist_id}","starred_url":"https://api.github.com/users/amstone326/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amstone326/subscriptions","organizations_url":"https://api.github.com/users/amstone326/orgs","repos_url":"https://api.github.com/users/amstone326/repos","events_url":"https://api.github.com/users/amstone326/events{/privacy}","received_events_url":"https://api.github.com/users/amstone326/received_events","type":"User","site_admin":false},"body":"@ctsims This actually doesn't look simple to hook up (since the parsing and committing of data from a restore file is currently very coupled, and we would want to be able to very clearly parse but not commit any of the data at this stage), so going to wait for confirmation that this is the best approach before attempting.","created_at":"2016-09-26T14:45:00Z","updated_at":"2016-09-26T14:45:00Z","html_url":"https://github.com/dimagi/commcare-core/pull/359#discussion_r80491221","pull_request_url":"https://api.github.com/repos/dimagi/commcare-core/pulls/359","_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-core/pulls/comments/80491221"},"html":{"href":"https://github.com/dimagi/commcare-core/pull/359#discussion_r80491221"},"pull_request":{"href":"https://api.github.com/repos/dimagi/commcare-core/pulls/359"}}},"pull_request":{"url":"https://api.github.com/repos/dimagi/commcare-core/pulls/359","id":80500276,"html_url":"https://github.com/dimagi/commcare-core/pull/359","diff_url":"https://github.com/dimagi/commcare-core/pull/359.diff","patch_url":"https://github.com/dimagi/commcare-core/pull/359.patch","issue_url":"https://api.github.com/repos/dimagi/commcare-core/issues/359","number":359,"state":"open","locked":false,"title":"Offline demo user restore","user":{"login":"phillipm","id":94817,"avatar_url":"https://avatars.githubusercontent.com/u/94817?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipm","html_url":"https://github.com/phillipm","followers_url":"https://api.github.com/users/phillipm/followers","following_url":"https://api.github.com/users/phillipm/following{/other_user}","gists_url":"https://api.github.com/users/phillipm/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipm/subscriptions","organizations_url":"https://api.github.com/users/phillipm/orgs","repos_url":"https://api.github.com/users/phillipm/repos","events_url":"https://api.github.com/users/phillipm/events{/privacy}","received_events_url":"https://api.github.com/users/phillipm/received_events","type":"User","site_admin":false},"body":"Also extends CLI to take in `-d` flag, which tries to log in as the demo user using the demo user restore present in the app.\r\n\r\ncross-request: https://github.com/dimagi/commcare-android/pull/1438","created_at":"2016-08-08T18:40:57Z","updated_at":"2016-09-26T14:45:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4879e6231766faa1387a42c871690b41393cb6dc","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/dimagi/commcare-core/milestones/9","html_url":"https://github.com/dimagi/commcare-core/milestones/commcare_2.31","labels_url":"https://api.github.com/repos/dimagi/commcare-core/milestones/9/labels","id":1985812,"number":9,"title":"commcare_2.31","description":null,"creator":{"login":"phillipm","id":94817,"avatar_url":"https://avatars.githubusercontent.com/u/94817?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipm","html_url":"https://github.com/phillipm","followers_url":"https://api.github.com/users/phillipm/followers","following_url":"https://api.github.com/users/phillipm/following{/other_user}","gists_url":"https://api.github.com/users/phillipm/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipm/subscriptions","organizations_url":"https://api.github.com/users/phillipm/orgs","repos_url":"https://api.github.com/users/phillipm/repos","events_url":"https://api.github.com/users/phillipm/events{/privacy}","received_events_url":"https://api.github.com/users/phillipm/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":13,"state":"open","created_at":"2016-09-06T10:06:44Z","updated_at":"2016-09-25T22:04:21Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/dimagi/commcare-core/pulls/359/commits","review_comments_url":"https://api.github.com/repos/dimagi/commcare-core/pulls/359/comments","review_comment_url":"https://api.github.com/repos/dimagi/commcare-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dimagi/commcare-core/issues/359/comments","statuses_url":"https://api.github.com/repos/dimagi/commcare-core/statuses/0db0ed1f92cb14fa9e63c40b86626820f13ed6ee","head":{"label":"dimagi:demo-user-restore","ref":"demo-user-restore","sha":"0db0ed1f92cb14fa9e63c40b86626820f13ed6ee","user":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":20939782,"name":"commcare-core","full_name":"dimagi/commcare-core","owner":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-core","description":"Last-mile mobile app platform utilized across sectors, from healthcare to supply and logistics","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-core","forks_url":"https://api.github.com/repos/dimagi/commcare-core/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-core/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-core/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-core/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-core/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-core/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-core/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-core/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-core/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-core/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-core/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-core/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-core/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-core/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-core/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-core/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-core/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-core/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-core/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-core/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-core/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-core/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-core/deployments","created_at":"2014-06-17T21:13:25Z","updated_at":"2016-06-26T22:32:46Z","pushed_at":"2016-09-26T12:12:15Z","git_url":"git://github.com/dimagi/commcare-core.git","ssh_url":"git@github.com:dimagi/commcare-core.git","clone_url":"https://github.com/dimagi/commcare-core.git","svn_url":"https://github.com/dimagi/commcare-core","homepage":"http://www.dimagi.com/products/","size":20557,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":5,"forks":6,"open_issues":5,"watchers":2,"default_branch":"master"}},"base":{"label":"dimagi:master","ref":"master","sha":"5e16b62a0d90dfa5a86c4578498434530e922ec2","user":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":20939782,"name":"commcare-core","full_name":"dimagi/commcare-core","owner":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-core","description":"Last-mile mobile app platform utilized across sectors, from healthcare to supply and logistics","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-core","forks_url":"https://api.github.com/repos/dimagi/commcare-core/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-core/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-core/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-core/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-core/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-core/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-core/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-core/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-core/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-core/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-core/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-core/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-core/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-core/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-core/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-core/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-core/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-core/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-core/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-core/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-core/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-core/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-core/deployments","created_at":"2014-06-17T21:13:25Z","updated_at":"2016-06-26T22:32:46Z","pushed_at":"2016-09-26T12:12:15Z","git_url":"git://github.com/dimagi/commcare-core.git","ssh_url":"git@github.com:dimagi/commcare-core.git","clone_url":"https://github.com/dimagi/commcare-core.git","svn_url":"https://github.com/dimagi/commcare-core","homepage":"http://www.dimagi.com/products/","size":20557,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":5,"forks":6,"open_issues":5,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-core/pulls/359"},"html":{"href":"https://github.com/dimagi/commcare-core/pull/359"},"issue":{"href":"https://api.github.com/repos/dimagi/commcare-core/issues/359"},"comments":{"href":"https://api.github.com/repos/dimagi/commcare-core/issues/359/comments"},"review_comments":{"href":"https://api.github.com/repos/dimagi/commcare-core/pulls/359/comments"},"review_comment":{"href":"https://api.github.com/repos/dimagi/commcare-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dimagi/commcare-core/pulls/359/commits"},"statuses":{"href":"https://api.github.com/repos/dimagi/commcare-core/statuses/0db0ed1f92cb14fa9e63c40b86626820f13ed6ee"}}}}
{"actor":{"display_login":"amstone326"}}