Example #1
0
 @Override
 public JsonValue asJson() {
   JsonObjectBuilder builder = JsonUtils.createObjectBuilder();
   JsonUtils.add(builder, NAME_PROPERTY, mName);
   JsonUtils.add(builder, EXPRESSION_PROPERTY, mExpression);
   JsonUtils.add(builder, VALUE_PROPERTY, mValue);
   return builder.build();
 }
Example #2
0
 @Override
 protected void addTurnProperties(JsonObjectBuilder builder) {
   JsonUtils.add(builder, SUBMIT_URI_PROPERTY, mUri);
   JsonUtils.add(builder, SUBMIT_METHOD_PROPERTY, mMethod.name());
   JsonUtils.add(builder, SUBMIT_PARAMETERS_PROPERTY, mSubmitParameters);
   JsonUtils.add(builder, SUBDIALOGUE_PARAMETERS_PROPERTY, JsonUtils.toJson(mParameters));
   JsonUtils.add(builder, FETCH_CONFIGURATION_PROPERTY, mFetchConfiguration);
   JsonUtils.add(builder, POST_DIALOGUE_SCRIPT_PROPERTY, getPostDialogueScript());
 }
Example #3
0
 public static void addTypedNode(ObjectNode node, String key, Object value) throws LeanException {
   if (value instanceof List) {
     List list = (List) value;
     ArrayNode arrayNode = JsonUtils.getObjectMapper().createArrayNode();
     for (Object listItem : list) {
       addTypedValueToArray(arrayNode, listItem);
     }
     node.put(key, arrayNode);
   } else {
     addTypedValue(node, key, value);
   }
 }
Example #4
0
 private OAuthAccessToken parseJsonToken(HttpMessage response) {
   com.google.gson.JsonObject root = new com.google.gson.JsonObject();
   com.google.gson.JsonParseException pe = null;
   try {
     root =
         (com.google.gson.JsonObject) new com.google.gson.JsonParser().parse(response.getBody());
   } catch (com.google.gson.JsonParseException error) {
     pe = error;
   }
   boolean ok = root != null;
   if (!ok) {
     logger.error(
         new StringWriter().append("parseJsonToken(): ").append(pe.toString()).toString());
     throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badjson"));
   } else {
     if (response.getStatus() == 200) {
       try {
         String accessToken = root.get("access_token").getAsString();
         int secs = JsonUtils.orIfNullInt(root.get("expires_in"), -1);
         WDate expires = null;
         if (secs > 0) {
           expires = new WDate(new Date()).addSeconds(secs);
         }
         String refreshToken = JsonUtils.orIfNullString(root.get("refreshToken"), "");
         return new OAuthAccessToken(accessToken, expires, refreshToken);
       } catch (RuntimeException e) {
         logger.error(
             new StringWriter().append("token response error: ").append(e.toString()).toString());
         throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
       }
     } else {
       throw new OAuthProcess.TokenError(
           WString.tr(
               "Wt.Auth.OAuthService."
                   + JsonUtils.orIfNullString(root.get("error"), "missing error")));
     }
   }
 }
 @Override
 public JsonValue asJson() {
   JsonObjectBuilder builder = JsonUtils.createObjectBuilder();
   JsonUtils.add(
       builder, ACKNOWLEDGE_AUDIO_ITEMS_PROPERTY, JsonUtils.toJson(mAcknowledgeAudioItems));
   JsonUtils.add(builder, DTMF_RECOGNITION_CONFIGURATION_PROPERTY, mDtmfRecognitionConfiguration);
   JsonUtils.add(
       builder, SPEECH_RECOGNITION_CONFIGURATION_PROPERTY, mSpeechRecognitionConfiguration);
   JsonUtils.addTimeProperty(builder, NO_INPUT_TIMEOUT_PROPERTY, mNoInputTimeout);
   return builder.build();
 }
Example #6
0
 private static ObjectNode getTextNode(Text text) {
   ObjectNode dateNode = JsonUtils.getObjectMapper().createObjectNode();
   dateNode.put("type", "text");
   dateNode.put("value", text.getValue());
   return dateNode;
 }
Example #7
0
 private static ObjectNode getDateNode(Date date) {
   ObjectNode dateNode = JsonUtils.getObjectMapper().createObjectNode();
   dateNode.put("type", "date");
   dateNode.put("value", date.getTime());
   return dateNode;
 }