You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/03/11 15:22:13 UTC
[08/50] [abbrv] git commit: Use validation utils to validate entity
and scope.
Use validation utils to validate entity and scope.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c7dd4e59
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c7dd4e59
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c7dd4e59
Branch: refs/heads/optimistic-tx-semantics
Commit: c7dd4e59f00b334bbc15fe2b431fd759c3db791c
Parents: c378912
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Mar 10 14:00:35 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Mar 10 14:00:35 2014 -0400
----------------------------------------------------------------------
.../index/impl/EsEntityCollectionIndex.java | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c7dd4e59/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
index 441dfd9..2de269d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
@@ -33,6 +33,7 @@ import org.apache.commons.lang3.time.StopWatch;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
+import org.apache.usergrid.persistence.collection.mvcc.entity.ValidationUtils;
import org.apache.usergrid.persistence.exceptions.IndexException;
import org.apache.usergrid.persistence.index.EntityCollectionIndex;
import org.apache.usergrid.persistence.index.IndexFig;
@@ -105,6 +106,8 @@ public class EsEntityCollectionIndex implements EntityCollectionIndex {
EsProvider provider,
EntityCollectionManagerFactory factory) {
+ ValidationUtils.validateCollectionScope( scope );
+
this.manager = factory.createCollectionManager(scope);
this.client = provider.getClient();
this.scope = scope;
@@ -188,22 +191,14 @@ public class EsEntityCollectionIndex implements EntityCollectionIndex {
public void index(Entity entity) {
+ ValidationUtils.verifyEntityWrite(entity);
+
StopWatch timer = null;
if ( log.isDebugEnabled() ) {
timer = new StopWatch();
timer.start();
}
- if (entity.getId() == null) {
- throw new IllegalArgumentException("Cannot index entity with id null");
- }
- if (entity.getId().getUuid() == null || entity.getId().getType() == null) {
- throw new IllegalArgumentException("Cannot index entity with incomplete id");
- }
- if (entity.getVersion() == null) {
- throw new IllegalArgumentException("Cannot index entity with version null");
- }
-
Map<String, Object> entityAsMap = EsEntityCollectionIndex.entityToMap(entity);
entityAsMap.put("created", entity.getId().getUuid().timestamp());
entityAsMap.put("updated", entity.getVersion().timestamp());
@@ -232,14 +227,19 @@ public class EsEntityCollectionIndex implements EntityCollectionIndex {
}
public void deindex(Entity entity) {
+
deindex(entity.getId(), entity.getVersion());
+
}
public void deindex(Id entityId, UUID version) {
+
String indexId = createIndexId(entityId, version);
+
client.prepareDelete( indexName, typeName, indexId )
.setRefresh( refresh )
.execute().actionGet();
+
log.debug("Deindexed Entity with index id " + indexId);
}