Roberto Sánchez
2014-01-27 c3d9abdd3cd55a12d6509ade288648c2408baeb5
#395 feature - Added expiration date to license and automatic
preactivation flag
1 files added
8 files modified
changed files
securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/License.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/Pack.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/LicenseResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/PackResource.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/exception/SeCurisServiceException.java patch | view | blame | history
securis/src/main/resources/db/schema.sql patch | view | blame | history
securis/src/main/resources/static/js/licenses.js patch | view | blame | history
securis/src/main/resources/static/licenses.html patch | view | blame | history
securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java
....@@ -10,6 +10,8 @@
1010 import javax.ws.rs.ext.ExceptionMapper;
1111 import javax.ws.rs.ext.Provider;
1212
13
+import net.curisit.securis.services.exception.SeCurisServiceException;
14
+
1315 import org.slf4j.Logger;
1416 import org.slf4j.LoggerFactory;
1517
....@@ -37,6 +39,11 @@
3739 return Response.status(Status.UNAUTHORIZED).header(ERROR_MESSAGE_HEADER, "Unathorized access to the application").type(MediaType.APPLICATION_JSON).build();
3840 }
3941
42
+ if (e instanceof SeCurisServiceException) {
43
+ log.warn("SeCurisServiceException accessing to {}, user: {}", request.getPathInfo(), bsc.getUserPrincipal());
44
+ return Response.status(Status.fromStatusCode(((SeCurisServiceException) e).getStatus())).header(ERROR_MESSAGE_HEADER, e.getMessage()).type(MediaType.APPLICATION_JSON).build();
45
+ }
46
+
4047 log.error("Unexpected error accesing to '{}' by user: {}", request.getPathInfo(), bsc.getUserPrincipal());
4148 log.error("Request sent from {}, with User-Agent: {}", request.getRemoteHost(), request.getHeader("User-Agent"));
4249 log.error("Request url: " + request.getRequestURL(), e);
securis/src/main/java/net/curisit/securis/db/License.java
....@@ -83,6 +83,9 @@
8383 @Column(name = "last_access_timestamp")
8484 private Date lastAccessTimestamp;
8585
86
+ @Column(name = "expiration_date")
87
+ private Date expirationDate;
88
+
8689 private String comments;
8790
8891 @OneToMany(fetch = FetchType.LAZY, mappedBy = "license")
....@@ -258,6 +261,14 @@
258261 this.history = history;
259262 }
260263
264
+ public Date getExpirationDate() {
265
+ return expirationDate;
266
+ }
267
+
268
+ public void setExpirationDate(Date expirationDate) {
269
+ this.expirationDate = expirationDate;
270
+ }
271
+
261272 public static class Status {
262273 public static final int CREATED = 0;
263274 public static final int SENT = 1;
securis/src/main/java/net/curisit/securis/db/Pack.java
....@@ -73,6 +73,10 @@
7373 @JsonProperty("num_licenses")
7474 private int numLicenses;
7575
76
+ @Column(name = "license_preactivation")
77
+ @JsonProperty("license_preactivation")
78
+ private boolean licensePreactivation;
79
+
7680 public int getId() {
7781 return id;
7882 }
....@@ -240,4 +244,12 @@
240244 this.comments = comments;
241245 }
242246
247
+ public boolean isLicensePreactivation() {
248
+ return licensePreactivation;
249
+ }
250
+
251
+ public void setLicensePreactivation(boolean licensePreactivation) {
252
+ this.licensePreactivation = licensePreactivation;
253
+ }
254
+
243255 }
securis/src/main/java/net/curisit/securis/services/LicenseResource.java
....@@ -22,9 +22,7 @@
2222 import javax.ws.rs.core.Response;
2323 import javax.ws.rs.core.Response.Status;
2424
25
-import net.curisit.integrity.commons.JsonUtils;
2625 import net.curisit.integrity.commons.Utils;
27
-import net.curisit.integrity.exception.CurisException;
2826 import net.curisit.securis.DefaultExceptionHandler;
2927 import net.curisit.securis.db.License;
3028 import net.curisit.securis.db.LicenseHistory;
....@@ -32,6 +30,7 @@
3230 import net.curisit.securis.db.User;
3331 import net.curisit.securis.security.BasicSecurityContext;
3432 import net.curisit.securis.security.Securable;
33
+import net.curisit.securis.services.exception.SeCurisServiceException;
3534 import net.curisit.securis.utils.TokenHelper;
3635
3736 import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
....@@ -92,69 +91,43 @@
9291 /**
9392 *
9493 * @return the server version in format majorVersion.minorVersion
94
+ * @throws SeCurisServiceException
9595 */
9696 @GET
9797 @Path("/{licId}")
9898 @Securable
9999 @Produces(
100100 { MediaType.APPLICATION_JSON })
101
- public Response get(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) {
101
+ public Response get(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
102102 log.info("Getting organization data for id: {}: ", licId);
103
- if (licId == null || licId.equals("")) {
104
- log.error("License ID is mandatory");
105
- return Response.status(Status.NOT_FOUND).build();
106
- }
107103
108104 EntityManager em = emProvider.get();
109
- License lic = em.find(License.class, licId);
110
- if (lic == null) {
111
- log.error("License with id {} not found in DB", licId);
112
- return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License not found for ID: " + licId).build();
113
- }
114
- if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) {
115
- if (!bsc.getOrganizationsIds().contains(lic.getPack().getOrganization().getId())) {
116
- log.error("License with id {} is not accesible by user {}", licId, bsc.getUserPrincipal());
117
- return Response.status(Status.UNAUTHORIZED).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Unathorized access to license data").build();
118
- }
119
- }
105
+ License lic = getCurrentLicense(licId, bsc, em);
120106 return Response.ok(lic).build();
121107 }
122108
123109 /**
124110 *
125111 * @return The license file, only of license is active
112
+ * @throws SeCurisServiceException
126113 */
127114 @GET
128115 @Path("/{licId}/download")
129116 @Securable
130117 @Produces(
131118 { MediaType.APPLICATION_OCTET_STREAM })
132
- public Response download(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) {
133
- log.info("Getting license data for id: {}: ", licId);
134
- if (licId == null || licId.equals("")) {
135
- log.error("License ID is mandatory");
136
- return Response.status(Status.NOT_FOUND).build();
137
- }
119
+ public Response download(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
138120
139121 EntityManager em = emProvider.get();
140
- License lic = em.find(License.class, licId);
141
- if (lic == null) {
142
- log.error("License with id {} not found in DB", licId);
143
- return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License not found for ID: " + licId).build();
144
- }
145
- if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) {
146
- if (!bsc.getOrganizationsIds().contains(lic.getPack().getOrganization().getId())) {
147
- log.error("License with id {} is not accesible by user {}", licId, bsc.getUserPrincipal());
148
- return Response.status(Status.UNAUTHORIZED).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Unathorized access to license data").build();
149
- }
150
- }
122
+ License lic = getCurrentLicense(licId, bsc, em);
123
+
151124 if (lic.getLicenseData() == null) {
152125 log.error("License with id {} has not license file generated", licId, bsc.getUserPrincipal());
153
- return Response.status(Status.FORBIDDEN).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License has not contain data to generate license file").build();
126
+ throw new SeCurisServiceException(Status.FORBIDDEN.getStatusCode(), "License has not contain data to generate license file");
154127 }
155128 if (lic.getStatus() != License.Status.ACTIVE) {
156129 log.error("License with id {} is not active, so It can not downloaded", licId, bsc.getUserPrincipal());
157
- return Response.status(Status.FORBIDDEN).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License is not active, so It can not be downloaded").build();
130
+ throw new SeCurisServiceException(Status.FORBIDDEN.getStatusCode(), "License is not active, so It can not be downloaded");
158131 }
159132 return Response.ok(lic.getLicenseData()).build();
160133 }
....@@ -167,42 +140,60 @@
167140 @Consumes(MediaType.APPLICATION_JSON)
168141 @Produces(
169142 { MediaType.APPLICATION_JSON })
170
- public Response activate(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) {
171
- log.info("Getting license data for id: {}: ", licId);
172
- if (licId == null || licId.equals("")) {
173
- log.error("License ID is mandatory");
174
- return Response.status(Status.NOT_FOUND).build();
175
- }
143
+ public Response activate(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
176144
177145 EntityManager em = emProvider.get();
178
- License lic = em.find(License.class, licId);
179
- if (lic == null) {
180
- log.error("License with id {} not found in DB", licId);
181
- return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License not found for ID: " + licId).build();
182
- }
183
- if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) {
184
- if (!bsc.getOrganizationsIds().contains(lic.getPack().getOrganization().getId())) {
185
- log.error("License with id {} is not accesible by user {}", licId, bsc.getUserPrincipal());
186
- return Response.status(Status.UNAUTHORIZED).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Unathorized access to license data").build();
187
- }
188
- }
146
+ License lic = getCurrentLicense(licId, bsc, em);
189147
190
- User user = null;
191
- try {
192
- user = getUser(bsc.getUserPrincipal().getName(), em);
193
- } catch (CurisException ex) {
194
- return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Current user not found in DB: " + bsc.getUserPrincipal()).build();
195
- }
148
+ User user = getUser(bsc.getUserPrincipal().getName(), em);
196149
197150 lic.setStatus(License.Status.ACTIVE);
198151 lic.setModificationTimestamp(new Date());
199152 em.persist(lic);
200
- LicenseHistory lh = new LicenseHistory();
201
- lh.setLicense(lic);
202
- lh.setUser(user);
203
- lh.setTimestamp(new Date());
204
- lh.setAction(LicenseHistory.Actions.ACTIVATE);
205
- em.persist(lh);
153
+ em.persist(createLicenseHistoryAction(lic, user, LicenseHistory.Actions.ACTIVATE));
154
+ return Response.ok(lic).build();
155
+ }
156
+
157
+ @PUT
158
+ @POST
159
+ @Path("/{licId}/send")
160
+ @Securable
161
+ @Transactional
162
+ @Consumes(MediaType.APPLICATION_JSON)
163
+ @Produces(
164
+ { MediaType.APPLICATION_JSON })
165
+ public Response send(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
166
+
167
+ EntityManager em = emProvider.get();
168
+ License lic = getCurrentLicense(licId, bsc, em);
169
+
170
+ User user = getUser(bsc.getUserPrincipal().getName(), em);
171
+ // TODO: Send mail with lic file
172
+ lic.setModificationTimestamp(new Date());
173
+ em.persist(lic);
174
+ em.persist(createLicenseHistoryAction(lic, user, LicenseHistory.Actions.SEND, "Email sent to: " + lic.getEmail()));
175
+ return Response.ok(lic).build();
176
+ }
177
+
178
+ @PUT
179
+ @POST
180
+ @Path("/{licId}/cancel")
181
+ @Securable
182
+ @Transactional
183
+ @Consumes(MediaType.APPLICATION_JSON)
184
+ @Produces(
185
+ { MediaType.APPLICATION_JSON })
186
+ public Response cancel(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
187
+
188
+ EntityManager em = emProvider.get();
189
+ License lic = getCurrentLicense(licId, bsc, em);
190
+
191
+ User user = getUser(bsc.getUserPrincipal().getName(), em);
192
+
193
+ lic.setStatus(License.Status.CANCELED);
194
+ lic.setModificationTimestamp(new Date());
195
+ em.persist(lic);
196
+ em.persist(createLicenseHistoryAction(lic, user, LicenseHistory.Actions.CANCEL));
206197 return Response.ok(lic).build();
207198 }
208199
....@@ -213,7 +204,7 @@
213204 @Produces(
214205 { MediaType.APPLICATION_JSON })
215206 @Transactional
216
- public Response create(License lic, @Context BasicSecurityContext bsc) {
207
+ public Response create(License lic, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
217208 log.info("Creating new license from create()");
218209 EntityManager em = emProvider.get();
219210 Pack pack = null;
....@@ -232,14 +223,7 @@
232223 }
233224 }
234225
235
- User createdBy = null;
236
- try {
237
- createdBy = getUser(bsc.getUserPrincipal().getName(), em);
238
- } catch (CurisException ex) {
239
- String createdByUsername = lic.getCreatedById();
240
- log.error("License created by user with id {} not found in DB", createdByUsername);
241
- return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's created by user not found with ID: " + createdByUsername).build();
242
- }
226
+ User createdBy = getUser(bsc.getUserPrincipal().getName(), em);
243227
244228 // ODO: Manage status if request data is set
245229 lic.setCreatedBy(createdBy);
....@@ -247,12 +231,7 @@
247231 lic.setCreationTimestamp(new Date());
248232 lic.setModificationTimestamp(lic.getCreationTimestamp());
249233 em.persist(lic);
250
- LicenseHistory lh = new LicenseHistory();
251
- lh.setLicense(lic);
252
- lh.setUser(createdBy);
253
- lh.setTimestamp(new Date());
254
- lh.setAction(LicenseHistory.Actions.CREATE);
255
- em.persist(lh);
234
+ em.persist(createLicenseHistoryAction(lic, createdBy, LicenseHistory.Actions.CREATE));
256235
257236 return Response.ok(lic).build();
258237 }
....@@ -264,7 +243,7 @@
264243 @Produces(
265244 { MediaType.APPLICATION_JSON })
266245 @Transactional
267
- public Response createWithFile(MultipartFormDataInput mpfdi, @Context BasicSecurityContext bsc) throws IOException {
246
+ public Response createWithFile(MultipartFormDataInput mpfdi, @Context BasicSecurityContext bsc) throws IOException, SeCurisServiceException {
268247 License lic = new License();
269248 lic.setCode(mpfdi.getFormDataPart("code", String.class, null));
270249 lic.setRequestData(mpfdi.getFormDataPart("request_data", String.class, null));
....@@ -272,25 +251,8 @@
272251 lic.setFullName(mpfdi.getFormDataPart("full_name", String.class, null));
273252 lic.setEmail(mpfdi.getFormDataPart("email", String.class, null));
274253 lic.setComments(mpfdi.getFormDataPart("comments", String.class, null));
275
- try {
276
- log.info("File content: {}", lic.getRequestData());
277
- log.info("License read from multipart: {}", JsonUtils.toJSON(lic));
278
- } catch (CurisException e) {
279
- // TODO Auto-generated catch block
280
- e.printStackTrace();
281
- }
282
- return create(lic, bsc);
283
- }
284254
285
- private User getUser(String username, EntityManager em) throws CurisException {
286
- User user = null;
287
- if (username != null) {
288
- user = em.find(User.class, username);
289
- if (user == null) {
290
- throw new CurisException("User not found");
291
- }
292
- }
293
- return user;
255
+ return create(lic, bsc);
294256 }
295257
296258 @PUT
....@@ -301,57 +263,13 @@
301263 @Consumes(MediaType.APPLICATION_JSON)
302264 @Produces(
303265 { MediaType.APPLICATION_JSON })
304
- public Response modify(License lic, @PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) {
266
+ public Response modify(License lic, @PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
305267 log.info("Modifying organization with id: {}", licId);
268
+
306269 EntityManager em = emProvider.get();
307270
308
- // Pack pack = null;
309
- // if (lic.getPackId() != null) {
310
- // pack = em.find(Pack.class, lic.getPackId());
311
- // if (pack == null) {
312
- // log.error("License pack with id {} not found in DB", lic.getPackId());
313
- // return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's pack not found with ID: " + lic.getPackId()).build();
314
- // } else {
315
- // if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) {
316
- // if (!bsc.getOrganizationsIds().contains(pack.getOrganization().getId())) {
317
- // log.error("License for pack with id {} can not be modified by user {}", pack.getId(), bsc.getUserPrincipal());
318
- // return Response.status(Status.UNAUTHORIZED).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Unathorized action on pack license").build();
319
- // }
320
- // }
321
- // }
322
- // }
323
- User createdBy = null;
324
- try {
325
- createdBy = getUser(lic.getCreatedById(), em);
326
- } catch (CurisException ex) {
327
- String createdByUsername = lic.getCreatedById();
328
- log.error("License created by user with id {} not found in DB", createdByUsername);
329
- return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's created by user not found with ID: " + createdByUsername).build();
330
- }
271
+ License currentLicense = getCurrentLicense(licId, bsc, em);
331272
332
- User canceledBy = null;
333
- try {
334
- canceledBy = getUser(lic.getCanceledById(), em);
335
- } catch (CurisException ex) {
336
- String canceledByUsername = lic.getCreatedById();
337
- log.error("License canceled by user with id {} not found in DB", canceledByUsername);
338
- return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License's canceled by user not found with ID: " + canceledByUsername).build();
339
- }
340
- License currentLicense = em.find(License.class, lic.getId());
341
- if (currentLicense == null) {
342
- log.error("License with id {} not found in DB", licId);
343
- return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License not found for ID: " + licId).build();
344
- }
345
- if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) {
346
- if (!bsc.getOrganizationsIds().contains(lic.getPack().getOrganization().getId())) {
347
- log.error("License with id {} is not accesible by user {}", licId, bsc.getUserPrincipal());
348
- return Response.status(Status.UNAUTHORIZED).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Unathorized access to license data").build();
349
- }
350
- }
351
- // TODO: set status based in current one and dates ? use custom actions ?
352
- currentLicense.setCreatedBy(createdBy);
353
- currentLicense.setCanceledBy(canceledBy);
354
- // currentLicense.setPack(pack);
355273 currentLicense.setCode(lic.getCode());
356274 currentLicense.setFullName(lic.getFullName());
357275 currentLicense.setEmail(lic.getEmail());
....@@ -368,21 +286,10 @@
368286 @Securable
369287 @Produces(
370288 { MediaType.APPLICATION_JSON })
371
- public Response delete(@PathParam("licId") String licId, @Context BasicSecurityContext bsc) {
289
+ public Response delete(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
372290 log.info("Deleting license with id: {}", licId);
373291 EntityManager em = emProvider.get();
374
- License lic = em.find(License.class, Integer.parseInt(licId));
375
- if (lic == null) {
376
- log.error("License with id {} can not be deleted, It was not found in DB", licId);
377
- return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "License was not found, ID: " + licId).build();
378
- }
379
-
380
- if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) {
381
- if (!bsc.getOrganizationsIds().contains(lic.getPack().getOrganization().getId())) {
382
- log.error("License with id {} is not accesible by user {}", licId, bsc.getUserPrincipal());
383
- return Response.status(Status.UNAUTHORIZED).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Unathorized access to license data").build();
384
- }
385
- }
292
+ License lic = getCurrentLicense(licId, bsc, em);
386293
387294 if (lic.getStatus() != License.Status.CANCELED || lic.getStatus() != License.Status.CREATED) {
388295 log.error("License {} can not be deleted with status {}", lic.getCode(), lic.getStatus());
....@@ -393,4 +300,48 @@
393300 return Response.ok(Utils.createMap("success", true, "id", licId)).build();
394301 }
395302
303
+ private License getCurrentLicense(Integer licId, BasicSecurityContext bsc, EntityManager em) throws SeCurisServiceException {
304
+ if (licId == null || licId.equals("")) {
305
+ log.error("License ID is mandatory");
306
+ throw new SeCurisServiceException(Status.NOT_FOUND.getStatusCode(), "Missing license ID");
307
+ }
308
+
309
+ License lic = em.find(License.class, licId);
310
+ if (lic == null) {
311
+ log.error("License with id {} not found in DB", licId);
312
+ throw new SeCurisServiceException(Status.NOT_FOUND.getStatusCode(), "License not found for ID: " + licId);
313
+ }
314
+ if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) {
315
+ if (!bsc.getOrganizationsIds().contains(lic.getPack().getOrganization().getId())) {
316
+ log.error("License with id {} is not accesible by user {}", licId, bsc.getUserPrincipal());
317
+ throw new SeCurisServiceException(Status.UNAUTHORIZED.getStatusCode(), "Unathorized access to license data");
318
+ }
319
+ }
320
+ return lic;
321
+ }
322
+
323
+ private User getUser(String username, EntityManager em) throws SeCurisServiceException {
324
+ User user = null;
325
+ if (username != null) {
326
+ user = em.find(User.class, username);
327
+ if (user == null) {
328
+ throw new SeCurisServiceException(Status.NOT_FOUND.getStatusCode(), "User not found with username: " + username);
329
+ }
330
+ }
331
+ return user;
332
+ }
333
+
334
+ private LicenseHistory createLicenseHistoryAction(License lic, User user, String action, String comments) {
335
+ LicenseHistory lh = new LicenseHistory();
336
+ lh.setLicense(lic);
337
+ lh.setUser(user);
338
+ lh.setTimestamp(new Date());
339
+ lh.setAction(action);
340
+ lh.setComments(comments);
341
+ return lh;
342
+ }
343
+
344
+ private LicenseHistory createLicenseHistoryAction(License lic, User user, String action) {
345
+ return createLicenseHistoryAction(lic, user, action, null);
346
+ }
396347 }
securis/src/main/java/net/curisit/securis/services/PackResource.java
....@@ -192,6 +192,7 @@
192192 return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Pack license type not found with ID: " + pack.getLicTypeId()).build();
193193 }
194194 }
195
+ currentPack.setLicensePreactivation(pack.isLicensePreactivation());
195196 currentPack.setLicenseType(lt);
196197 currentPack.setOrganization(org);
197198 currentPack.setCode(pack.getCode());
securis/src/main/java/net/curisit/securis/services/exception/SeCurisServiceException.java
....@@ -0,0 +1,23 @@
1
+package net.curisit.securis.services.exception;
2
+
3
+import net.curisit.integrity.exception.CurisException;
4
+
5
+public class SeCurisServiceException extends CurisException {
6
+
7
+ private int status = 0;
8
+
9
+ public SeCurisServiceException(int status, String msg) {
10
+ super(msg);
11
+ this.status = status;
12
+ }
13
+
14
+ public int getStatus() {
15
+ return status;
16
+ }
17
+
18
+ /**
19
+ *
20
+ */
21
+ private static final long serialVersionUID = 1L;
22
+
23
+}
securis/src/main/resources/db/schema.sql
....@@ -61,6 +61,7 @@
6161 comments VARCHAR(1024) NULL ,
6262 license_type_id INT NOT NULL,
6363 organization_id INT NOT NULL,
64
+ license_preactivation BOOLEAN NOT NULL DEFAULT true,
6465 created_by varchar(45) NULL ,
6566 creation_timestamp DATETIME NOT NULL ,
6667 PRIMARY KEY (id));
....@@ -78,6 +79,7 @@
7879 creation_timestamp DATETIME NOT NULL ,
7980 modification_timestamp DATETIME NULL ,
8081 last_access_timestamp DATETIME NULL ,
82
+ expiration_date DATETIME NULL ,
8183 canceled_by varchar(45) NULL ,
8284 created_by varchar(45) NULL ,
8385 status INT NOT NULL default 0,
securis/src/main/resources/static/js/licenses.js
....@@ -118,7 +118,8 @@
118118 $scope.isNew = true;
119119 $scope.showForm = true;
120120 $scope.pack = {
121
- num_licenses: 1,
121
+ license_preactivation: true,
122
+ num_licenses: 1,
122123 license_type_id: !$scope.refs.license_type_id || !$scope.refs.license_type_id.length ? null : $scope.refs.license_type_id[0].id,
123124 organization_id: !$scope.refs.organization_id || !$scope.refs.organization_id.length ? null : $scope.refs.organization_id[0].id
124125 }
securis/src/main/resources/static/licenses.html
....@@ -89,6 +89,12 @@
8989 </div>
9090 </div>
9191 </div>
92
+ <div class="form-group" >
93
+ <label class="col-md-3 control-label" for="license_preactivation" i18n>License preactivation</label>
94
+ <div class="col-md-8">
95
+ <input type="checkbox" class="form-control" ng-model="pack.license_preactivation" />
96
+ </div>
97
+ </div>
9298
9399
94100 <div class="form-group" >
....@@ -253,7 +259,6 @@
253259 </div>
254260 </div>
255261 </div>
256
-{{request_data}}
257262 <div class="form-group" ng-if="isNew || !license.request_data" >
258263 <label class="col-md-3 control-label" for="request_data" i18n>Request data</label>
259264 <div class="col-md-8">