<script type="text/javascript">
function onUploadLicense() {
if ($('fileInput').value.blank()) {
alert('<bean:message key="license.upload.blank" locale="<%=Constants.RMC_USER_LANGUAGE%>" />');
return false;
}
}
<logic:present name="isAlreadyUsed">
alert('<bean:message key="license.upload.error.used" locale="<%=Constants.RMC_USER_LANGUAGE%>" />');
</logic:present>
</script>
action:
if (!licenseService.isLicenseAlreadyUsed(uploadedLicenseKey)) {
licenseService.addLicense(uploadedLicenseKey);
licenseSource = sourceFile.getInputStream();
} else {
request.setAttribute("isAlreadyUsed", "true");
return mapping.findForward("review.license");
}
Service
public boolean isLicenseAlreadyUsed(String licenseKey) {
String result = ld.findObjectsByLicensekey(licenseKey);
return StringUtils.isNotBlank(StringUtils.defaultIfEmpty(result, ""));
}