Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2014-01-28 15:53:37 +0000
committerjmisinco2014-01-28 17:11:13 +0000
commitab827b424c9f0f12ff8b5fdf7a8b9a8cfa75dbc8 (patch)
treee3169ecdd0c34dc3d625b8e01314ad8f83062844 /plugins
parent956ac672727824018a2a7658dae15bf918e9b332 (diff)
downloadorg.eclipse.osee-ab827b424c9f0f12ff8b5fdf7a8b9a8cfa75dbc8.tar.gz
org.eclipse.osee-ab827b424c9f0f12ff8b5fdf7a8b9a8cfa75dbc8.tar.xz
org.eclipse.osee-ab827b424c9f0f12ff8b5fdf7a8b9a8cfa75dbc8.zip
bug: Add code to limit artifact join sizes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.database.test/src/org/eclipse/osee/framework/database/core/ArtifactJoinQueryTest.java16
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java9
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java15
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeInfo.java16
4 files changed, 48 insertions, 8 deletions
diff --git a/plugins/org.eclipse.osee.framework.database.test/src/org/eclipse/osee/framework/database/core/ArtifactJoinQueryTest.java b/plugins/org.eclipse.osee.framework.database.test/src/org/eclipse/osee/framework/database/core/ArtifactJoinQueryTest.java
index 3735e984bd..2eb712c63a 100644
--- a/plugins/org.eclipse.osee.framework.database.test/src/org/eclipse/osee/framework/database/core/ArtifactJoinQueryTest.java
+++ b/plugins/org.eclipse.osee.framework.database.test/src/org/eclipse/osee/framework/database/core/ArtifactJoinQueryTest.java
@@ -28,7 +28,7 @@ public class ArtifactJoinQueryTest {
@Test
public void testAdd() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, 999);
+ ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, 999, 10);
Assert.assertEquals(0, join.size());
Assert.assertEquals(true, join.isEmpty());
@@ -61,7 +61,7 @@ public class ArtifactJoinQueryTest {
@Test(expected = OseeDataStoreException.class)
public void testStoreTwice() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, 1000);
+ ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, 1000, 10);
Assert.assertEquals(false, join.wasStored());
join.store();
@@ -72,4 +72,16 @@ public class ArtifactJoinQueryTest {
join.store();
}
+
+ @Test(expected = OseeDataStoreException.class)
+ public void testMoreThanAllowed() throws OseeCoreException {
+ MockJoinAccessor joinAccessor = new MockJoinAccessor();
+ int maxSize = 5;
+ ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, 1000, maxSize);
+
+ for (int i = 0; i < maxSize + 1; i++) {
+ join.add(i + 1, 1123L, null);
+ }
+
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java
index 78ad2a3f30..4750a3acd7 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.framework.database.core;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.database.core.DatabaseJoinAccessor.JoinItem;
/**
@@ -17,6 +18,8 @@ import org.eclipse.osee.framework.database.core.DatabaseJoinAccessor.JoinItem;
*/
public class ArtifactJoinQuery extends AbstractJoinQuery {
+ private final int maxJoinSize;
+
private final class Entry implements IJoinRow {
private final Integer artId;
private final Long branchId;
@@ -93,12 +96,16 @@ public class ArtifactJoinQuery extends AbstractJoinQuery {
}
}
- protected ArtifactJoinQuery(IJoinAccessor joinAccessor, int queryId) {
+ protected ArtifactJoinQuery(IJoinAccessor joinAccessor, int queryId, int maxJoinSize) {
super(joinAccessor, JoinItem.ARTIFACT, queryId);
+ this.maxJoinSize = maxJoinSize;
}
public void add(Integer art_id, Long branchId, Integer transactionId) {
entries.add(new Entry(art_id, branchId, transactionId));
+ if (entries.size() > maxJoinSize) {
+ throw new OseeDataStoreException("Exceeded max artifact join size of [%d]", maxJoinSize);
+ }
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java
index 0178ae62bd..5e924bd0ee 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java
@@ -14,6 +14,7 @@ import java.util.Random;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.internal.ServiceUtil;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
/**
* @author Roberto E. Escobar
@@ -51,7 +52,7 @@ public class JoinUtility {
}
public static ArtifactJoinQuery createArtifactJoinQuery(IOseeDatabaseService service) {
- return new ArtifactJoinQuery(createAccessor(service), getNewQueryId());
+ return new ArtifactJoinQuery(createAccessor(service), getNewQueryId(), getMaxArtifactJoinSize(service));
}
public static SearchTagJoinQuery createSearchTagJoinQuery(IOseeDatabaseService service) {
@@ -88,7 +89,8 @@ public class JoinUtility {
}
public static ArtifactJoinQuery createArtifactJoinQuery() throws OseeDataStoreException {
- return new ArtifactJoinQuery(createAccessor(getDatabase()), getNewQueryId());
+ return new ArtifactJoinQuery(createAccessor(getDatabase()), getNewQueryId(),
+ getMaxArtifactJoinSize(getDatabase()));
}
public static SearchTagJoinQuery createSearchTagJoinQuery() throws OseeDataStoreException {
@@ -103,4 +105,13 @@ public class JoinUtility {
return new ExportImportJoinQuery(createAccessor(getDatabase()), getNewQueryId());
}
+ private static int getMaxArtifactJoinSize(IOseeDatabaseService service) {
+ int toReturn = Integer.MAX_VALUE;
+ String maxSize = OseeInfo.getCachedValue(service, "artifact.join.max.size");
+ if (Strings.isNumeric(maxSize)) {
+ toReturn = Integer.parseInt(maxSize);
+ }
+ return toReturn;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeInfo.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeInfo.java
index c3c595c043..31b60478ed 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeInfo.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeInfo.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.framework.database.core;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -31,19 +32,28 @@ public class OseeInfo {
private static Map<String, String> cache = new HashMap<String, String>();
public static String getValue(String key) throws OseeCoreException {
- String toReturn = ConnectionHandler.runPreparedQueryFetchString("", GET_VALUE_SQL, key);
+ return getValue(ConnectionHandler.getDatabase(), key);
+ }
+
+ public static String getValue(IOseeDatabaseService service, String key) throws OseeCoreException {
+ String toReturn = service.runPreparedQueryFetchObject("", GET_VALUE_SQL, key);
cache.put(key, toReturn);
return toReturn;
}
- public static String getCachedValue(String key) throws OseeCoreException {
+ public static String getCachedValue(IOseeDatabaseService service, String key) throws OseeCoreException {
String cacheValue = cache.get(key);
if (cacheValue == null) {
- cacheValue = getValue(key);
+ cacheValue = getValue(service, key);
cache.put(key, cacheValue);
}
return cacheValue;
+
+ }
+
+ public static String getCachedValue(String key) throws OseeCoreException {
+ return getCachedValue(ConnectionHandler.getDatabase(), key);
}
/**

Back to the top