Examples of JsonNode


Examples of org.codehaus.jackson.JsonNode

  protected BeanFactory beanFactory;

  public String getClassKey(LayerRequest layer) throws Exception {
    this.readConfigFile();
    SolrRecord record = layer.getLayerInfo();
    JsonNode institutions = this.configContents.path("institutions");
    if (!institutions.isArray()){
      try{
        return this.getDefaultDownloadKey(institutions, layer);
      } catch (Exception e){
        e.printStackTrace();
        logger.error("Class Key not defined for this layer.");
        throw new Exception("Class Key not defined for this layer.");
      }
    }
    ArrayNode jsonArray = (ArrayNode) institutions.path(record.getInstitution());
    Iterator<JsonNode> institutionIterator = jsonArray.getElements();
    String classKey = null;
    while (institutionIterator.hasNext()){
      JsonNode currentNode = institutionIterator.next();
      logger.debug("trying matches...");
      Boolean accessMatch = matchNode(currentNode, "accessLevel", record.getAccess().toLowerCase());
      if (!accessMatch){
        continue;
      }
      logger.debug("access match");
     

      Boolean dataTypeMatch = matchNode(currentNode, "dataType", getGeneralizedDataType(record.getDataType().toLowerCase()));
      if (!dataTypeMatch){
        continue;
      }
      logger.debug("data type match");
     
      Boolean outputFormatMatch = matchNode(currentNode, "outputFormats", layer.getRequestedFormat().toLowerCase());
      if (!outputFormatMatch){
        continue;
      }
      logger.debug("requested format match");
     
      classKey = currentNode.path("classKey").getTextValue();
      if (accessMatch && dataTypeMatch && outputFormatMatch){
        break;
      }
    }
    if (classKey == null){
View Full Code Here

Examples of org.codehaus.jackson.JsonNode

    return dataType;
  }
 
  private static Boolean matchNode(JsonNode parentNode, String path, String value){
    Boolean match = false;
    JsonNode matchNode = parentNode.path(path);
    if (matchNode.isArray()){
      ArrayNode arrayNode = (ArrayNode) matchNode;
      Iterator<JsonNode> iterator = arrayNode.iterator();
      while (iterator.hasNext()){
        JsonNode currentNode = iterator.next();
        slogger.debug("node value:" + currentNode.getTextValue());
        if (currentNode.getTextValue().equalsIgnoreCase(value.trim())){
          match = true;
        }
      }
    } else if (matchNode.isTextual()){
      slogger.debug("text node");
View Full Code Here

Examples of org.codehaus.jackson.JsonNode

    return hasInfo;
  }
 
  private String getDefaultDownloadKey(JsonNode institutions, LayerRequest layer) throws Exception{
    logger.info("Trying default method...");
    JsonNode defaultNode = institutions.path("default");
    if (!defaultNode.isArray()){
      throw new Exception("No default defined!");
    }
    ArrayNode jsonArray = (ArrayNode) defaultNode;
    Iterator<JsonNode> iterator = jsonArray.getElements();
    SortedMap<Integer, String> classKeys = new TreeMap<Integer, String>();
    while (iterator.hasNext()){
      JsonNode currentNode = iterator.next();
      Boolean outputFormatMatch = matchNode(currentNode, "outputFormats", layer.getRequestedFormat().toLowerCase());
      if (outputFormatMatch){
        String classKey = currentNode.path("classKey").getTextValue();
        Integer preference = currentNode.path("preference").getIntValue();
        logger.debug("Matched classKey: " + classKey);
        if (hasRequirements(classKey, layer)){
          logger.debug("requirements met: " + classKey);
          classKeys.put(preference, classKey);
        } else {
View Full Code Here

Examples of org.codehaus.jackson.JsonNode

   * @throws IOException
   */
  public void readConfigFile() throws IOException{
    if (configContents == null){
      ObjectMapper mapper = new ObjectMapper();
      JsonNode rootNode = mapper.readValue(this.loadConfigFile(), JsonNode.class);     
      JsonNode jsonResponse = rootNode.path("config");
      this.configContents = jsonResponse;
    }
  }
View Full Code Here

Examples of org.codehaus.jackson.JsonNode

        assertResultOK(proxy);

        ObjectNode obj = getJSON(proxy);
        assertThat(obj.get("totalTicketCount").asInt(), is(20));

        JsonNode array = obj.get("ticketStatuses");
        assertThat(array.size(), is(10));
        for (int i = 0; i < 10; ++i) {
            assertThat(array.get(i).get("ticket").get("id").asText(), is(ids.get(i).getFirst().toString()));
            assertThat(array.get(i).get("status").asText(), is("enrolled"));
        }
    }
View Full Code Here

Examples of org.codehaus.jackson.JsonNode

        assertResultOK(proxy);

        ObjectNode obj = getJSON(proxy);
        assertThat(obj.get("totalEventCount").asInt(), is(N));
        assertThat(obj.get("eventStatuses"), is(not(nullValue())));
        JsonNode array = obj.get("eventStatuses");
        assertThat(array.size(), is(10));
        for (int i = 0; i < array.size(); ++i) {
            JsonNode eventStatus = array.get(i);
            JsonNode event = eventStatus.get("event");
            assertThat(event.get("id").asText(), is(ids.get(N - i - 1)));
        }
    }
View Full Code Here

Examples of org.codehaus.jackson.JsonNode

        assertResultOK(proxy);

        ObjectNode obj = getJSON(proxy);
        assertThat(obj.get("totalEventCount").asInt(), is(N));
        assertThat(obj.get("eventStatuses"), is(not(nullValue())));
        JsonNode array = obj.get("eventStatuses");
        assertThat(array.size(), is(10));
        for (int i = 0; i < array.size(); ++i) {
            JsonNode eventStatus = array.get(i);
            JsonNode event = eventStatus.get("event");
            assertThat(event.get("id").asText(), is(ids.get(N - i - 1)));
        }
    }
View Full Code Here

Examples of org.codehaus.jackson.JsonNode

        assertThat(obj.get("id").asText(), is(TestDataProvider.DEFAULT_USER_ID));

        // TODO: Checks Twitter?

        // Checks UserPreference.
        JsonNode prefObj = obj.get("preference");
        UserPreference pref = UserPreference.getDefaultPreference(TestDataProvider.DEFAULT_USER_ID);
        Assert.assertEquals(pref.isProfilePublic(), prefObj.get("profilePublic").asBoolean());
        Assert.assertEquals(pref.isReceivingTwitterMessage(), prefObj.get("receivingTwitterMessage").asBoolean());
        Assert.assertEquals(pref.tweetsAttendanceAutomatically(), prefObj.get("tweetingAttendanceAutomatically").asBoolean());

        // Checks OpenIds
        JsonNode array = obj.get("openIds");
        List<String> openIds = new ArrayList<String>();
        for (int i = 0; i < array.size(); ++i)
            openIds.add(array.get(i).get("identifier").asText());

        assertThat(openIds, hasItem(TestDataProvider.DEFAULT_USER_OPENID_IDENTIFIER));
        assertThat(openIds, hasItem(TestDataProvider.DEFAULT_USER_OPENID_ALTERNATIVE_IDENTIFIER));
    }
View Full Code Here

Examples of org.codehaus.jackson.JsonNode

        ObjectNode obj = getJSON(proxy);
        assertThat(obj.get("result").asText(), is("invalid"));
        assertThat(obj.get("reason").asText(), is(ec.getReasonString()));

        JsonNode additionalObj = obj.get("additional");
        assertThat(additionalObj.has(additional), is(true));
    }
View Full Code Here

Examples of org.codehaus.jackson.JsonNode

        assertThat(obj.get("id").asText(), is(DEFAULT_USER_ID));
        // These values should not be public.
        assertThat(obj.get("twitterId"), is(nullValue()));
        assertThat(obj.get("lastLoginAt"), is(nullValue()));
        assertThat(obj.get("calendarId"), is(nullValue()));
        JsonNode twitter = obj.get("twitter");
        assertThat(twitter, is(notNullValue()));
        assertThat(twitter.get("screenName").asText(), is(DEFAULT_TWITTER_SCREENNAME));
        assertThat(twitter.get("profileImageURL").asText(), is("http://www.example.com/"));
        // These values should not be public.
        assertThat(twitter.get("accessToken"), is(nullValue()));
        assertThat(twitter.get("accessTokenSecret"), is(nullValue()));

        // We don't expose OpenID Linkage.
        assertThat(obj.get("openIDLinakge"), is(nullValue()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.