{"action":"created","comment":{"url":"https://api.github.com/repos/topolik/liferay-docs/pulls/comments/173524178","pull_request_review_id":102736246,"id":173524178,"diff_hunk":"@@ -49,6 +53,77 @@ or group template (site template). These are used internally for those objects,\n so you'd only use them if you were customizing functionality for creating and\n deleting them. \n \n+Now you're ready to register your entities with the permissions service. \n+\n+## Registering Entities to the Permissions Service\n+\n+The permissions service that's running needs to know about your entities and how\n+to check permissions for them. This requires creating a permissions registrar\n+class. \n+\n+1.  In your service bundle, create a package that by convention ends in\n+    `internal.security.permission.resource`. For example, the Blogs\n+    application's package is named\n+    `com.liferay.blogs.internal.security.permission.resource`. \n+\n+2.  Create a class in this package called `[Entity\n+    Name]ModelResourcePermissionRegistrar`. For example, the Blogs application's\n+    class is named `BlogsEntryModelResourcePermissionRegistrar`. \n+\n+3.  This class is a component class that requires overriding the `activate`\n+    method to register the permissions logic you want for your entities. For\n+    example, this is how the Blogs application registers its permissions: \n+\n+        @Component(immediate = true)\n+        public class BlogsEntryModelResourcePermissionRegistrar {\n+\n+            @Activate\n+            public void activate(BundleContext bundleContext) {\n+                Dictionary<String, Object> properties = new HashMapDictionary<>();\n+\n+                properties.put(\"model.class.name\", BlogsEntry.class.getName());\n+\n+                _serviceRegistration = bundleContext.registerService(\n+                    ModelResourcePermission.class,\n+                    ModelResourcePermissionFactory.create(\n+                        BlogsEntry.class, BlogsEntry::getEntryId,\n+                        _blogsEntryLocalService::getEntry, _portletResourcePermission,\n+                        (modelResourcePermission, consumer) -> {\n+                            consumer.accept(\n+                                new StagedModelPermissionLogic<>(\n+                                    _stagingPermission, BlogsPortletKeys.BLOGS,\n+                                    BlogsEntry::getEntryId));\n+                            consumer.accept(\n+                                new WorkflowedModelPermissionLogic<>(\n+                                    _workflowPermission, modelResourcePermission,\n+                                    BlogsEntry::getEntryId));\n+                        }),\n+                    properties);\n+            }\n+\n+            @Deactivate\n+            public void deactivate() {\n+                _serviceRegistration.unregister();\n+            }\n+\n+            @Reference\n+            private BlogsEntryLocalService _blogsEntryLocalService;\n+\n+            @Reference(target = \"(resource.name=\" + BlogsConstants.RESOURCE_NAME + \")\")\n+            private PortletResourcePermission _portletResourcePermission;","path":"develop/tutorials/articles/140-application-security/01-application-permissions/03-registering-permissions.markdown","position":113,"original_position":78,"commit_id":"34dddbf38a7c2bd1381d60105e3b142c197dfdc2","original_commit_id":"52d44ccd5b78ec7b20b7e0095a06b695da74b0b8","user":{"login":"Preston-Crary","id":1714297,"avatar_url":"https://avatars2.githubusercontent.com/u/1714297?v=4","gravatar_id":"","url":"https://api.github.com/users/Preston-Crary","html_url":"https://github.com/Preston-Crary","followers_url":"https://api.github.com/users/Preston-Crary/followers","following_url":"https://api.github.com/users/Preston-Crary/following{/other_user}","gists_url":"https://api.github.com/users/Preston-Crary/gists{/gist_id}","starred_url":"https://api.github.com/users/Preston-Crary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Preston-Crary/subscriptions","organizations_url":"https://api.github.com/users/Preston-Crary/orgs","repos_url":"https://api.github.com/users/Preston-Crary/repos","events_url":"https://api.github.com/users/Preston-Crary/events{/privacy}","received_events_url":"https://api.github.com/users/Preston-Crary/received_events","type":"User","site_admin":false},"body":"This is how they should reference PortletResourcePermissions and ModelResourcePermissions in component classes.  In the case of ModelResourcePermissions they should use a filter matching the \"model.class.name\" property they set above.","created_at":"2018-03-09T18:06:42Z","updated_at":"2018-03-09T18:06:43Z","html_url":"https://github.com/topolik/liferay-docs/pull/2#discussion_r173524178","pull_request_url":"https://api.github.com/repos/topolik/liferay-docs/pulls/2","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/topolik/liferay-docs/pulls/comments/173524178"},"html":{"href":"https://github.com/topolik/liferay-docs/pull/2#discussion_r173524178"},"pull_request":{"href":"https://api.github.com/repos/topolik/liferay-docs/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/topolik/liferay-docs/pulls/2","id":173874285,"html_url":"https://github.com/topolik/liferay-docs/pull/2","diff_url":"https://github.com/topolik/liferay-docs/pull/2.diff","patch_url":"https://github.com/topolik/liferay-docs/pull/2.patch","issue_url":"https://api.github.com/repos/topolik/liferay-docs/issues/2","number":2,"state":"open","locked":false,"title":"LRDOCS-4349 New Permissions API Tutorials","user":{"login":"sez11a","id":515497,"avatar_url":"https://avatars3.githubusercontent.com/u/515497?v=4","gravatar_id":"","url":"https://api.github.com/users/sez11a","html_url":"https://github.com/sez11a","followers_url":"https://api.github.com/users/sez11a/followers","following_url":"https://api.github.com/users/sez11a/following{/other_user}","gists_url":"https://api.github.com/users/sez11a/gists{/gist_id}","starred_url":"https://api.github.com/users/sez11a/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sez11a/subscriptions","organizations_url":"https://api.github.com/users/sez11a/orgs","repos_url":"https://api.github.com/users/sez11a/repos","events_url":"https://api.github.com/users/sez11a/events{/privacy}","received_events_url":"https://api.github.com/users/sez11a/received_events","type":"User","site_admin":false},"body":"@preston-crary This is really for you, but you haven't forked/cloned liferay-docs. But I'd like it if both of you guys could review this and let me know what you think. Thanks! ","created_at":"2018-03-08T22:54:56Z","updated_at":"2018-03-09T18:06:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8edb93accd0dc8177fd245573d454437f6fec450","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/topolik/liferay-docs/pulls/2/commits","review_comments_url":"https://api.github.com/repos/topolik/liferay-docs/pulls/2/comments","review_comment_url":"https://api.github.com/repos/topolik/liferay-docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/topolik/liferay-docs/issues/2/comments","statuses_url":"https://api.github.com/repos/topolik/liferay-docs/statuses/34dddbf38a7c2bd1381d60105e3b142c197dfdc2","head":{"label":"sez11a:LRDOCS-4349-permissions","ref":"LRDOCS-4349-permissions","sha":"34dddbf38a7c2bd1381d60105e3b142c197dfdc2","user":{"login":"sez11a","id":515497,"avatar_url":"https://avatars3.githubusercontent.com/u/515497?v=4","gravatar_id":"","url":"https://api.github.com/users/sez11a","html_url":"https://github.com/sez11a","followers_url":"https://api.github.com/users/sez11a/followers","following_url":"https://api.github.com/users/sez11a/following{/other_user}","gists_url":"https://api.github.com/users/sez11a/gists{/gist_id}","starred_url":"https://api.github.com/users/sez11a/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sez11a/subscriptions","organizations_url":"https://api.github.com/users/sez11a/orgs","repos_url":"https://api.github.com/users/sez11a/repos","events_url":"https://api.github.com/users/sez11a/events{/privacy}","received_events_url":"https://api.github.com/users/sez11a/received_events","type":"User","site_admin":false},"repo":{"id":2181257,"name":"liferay-docs","full_name":"sez11a/liferay-docs","owner":{"login":"sez11a","id":515497,"avatar_url":"https://avatars3.githubusercontent.com/u/515497?v=4","gravatar_id":"","url":"https://api.github.com/users/sez11a","html_url":"https://github.com/sez11a","followers_url":"https://api.github.com/users/sez11a/followers","following_url":"https://api.github.com/users/sez11a/following{/other_user}","gists_url":"https://api.github.com/users/sez11a/gists{/gist_id}","starred_url":"https://api.github.com/users/sez11a/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sez11a/subscriptions","organizations_url":"https://api.github.com/users/sez11a/orgs","repos_url":"https://api.github.com/users/sez11a/repos","events_url":"https://api.github.com/users/sez11a/events{/privacy}","received_events_url":"https://api.github.com/users/sez11a/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sez11a/liferay-docs","description":null,"fork":true,"url":"https://api.github.com/repos/sez11a/liferay-docs","forks_url":"https://api.github.com/repos/sez11a/liferay-docs/forks","keys_url":"https://api.github.com/repos/sez11a/liferay-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sez11a/liferay-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sez11a/liferay-docs/teams","hooks_url":"https://api.github.com/repos/sez11a/liferay-docs/hooks","issue_events_url":"https://api.github.com/repos/sez11a/liferay-docs/issues/events{/number}","events_url":"https://api.github.com/repos/sez11a/liferay-docs/events","assignees_url":"https://api.github.com/repos/sez11a/liferay-docs/assignees{/user}","branches_url":"https://api.github.com/repos/sez11a/liferay-docs/branches{/branch}","tags_url":"https://api.github.com/repos/sez11a/liferay-docs/tags","blobs_url":"https://api.github.com/repos/sez11a/liferay-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sez11a/liferay-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sez11a/liferay-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/sez11a/liferay-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sez11a/liferay-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/sez11a/liferay-docs/languages","stargazers_url":"https://api.github.com/repos/sez11a/liferay-docs/stargazers","contributors_url":"https://api.github.com/repos/sez11a/liferay-docs/contributors","subscribers_url":"https://api.github.com/repos/sez11a/liferay-docs/subscribers","subscription_url":"https://api.github.com/repos/sez11a/liferay-docs/subscription","commits_url":"https://api.github.com/repos/sez11a/liferay-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/sez11a/liferay-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/sez11a/liferay-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/sez11a/liferay-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/sez11a/liferay-docs/contents/{+path}","compare_url":"https://api.github.com/repos/sez11a/liferay-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sez11a/liferay-docs/merges","archive_url":"https://api.github.com/repos/sez11a/liferay-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sez11a/liferay-docs/downloads","issues_url":"https://api.github.com/repos/sez11a/liferay-docs/issues{/number}","pulls_url":"https://api.github.com/repos/sez11a/liferay-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/sez11a/liferay-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/sez11a/liferay-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sez11a/liferay-docs/labels{/name}","releases_url":"https://api.github.com/repos/sez11a/liferay-docs/releases{/id}","deployments_url":"https://api.github.com/repos/sez11a/liferay-docs/deployments","created_at":"2011-08-09T19:37:02Z","updated_at":"2017-09-15T18:09:44Z","pushed_at":"2018-03-09T17:02:12Z","git_url":"git://github.com/sez11a/liferay-docs.git","ssh_url":"git@github.com:sez11a/liferay-docs.git","clone_url":"https://github.com/sez11a/liferay-docs.git","svn_url":"https://github.com/sez11a/liferay-docs","homepage":"","size":687527,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":5,"open_issues":24,"watchers":3,"default_branch":"master"}},"base":{"label":"topolik:master","ref":"master","sha":"863cea956808c5d538a13e84818a81d992ff6007","user":{"login":"topolik","id":148147,"avatar_url":"https://avatars2.githubusercontent.com/u/148147?v=4","gravatar_id":"","url":"https://api.github.com/users/topolik","html_url":"https://github.com/topolik","followers_url":"https://api.github.com/users/topolik/followers","following_url":"https://api.github.com/users/topolik/following{/other_user}","gists_url":"https://api.github.com/users/topolik/gists{/gist_id}","starred_url":"https://api.github.com/users/topolik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/topolik/subscriptions","organizations_url":"https://api.github.com/users/topolik/orgs","repos_url":"https://api.github.com/users/topolik/repos","events_url":"https://api.github.com/users/topolik/events{/privacy}","received_events_url":"https://api.github.com/users/topolik/received_events","type":"User","site_admin":false},"repo":{"id":6596249,"name":"liferay-docs","full_name":"topolik/liferay-docs","owner":{"login":"topolik","id":148147,"avatar_url":"https://avatars2.githubusercontent.com/u/148147?v=4","gravatar_id":"","url":"https://api.github.com/users/topolik","html_url":"https://github.com/topolik","followers_url":"https://api.github.com/users/topolik/followers","following_url":"https://api.github.com/users/topolik/following{/other_user}","gists_url":"https://api.github.com/users/topolik/gists{/gist_id}","starred_url":"https://api.github.com/users/topolik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/topolik/subscriptions","organizations_url":"https://api.github.com/users/topolik/orgs","repos_url":"https://api.github.com/users/topolik/repos","events_url":"https://api.github.com/users/topolik/events{/privacy}","received_events_url":"https://api.github.com/users/topolik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/topolik/liferay-docs","description":null,"fork":true,"url":"https://api.github.com/repos/topolik/liferay-docs","forks_url":"https://api.github.com/repos/topolik/liferay-docs/forks","keys_url":"https://api.github.com/repos/topolik/liferay-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/topolik/liferay-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/topolik/liferay-docs/teams","hooks_url":"https://api.github.com/repos/topolik/liferay-docs/hooks","issue_events_url":"https://api.github.com/repos/topolik/liferay-docs/issues/events{/number}","events_url":"https://api.github.com/repos/topolik/liferay-docs/events","assignees_url":"https://api.github.com/repos/topolik/liferay-docs/assignees{/user}","branches_url":"https://api.github.com/repos/topolik/liferay-docs/branches{/branch}","tags_url":"https://api.github.com/repos/topolik/liferay-docs/tags","blobs_url":"https://api.github.com/repos/topolik/liferay-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/topolik/liferay-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/topolik/liferay-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/topolik/liferay-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/topolik/liferay-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/topolik/liferay-docs/languages","stargazers_url":"https://api.github.com/repos/topolik/liferay-docs/stargazers","contributors_url":"https://api.github.com/repos/topolik/liferay-docs/contributors","subscribers_url":"https://api.github.com/repos/topolik/liferay-docs/subscribers","subscription_url":"https://api.github.com/repos/topolik/liferay-docs/subscription","commits_url":"https://api.github.com/repos/topolik/liferay-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/topolik/liferay-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/topolik/liferay-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/topolik/liferay-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/topolik/liferay-docs/contents/{+path}","compare_url":"https://api.github.com/repos/topolik/liferay-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/topolik/liferay-docs/merges","archive_url":"https://api.github.com/repos/topolik/liferay-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/topolik/liferay-docs/downloads","issues_url":"https://api.github.com/repos/topolik/liferay-docs/issues{/number}","pulls_url":"https://api.github.com/repos/topolik/liferay-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/topolik/liferay-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/topolik/liferay-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/topolik/liferay-docs/labels{/name}","releases_url":"https://api.github.com/repos/topolik/liferay-docs/releases{/id}","deployments_url":"https://api.github.com/repos/topolik/liferay-docs/deployments","created_at":"2012-11-08T12:50:08Z","updated_at":"2018-03-09T17:48:48Z","pushed_at":"2018-03-08T22:54:57Z","git_url":"git://github.com/topolik/liferay-docs.git","ssh_url":"git@github.com:topolik/liferay-docs.git","clone_url":"https://github.com/topolik/liferay-docs.git","svn_url":"https://github.com/topolik/liferay-docs","homepage":"","size":508026,"stargazers_count":0,"watchers_count":0,"language":"Java","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":1,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/topolik/liferay-docs/pulls/2"},"html":{"href":"https://github.com/topolik/liferay-docs/pull/2"},"issue":{"href":"https://api.github.com/repos/topolik/liferay-docs/issues/2"},"comments":{"href":"https://api.github.com/repos/topolik/liferay-docs/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/topolik/liferay-docs/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/topolik/liferay-docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/topolik/liferay-docs/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/topolik/liferay-docs/statuses/34dddbf38a7c2bd1381d60105e3b142c197dfdc2"}},"author_association":"NONE"}}
{"actor":{"display_login":"Preston-Crary"}}