{"action":"created","comment":{"url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/comments/106444560","pull_request_review_id":27364830,"id":106444560,"diff_hunk":"@@ -398,6 +412,74 @@ public RuntimeContext deployTestContrib(String bundle, URL contrib) throws Excep\n         return ctx;\n     }\n \n+    @Override\n+    public void deployPartial(String name, Set<TargetExtensions> targetExtensions) throws Exception {\n+        // Do not install bundle; we only need the Object to list his components\n+        Bundle bundle = new BundleImpl(osgi, lookupBundle(name), null);\n+\n+        RuntimeContext ctx = new OSGiRuntimeContext(runtime, bundle);\n+        listBundleComponents(bundle).stream().map(URLStreamRef::new).forEach(component -> {\n+            try {\n+                this.deployPartialComponent(ctx, targetExtensions, component);\n+            } catch (IOException e) {\n+                log.warn(\"PartialBundle: \" + name + \" failed to load: \" + component, e);\n+            }\n+        });\n+    }\n+\n+    /**\n+     * Read a component from his StreamRef and create a new component (suffixed with `-partial`, and the base component\n+     * name aliased) with only matching contributions of the extensionPoints parameter.\n+     * \n+     * @param ctx RuntimeContext in which the new component will be deployed\n+     * @param extensionPoints Set of white listed TargetExtensions\n+     * @param component Reference to the original component\n+     */\n+    protected void deployPartialComponent(RuntimeContext ctx, Set<TargetExtensions> extensionPoints,\n+            StreamRef component) throws IOException {\n+        RegistrationInfo ri = ((DefaultRuntimeContext) ctx).createRegistrationInfo(component);\n+        String alias = ri.getName().getName();\n+        String name = alias.concat(\"-partial\");\n+\n+        // Flatten Target Extension Points\n+        Set<Pair<String, String>> targets = extensionPoints.stream()\n+                                                           .map(TargetExtensions::getTargetExtensions)\n+                                                           .flatMap(Set::stream)\n+                                                           .collect(Collectors.toSet());\n+\n+        String ext = Arrays.stream(ri.getExtensions())\n+                           .filter(e -> targets.contains(\n+                                   Pair.of(e.getTargetComponent().getName(), e.getExtensionPoint())))\n+                           .map(Extension::toXML)\n+                           .reduce((o, x) -> o + x)\n+                           .orElse(\"\");\n+\n+        InlineURLFactory.install();\n+        ctx.deploy(new InlineRef(name,\n+                String.format(\"<component name=\\\"%s\\\"><alias>%s</alias>%s</component>\", name, alias, ext)));\n+    }\n+\n+    /**\n+     * Listing component's urls of a bundle. Inspired from org.nuxeo.runtime.osgi.OSGiRuntimeService#loadComponents but\n+     * without deploying anything.\n+     * \n+     * @param bundle Bundle to be read\n+     */\n+    protected List<URL> listBundleComponents(Bundle bundle) {\n+        String list = getComponentsList(bundle);\n+        String name = bundle.getSymbolicName();\n+        log.debug(\"PartialBundle: \" + name + \" components: \" + list);\n+        if (list == null) {\n+            return null;\n+        }\n+\n+        return Collections.list(new StringTokenizer(list, \", \\t\\n\\r\\f\"))\n+                          .stream()\n+                          .map(s -> bundle.getEntry((String) s))\n+                          .filter(Objects::nonNull)\n+                          .collect(Collectors.toList());","path":"nuxeo-runtime/nuxeo-runtime-test/src/main/java/org/nuxeo/runtime/test/NXRuntimeTestCase.java","position":124,"original_position":124,"commit_id":"28de09241082b4d40c40f4db0864e947c84f0e46","original_commit_id":"28de09241082b4d40c40f4db0864e947c84f0e46","user":{"login":"kevinleturc","id":3491744,"avatar_url":"https://avatars2.githubusercontent.com/u/3491744?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinleturc","html_url":"https://github.com/kevinleturc","followers_url":"https://api.github.com/users/kevinleturc/followers","following_url":"https://api.github.com/users/kevinleturc/following{/other_user}","gists_url":"https://api.github.com/users/kevinleturc/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinleturc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinleturc/subscriptions","organizations_url":"https://api.github.com/users/kevinleturc/orgs","repos_url":"https://api.github.com/users/kevinleturc/repos","events_url":"https://api.github.com/users/kevinleturc/events{/privacy}","received_events_url":"https://api.github.com/users/kevinleturc/received_events","type":"User","site_admin":false},"body":"As you use this method only in this class and you re-convert the list to a Steam, I would suggest to rename method `streamBundleComponents` and make it returning a `Stream`","created_at":"2017-03-16T15:14:04Z","updated_at":"2017-03-16T15:19:41Z","html_url":"https://github.com/nuxeo/nuxeo/pull/610#discussion_r106444560","pull_request_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/610","_links":{"self":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/comments/106444560"},"html":{"href":"https://github.com/nuxeo/nuxeo/pull/610#discussion_r106444560"},"pull_request":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/610"}}},"pull_request":{"url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/610","id":111087423,"html_url":"https://github.com/nuxeo/nuxeo/pull/610","diff_url":"https://github.com/nuxeo/nuxeo/pull/610.diff","patch_url":"https://github.com/nuxeo/nuxeo/pull/610.patch","issue_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/610","number":610,"state":"open","locked":false,"title":"NXP-21051: Allow to deploy a Bundle partially","user":{"login":"akervern","id":473951,"avatar_url":"https://avatars0.githubusercontent.com/u/473951?v=3","gravatar_id":"","url":"https://api.github.com/users/akervern","html_url":"https://github.com/akervern","followers_url":"https://api.github.com/users/akervern/followers","following_url":"https://api.github.com/users/akervern/following{/other_user}","gists_url":"https://api.github.com/users/akervern/gists{/gist_id}","starred_url":"https://api.github.com/users/akervern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akervern/subscriptions","organizations_url":"https://api.github.com/users/akervern/orgs","repos_url":"https://api.github.com/users/akervern/repos","events_url":"https://api.github.com/users/akervern/events{/privacy}","received_events_url":"https://api.github.com/users/akervern/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-16T14:57:15Z","updated_at":"2017-03-16T15:19:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"68d2489143809c5964ec6e9f37d507aad006c9d6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/610/commits","review_comments_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/610/comments","review_comment_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/610/comments","statuses_url":"https://api.github.com/repos/nuxeo/nuxeo/statuses/28de09241082b4d40c40f4db0864e947c84f0e46","head":{"label":"nuxeo:improvement-NXP-21051-forceDeploy-annotation","ref":"improvement-NXP-21051-forceDeploy-annotation","sha":"28de09241082b4d40c40f4db0864e947c84f0e46","user":{"login":"nuxeo","id":460607,"avatar_url":"https://avatars2.githubusercontent.com/u/460607?v=3","gravatar_id":"","url":"https://api.github.com/users/nuxeo","html_url":"https://github.com/nuxeo","followers_url":"https://api.github.com/users/nuxeo/followers","following_url":"https://api.github.com/users/nuxeo/following{/other_user}","gists_url":"https://api.github.com/users/nuxeo/gists{/gist_id}","starred_url":"https://api.github.com/users/nuxeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuxeo/subscriptions","organizations_url":"https://api.github.com/users/nuxeo/orgs","repos_url":"https://api.github.com/users/nuxeo/repos","events_url":"https://api.github.com/users/nuxeo/events{/privacy}","received_events_url":"https://api.github.com/users/nuxeo/received_events","type":"Organization","site_admin":false},"repo":{"id":2988101,"name":"nuxeo","full_name":"nuxeo/nuxeo","owner":{"login":"nuxeo","id":460607,"avatar_url":"https://avatars2.githubusercontent.com/u/460607?v=3","gravatar_id":"","url":"https://api.github.com/users/nuxeo","html_url":"https://github.com/nuxeo","followers_url":"https://api.github.com/users/nuxeo/followers","following_url":"https://api.github.com/users/nuxeo/following{/other_user}","gists_url":"https://api.github.com/users/nuxeo/gists{/gist_id}","starred_url":"https://api.github.com/users/nuxeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuxeo/subscriptions","organizations_url":"https://api.github.com/users/nuxeo/orgs","repos_url":"https://api.github.com/users/nuxeo/repos","events_url":"https://api.github.com/users/nuxeo/events{/privacy}","received_events_url":"https://api.github.com/users/nuxeo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nuxeo/nuxeo","description":"Content management platform to build modern business applications","fork":false,"url":"https://api.github.com/repos/nuxeo/nuxeo","forks_url":"https://api.github.com/repos/nuxeo/nuxeo/forks","keys_url":"https://api.github.com/repos/nuxeo/nuxeo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nuxeo/nuxeo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nuxeo/nuxeo/teams","hooks_url":"https://api.github.com/repos/nuxeo/nuxeo/hooks","issue_events_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/events{/number}","events_url":"https://api.github.com/repos/nuxeo/nuxeo/events","assignees_url":"https://api.github.com/repos/nuxeo/nuxeo/assignees{/user}","branches_url":"https://api.github.com/repos/nuxeo/nuxeo/branches{/branch}","tags_url":"https://api.github.com/repos/nuxeo/nuxeo/tags","blobs_url":"https://api.github.com/repos/nuxeo/nuxeo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nuxeo/nuxeo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nuxeo/nuxeo/git/refs{/sha}","trees_url":"https://api.github.com/repos/nuxeo/nuxeo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nuxeo/nuxeo/statuses/{sha}","languages_url":"https://api.github.com/repos/nuxeo/nuxeo/languages","stargazers_url":"https://api.github.com/repos/nuxeo/nuxeo/stargazers","contributors_url":"https://api.github.com/repos/nuxeo/nuxeo/contributors","subscribers_url":"https://api.github.com/repos/nuxeo/nuxeo/subscribers","subscription_url":"https://api.github.com/repos/nuxeo/nuxeo/subscription","commits_url":"https://api.github.com/repos/nuxeo/nuxeo/commits{/sha}","git_commits_url":"https://api.github.com/repos/nuxeo/nuxeo/git/commits{/sha}","comments_url":"https://api.github.com/repos/nuxeo/nuxeo/comments{/number}","issue_comment_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/comments{/number}","contents_url":"https://api.github.com/repos/nuxeo/nuxeo/contents/{+path}","compare_url":"https://api.github.com/repos/nuxeo/nuxeo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nuxeo/nuxeo/merges","archive_url":"https://api.github.com/repos/nuxeo/nuxeo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nuxeo/nuxeo/downloads","issues_url":"https://api.github.com/repos/nuxeo/nuxeo/issues{/number}","pulls_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls{/number}","milestones_url":"https://api.github.com/repos/nuxeo/nuxeo/milestones{/number}","notifications_url":"https://api.github.com/repos/nuxeo/nuxeo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nuxeo/nuxeo/labels{/name}","releases_url":"https://api.github.com/repos/nuxeo/nuxeo/releases{/id}","deployments_url":"https://api.github.com/repos/nuxeo/nuxeo/deployments","created_at":"2011-12-15T14:35:41Z","updated_at":"2017-03-11T14:26:38Z","pushed_at":"2017-03-16T15:14:11Z","git_url":"git://github.com/nuxeo/nuxeo.git","ssh_url":"git@github.com:nuxeo/nuxeo.git","clone_url":"https://github.com/nuxeo/nuxeo.git","svn_url":"https://github.com/nuxeo/nuxeo","homepage":"http://www.nuxeo.com","size":203967,"stargazers_count":149,"watchers_count":149,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":105,"mirror_url":null,"open_issues_count":26,"forks":105,"open_issues":26,"watchers":149,"default_branch":"master"}},"base":{"label":"nuxeo:master","ref":"master","sha":"0a1fe5fe7dade56966c048dfc4311a99d63f2b6f","user":{"login":"nuxeo","id":460607,"avatar_url":"https://avatars2.githubusercontent.com/u/460607?v=3","gravatar_id":"","url":"https://api.github.com/users/nuxeo","html_url":"https://github.com/nuxeo","followers_url":"https://api.github.com/users/nuxeo/followers","following_url":"https://api.github.com/users/nuxeo/following{/other_user}","gists_url":"https://api.github.com/users/nuxeo/gists{/gist_id}","starred_url":"https://api.github.com/users/nuxeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuxeo/subscriptions","organizations_url":"https://api.github.com/users/nuxeo/orgs","repos_url":"https://api.github.com/users/nuxeo/repos","events_url":"https://api.github.com/users/nuxeo/events{/privacy}","received_events_url":"https://api.github.com/users/nuxeo/received_events","type":"Organization","site_admin":false},"repo":{"id":2988101,"name":"nuxeo","full_name":"nuxeo/nuxeo","owner":{"login":"nuxeo","id":460607,"avatar_url":"https://avatars2.githubusercontent.com/u/460607?v=3","gravatar_id":"","url":"https://api.github.com/users/nuxeo","html_url":"https://github.com/nuxeo","followers_url":"https://api.github.com/users/nuxeo/followers","following_url":"https://api.github.com/users/nuxeo/following{/other_user}","gists_url":"https://api.github.com/users/nuxeo/gists{/gist_id}","starred_url":"https://api.github.com/users/nuxeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nuxeo/subscriptions","organizations_url":"https://api.github.com/users/nuxeo/orgs","repos_url":"https://api.github.com/users/nuxeo/repos","events_url":"https://api.github.com/users/nuxeo/events{/privacy}","received_events_url":"https://api.github.com/users/nuxeo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nuxeo/nuxeo","description":"Content management platform to build modern business applications","fork":false,"url":"https://api.github.com/repos/nuxeo/nuxeo","forks_url":"https://api.github.com/repos/nuxeo/nuxeo/forks","keys_url":"https://api.github.com/repos/nuxeo/nuxeo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nuxeo/nuxeo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nuxeo/nuxeo/teams","hooks_url":"https://api.github.com/repos/nuxeo/nuxeo/hooks","issue_events_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/events{/number}","events_url":"https://api.github.com/repos/nuxeo/nuxeo/events","assignees_url":"https://api.github.com/repos/nuxeo/nuxeo/assignees{/user}","branches_url":"https://api.github.com/repos/nuxeo/nuxeo/branches{/branch}","tags_url":"https://api.github.com/repos/nuxeo/nuxeo/tags","blobs_url":"https://api.github.com/repos/nuxeo/nuxeo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nuxeo/nuxeo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nuxeo/nuxeo/git/refs{/sha}","trees_url":"https://api.github.com/repos/nuxeo/nuxeo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nuxeo/nuxeo/statuses/{sha}","languages_url":"https://api.github.com/repos/nuxeo/nuxeo/languages","stargazers_url":"https://api.github.com/repos/nuxeo/nuxeo/stargazers","contributors_url":"https://api.github.com/repos/nuxeo/nuxeo/contributors","subscribers_url":"https://api.github.com/repos/nuxeo/nuxeo/subscribers","subscription_url":"https://api.github.com/repos/nuxeo/nuxeo/subscription","commits_url":"https://api.github.com/repos/nuxeo/nuxeo/commits{/sha}","git_commits_url":"https://api.github.com/repos/nuxeo/nuxeo/git/commits{/sha}","comments_url":"https://api.github.com/repos/nuxeo/nuxeo/comments{/number}","issue_comment_url":"https://api.github.com/repos/nuxeo/nuxeo/issues/comments{/number}","contents_url":"https://api.github.com/repos/nuxeo/nuxeo/contents/{+path}","compare_url":"https://api.github.com/repos/nuxeo/nuxeo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nuxeo/nuxeo/merges","archive_url":"https://api.github.com/repos/nuxeo/nuxeo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nuxeo/nuxeo/downloads","issues_url":"https://api.github.com/repos/nuxeo/nuxeo/issues{/number}","pulls_url":"https://api.github.com/repos/nuxeo/nuxeo/pulls{/number}","milestones_url":"https://api.github.com/repos/nuxeo/nuxeo/milestones{/number}","notifications_url":"https://api.github.com/repos/nuxeo/nuxeo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nuxeo/nuxeo/labels{/name}","releases_url":"https://api.github.com/repos/nuxeo/nuxeo/releases{/id}","deployments_url":"https://api.github.com/repos/nuxeo/nuxeo/deployments","created_at":"2011-12-15T14:35:41Z","updated_at":"2017-03-11T14:26:38Z","pushed_at":"2017-03-16T15:14:11Z","git_url":"git://github.com/nuxeo/nuxeo.git","ssh_url":"git@github.com:nuxeo/nuxeo.git","clone_url":"https://github.com/nuxeo/nuxeo.git","svn_url":"https://github.com/nuxeo/nuxeo","homepage":"http://www.nuxeo.com","size":203967,"stargazers_count":149,"watchers_count":149,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":105,"mirror_url":null,"open_issues_count":26,"forks":105,"open_issues":26,"watchers":149,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/610"},"html":{"href":"https://github.com/nuxeo/nuxeo/pull/610"},"issue":{"href":"https://api.github.com/repos/nuxeo/nuxeo/issues/610"},"comments":{"href":"https://api.github.com/repos/nuxeo/nuxeo/issues/610/comments"},"review_comments":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/610/comments"},"review_comment":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nuxeo/nuxeo/pulls/610/commits"},"statuses":{"href":"https://api.github.com/repos/nuxeo/nuxeo/statuses/28de09241082b4d40c40f4db0864e947c84f0e46"}}}}
{"actor":{"display_login":"kevinleturc"}}