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 2016/01/04 14:35:20 UTC
[1/9] usergrid git commit: USERGRID-1099 - Porting new test from 1.x
into latest 2.x code.
Repository: usergrid
Updated Branches:
refs/heads/USERGRID-872 41a6cea24 -> 41caeaa10
USERGRID-1099 - Porting new test from 1.x into latest 2.x code.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/f7a82ba8
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/f7a82ba8
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/f7a82ba8
Branch: refs/heads/USERGRID-872
Commit: f7a82ba81cf49f5bdd536370f966dd0480f1edf4
Parents: c6945e3
Author: Michael Russo <mi...@gmail.com>
Authored: Thu Dec 17 14:15:42 2015 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Thu Dec 17 14:15:42 2015 -0800
----------------------------------------------------------------------
.../persistence/query/ParenthesisProblemIT.java | 81 ++++++++++++++++++++
1 file changed, 81 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f7a82ba8/stack/core/src/test/java/org/apache/usergrid/persistence/query/ParenthesisProblemIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ParenthesisProblemIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ParenthesisProblemIT.java
new file mode 100644
index 0000000..60c1622
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ParenthesisProblemIT.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.persistence.query;
+
+import org.apache.usergrid.AbstractCoreIT;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Results;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+
+import static org.junit.Assert.assertEquals;
+
+
+// Created for https://issues.apache.org/jira/browse/USERGRID-1099
+public class ParenthesisProblemIT extends AbstractCoreIT {
+ private static final Logger logger = LoggerFactory.getLogger( ParenthesisProblemIT.class );
+
+ @Test
+ public void parenthesisProblem1() throws Exception {
+ // C = c and ( A > a or B = false )
+ parenthesisProblem(1, "color = 'tabby' and (age > 7 or large = true)");
+ }
+
+ @Test
+ public void parenthesisProblem2() throws Exception {
+ // same as #1 except for order of things listed in 'and' operation
+ // ( A > a or B = false ) and C = c
+ parenthesisProblem(1, "select * where (age > 7 or large = true) and color = 'tabby'");
+ }
+
+ private void parenthesisProblem( int expect, String query ) throws Exception {
+
+ EntityManager em =app.getEntityManager();
+
+ em.create( "cat", new HashMap<String, Object>() {{
+ put("name","enzo");
+ put("color","orange");
+ put("large", true);
+ put("age",6);
+ }});
+
+ em.create( "cat", new HashMap<String, Object> () {{
+ put("name","marquee");
+ put("color","grey");
+ put("large",false);
+ put("age",8);
+ }});
+
+ em.create( "cat", new HashMap<String, Object> () {{
+ put("name","bertha");
+ put("color","tabby");
+ put("large",true);
+ put("age",1);
+ }});
+
+ app.refreshIndex();
+
+ final Results entities = em.searchCollection( em.getApplicationRef(), "cats", Query.fromQL(query));
+
+ assertEquals(expect, entities.size());
+ }
+}
[9/9] usergrid git commit: Merge branch 'master' into USERGRID-872
Posted by sn...@apache.org.
Merge branch 'master' into USERGRID-872
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/41caeaa1
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/41caeaa1
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/41caeaa1
Branch: refs/heads/USERGRID-872
Commit: 41caeaa1033700b2a60325cdd5c98fca46a95c55
Parents: 41a6cea 2867d26
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Jan 4 08:31:02 2016 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Jan 4 08:31:02 2016 -0500
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 30 +++++---
.../persistence/entities/Notification.java | 10 ++-
.../persistence/query/ParenthesisProblemIT.java | 81 ++++++++++++++++++++
.../persistence/cache/ScopedCacheTest.java | 15 ++--
.../rest/applications/ServiceResource.java | 59 ++++++++++----
.../rest/applications/users/UsersResource.java | 19 +++--
.../rest/test/resource/AbstractRestIT.java | 10 ++-
.../cassandra/ManagementServiceImpl.java | 55 +++++++++----
.../notifications/NotificationsService.java | 4 +-
.../apns/NotificationsServiceIT.java | 50 ++++++++++++
10 files changed, 278 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
[7/9] usergrid git commit: Moving test delay for index refresh to
account for the time it takes for Usergrid to process the test documents into
the index before asking Elasticsearch to refresh/flush the index.
Posted by sn...@apache.org.
Moving test delay for index refresh to account for the time it takes for Usergrid to process the test documents into the index before asking Elasticsearch to refresh/flush the index.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/fadad9ec
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/fadad9ec
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/fadad9ec
Branch: refs/heads/USERGRID-872
Commit: fadad9ec97b9ec964efb2ae2076a02d3d6566405
Parents: dc0c6d3
Author: Michael Russo <mi...@gmail.com>
Authored: Tue Dec 29 20:17:20 2015 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Tue Dec 29 20:17:20 2015 -0800
----------------------------------------------------------------------
.../org/apache/usergrid/rest/test/resource/AbstractRestIT.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/fadad9ec/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
index b253543..b25eb92 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
@@ -175,8 +175,8 @@ public class AbstractRestIT extends JerseyTest {
public void refreshIndex() {
//TODO see how we can refresh index (not async) for tests so sleep may not be needed
try {
+ Thread.sleep(250); //ensure index docs are finished being sent to Elasticsearch by Usergrid before refresh
clientSetup.refreshIndex();
- Thread.sleep(100);
} catch (InterruptedException e) {
System.out.println("Error refreshing index");
e.printStackTrace();
[4/9] usergrid git commit: Allow notification entities to be deleted
if they are not in a state that represents "in progress".
Posted by sn...@apache.org.
Allow notification entities to be deleted if they are not in a state that represents "in progress".
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/208be571
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/208be571
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/208be571
Branch: refs/heads/USERGRID-872
Commit: 208be5719e8b54721bde5215a8488636d3a8411f
Parents: 5727925
Author: Michael Russo <mi...@gmail.com>
Authored: Tue Dec 22 22:07:47 2015 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Tue Dec 22 22:07:47 2015 -0800
----------------------------------------------------------------------
.../usergrid/services/notifications/NotificationsService.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/208be571/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
index 2a72a01..202971d 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
@@ -231,7 +231,9 @@ public class NotificationsService extends AbstractCollectionService {
@Override
protected boolean isDeleteAllowed(ServiceContext context, Entity entity) {
Notification notification = (Notification) entity;
- return (notification.getStarted() == null);
+ Notification.State state = notification.getState();
+ return !(state.equals(Notification.State.CREATED) || state.equals(Notification.State.STARTED) ||
+ state.equals(Notification.State.SCHEDULED));
}
// validate payloads
[5/9] usergrid git commit: Merge branch 'release' of
https://git-wip-us.apache.org/repos/asf/usergrid
Posted by sn...@apache.org.
Merge branch 'release' of https://git-wip-us.apache.org/repos/asf/usergrid
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/1cdefdb7
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/1cdefdb7
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/1cdefdb7
Branch: refs/heads/USERGRID-872
Commit: 1cdefdb72b21c23cd084f6efb2b343733d77e83d
Parents: db26ba7 208be57
Author: Michael Russo <mi...@gmail.com>
Authored: Tue Dec 29 14:59:52 2015 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Tue Dec 29 14:59:52 2015 -0800
----------------------------------------------------------------------
.../usergrid/persistence/entities/Notification.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
[2/9] usergrid git commit: Allow notification entities to be deleted
if they are not currently in progress.
Posted by sn...@apache.org.
Allow notification entities to be deleted if they are not currently in progress.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/db26ba72
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/db26ba72
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/db26ba72
Branch: refs/heads/USERGRID-872
Commit: db26ba723dbdc91ffb5a6fade1339032e31de9b3
Parents: f7a82ba
Author: Michael Russo <mi...@gmail.com>
Authored: Thu Dec 17 18:00:36 2015 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Thu Dec 17 18:00:36 2015 -0800
----------------------------------------------------------------------
.../notifications/NotificationsService.java | 4 +-
.../apns/NotificationsServiceIT.java | 50 ++++++++++++++++++++
2 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/db26ba72/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
index 2a72a01..202971d 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
@@ -231,7 +231,9 @@ public class NotificationsService extends AbstractCollectionService {
@Override
protected boolean isDeleteAllowed(ServiceContext context, Entity entity) {
Notification notification = (Notification) entity;
- return (notification.getStarted() == null);
+ Notification.State state = notification.getState();
+ return !(state.equals(Notification.State.CREATED) || state.equals(Notification.State.STARTED) ||
+ state.equals(Notification.State.SCHEDULED));
}
// validate payloads
http://git-wip-us.apache.org/repos/asf/usergrid/blob/db26ba72/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index 60b02a6..daf73d6 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -22,6 +22,7 @@ import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.entities.*;
import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.queue.LocalQueueManager;
+import org.apache.usergrid.services.exceptions.ForbiddenServiceOperationException;
import org.apache.usergrid.services.notifications.*;
import org.junit.*;
import org.slf4j.Logger;
@@ -816,6 +817,55 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
// checkStatistics(notification, NUM_DEVICES, 0);
}
+ @Test
+ public void testDeleteNotification() throws Exception {
+
+ // create push notification //
+ setup.getEntityIndex().refresh(app.getId());
+ app.clear();
+
+ String payload = getPayload();
+
+ Map<String, String> payloads = new HashMap<String, String>(1);
+ payloads.put(notifier.getName().toString(), payload);
+ app.put("payloads", payloads);
+ app.put("queued", System.currentTimeMillis());
+ app.put("debug", true);
+ app.put("expire", System.currentTimeMillis() + 300000); // add 5 minutes to current time
+
+ Entity sentNotification = app.testRequest(ServiceAction.POST, 1, "notifications")
+ .getEntity();
+
+ Entity fetchedNotification = app.testRequest(ServiceAction.GET, 1, "notifications",
+ sentNotification.getUuid()).getEntity();
+
+
+ // can't delete before it's finished
+ try {
+ app.testRequest(ServiceAction.DELETE, 1, "notifications", fetchedNotification.getUuid());
+ } catch (Exception e) {
+ assertEquals(e.getClass(), ForbiddenServiceOperationException.class);
+ }
+
+
+ Notification notification = app.getEntityManager().get(fetchedNotification.getUuid(),
+ Notification.class);
+
+ // perform push //
+ notification = scheduleNotificationAndWait(notification);
+ setup.getEntityIndex().refresh(app.getId());
+
+ try {
+ notification = app.getEntityManager().get(notification.getUuid(), Notification.class);
+ assertEquals(Notification.State.FINISHED, notification.getState());
+
+ //try to delete again after it is in the FINISHED STATE
+ app.testRequest(ServiceAction.DELETE, 1, "notifications", notification.getUuid());
+ } catch (Exception e) {
+ fail("Delete should be successful after notification has finished.");
+ }
+ }
+
private String getPayload(){
ApnsPayloadBuilder builder = new ApnsPayloadBuilder();
builder.setAlertBody("Hello, World!");
[3/9] usergrid git commit: Fix issue where user scoped notification
requests were not finding devices to send notifications to.
Posted by sn...@apache.org.
Fix issue where user scoped notification requests were not finding devices to send notifications to.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/57279250
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/57279250
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/57279250
Branch: refs/heads/USERGRID-872
Commit: 57279250e473b60e6324327ce8d67c976aadef41
Parents: fdc0d80
Author: Michael Russo <mi...@gmail.com>
Authored: Tue Dec 22 22:02:41 2015 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Tue Dec 22 22:02:41 2015 -0800
----------------------------------------------------------------------
.../usergrid/persistence/entities/Notification.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/57279250/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
index 362201a..096706b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
@@ -304,7 +304,15 @@ public class Notification extends TypedEntity {
String collection = pathToken.getCollection();
Query query = new Query();
if (pathToken.getIdentifier()!=null) {
- query.addIdentifier(pathToken.getIdentifier());
+
+ // users collection is special case and uses "username" instaed of "name"
+ // build a query using QL with "username" as Identifier.Type.USERNAME doesn't exist
+ if (collection.equals("users") && pathToken.getIdentifier().getType() == Identifier.Type.NAME){
+ query.setQl("select * where username ='"+pathToken.getIdentifier().getName()+"'");
+ }else{
+ query.addIdentifier(pathToken.getIdentifier());
+ }
+
}
query.setLimit(100);
query.setCollection(collection);
[6/9] usergrid git commit: Remove duplicate entity get from update by
name/id paths. Requires caller to pass in entity to em.updateProperties.
Check if debug is enabled in many placesbefore calling logger.debug.
Posted by sn...@apache.org.
Remove duplicate entity get from update by name/id paths. Requires caller to pass in entity to em.updateProperties. Check if debug is enabled in many placesbefore calling logger.debug.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/dc0c6d39
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/dc0c6d39
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/dc0c6d39
Branch: refs/heads/USERGRID-872
Commit: dc0c6d3999207d301ed4872b91b0b9e8dd25d011
Parents: 1cdefdb
Author: Michael Russo <mi...@gmail.com>
Authored: Tue Dec 29 17:41:47 2015 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Tue Dec 29 17:41:47 2015 -0800
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 30 ++++++----
.../rest/applications/ServiceResource.java | 59 ++++++++++++++------
.../rest/applications/users/UsersResource.java | 19 +++++--
.../rest/test/resource/AbstractRestIT.java | 10 +++-
.../cassandra/ManagementServiceImpl.java | 55 +++++++++++++-----
5 files changed, 125 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc0c6d39/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 d652293..cbb06ed 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
@@ -733,7 +733,8 @@ public class CpEntityManager implements EntityManager {
@Override
public void updateApplication( Map<String, Object> properties ) throws Exception {
- this.updateProperties(new SimpleEntityRef(Application.ENTITY_TYPE, applicationId), properties);
+ Entity entity = this.get(applicationId, Application.class);
+ this.updateProperties(entity, properties);
this.application = get( applicationId, Application.class );
}
@@ -1013,7 +1014,9 @@ public class CpEntityManager implements EntityManager {
entityRef = cref.getItemRef();
}
- Entity entity = get( entityRef );
+ // removing the nested em.get and requiring the caller to pass in the full entity entity
+ //Entity entity = get( entityRef );
+ Entity entity = ( Entity )entityRef;
properties.put(PROPERTY_MODIFIED, UUIDUtils.getTimestampInMillis(UUIDUtils.newTimeUUID()));
@@ -1060,16 +1063,20 @@ public class CpEntityManager implements EntityManager {
cpEntity.removeField( propertyName );
- logger.debug( "About to Write {}:{} version {}", new Object[] {
+ if(logger.isDebugEnabled()){
+ logger.debug( "About to Write {}:{} version {}", new Object[] {
cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
- } );
+ } );
+ }
//TODO: does this call and others like it need a graphite reporter?
cpEntity = ecm.write( cpEntity ).toBlocking().last();
- logger.debug("Wrote {}:{} version {}", new Object[]{
- cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
- });
+ if(logger.isDebugEnabled()){
+ logger.debug("Wrote {}:{} version {}", new Object[]{
+ cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
+ });
+ }
//Adding graphite metrics
@@ -2134,10 +2141,14 @@ public class CpEntityManager implements EntityManager {
public EntityRef getUserByIdentifier( Identifier identifier ) throws Exception {
if ( identifier == null ) {
- logger.debug( "getUserByIdentifier: returning null for null identifier" );
+ if(logger.isDebugEnabled()){
+ logger.debug( "getUserByIdentifier: returning null for null identifier" );
+ }
return null;
}
- logger.debug( "getUserByIdentifier {}:{}", identifier.getType(), identifier.toString() );
+ if(logger.isDebugEnabled()){
+ logger.debug( "getUserByIdentifier {}:{}", identifier.getType(), identifier.toString() );
+ }
if ( identifier.isUUID() ) {
return new SimpleEntityRef( "user", identifier.getUUID() );
@@ -2172,7 +2183,6 @@ public class CpEntityManager implements EntityManager {
// }
// else {
// look-aside as it might be an email in the name field
- logger.debug( "return alias" );
return this.getAlias( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), "user",
identifier.getEmail() );
// }
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc0c6d39/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
index e98f366..9956ff7 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
@@ -179,7 +179,11 @@ public class ServiceResource extends AbstractContextResource {
@Path("file")
public AbstractContextResource getFileResource( @Context UriInfo ui ) throws Exception {
- logger.debug( "in assets in ServiceResource" );
+
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.getFileResource" );
+ }
+
ServiceParameter.addParameter( getServiceParameters(), "assets" );
PathSegment ps = getFirstPathSegment( "assets" );
@@ -195,7 +199,9 @@ public class ServiceResource extends AbstractContextResource {
public AbstractContextResource addIdParameter( @Context UriInfo ui, @PathParam("entityId") PathSegment entityId )
throws Exception {
- logger.debug( "ServiceResource.addIdParameter" );
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.addIdParameter" );
+ }
UUID itemId = UUID.fromString( entityId.getPath() );
@@ -210,10 +216,11 @@ public class ServiceResource extends AbstractContextResource {
@Path("{itemName}")
public AbstractContextResource addNameParameter( @Context UriInfo ui, @PathParam("itemName") PathSegment itemName )
throws Exception {
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.addNameParameter" );
+ logger.debug( "Current segment is {}", itemName.getPath() );
+ }
- logger.debug( "ServiceResource.addNameParameter" );
-
- logger.debug( "Current segment is {}", itemName.getPath() );
if ( itemName.getPath().startsWith( "{" ) ) {
Query query = Query.fromJsonString( itemName.getPath() );
@@ -233,8 +240,10 @@ public class ServiceResource extends AbstractContextResource {
public ServiceResults executeServiceRequest( UriInfo ui, ApiResponse response, ServiceAction action,
ServicePayload payload ) throws Exception {
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.executeServiceRequest" );
+ }
- logger.debug( "ServiceResource.executeServiceRequest" );
boolean tree = "true".equalsIgnoreCase( ui.getQueryParameters().getFirst( "tree" ) );
@@ -321,7 +330,9 @@ public class ServiceResource extends AbstractContextResource {
@QueryParam("callback") @DefaultValue("callback") String callback )
throws Exception {
- logger.debug( "ServiceResource.executeGet" );
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.executeGet" );
+ }
ApiResponse response = createApiResponse();
@@ -370,7 +381,9 @@ public class ServiceResource extends AbstractContextResource {
public ApiResponse executePostWithObject( @Context UriInfo ui, Object json,
@QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
- logger.debug( "ServiceResource.executePostWithMap" );
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.executePostWithMap" );
+ }
ApiResponse response = createApiResponse();
@@ -417,7 +430,9 @@ public class ServiceResource extends AbstractContextResource {
public ApiResponse executePost( @Context UriInfo ui, String body,
@QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
- logger.debug( "ServiceResource.executePost: body = " + body );
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.executePost: body = " + body );
+ }
Object json;
if ( StringUtils.isEmpty( body ) ) {
@@ -451,7 +466,9 @@ public class ServiceResource extends AbstractContextResource {
@QueryParam("callback") @DefaultValue("callback") String callback )
throws Exception {
- logger.debug( "ServiceResource.executePut" );
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.executePut" );
+ }
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> json = mapper.readValue( body, mapTypeReference );
@@ -470,7 +487,9 @@ public class ServiceResource extends AbstractContextResource {
@QueryParam("app_delete_confirm") String confirmAppDelete )
throws Exception {
- logger.debug( "ServiceResource.executeDelete" );
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.executeDelete" );
+ }
ApiResponse response = createApiResponse();
response.setAction( "delete" );
@@ -587,7 +606,9 @@ public class ServiceResource extends AbstractContextResource {
@QueryParam("callback") @DefaultValue("callback") String callback,
FormDataMultiPart multiPart ) throws Exception {
- logger.debug( "ServiceResource.executeMultiPartPost" );
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.executeMultiPartPost" );
+ }
return executeMultiPart( ui, callback, multiPart, ServiceAction.POST );
}
@@ -601,7 +622,9 @@ public class ServiceResource extends AbstractContextResource {
@QueryParam("callback") @DefaultValue("callback") String callback,
FormDataMultiPart multiPart ) throws Exception {
- logger.debug( "ServiceResource.executeMultiPartPut" );
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.executeMultiPartPut" );
+ }
return executeMultiPart( ui, callback, multiPart, ServiceAction.PUT );
}
@@ -723,7 +746,9 @@ public class ServiceResource extends AbstractContextResource {
@HeaderParam("range") String rangeHeader,
@HeaderParam("if-modified-since") String modifiedSince ) throws Exception {
- logger.debug( "ServiceResource.executeStreamGet" );
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.executeStreamGet" );
+ }
//Needed for testing
if(properties.getProperty( PROPERTIES_USERGRID_BINARY_UPLOADER ).equals( "local" )){
@@ -740,8 +765,10 @@ public class ServiceResource extends AbstractContextResource {
ServiceResults serviceResults = executeServiceRequest( ui, response, ServiceAction.GET, null );
Entity entity = serviceResults.getEntity();
- logger.info( "In ServiceResource.executeStreamGet with id: {}, range: {}, modifiedSince: {}",
- new Object[] { entityId, rangeHeader, modifiedSince } );
+ if(logger.isDebugEnabled()){
+ logger.debug( "In ServiceResource.executeStreamGet with id: {}, range: {}, modifiedSince: {}",
+ new Object[] { entityId, rangeHeader, modifiedSince } );
+ }
Map<String, Object> fileMetadata = AssetUtils.getFileMetadata( entity );
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc0c6d39/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
index 3769449..6b1aba4 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
@@ -71,7 +71,9 @@ public class UsersResource extends ServiceResource {
public AbstractContextResource addIdParameter( @Context UriInfo ui, @PathParam("entityId") PathSegment entityId )
throws Exception {
- logger.info( "ServiceResource.addIdParameter" );
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.addIdParameter" );
+ }
UUID itemId = UUID.fromString( entityId.getPath() );
@@ -87,10 +89,11 @@ public class UsersResource extends ServiceResource {
@Path("{itemName}")
public AbstractContextResource addNameParameter( @Context UriInfo ui, @PathParam("itemName") PathSegment itemName )
throws Exception {
+ if(logger.isDebugEnabled()){
+ logger.debug( "ServiceResource.addNameParameter" );
+ logger.debug( "Current segment is " + itemName.getPath() );
+ }
- logger.info( "ServiceResource.addNameParameter" );
-
- logger.info( "Current segment is " + itemName.getPath() );
if ( itemName.getPath().startsWith( "{" ) ) {
Query query = Query.fromJsonString( itemName.getPath() );
@@ -209,7 +212,9 @@ public class UsersResource extends ServiceResource {
@QueryParam("callback") @DefaultValue("callback") String callback )
throws Exception {
- logger.debug( "UsersResource.executePost: body = " + body);
+ if(logger.isDebugEnabled()){
+ logger.debug( "UsersResource.executePost: body = " + body);
+ }
Object json = readJsonToObject( body );
@@ -221,7 +226,9 @@ public class UsersResource extends ServiceResource {
boolean activated = !( ( confRequred != null ) && confRequred );
- logger.debug("Confirmation required: {} Activated: {}", confRequred, activated );
+ if(logger.isDebugEnabled()){
+ logger.debug("Confirmation required: {} Activated: {}", confRequred, activated );
+ }
if ( json instanceof Map ) {
@SuppressWarnings("unchecked") Map<String, Object> map = ( Map<String, Object> ) json;
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc0c6d39/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
index 4282853..b253543 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
@@ -173,8 +173,14 @@ public class AbstractRestIT extends JerseyTest {
}
public void refreshIndex() {
- //TODO: add error checking and logging
- clientSetup.refreshIndex();
+ //TODO see how we can refresh index (not async) for tests so sleep may not be needed
+ try {
+ clientSetup.refreshIndex();
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ System.out.println("Error refreshing index");
+ e.printStackTrace();
+ }
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc0c6d39/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index 5ffe830..af70966 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -269,7 +269,9 @@ public class ManagementServiceImpl implements ManagementService {
try {
createApplication( organization.getUuid(), test_app_name );
}catch(ApplicationAlreadyExistsException aaee){
- logger.debug("The database setup already found an existing application");
+ if(logger.isDebugEnabled()){
+ logger.debug("The database setup already found an existing application");
+ }
}
}
}
@@ -410,7 +412,9 @@ public class ManagementServiceImpl implements ManagementService {
public OrganizationOwnerInfo createOwnerAndOrganization( String organizationName, String username, String name,
String email, String password ) throws Exception {
- logger.debug("createOwnerAndOrganization1");
+ if(logger.isDebugEnabled()){
+ logger.debug("createOwnerAndOrganization1");
+ }
boolean activated = !newAdminUsersNeedSysAdminApproval() && !newOrganizationsNeedSysAdminApproval();
boolean disabled = newAdminUsersRequireConfirmation();
// if we are active and enabled, skip the send email step
@@ -424,7 +428,9 @@ public class ManagementServiceImpl implements ManagementService {
public OrganizationOwnerInfo createOwnerAndOrganization( String organizationName, String username, String name,
String email, String password, boolean activated,
boolean disabled ) throws Exception {
- logger.debug("createOwnerAndOrganization2");
+ if(logger.isDebugEnabled()){
+ logger.debug("createOwnerAndOrganization2");
+ }
return createOwnerAndOrganization( organizationName, username, name, email, password,
activated, disabled, null, null );
}
@@ -437,7 +443,9 @@ public class ManagementServiceImpl implements ManagementService {
Map<String, Object> organizationProperties )
throws Exception {
- logger.debug("createOwnerAndOrganization3");
+ if(logger.isDebugEnabled()){
+ logger.debug("createOwnerAndOrganization3");
+ }
/**
* Only lock on the target values. We don't want lock contention if another
@@ -472,7 +480,9 @@ public class ManagementServiceImpl implements ManagementService {
user = createAdminUserInternal( username, name, email, password, activated, disabled, userProperties );
}
- logger.debug("User created");
+ if(logger.isDebugEnabled()){
+ logger.debug("User created");
+ }
organization = createOrganizationInternal( null, organizationName, user, true, organizationProperties );
}
finally {
@@ -487,7 +497,9 @@ public class ManagementServiceImpl implements ManagementService {
private OrganizationInfo createOrganizationInternal(
UUID orgUuid, String organizationName, UserInfo user, boolean activated ) throws Exception {
- logger.debug("createOrganizationInternal1");
+ if(logger.isDebugEnabled()){
+ logger.debug("createOrganizationInternal1");
+ }
return createOrganizationInternal( orgUuid, organizationName, user, activated, null );
}
@@ -495,14 +507,20 @@ public class ManagementServiceImpl implements ManagementService {
private OrganizationInfo createOrganizationInternal( UUID orgUuid, String organizationName, UserInfo user, boolean activated,
Map<String, Object> properties ) throws Exception {
- logger.info( "createOrganizationInternal2: {}", organizationName );
+ if(logger.isDebugEnabled()){
+ logger.debug( "createOrganizationInternal2: {}", organizationName );
+ }
if ( organizationName == null ) {
- logger.debug("organizationName = null");
+ if(logger.isDebugEnabled()){
+ logger.debug("organizationName = null");
+ }
return null;
}
if ( user == null ) {
- logger.debug("user = null");
+ if(logger.isDebugEnabled()){
+ logger.debug("user = null");
+ }
return null;
}
@@ -995,7 +1013,8 @@ public class ManagementServiceImpl implements ManagementService {
json.remove( "newpassword" );
Map<String, Object> userProperties = user.getProperties();
userProperties.putAll( json );
- em.updateProperties( entityRef, userProperties );
+ Entity entity = em.get( entityRef, User.class);
+ em.updateProperties( entity, userProperties );
}
user = getAdminUserByUuid( user.getUuid() );
@@ -1208,7 +1227,9 @@ public class ManagementServiceImpl implements ManagementService {
public int calculatePasswordHistorySizeForUser( UUID userId ) throws Exception {
- logger.debug( "calculatePasswordHistorySizeForUser " + userId.toString() );
+ if(logger.isDebugEnabled()){
+ logger.debug( "calculatePasswordHistorySizeForUser " + userId.toString() );
+ }
int size = 0;
EntityManager em = emf.getEntityManager( smf.getManagementAppId() );
@@ -1216,13 +1237,17 @@ public class ManagementServiceImpl implements ManagementService {
Results orgResults = em.getCollection( new SimpleEntityRef( User.ENTITY_TYPE, userId ),
Schema.COLLECTION_GROUPS, null, 10000, Level.REFS, false );
- logger.debug(" orgResults.size() = " + orgResults.size());
+ if(logger.isDebugEnabled()){
+ logger.debug(" orgResults.size() = " + orgResults.size());
+ }
for ( EntityRef orgRef : orgResults.getRefs() ) {
Map properties = em.getDictionaryAsMap( orgRef, ORGANIZATION_PROPERTIES_DICTIONARY );
if ( properties != null ) {
OrganizationInfo orgInfo = new OrganizationInfo( null, null, properties );
- logger.debug( " orgInfo.getPasswordHistorySize() = " + orgInfo.getPasswordHistorySize() );
+ if(logger.isDebugEnabled()){
+ logger.debug( " orgInfo.getPasswordHistorySize() = " + orgInfo.getPasswordHistorySize() );
+ }
size = Math.max( orgInfo.getPasswordHistorySize(), size );
}
}
@@ -1246,7 +1271,9 @@ public class ManagementServiceImpl implements ManagementService {
public UserInfo verifyAdminUserPasswordCredentials( String name, String password ) throws Exception {
UserInfo userInfo = null;
- logger.debug("verifyAdminUserPasswordCredentials for {}/{}", name, password);
+ if(logger.isDebugEnabled()){
+ logger.debug("verifyAdminUserPasswordCredentials for {}/{}", name, password);
+ }
User user = findUserEntity( smf.getManagementAppId(), name );
if ( user == null ) {
[8/9] usergrid git commit: Add some buffering to the permissions
cache tests in case a slow c* cluster is being used.
Posted by sn...@apache.org.
Add some buffering to the permissions cache tests in case a slow c* cluster is being used.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/2867d26d
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/2867d26d
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/2867d26d
Branch: refs/heads/USERGRID-872
Commit: 2867d26d681b4ba8d868066117302cc0a4494cbb
Parents: fadad9e
Author: Michael Russo <mi...@gmail.com>
Authored: Tue Dec 29 22:09:29 2015 -0800
Committer: Michael Russo <mi...@gmail.com>
Committed: Tue Dec 29 22:09:29 2015 -0800
----------------------------------------------------------------------
.../usergrid/persistence/cache/ScopedCacheTest.java | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/2867d26d/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java b/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
index 73cffe1..3ec6f6a 100644
--- a/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
+++ b/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
@@ -132,18 +132,22 @@ public class ScopedCacheTest {
ScopedCache<String, Map<String, Object>> cache = cf.getScopedCache(scope);
assertNotNull("should get a cache", cache);
- // cache item for 1 second
+ // cache item for 3 seconds
+ final int timeout = 3000;
Map<String, Object> item = new HashMap<String, Object>() {{
put("field1", "value1");
}};
- cache.put("item", item, 1);
+ cache.put("item", item, timeout/1000);
+
+ // in the event that the tests have slowed c*, sleep some to ensure the write has committed
+ try { Thread.sleep(500); } catch (InterruptedException ignored) {}
Map<String, Object> retrievedItem = cache.get("item", typeRef);
assertNotNull("should get back item", retrievedItem);
assertEquals("value1", retrievedItem.get("field1"));
- try { Thread.sleep(1000); } catch (InterruptedException ignored) {}
+ try { Thread.sleep(timeout); } catch (InterruptedException ignored) {}
assertNull( cache.get("item", typeRef));
}
@@ -155,12 +159,13 @@ public class ScopedCacheTest {
ScopedCache<String, Map<String, Object>> cache = cf.getScopedCache(scope);
assertNotNull("should get a cache", cache);
- // cache item for 1 second
+ // cache item for 3 seconds
+ final int timeout = 3000;
Map<String, Object> item = new HashMap<String, Object>() {{
put("field1", "value1");
}};
- cache.put("item", item, 1);
+ cache.put("item", item, timeout/1000);
Map<String, Object> retrievedItem = cache.get("item", typeRef);
assertNotNull( "should get back item", retrievedItem );