usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject incubator-usergrid git commit: syntax fixes
Date Wed, 04 Mar 2015 16:20:03 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-432 823391678 -> ccc884b6e


syntax fixes


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

Branch: refs/heads/USERGRID-432
Commit: ccc884b6e4d29c2f6dcc18308094fcc867674b33
Parents: 8233916
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Mar 4 09:19:54 2015 -0700
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Mar 4 09:19:54 2015 -0700

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpEntityManager.java |  8 +++-----
 .../corepersistence/CpEntityManagerFactory.java   | 11 ++++++-----
 .../cassandra/EntityManagerFactoryImplIT.java     | 18 +++++++-----------
 .../persistence/index/impl/EsEntityIndexImpl.java |  2 +-
 .../org/apache/usergrid/rest/IndexResource.java   |  9 +++++----
 .../org/apache/usergrid/rest/IndexResourceIT.java |  1 +
 6 files changed, 23 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc884b6/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 6d97605..5619382 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -491,13 +491,11 @@ public class CpEntityManager implements EntityManager {
 
     @Override
     public void update( Entity entity ) throws Exception {
-        if(entity == null)
-            return;
-        Preconditions.checkNotNull("entity should never be null",entity);
+        Preconditions.checkNotNull(entity,"entity should never be null");
         String type = entity.getType();
-        Preconditions.checkNotNull("entity type should never be null",type);
+        Preconditions.checkNotNull(type,"entity type should never be null");
         Id appId  = getApplicationScope().getApplication();
-        Preconditions.checkNotNull("app scope should never be null",appId);
+        Preconditions.checkNotNull(appId,"app scope should never be null");
         // first, update entity index in its own collection scope
 
         CollectionScope collectionScope = getCollectionScopeNameFromEntityType(appId, type
);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc884b6/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index a4e91b5..9aa36a0 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -315,18 +315,19 @@ public class CpEntityManagerFactory implements EntityManagerFactory,
Application
         // remove old appinfo Entity, which is in the System App's appinfos collection
         EntityManager em = getEntityManager(CpNamingUtils.SYSTEM_APP_ID);
         Query q = Query.fromQL(String.format("select * where applicationUuid = '%s'", applicationId.toString()));
-        Results results = em.searchCollection( em.getApplicationRef(), "appinfos", q);
+        Results results = em.searchCollection(em.getApplicationRef(), "appinfos", q);
+
         Entity appToDelete = results.getEntity();
         if(appToDelete != null) {
-            em.delete(appToDelete);
             // create new Entity in deleted_appinfos collection, with same UUID and properties
as deleted appinfo
             em.create("deleted_appinfo", appToDelete.getProperties());
-        }
+            em.delete(appToDelete);
 
+        }
         // delete the application's index
-        EntityIndex ei = managerCache.getEntityIndex(new ApplicationScopeImpl(
-            new SimpleId(applicationId, TYPE_APPLICATION)));
+        EntityIndex ei = managerCache.getEntityIndex(new ApplicationScopeImpl(new SimpleId(applicationId,
TYPE_APPLICATION)));
         ei.deleteIndex();
+        em.refreshIndex();
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc884b6/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index e5f8709..9392d06 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -129,19 +129,15 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
         Func2<UUID, Map<String, UUID> ,Boolean> findApps = new Func2<UUID,Map<String,
UUID> ,Boolean>() {
             @Override
             public Boolean call(UUID applicationId,  Map<String, UUID> apps) {
-                try {
-                    boolean found = false;
-                    for (String appName : apps.keySet()) {
-                        UUID appId = apps.get(appName);
-                        if (appId.equals(applicationId)) {
-                            found = true;
-                            break;
-                        }
+                boolean found = false;
+                for (String appName : apps.keySet()) {
+                    UUID appId = apps.get(appName);
+                    if (appId.equals(applicationId)) {
+                        found = true;
+                        break;
                     }
-                    return found;
-                }catch (Exception e){
-                    throw new RuntimeException(e);
                 }
+                return found;
             }
         };
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc884b6/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 1910cdc..49026e2 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -161,7 +161,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
                 Settings settings = ImmutableSettings.settingsBuilder()
                         .put("index.number_of_shards", numberOfShards)
                         .put("index.number_of_replicas", numberOfReplicas)
-                        .put("action.write_consistency", writeConsistency)
+                        .put("action.write_consistency", writeConsistency )
                     .build();
                 final CreateIndexResponse cir = admin.indices().prepareCreate(indexName)
                         .setSettings(settings)

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc884b6/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index f4ebf23..3269ec0 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@ -21,10 +21,8 @@
 package org.apache.usergrid.rest;
 
 import com.sun.jersey.api.json.JSONWithPadding;
-import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.EntityManagerFactory;
 import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.EntityIndex;
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
 import org.slf4j.Logger;
@@ -53,6 +51,10 @@ public class IndexResource extends AbstractContextResource {
 
     private static final Logger logger = LoggerFactory.getLogger(IndexResource.class);
 
+    public IndexResource(){
+        super();
+    }
+
     @RequireSystemAccess
     @PUT
     @Path( "rebuild" )
@@ -250,10 +252,9 @@ public class IndexResource extends AbstractContextResource {
             throw new IllegalArgumentException("Please add an indexSuffix to your post");
         }
 
-        String writeConsistency = config.get("writeConsistency") != null ? (String)config.get("writeConsistency")
: "one" ;
 
         emf.addIndex(appId, config.get("indexSuffix").toString(),
-            (int) config.get("shards"),(int) config.get("replicas"),writeConsistency);
+            (int) config.get("shards"),(int) config.get("replicas"),(String)config.get("writeConsistency"));
         response.setAction("Add index to alias");
 
         return new JSONWithPadding(response, callback);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ccc884b6/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
index 7f8d085..77f443f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
@@ -58,6 +58,7 @@ public class IndexResourceIT extends AbstractRestIT {
         Map<String, Object> data = new HashMap<String, Object>();
         data.put( "replicas", 0 );
         data.put( "shards", 1 );
+        data.put( "writeConsistency", "one" );
 
         UUID appId = this.context.getAppUuid();
 


Mime
View raw message