This is an automated email from the ASF dual-hosted git repository.

mpapirkovskyy pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new a244d6a  AMBARI-23538. Not able to add a user in ambari. 
(mpapirkovskyy)
a244d6a is described below

commit a244d6af84340d038029405466f9c4e3c65f1afd
Author: Myroslav Papirkovskyi <mpapirkovs...@apache.org>
AuthorDate: Fri Apr 13 14:15:00 2018 +0300

    AMBARI-23538. Not able to add a user in ambari. (mpapirkovskyy)
---
 .../services/parsers/JsonRequestBodyParser.java    | 41 +---------------------
 1 file changed, 1 insertion(+), 40 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonRequestBodyParser.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonRequestBodyParser.java
index d64b590..d677251 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonRequestBodyParser.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonRequestBodyParser.java
@@ -32,8 +32,6 @@ import org.apache.ambari.server.api.services.NamedPropertySet;
 import org.apache.ambari.server.api.services.RequestBody;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.SerializableString;
-import org.codehaus.jackson.io.CharacterEscapes;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -49,10 +47,6 @@ public class JsonRequestBodyParser implements 
RequestBodyParser {
 
   private final static ObjectMapper mapper = new ObjectMapper();
 
-  static {
-    mapper.getJsonFactory().setCharacterEscapes(new AmbariEscapes());
-  }
-
   @Override
   public Set<RequestBody> parse(String body) throws BodyParseException {
 
@@ -166,9 +160,8 @@ public class JsonRequestBodyParser implements 
RequestBodyParser {
               path.substring(REQUEST_INFO_PATH.length() + SLASH.length()), 
name),
               value);
         } else {
-          String escapedName = AmbariEscapes.escapeValue(mapper, name);
           propertySet.getProperties().put(PropertyHelper.getPropertyId(
-              path.equals(BODY_TITLE) ? "" : path, escapedName), value);
+              path.equals(BODY_TITLE) ? "" : path, name), value);
         }
       }
     }
@@ -177,36 +170,4 @@ public class JsonRequestBodyParser implements 
RequestBodyParser {
   private String ensureArrayFormat(String s) {
     return s.startsWith("[") ? s : '[' + s + ']';
   }
-
-  static class AmbariEscapes extends CharacterEscapes {
-
-    private final int[] escapeCodesForAscii;
-
-    public AmbariEscapes() {
-      this.escapeCodesForAscii = standardAsciiEscapesForJSON();
-      escapeCodesForAscii['/'] = CharacterEscapes.ESCAPE_STANDARD;
-    }
-
-    @Override
-    public int[] getEscapeCodesForAscii() {
-      return escapeCodesForAscii;
-    }
-
-    @Override
-    public SerializableString getEscapeSequence(int ch) {
-      return null;
-    }
-
-    /**
-     * Converts string to escaped and removes first and last symbols (double 
brackets)
-     * @param mapper mapper
-     * @param value string to be escaped
-     * @return escaped string
-     * @throws IOException
-     */
-    private static String escapeValue(ObjectMapper mapper, String value) 
throws IOException {
-      String escapedString = mapper.writeValueAsString(value);
-      return escapedString.substring(1, escapedString.length() - 1);
-    }
-  }
 }

-- 
To stop receiving notification emails like this one, please contact
mpapirkovs...@apache.org.

Reply via email to