} else {
this.updateRegMetadata(regMetadata);
}
//save the licence:
LicenceBean licenceBean = mdRegistrationBean.getLicenceBean();
Licence licence = copyLicenceBeanToLicence(licenceBean);
licence.setRegMetadata(regMetadata);
if (licence.getId() == 0) {
Licence existedLicence = this.getLicenceByRegMetadataId(regMetadata.getId());
if (existedLicence != null) {
licence.setId(existedLicence.getId());
this.mergeLicence(licence);
} else {
this.saveLicence(licence);
}
} else {