| .. | .. |
|---|
| 209 | 209 | |
|---|
| 210 | 210 | License existingLicense = License.findActiveLicenseByRequestData(lic.getRequestData(), em); |
|---|
| 211 | 211 | if (existingLicense != null && existingLicense.getStatus() == LicenseStatus.ACTIVE) { |
|---|
| 212 | | - throw new SeCurisServiceException(ErrorCodes.NO_AVAILABLE_LICENSES, "The pack has not available licenses"); |
|---|
| 212 | + throw new SeCurisServiceException(ErrorCodes.NO_AVAILABLE_LICENSES, "An active license already exists for the given request data"); |
|---|
| 213 | 213 | } |
|---|
| 214 | 214 | |
|---|
| 215 | 215 | lic.setStatus(LicenseStatus.ACTIVE); |
|---|
| .. | .. |
|---|
| 347 | 347 | if (checkIfCodeExists(lic.getCode(), em)) { |
|---|
| 348 | 348 | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The license code is already used in an existing license"); |
|---|
| 349 | 349 | } |
|---|
| 350 | + if (lic.getActivationCode() == null) { |
|---|
| 351 | + throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The activation code is mandatory"); |
|---|
| 352 | + } |
|---|
| 353 | + License existingLic = License.findLicenseByActivationCode(lic.getActivationCode(), em); |
|---|
| 354 | + if (existingLic != null) { |
|---|
| 355 | + throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The activation code is already used in: " + existingLic.getCode()); |
|---|
| 356 | + } |
|---|
| 350 | 357 | if (!LicUtils.checkValidLicenseCodeCrc(lic.getCode())) { |
|---|
| 351 | 358 | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The license code is not valid"); |
|---|
| 352 | 359 | } |
|---|
| 360 | + if (!Utils.isValidEmail(lic.getEmail())) { |
|---|
| 361 | + throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The user email should be a valid email"); |
|---|
| 362 | + } |
|---|
| 353 | 363 | |
|---|
| 354 | 364 | Pack pack = null; |
|---|
| 355 | 365 | if (lic.getPackId() != null) { |
|---|