You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/09/11 03:27:39 UTC
[08/50] usergrid git commit: add new methods to size
add new methods to size
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/eac865ad
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/eac865ad
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/eac865ad
Branch: refs/heads/USERGRID-909
Commit: eac865adab0aa623224226b0dcc4cc65a92bdc04
Parents: c4b5071
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 1 15:06:14 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 1 15:06:14 2015 -0600
----------------------------------------------------------------------
.../service/AggregationService.java | 10 +--
.../service/AggregationServiceImpl.java | 13 ++-
.../apache/usergrid/count/SimpleBatcher.java | 2 +-
.../corepersistence/AggregationServiceTest.java | 14 +--
.../applications/ApplicationResource.java | 36 ++++++--
.../rest/management/ManagementResourceIT.java | 16 ++--
.../usergrid/management/ManagementService.java | 2 +
.../cassandra/ManagementServiceImpl.java | 91 +++++++++++---------
8 files changed, 107 insertions(+), 77 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/eac865ad/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationService.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationService.java
index 089ca2b..78502fa 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationService.java
@@ -36,14 +36,14 @@ public interface AggregationService {
* @param applicationScope
* @return
*/
- long sumAllCollections(ApplicationScope applicationScope);
+ long getApplicationSize(ApplicationScope applicationScope);
/**
* get entity size for app
*
* @param applicationScope
* @return
*/
- Map<String,Long> sumEachCollection(ApplicationScope applicationScope);
+ Map<String,Long> getEachCollectionSize(ApplicationScope applicationScope);
/**
* get total entity size for an edge
@@ -52,13 +52,13 @@ public interface AggregationService {
* @param edge
* @return
*/
- long sum(final ApplicationScope applicationScope, final SearchEdge edge);
+ long getSize(final ApplicationScope applicationScope, final SearchEdge edge);
/**
- * get sum by collection name
+ * get getSize by collection name
* @param applicationScope
* @param collectionName
* @return
*/
- long getCollectionSum(final ApplicationScope applicationScope, final String collectionName);
+ long getCollectionSize(final ApplicationScope applicationScope, final String collectionName);
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/eac865ad/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationServiceImpl.java
index 29b48d8..44010db 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationServiceImpl.java
@@ -22,7 +22,6 @@ package org.apache.usergrid.corepersistence.service;
import com.codahale.metrics.Timer;
import com.google.common.base.Optional;
import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
@@ -35,8 +34,6 @@ import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexFactory;
import org.apache.usergrid.persistence.index.IndexLocationStrategy;
import org.apache.usergrid.persistence.index.SearchEdge;
-import org.apache.usergrid.persistence.index.impl.SearchEdgeImpl;
-import org.apache.usergrid.utils.IndexUtils;
import rx.observables.MathObservable;
import java.util.*;
@@ -68,7 +65,7 @@ public class AggregationServiceImpl implements AggregationService {
@Override
- public long sumAllCollections(ApplicationScope applicationScope) {
+ public long getApplicationSize(ApplicationScope applicationScope) {
final IndexLocationStrategy indexLocationStrategy = indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope);
EntityIndex entityIndex = entityIndexFactory.createEntityIndex(indexLocationStrategy);
GraphManager graphManager = graphManagerFactory.createEdgeManager(applicationScope);
@@ -83,7 +80,7 @@ public class AggregationServiceImpl implements AggregationService {
}
@Override
- public Map<String, Long> sumEachCollection(ApplicationScope applicationScope) {
+ public Map<String, Long> getEachCollectionSize(ApplicationScope applicationScope) {
final IndexLocationStrategy indexLocationStrategy = indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope);
EntityIndex entityIndex = entityIndexFactory.createEntityIndex(indexLocationStrategy);
GraphManager graphManager = graphManagerFactory.createEdgeManager(applicationScope);
@@ -103,15 +100,15 @@ public class AggregationServiceImpl implements AggregationService {
}
@Override
- public long sum(ApplicationScope applicationScope, SearchEdge edge) {
+ public long getSize(ApplicationScope applicationScope, SearchEdge edge) {
final IndexLocationStrategy indexLocationStrategy = indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope);
EntityIndex entityIndex = entityIndexFactory.createEntityIndex(indexLocationStrategy);
return entityIndex.getEntitySize(edge);
}
@Override
- public long getCollectionSum(final ApplicationScope applicationScope, final String collectionName) {
- return sum(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), collectionName));
+ public long getCollectionSize(final ApplicationScope applicationScope, final String collectionName) {
+ return getSize(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), collectionName));
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/eac865ad/stack/core/src/main/java/org/apache/usergrid/count/SimpleBatcher.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/count/SimpleBatcher.java b/stack/core/src/main/java/org/apache/usergrid/count/SimpleBatcher.java
index d5a6bf2..b72f544 100644
--- a/stack/core/src/main/java/org/apache/usergrid/count/SimpleBatcher.java
+++ b/stack/core/src/main/java/org/apache/usergrid/count/SimpleBatcher.java
@@ -24,7 +24,7 @@ import org.apache.usergrid.count.common.Count;
/**
- * A simple Batcher implementation that keeps a sum of the number of {@link Count} operations which have been applied.
+ * A simple Batcher implementation that keeps a getSize of the number of {@link Count} operations which have been applied.
* Counters are aggregated by name.
*
* @author zznate
http://git-wip-us.apache.org/repos/asf/usergrid/blob/eac865ad/stack/core/src/test/java/org/apache/usergrid/corepersistence/AggregationServiceTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/AggregationServiceTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/AggregationServiceTest.java
index d7d1ffa..9f1c9a4 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/AggregationServiceTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/AggregationServiceTest.java
@@ -51,15 +51,15 @@ public class AggregationServiceTest extends AbstractCoreIT {
this.app.refreshIndex();
Thread.sleep(500);
- long sum = aggregationService.sumAllCollections(applicationScope);
+ long sum = aggregationService.getApplicationSize(applicationScope);
Assert.assertTrue( sum >= 0 );
Assert.assertTrue(sum > (entity1.getSize() + entity2.getSize()));
- long sum1 = aggregationService.sum(applicationScope,CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(),"tests"));
+ long sum1 = aggregationService.getSize(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), "tests"));
Assert.assertEquals(sum1, entity1.getSize());
- long sum2 = aggregationService.sum(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), "test2s"));
+ long sum2 = aggregationService.getSize(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), "test2s"));
Assert.assertEquals(sum2, entity2.getSize());
props = new HashMap<>();
@@ -68,12 +68,12 @@ public class AggregationServiceTest extends AbstractCoreIT {
Entity entity3 = this.app.getEntityManager().create("test", props);
this.app.refreshIndex();
- long sum3 = aggregationService.sum(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), "tests"));
- Assert.assertEquals(sum3, entity1.getSize()+entity3.getSize());
+ long sum3 = aggregationService.getSize(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), "tests"));
+ Assert.assertEquals(sum3, entity1.getSize() + entity3.getSize());
- Map<String,Long> sumEach = aggregationService.sumEachCollection(applicationScope);
+ Map<String,Long> sumEach = aggregationService.getEachCollectionSize(applicationScope);
Assert.assertTrue(sumEach.containsKey("tests") && sumEach.containsKey("test2s"));
- Assert.assertEquals(sum3, (long)sumEach.get("tests"));
+ Assert.assertEquals(sum3, (long) sumEach.get("tests"));
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/eac865ad/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index df98b43..be8af2d 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@ -162,7 +162,7 @@ public class ApplicationResource extends AbstractContextResource {
@RequireOrganizationAccess
@GET
- @Path("size")
+ @Path("_size")
public JSONWithPadding getApplicationSize(
@Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback )
throws Exception {
@@ -173,16 +173,16 @@ public class ApplicationResource extends AbstractContextResource {
Map<String,Object> map = new HashMap<>();
Map<String,Object> innerMap = new HashMap<>();
Map<String,Object> sumMap = new HashMap<>();
- sumMap.put("sum",size);
- innerMap.put("application",sumMap);
- map.put("aggregation",innerMap);
+ innerMap.put("application",size);
+ sumMap.put("size",innerMap);
+ map.put("aggregation", sumMap);
response.setMetadata(map);
return new JSONWithPadding( response, callback );
}
@RequireOrganizationAccess
@GET
- @Path("size/{collection_name}")
+ @Path("{collection_name}/_size")
public JSONWithPadding getCollectionSize(
@Context UriInfo ui,
@PathParam( "collection_name" ) String collection_name,
@@ -190,13 +190,31 @@ public class ApplicationResource extends AbstractContextResource {
throws Exception {
ApiResponse response = createApiResponse();
response.setAction("get collection size for all entities");
- long size = management.getCollectionSize(this.applicationId ,collection_name);
+ long size = management.getCollectionSize(this.applicationId, collection_name);
Map<String,Object> map = new HashMap<>();
+ Map<String,Object> sumMap = new HashMap<>();
Map<String,Object> innerMap = new HashMap<>();
+ innerMap.put(collection_name,size);
+ sumMap.put("size",innerMap);
+ map.put("aggregation",sumMap);
+ response.setMetadata(map);
+ return new JSONWithPadding( response, callback );
+ }
+
+ @RequireOrganizationAccess
+ @GET
+ @Path("collections/_size")
+ public JSONWithPadding getEachCollectionSize(
+ @Context UriInfo ui,
+ @QueryParam("callback") @DefaultValue("callback") String callback )
+ throws Exception {
+ ApiResponse response = createApiResponse();
+ response.setAction("get collection size for all entities");
+ Map<String,Long> sizes = management.getEachCollectionSize(this.applicationId);
+ Map<String,Object> map = new HashMap<>();
Map<String,Object> sumMap = new HashMap<>();
- sumMap.put("sum",size);
- innerMap.put(collection_name,sumMap);
- map.put("aggregation",innerMap);
+ sumMap.put("size",sizes);
+ map.put("aggregation",sumMap);
response.setMetadata(map);
return new JSONWithPadding( response, callback );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/eac865ad/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index 99d2089..7f86ad1 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -314,18 +314,22 @@ public class ManagementResourceIT extends AbstractRestIT {
final String appname = clientSetup.getAppName();
this.app().collection("testCollection").post(new Entity().chainPut("name","test"));
refreshIndex();
- Entity size = management().orgs().org( clientSetup.getOrganizationName() ).app().addToPath(appname).addToPath("size").get();
- Entity rolesSize = management().orgs().org(clientSetup.getOrganizationName()).app().addToPath(appname).addToPath("size/roles").get();
+ Entity size = management().orgs().org( clientSetup.getOrganizationName() ).app().addToPath(appname).addToPath("_size").get();
+ Entity rolesSize = management().orgs().org(clientSetup.getOrganizationName()).app().addToPath(appname).addToPath("roles/_size").get();
+ Entity collectionsSize = management().orgs().org(clientSetup.getOrganizationName()).app().addToPath(appname).addToPath("collections/_size").get();
+
assertTrue(size != null);
assertTrue(rolesSize != null);
- int sum = (int)((LinkedHashMap)((LinkedHashMap)size.metadata().get("aggregation")).get("application")).get("sum");
- int sumRoles = (int)((LinkedHashMap)((LinkedHashMap)rolesSize.metadata().get("aggregation")).get("roles")).get("sum");
+ int sum = (int)((LinkedHashMap)((LinkedHashMap)size.metadata().get("aggregation")).get("size")).get("application");
+ int sumRoles = (int)((LinkedHashMap)((LinkedHashMap)rolesSize.metadata().get("aggregation")).get("size")).get("roles");
+ int sumRoles2 = (int)((LinkedHashMap)((LinkedHashMap)collectionsSize.metadata().get("aggregation")).get("size")).get("roles");
assertTrue(size != null);
assertTrue(rolesSize != null);
- assertNotEquals(sum,sumRoles);
- assertTrue(sum>sumRoles);
+ assertNotEquals(sum, sumRoles);
+ assertTrue(sum > sumRoles);
+ assertTrue(sumRoles == sumRoles2);
}
@Test
http://git-wip-us.apache.org/repos/asf/usergrid/blob/eac865ad/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java b/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
index c822057..43c1b30 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
@@ -336,4 +336,6 @@ public interface ManagementService {
long getApplicationSize(final UUID applicationId);
long getCollectionSize(final UUID applicationId, final String collectionName);
+
+ Map<String,Long> getEachCollectionSize(final UUID applicationId);
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/eac865ad/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 e36e31c..73f18b1 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
@@ -287,7 +287,7 @@ public class ManagementServiceImpl implements ManagementService {
boolean superuser_enabled = getBooleanProperty( PROPERTIES_SYSADMIN_LOGIN_ALLOWED );
String superuser_username = properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_NAME );
String superuser_email = properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_EMAIL );
- String superuser_password = properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_PASSWORD );
+ String superuser_password = properties.getProperty(PROPERTIES_SYSADMIN_LOGIN_PASSWORD);
if ( !anyNull( superuser_username, superuser_email, superuser_password ) ) {
UserInfo user = this.getAdminUserByUsername( superuser_username );
@@ -301,7 +301,7 @@ public class ManagementServiceImpl implements ManagementService {
}
else {
System.out.println(
- "Missing values for superuser account, check properties. Skipping superuser account setup..." );
+ "Missing values for superuser account, check properties. Skipping superuser account setup...");
}
}
@@ -389,7 +389,7 @@ public class ManagementServiceImpl implements ManagementService {
@Override
public ServiceResults getAdminUserActivity( UserInfo user ) throws Exception {
- ServiceManager sm = smf.getServiceManager( smf.getManagementAppId() );
+ ServiceManager sm = smf.getServiceManager(smf.getManagementAppId());
return sm.newRequest( ServiceAction.GET, parameters( "users", user.getUuid(), "feed" ) ).execute();
}
@@ -680,7 +680,7 @@ public class ManagementServiceImpl implements ManagementService {
@Override
public BiMap<UUID, String> getOrganizations() throws Exception {
- List<OrganizationInfo> orgs = getOrganizations( null, 10000 );
+ List<OrganizationInfo> orgs = getOrganizations(null, 10000);
return buildOrgBiMap( orgs );
}
@@ -696,7 +696,7 @@ public class ManagementServiceImpl implements ManagementService {
@Override
public OrganizationInfo getOrganizationInfoFromAccessToken( String token ) throws Exception {
- Entity entity = getEntityFromAccessToken( token, null, ORGANIZATION );
+ Entity entity = getEntityFromAccessToken(token, null, ORGANIZATION);
if ( entity == null ) {
return null;
}
@@ -711,7 +711,7 @@ public class ManagementServiceImpl implements ManagementService {
return null;
}
- EntityManager em = emf.getEntityManager( smf.getManagementAppId() );
+ EntityManager em = emf.getEntityManager(smf.getManagementAppId());
EntityRef ref = em.getAlias( Group.ENTITY_TYPE, organizationName );
if ( ref == null ) {
return null;
@@ -820,17 +820,17 @@ public class ManagementServiceImpl implements ManagementService {
@Override
public UserInfo createAdminFrom( User user, String password ) throws Exception {
- return doCreateAdmin( user,
- encryptionService.defaultEncryptedCredentials( password, user.getUuid(), smf.getManagementAppId() ),
- encryptionService.plainTextCredentials( mongoPassword( user.getUsername(), password ), user.getUuid(),
- smf.getManagementAppId() ) );
+ return doCreateAdmin(user,
+ encryptionService.defaultEncryptedCredentials(password, user.getUuid(), smf.getManagementAppId()),
+ encryptionService.plainTextCredentials(mongoPassword(user.getUsername(), password), user.getUuid(),
+ smf.getManagementAppId()));
}
@Override
public UserInfo createAdminUser( String username, String name, String email, String password, boolean activated,
boolean disabled ) throws Exception {
- return createAdminUser( username, name, email, password, activated, disabled, null );
+ return createAdminUser(username, name, email, password, activated, disabled, null);
}
@@ -838,7 +838,7 @@ public class ManagementServiceImpl implements ManagementService {
public UserInfo createAdminUser( String username, String name, String email, String password, boolean activated,
boolean disabled, Map<String, Object> userProperties ) throws Exception {
- if ( !validateAdminInfo( username, name, email, password ) ) {
+ if ( !validateAdminInfo(username, name, email, password) ) {
return null;
}
return createAdminUserInternal( username, name, email, password, activated, disabled, userProperties );
@@ -935,10 +935,10 @@ public class ManagementServiceImpl implements ManagementService {
List<UserInfo> users = new ArrayList<UserInfo>();
- EntityManager em = emf.getEntityManager( smf.getManagementAppId() );
+ EntityManager em = emf.getEntityManager(smf.getManagementAppId());
Results results =
- em.getCollection( new SimpleEntityRef( Group.ENTITY_TYPE, organizationId ), "users", null, 10000,
- Level.ALL_PROPERTIES, false );
+ em.getCollection(new SimpleEntityRef(Group.ENTITY_TYPE, organizationId), "users", null, 10000,
+ Level.ALL_PROPERTIES, false);
for ( Entity entity : results.getEntities() ) {
users.add( getUserInfo( smf.getManagementAppId(), entity ) );
}
@@ -1003,7 +1003,7 @@ public class ManagementServiceImpl implements ManagementService {
return null;
}
- return getUserEntityByIdentifier( smf.getManagementAppId(), Identifier.fromEmail( email ) );
+ return getUserEntityByIdentifier(smf.getManagementAppId(), Identifier.fromEmail(email));
}
@@ -1012,14 +1012,14 @@ public class ManagementServiceImpl implements ManagementService {
if ( email == null ) {
return null;
}
- return getUserInfo( smf.getManagementAppId(),
- getUserEntityByIdentifier( smf.getManagementAppId(), Identifier.fromEmail( email ) ) );
+ return getUserInfo(smf.getManagementAppId(),
+ getUserEntityByIdentifier(smf.getManagementAppId(), Identifier.fromEmail(email)));
}
public User getUserEntityByIdentifier( UUID applicationId, Identifier identifier ) throws Exception {
EntityManager em = emf.getEntityManager( applicationId );
- return em.get( em.getUserByIdentifier( identifier ), User.class );
+ return em.get(em.getUserByIdentifier(identifier), User.class);
}
@@ -1028,8 +1028,8 @@ public class ManagementServiceImpl implements ManagementService {
if ( username == null ) {
return null;
}
- return getUserInfo( smf.getManagementAppId(),
- getUserEntityByIdentifier( smf.getManagementAppId(), Identifier.fromName( username ) ) );
+ return getUserInfo(smf.getManagementAppId(),
+ getUserEntityByIdentifier(smf.getManagementAppId(), Identifier.fromName(username)));
}
@@ -1038,14 +1038,14 @@ public class ManagementServiceImpl implements ManagementService {
if ( id == null ) {
return null;
}
- return getUserEntityByIdentifier( smf.getManagementAppId(), Identifier.fromUUID( id ) );
+ return getUserEntityByIdentifier(smf.getManagementAppId(), Identifier.fromUUID(id));
}
@Override
public UserInfo getAdminUserByUuid( UUID id ) throws Exception {
- return getUserInfo( smf.getManagementAppId(),
- getUserEntityByIdentifier( smf.getManagementAppId(), Identifier.fromUUID( id ) ) );
+ return getUserInfo(smf.getManagementAppId(),
+ getUserEntityByIdentifier(smf.getManagementAppId(), Identifier.fromUUID(id)));
}
@@ -1127,7 +1127,7 @@ public class ManagementServiceImpl implements ManagementService {
throw new IncorrectPasswordException( "Old password does not match" );
}
- setAdminUserPassword( userId, newPassword );
+ setAdminUserPassword(userId, newPassword);
}
@@ -1204,7 +1204,7 @@ 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() );
+ logger.debug(" orgResults.size() = " + orgResults.size());
for ( EntityRef orgRef : orgResults.getRefs() ) {
Map properties = em.getDictionaryAsMap( orgRef, ORGANIZATION_PROPERTIES_DICTIONARY );
@@ -1308,7 +1308,7 @@ public class ManagementServiceImpl implements ManagementService {
public String getTokenForPrincipal( TokenCategory token_category, String token_type, UUID applicationId,
AuthPrincipalType principal_type, UUID id, long duration ) throws Exception {
- if ( anyNull( token_category, applicationId, principal_type, id ) ) {
+ if ( anyNull(token_category, applicationId, principal_type, id) ) {
return null;
}
@@ -1361,7 +1361,7 @@ public class ManagementServiceImpl implements ManagementService {
AuthPrincipalType expected_principal_type ) throws Exception {
AuthPrincipalInfo principal =
- getPrincipalFromAccessToken( token, expected_token_type, expected_principal_type );
+ getPrincipalFromAccessToken(token, expected_token_type, expected_principal_type);
if ( principal == null ) {
return null;
}
@@ -1376,8 +1376,8 @@ public class ManagementServiceImpl implements ManagementService {
principal.getApplicationId() != null
? principal.getApplicationId() : smf.getManagementAppId() );
- Entity entity = em.get( new SimpleEntityRef(
- principal.getType().getEntityType(), principal.getUuid()));
+ Entity entity = em.get(new SimpleEntityRef(
+ principal.getType().getEntityType(), principal.getUuid()));
return entity;
}
@@ -1406,7 +1406,7 @@ public class ManagementServiceImpl implements ManagementService {
*/
@Override
public void revokeAccessTokensForAdminUser( UUID userId ) throws Exception {
- revokeTokensForPrincipal( ADMIN_USER, smf.getManagementAppId(), userId );
+ revokeTokensForPrincipal(ADMIN_USER, smf.getManagementAppId(), userId);
}
@@ -1421,21 +1421,21 @@ public class ManagementServiceImpl implements ManagementService {
throw new TokenException( "Could not match token : " + token );
}
- tokens.revokeToken( token );
+ tokens.revokeToken(token);
}
@Override
public Entity getAdminUserEntityFromAccessToken( String token ) throws Exception {
- Entity user = getEntityFromAccessToken( token, null, ADMIN_USER );
+ Entity user = getEntityFromAccessToken(token, null, ADMIN_USER);
return user;
}
@Override
public UserInfo getAdminUserInfoFromAccessToken( String token ) throws Exception {
- Entity user = getAdminUserEntityFromAccessToken( token );
+ Entity user = getAdminUserEntityFromAccessToken(token);
return new UserInfo( smf.getManagementAppId(), user.getProperties() );
}
@@ -1487,7 +1487,7 @@ public class ManagementServiceImpl implements ManagementService {
@Override
public Long getLastAdminPasswordChange( UUID userId ) throws Exception {
- CredentialsInfo ci = readUserPasswordCredentials( smf.getManagementAppId(), userId, User.ENTITY_TYPE );
+ CredentialsInfo ci = readUserPasswordCredentials(smf.getManagementAppId(), userId, User.ENTITY_TYPE);
return ci.getCreated();
}
@@ -1568,8 +1568,8 @@ public class ManagementServiceImpl implements ManagementService {
}
EntityManager em = emf.getEntityManager( smf.getManagementAppId() );
- em.addToCollection( new SimpleEntityRef( Group.ENTITY_TYPE, organization.getUuid() ), "users",
- new SimpleEntityRef( User.ENTITY_TYPE, user.getUuid() ) );
+ em.addToCollection(new SimpleEntityRef(Group.ENTITY_TYPE, organization.getUuid()), "users",
+ new SimpleEntityRef(User.ENTITY_TYPE, user.getUuid()));
if ( email ) {
sendAdminUserInvitedEmail( user, organization );
@@ -1596,8 +1596,8 @@ public class ManagementServiceImpl implements ManagementService {
throw new UnableToLeaveOrganizationException( "Organizations must have at least one member." );
}
- em.removeFromCollection( new SimpleEntityRef( Group.ENTITY_TYPE, organizationId ), "users",
- new SimpleEntityRef( User.ENTITY_TYPE, userId ) );
+ em.removeFromCollection(new SimpleEntityRef(Group.ENTITY_TYPE, organizationId), "users",
+ new SimpleEntityRef(User.ENTITY_TYPE, userId));
}
@@ -1721,7 +1721,15 @@ public class ManagementServiceImpl implements ManagementService {
AggregationServiceFactory aggregationServiceFactory = injector.getInstance(AggregationServiceFactory.class);
AggregationService aggregationService = aggregationServiceFactory.getAggregationService();
ApplicationScope applicationScope =CpNamingUtils.getApplicationScope(applicationId);
- return aggregationService.sumAllCollections(applicationScope);
+ return aggregationService.getApplicationSize(applicationScope);
+ }
+
+ @Override
+ public Map<String,Long> getEachCollectionSize(final UUID applicationId) {
+ AggregationServiceFactory aggregationServiceFactory = injector.getInstance(AggregationServiceFactory.class);
+ AggregationService aggregationService = aggregationServiceFactory.getAggregationService();
+ ApplicationScope applicationScope =CpNamingUtils.getApplicationScope(applicationId);
+ return aggregationService.getEachCollectionSize(applicationScope);
}
@Override
@@ -1729,10 +1737,11 @@ public class ManagementServiceImpl implements ManagementService {
AggregationServiceFactory aggregationServiceFactory = injector.getInstance(AggregationServiceFactory.class);
AggregationService aggregationService = aggregationServiceFactory.getAggregationService();
ApplicationScope applicationScope =CpNamingUtils.getApplicationScope(applicationId);
- return aggregationService.sum(applicationScope,CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(),collectionName));
+ return aggregationService.getSize(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), collectionName));
}
+
@Override
public OrganizationInfo getOrganizationForApplication( UUID applicationInfoId ) throws Exception {