| .. | .. |
|---|
| 33 | 33 | import net.curisit.securis.db.User; |
|---|
| 34 | 34 | import net.curisit.securis.utils.TokenHelper; |
|---|
| 35 | 35 | |
|---|
| 36 | | -import org.apache.logging.log4j.Logger; |
|---|
| 37 | 36 | import org.apache.logging.log4j.LogManager; |
|---|
| 37 | +import org.apache.logging.log4j.Logger; |
|---|
| 38 | 38 | |
|---|
| 39 | 39 | import com.google.inject.persist.Transactional; |
|---|
| 40 | 40 | |
|---|
| .. | .. |
|---|
| 54 | 54 | |
|---|
| 55 | 55 | private static final Logger LOG = LogManager.getLogger(UserResource.class); |
|---|
| 56 | 56 | |
|---|
| 57 | | - public UserResource() {} |
|---|
| 57 | + public UserResource() { |
|---|
| 58 | + } |
|---|
| 58 | 59 | |
|---|
| 59 | 60 | /** |
|---|
| 60 | 61 | * |
|---|
| .. | .. |
|---|
| 62 | 63 | */ |
|---|
| 63 | 64 | @GET |
|---|
| 64 | 65 | @Path("/") |
|---|
| 65 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 66 | + @Produces({ |
|---|
| 67 | + MediaType.APPLICATION_JSON |
|---|
| 68 | + }) |
|---|
| 66 | 69 | public Response index() { |
|---|
| 67 | 70 | LOG.info("Getting users list "); |
|---|
| 68 | 71 | |
|---|
| .. | .. |
|---|
| 80 | 83 | */ |
|---|
| 81 | 84 | @GET |
|---|
| 82 | 85 | @Path("/{uid}") |
|---|
| 83 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 86 | + @Produces({ |
|---|
| 87 | + MediaType.APPLICATION_JSON |
|---|
| 88 | + }) |
|---|
| 84 | 89 | public Response get(@PathParam("uid") String uid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 85 | 90 | LOG.info("Getting user data for id: {}: ", uid); |
|---|
| 86 | 91 | if (uid == null || "".equals(uid)) { |
|---|
| .. | .. |
|---|
| 100 | 105 | @POST |
|---|
| 101 | 106 | @Path("/") |
|---|
| 102 | 107 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 103 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 108 | + @Produces({ |
|---|
| 109 | + MediaType.APPLICATION_JSON |
|---|
| 110 | + }) |
|---|
| 104 | 111 | @Transactional |
|---|
| 105 | 112 | public Response create(User user, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 106 | 113 | LOG.info("Creating new user"); |
|---|
| .. | .. |
|---|
| 126 | 133 | |
|---|
| 127 | 134 | private void setUserOrg(User user, Set<Integer> orgsIds, EntityManager em) throws SeCurisException { |
|---|
| 128 | 135 | Set<Organization> orgs = null; |
|---|
| 129 | | - if (orgsIds != null && orgsIds.size() > 0) { |
|---|
| 136 | + if (orgsIds != null && !orgsIds.isEmpty()) { |
|---|
| 130 | 137 | orgs = new HashSet<>(); |
|---|
| 131 | 138 | for (Integer orgId : orgsIds) { |
|---|
| 132 | 139 | Organization o = em.find(Organization.class, orgId); |
|---|
| .. | .. |
|---|
| 147 | 154 | @Path("/{uid}") |
|---|
| 148 | 155 | @Transactional |
|---|
| 149 | 156 | @Consumes(MediaType.APPLICATION_JSON) |
|---|
| 150 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 157 | + @Produces({ |
|---|
| 158 | + MediaType.APPLICATION_JSON |
|---|
| 159 | + }) |
|---|
| 151 | 160 | public Response modify(User user, @PathParam("uid") String uid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 152 | 161 | LOG.info("Modifying user with id: {}", uid); |
|---|
| 153 | 162 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 178 | 187 | @DELETE |
|---|
| 179 | 188 | @Path("/{uid}") |
|---|
| 180 | 189 | @Transactional |
|---|
| 181 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 190 | + @Produces({ |
|---|
| 191 | + MediaType.APPLICATION_JSON |
|---|
| 192 | + }) |
|---|
| 182 | 193 | public Response delete(@PathParam("uid") String uid, @Context HttpServletRequest request) { |
|---|
| 183 | 194 | LOG.info("Deleting app with id: {}", uid); |
|---|
| 184 | 195 | EntityManager em = emProvider.get(); |
|---|
| .. | .. |
|---|
| 194 | 205 | |
|---|
| 195 | 206 | @POST |
|---|
| 196 | 207 | @Path("/login") |
|---|
| 197 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 208 | + @Produces({ |
|---|
| 209 | + MediaType.APPLICATION_JSON |
|---|
| 210 | + }) |
|---|
| 198 | 211 | public Response login(@FormParam("username") String user, @FormParam("password") String password, @Context HttpServletRequest request) { |
|---|
| 199 | 212 | LOG.info("index session: " + request.getSession()); |
|---|
| 200 | 213 | LOG.info("user: {}, pass: {}", user, password); |
|---|
| .. | .. |
|---|
| 218 | 231 | */ |
|---|
| 219 | 232 | @POST |
|---|
| 220 | 233 | @Path("/check") |
|---|
| 221 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 234 | + @Produces({ |
|---|
| 235 | + MediaType.APPLICATION_JSON |
|---|
| 236 | + }) |
|---|
| 222 | 237 | public Response check(@HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token, @QueryParam("token") String token2) { |
|---|
| 223 | 238 | if (token == null) { |
|---|
| 224 | 239 | token = token2; |
|---|
| .. | .. |
|---|
| 241 | 256 | |
|---|
| 242 | 257 | @GET |
|---|
| 243 | 258 | @Path("/logout") |
|---|
| 244 | | - @Produces({ MediaType.APPLICATION_JSON }) |
|---|
| 259 | + @Produces({ |
|---|
| 260 | + MediaType.APPLICATION_JSON |
|---|
| 261 | + }) |
|---|
| 245 | 262 | public Response logout(@Context HttpServletRequest request) { |
|---|
| 246 | 263 | request.getSession().invalidate(); |
|---|
| 247 | 264 | return Response.ok().build(); |
|---|