private void validateNameUniqueness(Entity entity) throws ApplicationException { @SuppressWarnings("rawtypes") List keys = entityDefinitionCache.getKeys(); for (int i = 0; i < keys.size(); i++) { Object key = keys.get(i); Element elem = entityDefinitionCache.get(key); if (elem != null) { Entity item = (Entity) elem.getObjectValue(); if (item.getDateVoided() != null) { continue; } if (entity.getName().equalsIgnoreCase(item.getName()) && entity.getVersionId() == item.getVersionId()) { throw new ApplicationException( "Cannot add entity because another entity by the same name already exists."); } } } }