support other content types in VTN Coordinator REST API 76/20076/4
authorbalakrishnan <balakrishnan.ka@hcl.com>
Wed, 13 May 2015 04:53:57 +0000 (10:23 +0530)
committerbalakrishnan k <balakrishnan.ka@hcl.com>
Wed, 13 May 2015 09:40:33 +0000 (09:40 +0000)
  *http requests with test/xml as content-type is allowed

Change-Id: I7ea6c3c9bfafcd643071f87e5d27d5141d2e2135
Signed-off-by: balakrishnan <balakrishnan.ka@hcl.com>
coordinator/java/vtn-webapi/src/org/opendaylight/vtn/webapi/enums/ContentTypeEnum.java
coordinator/java/vtn-webapi/src/org/opendaylight/vtn/webapi/utils/DataConverter.java
coordinator/java/vtn-webapi/src/org/opendaylight/vtn/webapi/utils/VtnServiceCommonUtil.java

index 20666d8cf3d547c292910d737bdcbfc7ad72c79d..26faf227be51039bbb011ab470ac287fbd1b7d73 100644 (file)
@@ -17,16 +17,17 @@ public enum ContentTypeEnum {
 
        /** The APPLICATIO n_ xml. */
        APPLICATION_XML("application/xml"),
-
+       APPLICATION_XML_SCVMM("text/xml"),
        /** The APPLICATIO n_ json. */
        APPLICATION_JSON("application/json");
 
+
        /** The content type. */
        private String contentType;
 
        /**
         * Instantiates a new content type enum.
-        * 
+        *
         * @param type
         *            the type
         */
@@ -36,7 +37,7 @@ public enum ContentTypeEnum {
 
        /**
         * Gets the content type.
-        * 
+        *
         * @return the content type
         */
        public String getContentType() {
index 7ad1060cf5c07c6a772108d1a583719e2e3c463f..266ec66ea8dcc247dd8c826fe6862cc70795e171 100644 (file)
@@ -67,6 +67,8 @@ public final class DataConverter {
                final JsonParser parser = new JsonParser();
                try {
                        if (ContentTypeEnum.APPLICATION_XML.getContentType().equals(
+                                       contentType) ||
+                                       ContentTypeEnum.APPLICATION_XML_SCVMM.getContentType().equals(
                                        contentType)) {
                                final Random random = new Random();
                                final String randomString = String.valueOf(random.nextInt());
@@ -190,6 +192,8 @@ public final class DataConverter {
                                responseString = responseJson.toString();
                                // conversion is required only for XML type response type
                                if (ContentTypeEnum.APPLICATION_XML.getContentType().equals(
+                                               requiredContentType) ||
+                                               ContentTypeEnum.APPLICATION_XML_SCVMM.getContentType().equals(
                                                requiredContentType)) {
                                        // modify the json object to remove null and empty nested
                                        // json and arrays
index 49993eacd06ecb0fe0b71e68c555356b35f555aa..8ac16af79bf6a2e1312b696ce0482883928c15f2 100644 (file)
@@ -296,6 +296,7 @@ public final class VtnServiceCommonUtil {
                                                ApplicationConstants.PUT_METHOD_NAME)) {
                        isMediaTypeCorrect = false;
                        String contentType = request.getContentType();
+                       LOG.debug("Media Type : " + contentType);
                        if (contentType != null) {
                                String content[] = contentType
                                                .split(ApplicationConstants.SEMI_COLON);
@@ -304,6 +305,8 @@ public final class VtnServiceCommonUtil {
                                                                .equalsIgnoreCase(ContentTypeEnum.APPLICATION_JSON
                                                                                .getContentType()) || content[0]
                                                                .equalsIgnoreCase(ContentTypeEnum.APPLICATION_XML
+                                                                               .getContentType()) || content[0]
+                                                               .equalsIgnoreCase(ContentTypeEnum.APPLICATION_XML_SCVMM
                                                                                .getContentType()))) {
                                        isMediaTypeCorrect = true;
                                }