Use MediaType.APPLICATION_JSON 81/101681/14
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 1 Jul 2022 13:38:10 +0000 (15:38 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 1 Jul 2022 17:27:19 +0000 (19:27 +0200)
We have a number of repetitions of application/json -- use the JAX-RS
constant for that.

Change-Id: I672440b10ec1ee181240b85ac4fd6d91ac9c6121
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/idm/DomainHandler.java
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/idm/RoleHandler.java
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/idm/UserHandler.java

index 470195151457b3c8ef22c895b06a4d7291f71188..273da12fda4f59ba8e3a8ee35c8571707d582bae 100644 (file)
@@ -19,6 +19,7 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.aaa.api.ClaimCache;
@@ -65,7 +66,7 @@ public class DomainHandler {
      * @return a response with all domains stored in the H2 database
      */
     @GET
-    @Produces("application/json")
+    @Produces(MediaType.APPLICATION_JSON)
     public Response getDomains() {
         LOG.info("Get /domains");
         final Domains domains;
@@ -90,7 +91,7 @@ public class DomainHandler {
      */
     @GET
     @Path("/{id}")
-    @Produces("application/json")
+    @Produces(MediaType.APPLICATION_JSON)
     public Response getDomain(@PathParam("id") final String domainId) {
         LOG.info("Get /domains/{}", domainId);
         final Domain domain;
@@ -125,8 +126,8 @@ public class DomainHandler {
      * @return A response stating success or failure of domain creation.
      */
     @POST
-    @Consumes("application/json")
-    @Produces("application/json")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
     public Response createDomain(@Context final UriInfo info, final Domain domain) {
         LOG.info("Post /domains");
 
@@ -174,8 +175,8 @@ public class DomainHandler {
      */
     @PUT
     @Path("/{id}")
-    @Consumes("application/json")
-    @Produces("application/json")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
     public Response putDomain(@Context final UriInfo info, final Domain domain,
             @PathParam("id") final String domainId) {
         LOG.info("Put /domains/{}", domainId);
@@ -253,8 +254,8 @@ public class DomainHandler {
      */
     @POST
     @Path("/{did}/users/{uid}/roles")
-    @Consumes("application/json")
-    @Produces("application/json")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
     public Response createGrant(@Context final UriInfo info, @PathParam("did") final String domainId,
             @PathParam("uid") final String userId, final Grant grant) {
         LOG.info("Post /domains/{}/users/{}/roles", domainId, userId);
@@ -376,8 +377,8 @@ public class DomainHandler {
      */
     @POST
     @Path("/{did}/users/roles")
-    @Consumes("application/json")
-    @Produces("application/json")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
     public Response validateUser(@Context final UriInfo info, @PathParam("did") final String domainId,
             final UserPwd userpwd) {
         LOG.info("GET /domains/{}/users", domainId);
@@ -475,7 +476,7 @@ public class DomainHandler {
      */
     @GET
     @Path("/{did}/users/{uid}/roles")
-    @Produces("application/json")
+    @Produces(MediaType.APPLICATION_JSON)
     public Response getRoles(@Context final UriInfo info, @PathParam("did") final String domainId,
             @PathParam("uid") final String userId) {
         LOG.info("GET /domains/{}/users/{}/roles", domainId, userId);
index 871f33e3bd7820dfc03fba088058055898355b0f..81b6cbd36c6c75c24490b70e69a62f06079e32f7 100644 (file)
@@ -16,6 +16,7 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.aaa.api.ClaimCache;
@@ -56,7 +57,7 @@ public class RoleHandler {
      *         if one is encountered
      */
     @GET
-    @Produces("application/json")
+    @Produces(MediaType.APPLICATION_JSON)
     public Response getRoles() {
         LOG.info("get /roles");
         final Roles roles;
@@ -79,7 +80,7 @@ public class RoleHandler {
      */
     @GET
     @Path("/{id}")
-    @Produces("application/json")
+    @Produces(MediaType.APPLICATION_JSON)
     public Response getRole(@PathParam("id") final String id) {
         LOG.info("get /roles/{}", id);
 
@@ -108,8 +109,8 @@ public class RoleHandler {
      *         internal error if one is encountered
      */
     @POST
-    @Consumes("application/json")
-    @Produces("application/json")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
     public Response createRole(@Context final UriInfo info, final Role role) {
         LOG.info("Post /roles");
 
@@ -169,8 +170,8 @@ public class RoleHandler {
      */
     @PUT
     @Path("/{id}")
-    @Consumes("application/json")
-    @Produces("application/json")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
     public Response putRole(@Context final UriInfo info, final Role role, @PathParam("id") final String id) {
         LOG.info("put /roles/{}", id);
 
index a1c17371eb782e7e0d1a959d798529339978c764..5c6bf6b27312dd8bdce64094b7412ce7f2c5a013 100644 (file)
@@ -16,6 +16,7 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.aaa.api.ClaimCache;
@@ -54,7 +55,7 @@ public class UserHandler {
      * @return A response containing the users, or internal error if one occurs
      */
     @GET
-    @Produces("application/json")
+    @Produces(MediaType.APPLICATION_JSON)
     public Response getUsers() {
         LOG.info("GET /auth/v1/users  (extracts all users)");
 
@@ -82,7 +83,7 @@ public class UserHandler {
      */
     @GET
     @Path("/{id}")
-    @Produces("application/json")
+    @Produces(MediaType.APPLICATION_JSON)
     public Response getUser(@PathParam("id") final String id) {
         LOG.info("GET auth/v1/users/ {}  (extract user with specified id)", id);
 
@@ -123,8 +124,8 @@ public class UserHandler {
      * @return A response stating success or failure of user creation
      */
     @POST
-    @Consumes("application/json")
-    @Produces("application/json")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
     public Response createUser(@Context final UriInfo info, final User user) {
         LOG.info("POST /auth/v1/users  (create a user with the specified payload");
 
@@ -217,8 +218,8 @@ public class UserHandler {
      */
     @PUT
     @Path("/{id}")
-    @Consumes("application/json")
-    @Produces("application/json")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
     public Response putUser(@Context final UriInfo info, final User user, @PathParam("id") final String id) {
         LOG.info("PUT /auth/v1/users/{}  (Updates a user account)", id);