usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [20/50] [abbrv] incubator-usergrid git commit: Better checks for missing creds.
Date Fri, 24 Jul 2015 15:21:48 GMT
Better checks for missing creds.


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

Branch: refs/heads/USERGRID-869
Commit: e1b352ef96da0ff687be87092c35eb3067592ee4
Parents: 9c459f4
Author: Dave Johnson <snoopdave@apache.org>
Authored: Wed Jul 15 13:57:40 2015 -0400
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Wed Jul 15 13:57:40 2015 -0400

----------------------------------------------------------------------
 .../org/apache/usergrid/tools/ExportAdmins.java | 37 ++++++++------------
 .../org/apache/usergrid/tools/ImportAdmins.java |  5 +--
 2 files changed, 17 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b352ef/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
----------------------------------------------------------------------
diff --git a/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java b/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
index d726ad3..2c14da1 100644
--- a/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
+++ b/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
@@ -315,42 +315,33 @@ public class ExportAdmins extends ExportingToolBase {
 
         private void addDictionariesToTask(AdminUserWriteTask task, Entity entity) throws
Exception {
             EntityManager em = emf.getEntityManager( CassandraService.MANAGEMENT_APPLICATION_ID
);
+            
+            task.dictionariesByName = new HashMap<String, Map<Object, Object>>();
 
             Set<String> dictionaries = em.getDictionaries( entity );
             
             if ( dictionaries.isEmpty() ) {
                 logger.error("User {}:{} has no dictionaries", task.adminUser.getName(),
task.adminUser.getUuid() );
+                return;
             }
 
-            task.dictionariesByName = new HashMap<String, Map<Object, Object>>();
+            Map<Object, Object> credentialsDictionary = em.getDictionaryAsMap( entity,
"credentials" );
 
-            for (String dictionary : dictionaries) {
-                Map<Object, Object> dict = em.getDictionaryAsMap( entity, dictionary
);
-                if ( dict.isEmpty() ) {
-                    continue;
-                }
-                task.dictionariesByName.put( dictionary, dict );
-            }
-           
-            if ( task.dictionariesByName.isEmpty() ) {
-                logger.error( "User {}:{} has no dictionaries",
-                        new Object[]{task.adminUser.getName(), task.adminUser.getUuid() }
);
-                
-            } else if ( task.dictionariesByName.get("credentials") == null ) {
-                logger.error( "User {}:{} has no credentials dictionary",
-                        new Object[]{task.adminUser.getName(), task.adminUser.getUuid() }
);
-                
-            } else {
-                if ( task.dictionariesByName.get("credentials").get("password") == null )
{
+            if ( credentialsDictionary != null && !credentialsDictionary.isEmpty()
) {
+                task.dictionariesByName.put( "credentials", credentialsDictionary );
+
+                if (credentialsDictionary.get( "password" ) == null) {
                     logger.error( "User {}:{} has no password in credential dictionary",
-                            new Object[]{task.adminUser.getName(), task.adminUser.getUuid()
} );
+                        new Object[]{task.adminUser.getName(), task.adminUser.getUuid()}
);
                 }
-                if ( task.dictionariesByName.get("credentials").get("secret") == null ) {
+                if (credentialsDictionary.get( "secret" ) == null) {
                     logger.error( "User {}:{} has no secret in credential dictionary",
-                            new Object[]{task.adminUser.getName(), task.adminUser.getUuid()
} );
+                        new Object[]{task.adminUser.getName(), task.adminUser.getUuid()}
);
                 }
+            } else {
+                logger.error( "User {}:{} has no or empty credentials dictionary",
+                    new Object[]{task.adminUser.getName(), task.adminUser.getUuid()} );
             }
-                
         }
 
         private void addOrganizationsToTask(AdminUserWriteTask task) throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1b352ef/stack/tools/src/main/java/org/apache/usergrid/tools/ImportAdmins.java
----------------------------------------------------------------------
diff --git a/stack/tools/src/main/java/org/apache/usergrid/tools/ImportAdmins.java b/stack/tools/src/main/java/org/apache/usergrid/tools/ImportAdmins.java
index 0b69a98..0b693c8 100644
--- a/stack/tools/src/main/java/org/apache/usergrid/tools/ImportAdmins.java
+++ b/stack/tools/src/main/java/org/apache/usergrid/tools/ImportAdmins.java
@@ -382,7 +382,7 @@ public class ImportAdmins extends ToolBase {
                 String entityOwnerId = jp.getCurrentName();
 
                 try {
-                    EntityRef entityRef = em.getRef( UUID.fromString( entityOwnerId ) );
+                    EntityRef entityRef = em.get( UUID.fromString( entityOwnerId ) );
                     Map<String, Object> metadata = (Map<String, Object>) jp.readValueAs(
Map.class );
                     
                     workQueue.put( new ImportMetadataTask( entityRef, metadata ) );
@@ -414,7 +414,8 @@ public class ImportAdmins extends ToolBase {
             User user = em.get(entityRef, User.class);
             
             if (user == null) {
-                logger.error("User with uuid={} not found, not adding to organizations");
+                logger.error("User not found, not adding to organizations: " 
+                    + (entityRef == null ? null : entityRef.getUuid()));
 
             } else {
 


Mime
View raw message