| .. | .. |
|---|
| 165 | 165 | LOG.error("License with id {} has not license file generated", licId, bsc.getUserPrincipal()); |
|---|
| 166 | 166 | throw new SeCurisServiceException(Status.FORBIDDEN.getStatusCode(), "License has not contain data to generate license file"); |
|---|
| 167 | 167 | } |
|---|
| 168 | | - if (License.Status.isActionValid(License.Action.DOWNLOAD, lic.getStatus())) { |
|---|
| 168 | + if (!License.Status.isActionValid(License.Action.DOWNLOAD, lic.getStatus())) { |
|---|
| 169 | 169 | LOG.error("License with id {} is not active, so It can not downloaded", licId, bsc.getUserPrincipal()); |
|---|
| 170 | 170 | throw new SeCurisServiceException(ErrorCodes.WRONG_STATUS, "License is not active, so It can not be downloaded"); |
|---|
| 171 | 171 | } |
|---|
| .. | .. |
|---|
| 198 | 198 | EntityManager em = emProvider.get(); |
|---|
| 199 | 199 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 200 | 200 | |
|---|
| 201 | | - if (License.Status.isActionValid(License.Action.ACTIVATION, lic.getStatus())) { |
|---|
| 201 | + if (!License.Status.isActionValid(License.Action.ACTIVATION, lic.getStatus())) { |
|---|
| 202 | 202 | LOG.error("License with id {} can not be activated from current license status", licId); |
|---|
| 203 | 203 | throw new SeCurisServiceException(Status.FORBIDDEN.getStatusCode(), "License with id " + licId |
|---|
| 204 | 204 | + " can not be activated from the current license status"); |
|---|
| .. | .. |
|---|
| 250 | 250 | throw new SeCurisServiceException(Status.NOT_FOUND.getStatusCode(), "There is no license file available"); |
|---|
| 251 | 251 | } |
|---|
| 252 | 252 | |
|---|
| 253 | + if (lic.getFullName() == null) { |
|---|
| 254 | + throw new SeCurisServiceException(Status.NOT_FOUND.getStatusCode(), "Please add an user name in license data to send it the license file"); |
|---|
| 255 | + } |
|---|
| 256 | + |
|---|
| 253 | 257 | User user = userHelper.getUser(bsc.getUserPrincipal().getName(), em); |
|---|
| 254 | 258 | try { |
|---|
| 255 | 259 | String subject = MessageFormat.format(Params.get(Params.KEYS.EMAIL_LIC_DEFAULT_SUBJECT), lic.getPack().getAppName()); |
|---|
| 256 | | - String email_tpl = IOUtils.toString(this.getClass().getResourceAsStream("/lic_email_template.en")); |
|---|
| 260 | + String email_tpl = IOUtils.toString(this.getClass().getResourceAsStream("/lic_email.template.en")); |
|---|
| 257 | 261 | String body = MessageFormat.format(email_tpl, lic.getFullName(), app.getName()); |
|---|
| 258 | 262 | licFile = licenseHelper.createTemporaryLicenseFile(lic, app.getLicenseFilename()); |
|---|
| 259 | 263 | |
|---|
| .. | .. |
|---|
| 264 | 268 | } finally { |
|---|
| 265 | 269 | if (licFile != null) { |
|---|
| 266 | 270 | licFile.delete(); |
|---|
| 271 | + licFile.getParentFile().delete(); |
|---|
| 267 | 272 | } |
|---|
| 268 | 273 | } |
|---|
| 269 | 274 | |
|---|
| 270 | 275 | lic.setModificationTimestamp(new Date()); |
|---|
| 271 | | - em.persist(lic); |
|---|
| 276 | + em.merge(lic); |
|---|
| 272 | 277 | em.persist(licenseHelper.createLicenseHistoryAction(lic, user, LicenseHistory.Actions.SEND, "Email sent to: " + lic.getEmail())); |
|---|
| 273 | 278 | return Response.ok(lic).build(); |
|---|
| 274 | 279 | } |
|---|
| .. | .. |
|---|
| 296 | 301 | EntityManager em = emProvider.get(); |
|---|
| 297 | 302 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 298 | 303 | |
|---|
| 299 | | - if (License.Status.isActionValid(License.Action.CANCEL, lic.getStatus())) { |
|---|
| 304 | + if (!License.Status.isActionValid(License.Action.CANCEL, lic.getStatus())) { |
|---|
| 300 | 305 | LOG.error("License with id {} can not be canceled from current license status", licId); |
|---|
| 301 | 306 | throw new SeCurisServiceException(Status.FORBIDDEN.getStatusCode(), "License with id " + licId |
|---|
| 302 | 307 | + " can not be canceled from the current license status"); |
|---|
| .. | .. |
|---|
| 499 | 504 | EntityManager em = emProvider.get(); |
|---|
| 500 | 505 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 501 | 506 | |
|---|
| 502 | | - if (License.Status.isActionValid(License.Action.DELETE, lic.getStatus())) { |
|---|
| 507 | + if (!License.Status.isActionValid(License.Action.DELETE, lic.getStatus())) { |
|---|
| 503 | 508 | LOG.error("License {} can not be deleted with status {}", lic.getCode(), lic.getStatus()); |
|---|
| 504 | 509 | throw new SeCurisServiceException(ErrorCodes.WRONG_STATUS, "License can not be deleted in current status: " + lic.getStatus().name()); |
|---|
| 505 | 510 | } |
|---|