}
@Override
public void beforeCreateItem(ItemBase item) throws OpsException {
if (item instanceof DnsServer) {
DnsServer model = (DnsServer) item;
model.dnsName = normalize(model.dnsName);
if (Strings.isNullOrEmpty(model.dnsName)) {
throw new IllegalArgumentException("dnsName must be specified");
}
}
if (item instanceof DnsRecord) {
DnsRecord model = (DnsRecord) item;
model.dnsName = normalize(model.dnsName);
if (Strings.isNullOrEmpty(model.dnsName)) {
throw new IllegalArgumentException("dnsName must be specified");
}
if (Strings.isNullOrEmpty(model.recordType)) {
model.recordType = "A";
}
if (model.recordType.equals("A")) {
// OK
} else {
throw new IllegalArgumentException("Record type not supported: " + model.recordType);
}
}
if (item instanceof DnsZone) {
DnsZone model = (DnsZone) item;
model.dnsName = normalize(model.dnsName);
if (Strings.isNullOrEmpty(model.dnsName)) {
model.dnsName = normalize(model.getId());
}
}
super.beforeCreateItem(item);
}