| .. | .. |
|---|
| 74 | 74 | @Path("/") |
|---|
| 75 | 75 | @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 76 | 76 | @Securable |
|---|
| 77 | | - public Response index() { |
|---|
| 77 | + public Response index(@Context BasicSecurityContext bsc) { |
|---|
| 78 | 78 | LOG.info("Getting license types list "); |
|---|
| 79 | 79 | |
|---|
| 80 | 80 | // EntityManager em = emProvider.get(); |
|---|
| 81 | 81 | em.clear(); |
|---|
| 82 | | - TypedQuery<LicenseType> q = em.createNamedQuery("list-license_types", LicenseType.class); |
|---|
| 82 | + TypedQuery<LicenseType> q; |
|---|
| 83 | + if (bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) { |
|---|
| 84 | + q = em.createNamedQuery("list-license_types", LicenseType.class); |
|---|
| 85 | + } else { |
|---|
| 86 | + if (bsc.getApplicationsIds() == null || bsc.getApplicationsIds().isEmpty()) { |
|---|
| 87 | + return Response.ok().build(); |
|---|
| 88 | + } |
|---|
| 89 | + q = em.createNamedQuery("list-license_types-by_apps-id", LicenseType.class); |
|---|
| 90 | + |
|---|
| 91 | + q.setParameter("list_ids", bsc.getApplicationsIds()); |
|---|
| 92 | + } |
|---|
| 83 | 93 | List<LicenseType> list = q.getResultList(); |
|---|
| 84 | 94 | |
|---|
| 85 | 95 | return Response.ok(list).build(); |
|---|