summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.core
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-07-01 16:15:23 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-07-01 16:15:23 +0530
commit2c4ea3418784160bdf4f186b2488e974465161e7 (patch)
treedcbf4de394194c86f3d5df499fcb99b63dc35c5e /src/com.gluster.storage.management.core
parent40d4024c47ca1e1e15e2500a5412791d364bd8b0 (diff)
[Bug 3117] New: Failing to create volume should throw error message instead of stack trace.
Diffstat (limited to 'src/com.gluster.storage.management.core')
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java
index 4194a642..20b652f4 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java
@@ -26,6 +26,7 @@ import java.util.Set;
import com.gluster.storage.management.core.model.Brick;
import com.gluster.storage.management.core.model.Disk;
+import com.gluster.storage.management.core.model.Entity;
public class GlusterCoreUtil {
@@ -45,4 +46,42 @@ public class GlusterCoreUtil {
}
return qualifiedBricks;
}
+
+ /**
+ * Compares the two entity lists and returns the list of entities present only in the second argument
+ * <code>newEntities</code>
+ *
+ * @param oldEntities
+ * @param newEntities
+ * @return List of entities that are present only in the second argument <code>newEntities</code>
+ */
+ public static List<Entity> getAddedEntities(List<? extends Entity> oldEntities, List<Entity> newEntities) {
+ List<Entity> addedEntities = new ArrayList<Entity>();
+ for(Entity newEntity : newEntities) {
+ if(!containsEntity(oldEntities, newEntity, false)) {
+ // old entity list doesn't contain this entity. mark it as new.
+ addedEntities.add(newEntity);
+ }
+ }
+ return addedEntities;
+ }
+
+ public static boolean containsEntity(List<? extends Entity> entityList, Entity searchEntity, boolean caseInsensitive) {
+ String searchEntityName = searchEntity.getName();
+ if(caseInsensitive) {
+ searchEntityName = searchEntityName.toUpperCase();
+ }
+
+ for(Entity entity : entityList) {
+ String nextEntityName = entity.getName();
+ if(caseInsensitive) {
+ nextEntityName = nextEntityName.toUpperCase();
+ }
+ if(nextEntityName.equals(searchEntityName)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}