usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [1/3] usergrid git commit: Add index repair to merge duplicates.
Date Mon, 21 Dec 2015 16:54:38 GMT
Repository: usergrid
Updated Branches:
  refs/heads/1.x a2df8f9d0 -> 7a2e68f3b


Add index repair to merge duplicates.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/9be5d3a3
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/9be5d3a3
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/9be5d3a3

Branch: refs/heads/1.x
Commit: 9be5d3a3df999e54ef8fc081cc6a36da468c0db3
Parents: a2df8f9
Author: Dave Johnson <snoopdave@apache.org>
Authored: Mon Dec 21 08:52:48 2015 -0500
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Mon Dec 21 08:52:48 2015 -0500

----------------------------------------------------------------------
 .../org/apache/usergrid/tools/DuplicateOrgRepair.java | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/9be5d3a3/stack/tools/src/main/java/org/apache/usergrid/tools/DuplicateOrgRepair.java
----------------------------------------------------------------------
diff --git a/stack/tools/src/main/java/org/apache/usergrid/tools/DuplicateOrgRepair.java b/stack/tools/src/main/java/org/apache/usergrid/tools/DuplicateOrgRepair.java
index c703305..b1f2afc 100644
--- a/stack/tools/src/main/java/org/apache/usergrid/tools/DuplicateOrgRepair.java
+++ b/stack/tools/src/main/java/org/apache/usergrid/tools/DuplicateOrgRepair.java
@@ -529,10 +529,22 @@ public class DuplicateOrgRepair extends ToolBase {
         
         @Override
         public void removeOrg(Org keeper, Org duplicate) throws Exception {
-            // we don't have a remove org API so rename org so that it is no longer a duplicate
+            
+            // rename org so that it is no longer a duplicate
             OrganizationInfo orgInfo = managementService.getOrganizationByUuid( duplicate.getId()
);
             orgInfo.setName( "dup_" + keeper.getId() + "_" + RandomStringUtils.randomAlphanumeric(10)
);
             managementService.updateOrganization( orgInfo );
+
+            // fix the org name index
+            OrganizationInfo orgInfoKeeper = managementService.getOrganizationByUuid( duplicate.getId()
);
+            try {
+                managementService.updateOrganizationUniqueIndex( orgInfo, duplicate.getId()
);
+                
+            } catch ( Exception e ) {
+                // if there are multiple duplicates this will fail for all but one of them.
That's OK
+                logger.warn("Error repairing unique value keeper {} duplicate {}", 
+                        keeper.getId(), duplicate.getId());
+            }
         }
         
 


Mime
View raw message