.defaultText("Please choose at least one group").build());
}
}
public void validateLifecycle(ChannelDefinitionForm def, ValidationContext context) {
MessageContext messageContext = context.getMessageContext();
if (def.getLifecycleState() == null) {
messageContext.addMessage(new MessageBuilder().error().source("lifecycle")
.code("lifecycle.error.selectLifecycle")
.defaultText("Please select a lifecycle stage").build());
}
Date now = new Date();
if (def.getPublishDate() != null) {
if (def.getPublishDateTime().before(now)) {
messageContext.addMessage(new MessageBuilder().error().source("publishDate")
.code("lifecycle.error.invalidPublishDate")
.defaultText("The auto-publishing date must be in the future").build());
}
}
if (def.getExpirationDate() != null) {
if (def.getExpirationDateTime().before(now)) {
messageContext.addMessage(new MessageBuilder().error().source("expirationDate")
.code("lifecycle.error.invalidExpirationDate")
.defaultText("The auto-expiration date must be in the future").build());
}
}
if (def.getPublishDate() != null && def.getExpirationDate() != null) {
if (def.getExpirationDateTime().before(def.getPublishDateTime())) {
messageContext.addMessage(new MessageBuilder().error().source("expirationDate")
.code("lifecycle.error.invalidPublishAndExpirationDate")
.defaultText("The auto-expiration date must be after the auto-publish date").build());
}
}
}