Roberto Sánchez
2014-09-19 071a008cf28e733ca3aaafa57e675fd54a5ea33b
securis/src/main/java/net/curisit/securis/services/UserResource.java
....@@ -33,8 +33,8 @@
3333 import net.curisit.securis.db.User;
3434 import net.curisit.securis.utils.TokenHelper;
3535
36
-import org.apache.logging.log4j.Logger;
3736 import org.apache.logging.log4j.LogManager;
37
+import org.apache.logging.log4j.Logger;
3838
3939 import com.google.inject.persist.Transactional;
4040
....@@ -54,7 +54,8 @@
5454
5555 private static final Logger LOG = LogManager.getLogger(UserResource.class);
5656
57
- public UserResource() {}
57
+ public UserResource() {
58
+ }
5859
5960 /**
6061 *
....@@ -62,7 +63,9 @@
6263 */
6364 @GET
6465 @Path("/")
65
- @Produces({ MediaType.APPLICATION_JSON })
66
+ @Produces({
67
+ MediaType.APPLICATION_JSON
68
+ })
6669 public Response index() {
6770 LOG.info("Getting users list ");
6871
....@@ -80,7 +83,9 @@
8083 */
8184 @GET
8285 @Path("/{uid}")
83
- @Produces({ MediaType.APPLICATION_JSON })
86
+ @Produces({
87
+ MediaType.APPLICATION_JSON
88
+ })
8489 public Response get(@PathParam("uid") String uid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
8590 LOG.info("Getting user data for id: {}: ", uid);
8691 if (uid == null || "".equals(uid)) {
....@@ -100,7 +105,9 @@
100105 @POST
101106 @Path("/")
102107 @Consumes(MediaType.APPLICATION_JSON)
103
- @Produces({ MediaType.APPLICATION_JSON })
108
+ @Produces({
109
+ MediaType.APPLICATION_JSON
110
+ })
104111 @Transactional
105112 public Response create(User user, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
106113 LOG.info("Creating new user");
....@@ -126,7 +133,7 @@
126133
127134 private void setUserOrg(User user, Set<Integer> orgsIds, EntityManager em) throws SeCurisException {
128135 Set<Organization> orgs = null;
129
- if (orgsIds != null && orgsIds.size() > 0) {
136
+ if (orgsIds != null && !orgsIds.isEmpty()) {
130137 orgs = new HashSet<>();
131138 for (Integer orgId : orgsIds) {
132139 Organization o = em.find(Organization.class, orgId);
....@@ -147,7 +154,9 @@
147154 @Path("/{uid}")
148155 @Transactional
149156 @Consumes(MediaType.APPLICATION_JSON)
150
- @Produces({ MediaType.APPLICATION_JSON })
157
+ @Produces({
158
+ MediaType.APPLICATION_JSON
159
+ })
151160 public Response modify(User user, @PathParam("uid") String uid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
152161 LOG.info("Modifying user with id: {}", uid);
153162 EntityManager em = emProvider.get();
....@@ -178,7 +187,9 @@
178187 @DELETE
179188 @Path("/{uid}")
180189 @Transactional
181
- @Produces({ MediaType.APPLICATION_JSON })
190
+ @Produces({
191
+ MediaType.APPLICATION_JSON
192
+ })
182193 public Response delete(@PathParam("uid") String uid, @Context HttpServletRequest request) {
183194 LOG.info("Deleting app with id: {}", uid);
184195 EntityManager em = emProvider.get();
....@@ -194,7 +205,9 @@
194205
195206 @POST
196207 @Path("/login")
197
- @Produces({ MediaType.APPLICATION_JSON })
208
+ @Produces({
209
+ MediaType.APPLICATION_JSON
210
+ })
198211 public Response login(@FormParam("username") String user, @FormParam("password") String password, @Context HttpServletRequest request) {
199212 LOG.info("index session: " + request.getSession());
200213 LOG.info("user: {}, pass: {}", user, password);
....@@ -218,7 +231,9 @@
218231 */
219232 @POST
220233 @Path("/check")
221
- @Produces({ MediaType.APPLICATION_JSON })
234
+ @Produces({
235
+ MediaType.APPLICATION_JSON
236
+ })
222237 public Response check(@HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token, @QueryParam("token") String token2) {
223238 if (token == null) {
224239 token = token2;
....@@ -241,7 +256,9 @@
241256
242257 @GET
243258 @Path("/logout")
244
- @Produces({ MediaType.APPLICATION_JSON })
259
+ @Produces({
260
+ MediaType.APPLICATION_JSON
261
+ })
245262 public Response logout(@Context HttpServletRequest request) {
246263 request.getSession().invalidate();
247264 return Response.ok().build();