{"action":"created","comment":{"url":"https://api.github.com/repos/exodev/social/pulls/comments/59703697","id":59703697,"diff_hunk":"@@ -0,0 +1,264 @@\n+/*\n+ * Copyright (C) 2003-2016 eXo Platform SAS.\n+ *\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU Affero General Public License\n+ * as published by the Free Software Foundation; either version 3\n+ * of the License, or (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program; if not, see<http://www.gnu.org/licenses/>.\n+ */\n+package org.exoplatform.social.core.updater;\n+\n+import java.sql.Connection;\n+import java.sql.ResultSet;\n+import java.sql.SQLException;\n+import java.sql.Statement;\n+\n+import javax.jcr.ItemNotFoundException;\n+import javax.jcr.Node;\n+import javax.jcr.Session;\n+import javax.transaction.NotSupportedException;\n+import javax.transaction.SystemException;\n+import javax.transaction.UserTransaction;\n+\n+import org.apache.commons.lang.StringUtils;\n+import org.exoplatform.commons.upgrade.UpgradeProductPlugin;\n+import org.exoplatform.commons.version.util.VersionComparator;\n+import org.exoplatform.container.PortalContainer;\n+import org.exoplatform.container.xml.InitParams;\n+import org.exoplatform.container.xml.ValueParam;\n+import org.exoplatform.services.jcr.RepositoryService;\n+import org.exoplatform.services.jcr.config.WorkspaceEntry;\n+import org.exoplatform.services.jcr.core.ManageableRepository;\n+import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;\n+import org.exoplatform.services.jcr.ext.common.SessionProvider;\n+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;\n+import org.exoplatform.services.jcr.impl.core.SessionImpl;\n+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;\n+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;\n+import org.exoplatform.services.log.ExoLogger;\n+import org.exoplatform.services.log.Log;\n+import org.exoplatform.services.transaction.TransactionService;\n+\n+/**\n+ * Created by The eXo Platform SAS Author : Boubaker Khanfir\n+ * bkhanfir@exoplatform.com April 16, 2016\n+ */\n+public class SocialMixinCleanerUpgradePlugin extends UpgradeProductPlugin {\n+\n+  private static final int TRANSACTION_TIMEOUT_IN_SECONDS = 3600;\n+  private static final String PLUGIN_PROCEED_VERSION = \"4.3.1\";\n+  private static final String QUERY = \"select distinct PARENT_ID as id from JCR_SITEM\" + \" where container_name = 'social' and\" + \" (  NAME= '[http://www.exoplatform.com/jcr/exo/1.0]name' \"\n+      + \" or NAME= '[http://www.exoplatform.com/jcr/exo/1.0]title'\" + \" or NAME= '[http://www.exoplatform.com/jcr/exo/1.0]titlePublished'\"\n+      + \" or NAME= '[http://www.exoplatform.com/jcr/exo/1.0]index'\" + \" or NAME= '[http://www.exoplatform.com/jcr/publication/1.1/]liveDate'\"\n+      + \" or NAME= '[http://www.exoplatform.com/jcr/exo/1.0]owner'\" + \" or NAME= '[http://www.exoplatform.com/jcr/exo/1.0]dateCreated'\"\n+      + \" or NAME= '[http://www.exoplatform.com/jcr/exo/1.0]dateModified'\" + \" or NAME= '[http://www.exoplatform.com/jcr/exo/1.0]lastModifiedDate'\"\n+      + \" or NAME= '[http://www.exoplatform.com/jcr/exo/1.0]lastModifier'\" + \");\";\n+\n+  private static final Log log = ExoLogger.getLogger(SocialMixinCleanerUpgradePlugin.class);\n+  private final static String[] MIXIN_NAMES = new String[] { \"exo:modify\", \"exo:datetime\", \"exo:owneable\", \"exo:sortable\" };\n+\n+  private static final int FETCH_SIZE = 1000;\n+\n+  private final PortalContainer portalContainer;\n+  private final RepositoryService repositoryService;\n+  private final TransactionService txService;\n+  private final String workspaceName;\n+\n+  public SocialMixinCleanerUpgradePlugin(PortalContainer portalContainer, RepositoryService repositoryService, TransactionService txService, InitParams initParams) {\n+    super(initParams);\n+    ValueParam workspaceValueParam = initParams.getValueParam(\"workspace\");\n+    if (workspaceValueParam != null) {\n+      workspaceName = workspaceValueParam.getValue();\n+    } else {\n+      workspaceName = null;\n+    }\n+\n+    this.repositoryService = repositoryService;\n+    this.txService = txService;\n+    this.portalContainer = portalContainer;\n+  }\n+\n+  /**\n+   * @return true if current version is uppper or equals to than 4.3.1, else\n+   *         return false\n+   */\n+  @Override\n+  public boolean shouldProceedToUpgrade(String newVersion, String previousVersion) {\n+    return VersionComparator.isAfter(newVersion, PLUGIN_PROCEED_VERSION) || VersionComparator.isSame(newVersion, PLUGIN_PROCEED_VERSION);\n+  }\n+\n+  /**\n+   * {@inheritDoc}\n+   */\n+  @Override\n+  public void processUpgrade(String oldVersion, String newVersion) {\n+    new Thread(new Runnable() {\n+      @Override\n+      public void run() {\n+        while (!portalContainer.isStarted()) {","path":"component/core/src/main/java/org/exoplatform/social/core/updater/SocialMixinCleanerUpgradePlugin.java","position":106,"original_position":106,"commit_id":"c0ff9e7451c2c78a538356e2937be18f153cb282","original_commit_id":"d634899d9f77884040dacccae4defcb7fd20c073","user":{"login":"thomasdelhomenie","id":342645,"avatar_url":"https://avatars.githubusercontent.com/u/342645?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasdelhomenie","html_url":"https://github.com/thomasdelhomenie","followers_url":"https://api.github.com/users/thomasdelhomenie/followers","following_url":"https://api.github.com/users/thomasdelhomenie/following{/other_user}","gists_url":"https://api.github.com/users/thomasdelhomenie/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasdelhomenie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasdelhomenie/subscriptions","organizations_url":"https://api.github.com/users/thomasdelhomenie/orgs","repos_url":"https://api.github.com/users/thomasdelhomenie/repos","events_url":"https://api.github.com/users/thomasdelhomenie/events{/privacy}","received_events_url":"https://api.github.com/users/thomasdelhomenie/received_events","type":"User","site_admin":false},"body":"Is it really more complex ? Because it would be more elegant to launch the thread on an event than by polling with Thread.sleep.","created_at":"2016-04-14T11:52:53Z","updated_at":"2016-04-14T11:52:53Z","html_url":"https://github.com/exodev/social/pull/66#discussion_r59703697","pull_request_url":"https://api.github.com/repos/exodev/social/pulls/66","_links":{"self":{"href":"https://api.github.com/repos/exodev/social/pulls/comments/59703697"},"html":{"href":"https://github.com/exodev/social/pull/66#discussion_r59703697"},"pull_request":{"href":"https://api.github.com/repos/exodev/social/pulls/66"}}},"pull_request":{"url":"https://api.github.com/repos/exodev/social/pulls/66","id":66343940,"html_url":"https://github.com/exodev/social/pull/66","diff_url":"https://github.com/exodev/social/pull/66.diff","patch_url":"https://github.com/exodev/social/pull/66.patch","issue_url":"https://api.github.com/repos/exodev/social/issues/66","number":66,"state":"open","locked":false,"title":"SOC-5286: Optimize stored Social data","user":{"login":"boubaker","id":594824,"avatar_url":"https://avatars.githubusercontent.com/u/594824?v=3","gravatar_id":"","url":"https://api.github.com/users/boubaker","html_url":"https://github.com/boubaker","followers_url":"https://api.github.com/users/boubaker/followers","following_url":"https://api.github.com/users/boubaker/following{/other_user}","gists_url":"https://api.github.com/users/boubaker/gists{/gist_id}","starred_url":"https://api.github.com/users/boubaker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boubaker/subscriptions","organizations_url":"https://api.github.com/users/boubaker/orgs","repos_url":"https://api.github.com/users/boubaker/repos","events_url":"https://api.github.com/users/boubaker/events{/privacy}","received_events_url":"https://api.github.com/users/boubaker/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-13T15:42:21Z","updated_at":"2016-04-14T11:52:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1df74aab3cbd71cc9099c34a7715c5944b13bca3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/exodev/social/pulls/66/commits","review_comments_url":"https://api.github.com/repos/exodev/social/pulls/66/comments","review_comment_url":"https://api.github.com/repos/exodev/social/pulls/comments{/number}","comments_url":"https://api.github.com/repos/exodev/social/issues/66/comments","statuses_url":"https://api.github.com/repos/exodev/social/statuses/c0ff9e7451c2c78a538356e2937be18f153cb282","head":{"label":"exodev:fix/4.4.x/SOC-5286","ref":"fix/4.4.x/SOC-5286","sha":"c0ff9e7451c2c78a538356e2937be18f153cb282","user":{"login":"exodev","id":1606522,"avatar_url":"https://avatars.githubusercontent.com/u/1606522?v=3","gravatar_id":"","url":"https://api.github.com/users/exodev","html_url":"https://github.com/exodev","followers_url":"https://api.github.com/users/exodev/followers","following_url":"https://api.github.com/users/exodev/following{/other_user}","gists_url":"https://api.github.com/users/exodev/gists{/gist_id}","starred_url":"https://api.github.com/users/exodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exodev/subscriptions","organizations_url":"https://api.github.com/users/exodev/orgs","repos_url":"https://api.github.com/users/exodev/repos","events_url":"https://api.github.com/users/exodev/events{/privacy}","received_events_url":"https://api.github.com/users/exodev/received_events","type":"Organization","site_admin":false},"repo":{"id":4003303,"name":"social","full_name":"exodev/social","owner":{"login":"exodev","id":1606522,"avatar_url":"https://avatars.githubusercontent.com/u/1606522?v=3","gravatar_id":"","url":"https://api.github.com/users/exodev","html_url":"https://github.com/exodev","followers_url":"https://api.github.com/users/exodev/followers","following_url":"https://api.github.com/users/exodev/following{/other_user}","gists_url":"https://api.github.com/users/exodev/gists{/gist_id}","starred_url":"https://api.github.com/users/exodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exodev/subscriptions","organizations_url":"https://api.github.com/users/exodev/orgs","repos_url":"https://api.github.com/users/exodev/repos","events_url":"https://api.github.com/users/exodev/events{/privacy}","received_events_url":"https://api.github.com/users/exodev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/exodev/social","description":"eXo Social","fork":true,"url":"https://api.github.com/repos/exodev/social","forks_url":"https://api.github.com/repos/exodev/social/forks","keys_url":"https://api.github.com/repos/exodev/social/keys{/key_id}","collaborators_url":"https://api.github.com/repos/exodev/social/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/exodev/social/teams","hooks_url":"https://api.github.com/repos/exodev/social/hooks","issue_events_url":"https://api.github.com/repos/exodev/social/issues/events{/number}","events_url":"https://api.github.com/repos/exodev/social/events","assignees_url":"https://api.github.com/repos/exodev/social/assignees{/user}","branches_url":"https://api.github.com/repos/exodev/social/branches{/branch}","tags_url":"https://api.github.com/repos/exodev/social/tags","blobs_url":"https://api.github.com/repos/exodev/social/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/exodev/social/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/exodev/social/git/refs{/sha}","trees_url":"https://api.github.com/repos/exodev/social/git/trees{/sha}","statuses_url":"https://api.github.com/repos/exodev/social/statuses/{sha}","languages_url":"https://api.github.com/repos/exodev/social/languages","stargazers_url":"https://api.github.com/repos/exodev/social/stargazers","contributors_url":"https://api.github.com/repos/exodev/social/contributors","subscribers_url":"https://api.github.com/repos/exodev/social/subscribers","subscription_url":"https://api.github.com/repos/exodev/social/subscription","commits_url":"https://api.github.com/repos/exodev/social/commits{/sha}","git_commits_url":"https://api.github.com/repos/exodev/social/git/commits{/sha}","comments_url":"https://api.github.com/repos/exodev/social/comments{/number}","issue_comment_url":"https://api.github.com/repos/exodev/social/issues/comments{/number}","contents_url":"https://api.github.com/repos/exodev/social/contents/{+path}","compare_url":"https://api.github.com/repos/exodev/social/compare/{base}...{head}","merges_url":"https://api.github.com/repos/exodev/social/merges","archive_url":"https://api.github.com/repos/exodev/social/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/exodev/social/downloads","issues_url":"https://api.github.com/repos/exodev/social/issues{/number}","pulls_url":"https://api.github.com/repos/exodev/social/pulls{/number}","milestones_url":"https://api.github.com/repos/exodev/social/milestones{/number}","notifications_url":"https://api.github.com/repos/exodev/social/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/exodev/social/labels{/name}","releases_url":"https://api.github.com/repos/exodev/social/releases{/id}","deployments_url":"https://api.github.com/repos/exodev/social/deployments","created_at":"2012-04-12T09:45:16Z","updated_at":"2015-05-08T02:51:58Z","pushed_at":"2016-04-14T10:15:21Z","git_url":"git://github.com/exodev/social.git","ssh_url":"git@github.com:exodev/social.git","clone_url":"https://github.com/exodev/social.git","svn_url":"https://github.com/exodev/social","homepage":null,"size":37241,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":16,"forks":14,"open_issues":16,"watchers":6,"default_branch":"develop"}},"base":{"label":"exodev:develop","ref":"develop","sha":"4d07e25b1d16f9595345eecd8911df49f35041dd","user":{"login":"exodev","id":1606522,"avatar_url":"https://avatars.githubusercontent.com/u/1606522?v=3","gravatar_id":"","url":"https://api.github.com/users/exodev","html_url":"https://github.com/exodev","followers_url":"https://api.github.com/users/exodev/followers","following_url":"https://api.github.com/users/exodev/following{/other_user}","gists_url":"https://api.github.com/users/exodev/gists{/gist_id}","starred_url":"https://api.github.com/users/exodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exodev/subscriptions","organizations_url":"https://api.github.com/users/exodev/orgs","repos_url":"https://api.github.com/users/exodev/repos","events_url":"https://api.github.com/users/exodev/events{/privacy}","received_events_url":"https://api.github.com/users/exodev/received_events","type":"Organization","site_admin":false},"repo":{"id":4003303,"name":"social","full_name":"exodev/social","owner":{"login":"exodev","id":1606522,"avatar_url":"https://avatars.githubusercontent.com/u/1606522?v=3","gravatar_id":"","url":"https://api.github.com/users/exodev","html_url":"https://github.com/exodev","followers_url":"https://api.github.com/users/exodev/followers","following_url":"https://api.github.com/users/exodev/following{/other_user}","gists_url":"https://api.github.com/users/exodev/gists{/gist_id}","starred_url":"https://api.github.com/users/exodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exodev/subscriptions","organizations_url":"https://api.github.com/users/exodev/orgs","repos_url":"https://api.github.com/users/exodev/repos","events_url":"https://api.github.com/users/exodev/events{/privacy}","received_events_url":"https://api.github.com/users/exodev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/exodev/social","description":"eXo Social","fork":true,"url":"https://api.github.com/repos/exodev/social","forks_url":"https://api.github.com/repos/exodev/social/forks","keys_url":"https://api.github.com/repos/exodev/social/keys{/key_id}","collaborators_url":"https://api.github.com/repos/exodev/social/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/exodev/social/teams","hooks_url":"https://api.github.com/repos/exodev/social/hooks","issue_events_url":"https://api.github.com/repos/exodev/social/issues/events{/number}","events_url":"https://api.github.com/repos/exodev/social/events","assignees_url":"https://api.github.com/repos/exodev/social/assignees{/user}","branches_url":"https://api.github.com/repos/exodev/social/branches{/branch}","tags_url":"https://api.github.com/repos/exodev/social/tags","blobs_url":"https://api.github.com/repos/exodev/social/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/exodev/social/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/exodev/social/git/refs{/sha}","trees_url":"https://api.github.com/repos/exodev/social/git/trees{/sha}","statuses_url":"https://api.github.com/repos/exodev/social/statuses/{sha}","languages_url":"https://api.github.com/repos/exodev/social/languages","stargazers_url":"https://api.github.com/repos/exodev/social/stargazers","contributors_url":"https://api.github.com/repos/exodev/social/contributors","subscribers_url":"https://api.github.com/repos/exodev/social/subscribers","subscription_url":"https://api.github.com/repos/exodev/social/subscription","commits_url":"https://api.github.com/repos/exodev/social/commits{/sha}","git_commits_url":"https://api.github.com/repos/exodev/social/git/commits{/sha}","comments_url":"https://api.github.com/repos/exodev/social/comments{/number}","issue_comment_url":"https://api.github.com/repos/exodev/social/issues/comments{/number}","contents_url":"https://api.github.com/repos/exodev/social/contents/{+path}","compare_url":"https://api.github.com/repos/exodev/social/compare/{base}...{head}","merges_url":"https://api.github.com/repos/exodev/social/merges","archive_url":"https://api.github.com/repos/exodev/social/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/exodev/social/downloads","issues_url":"https://api.github.com/repos/exodev/social/issues{/number}","pulls_url":"https://api.github.com/repos/exodev/social/pulls{/number}","milestones_url":"https://api.github.com/repos/exodev/social/milestones{/number}","notifications_url":"https://api.github.com/repos/exodev/social/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/exodev/social/labels{/name}","releases_url":"https://api.github.com/repos/exodev/social/releases{/id}","deployments_url":"https://api.github.com/repos/exodev/social/deployments","created_at":"2012-04-12T09:45:16Z","updated_at":"2015-05-08T02:51:58Z","pushed_at":"2016-04-14T10:15:21Z","git_url":"git://github.com/exodev/social.git","ssh_url":"git@github.com:exodev/social.git","clone_url":"https://github.com/exodev/social.git","svn_url":"https://github.com/exodev/social","homepage":null,"size":37241,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":16,"forks":14,"open_issues":16,"watchers":6,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/exodev/social/pulls/66"},"html":{"href":"https://github.com/exodev/social/pull/66"},"issue":{"href":"https://api.github.com/repos/exodev/social/issues/66"},"comments":{"href":"https://api.github.com/repos/exodev/social/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/exodev/social/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/exodev/social/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/exodev/social/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/exodev/social/statuses/c0ff9e7451c2c78a538356e2937be18f153cb282"}}}}