private void validateDateRangeFor(Entity entity, Pair<Date,String> clusterMinStart,
Pair<Date,String> clusterMaxEnd, String start, String end) throws IvoryException {
Date instStart = EntityUtil.parseDateUTC(start);
if (instStart.before(clusterMinStart.first))
throw new ValidationException("Start date " + start + " is before "
+ entity.getEntityType() + "'s start "
+ SchemaHelper.formatDateUTC(clusterMinStart.first)
+ " for cluster " + clusterMinStart.second);
if (StringUtils.isNotEmpty(end)) {
Date instEnd = EntityUtil.parseDateUTC(end);
if (instStart.after(instEnd))
throw new ValidationException("Start date " + start
+ " is after end date " + end);
if (instEnd.after(clusterMaxEnd.first))
throw new ValidationException("End date " + end + " is after "
+ entity.getEntityType() + "'s end "
+ SchemaHelper.formatDateUTC(clusterMaxEnd.first)
+ " for cluster " + clusterMaxEnd.second);
} else if (instStart.after(clusterMaxEnd.first))
throw new ValidationException("Start date " + start + " is after "
+ entity.getEntityType() + "'s end "
+ SchemaHelper.formatDateUTC(clusterMaxEnd.first)
+ " for cluster " + clusterMaxEnd.second);
}