protected String urlencode(Object id) {
      if (id == null)
        return "";
      else {
        try {
          return new URLCodec().encode(id.toString());
        } catch (EncoderException e) {
          return id.toString();
        }
      }
    }
URL encodes the id (string) value

@param id the id to URL encode
@return null if id is null, else the URL encoded value of the id
ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseResourceDefinition.java