Merge pull request #68 from usergrid/applimitfix
Removed 10 app limit
diff --git a/stack/pom.xml b/stack/pom.xml
index bdf2137..1e4214c 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -1772,7 +1772,7 @@
<!-- git and IDE project files -->
<exclude>**/.git/**</exclude>
<exclude>**/.gitignore</exclude>
- <exclude>**..idea/**</exclude>
+ <exclude>**/.idea/**</exclude>
<exclude>**/*.iml</exclude>
<exclude>**/nbactions.xml</exclude>
<exclude>**/nb-configuration.xml</exclude>
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsIT.java
new file mode 100644
index 0000000..424c01c
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsIT.java
@@ -0,0 +1,84 @@
+/*
+ * 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.rest.management.organizations.applications;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.codehaus.jackson.JsonNode;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.TestContextSetup;
+
+import static org.junit.Assert.assertEquals;
+
+
+/**
+ *
+ *
+ */
+public class ApplicationsIT extends AbstractRestIT {
+
+ @Rule
+ public TestContextSetup context = new TestContextSetup( this );
+
+
+ @Test
+ public void test10AppLimit() {
+
+ int size = 11;
+
+ Set<String> appNames = new HashSet<String>( size );
+
+ for ( int i = 0; i < size; i++ ) {
+ final String name = i + "";
+
+ appNames.add( name );
+
+ context.withApp( name ).createAppForOrg();
+ }
+
+ //now go through and ensure each entry is present
+
+ final JsonNode apps = context.management().orgs().organization( context.getOrgName() ).apps().get();
+
+ final JsonNode data = apps.get( "data" );
+
+ final String orgName = context.getOrgName();
+
+
+ final Set<String> copy = new HashSet<String> (appNames);
+
+ for(String appName: copy){
+
+ final String mapEntryName = String.format( "%s/%s", orgName.toLowerCase(), appName.toLowerCase());
+
+ JsonNode orgApp = data.get( mapEntryName);
+
+ if(orgApp != null){
+ appNames.remove( appName );
+ }
+
+ }
+
+ assertEquals("All elements removed", 0, appNames.size());
+
+ }
+}
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 af30325..07175ec 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
@@ -55,6 +55,7 @@
import org.apache.usergrid.persistence.EntityManagerFactory;
import org.apache.usergrid.persistence.EntityRef;
import org.apache.usergrid.persistence.Identifier;
+import org.apache.usergrid.persistence.PagingResultsIterator;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.Results.Level;
import org.apache.usergrid.persistence.SimpleEntityRef;
@@ -1640,24 +1641,28 @@
if ( organizationId == null ) {
return null;
}
- BiMap<UUID, String> applications = HashBiMap.create();
- EntityManager em = emf.getEntityManager( MANAGEMENT_APPLICATION_ID );
- Results results = em.getConnectedEntities( organizationId, "owns", APPLICATION_INFO, Level.ALL_PROPERTIES );
- if ( !results.isEmpty() ) {
+ final BiMap<UUID, String> applications = HashBiMap.create();
+ final EntityManager em = emf.getEntityManager( MANAGEMENT_APPLICATION_ID );
+ final Results results = em.getConnectedEntities( organizationId, "owns", APPLICATION_INFO, Level.ALL_PROPERTIES );
+ final PagingResultsIterator itr = new PagingResultsIterator( results );
- String entityName = null;
- for ( Entity entity : results.getEntities() ) {
- entityName = entity.getName();
+ String entityName;
- if ( entityName != null ) {
- entityName = entityName.toLowerCase();
- }
+ while ( itr.hasNext() ) {
- applications.put( entity.getUuid(), entityName );
+ final Entity entity = ( Entity ) itr.next();
+
+ entityName = entity.getName();
+
+ if ( entityName != null ) {
+ entityName = entityName.toLowerCase();
}
+
+ applications.put( entity.getUuid(), entityName );
}
+
return applications;
}