Search in sources :

Example 61 with JsonParseException

use of org.codehaus.jackson.JsonParseException in project android-app by eoecn.

the class TopDao method mapperJson.

public List<Object> mapperJson(boolean useCache) {
    List<Object> topCategorys = new ArrayList<Object>();
    tabs.clear();
    try {
        String resultNews = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_NEWS_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
        NewsMoreResponse newsMoreResponse = mObjectMapper.readValue(resultNews, new TypeReference<NewsMoreResponse>() {
        });
        if (newsMoreResponse != null) {
            this.newsCategorys = newsMoreResponse.getResponse();
        }
        String resultBlogs = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_BLOG_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
        BlogsMoreResponse blogsMoreResponse = mObjectMapper.readValue(resultBlogs, new TypeReference<BlogsMoreResponse>() {
        });
        if (blogsMoreResponse != null) {
            this.blogsCategorys = blogsMoreResponse.getResponse();
        }
        String resultWiki = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_WIKI_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
        WikiMoreResponse wikiMoreResponse = mObjectMapper.readValue(resultWiki, new TypeReference<WikiMoreResponse>() {
        });
        if (wikiMoreResponse != null) {
            this.wikiCategorys = wikiMoreResponse.getResponse();
        }
        Collections.addAll(topCategorys, newsCategorys, blogsCategorys, wikiCategorys);
        return topCategorys;
    } catch (JsonParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) BlogsMoreResponse(cn.eoe.app.entity.BlogsMoreResponse) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) IOException(java.io.IOException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JsonParseException(org.codehaus.jackson.JsonParseException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) WikiMoreResponse(cn.eoe.app.entity.WikiMoreResponse) NewsMoreResponse(cn.eoe.app.entity.NewsMoreResponse)

Example 62 with JsonParseException

use of org.codehaus.jackson.JsonParseException in project gravel by gravel-st.

the class StringExtensions method parseAsJSONValue.

public static Map<String, Object> parseAsJSONValue(String src) {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode rootNode;
    try {
        rootNode = (ObjectNode) mapper.readValue(src, JsonNode.class);
    } catch (JsonParseException e) {
        throw new RuntimeException(e);
    } catch (JsonMappingException e) {
        throw new RuntimeException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    HashMap<String, Object> map = new HashMap<String, Object>();
    for (Iterator<Entry<String, JsonNode>> iter = rootNode.getFields(); iter.hasNext(); ) {
        Entry<String, JsonNode> field = iter.next();
        JsonNode value = field.getValue();
        Object o = jsonNodeAsSimpleObject(value);
        map.put(field.getKey(), o);
    }
    return map;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) HashMap(java.util.HashMap) JsonNode(org.codehaus.jackson.JsonNode) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) Entry(java.util.Map.Entry) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 63 with JsonParseException

use of org.codehaus.jackson.JsonParseException in project databus by linkedin.

the class ClusterCheckpointPersistenceProvider method getCheckpoint.

/**
 * internal function that fetches contents from Helix property store
 *
 * @param key
 * @return checkpoint or null
 */
private Checkpoint getCheckpoint(String key) {
    ZNRecord zn = _propertyStore.get(key, null, AccessOption.PERSISTENT);
    if (zn != null) {
        String v = zn.getSimpleField(KEY_CHECKPOINT);
        try {
            Checkpoint cp;
            cp = new Checkpoint(v);
            return cp;
        } catch (JsonParseException e) {
            LOG.error("Cannot deserialize value for key=" + key + " value=" + v + " exception=" + e);
        } catch (JsonMappingException e) {
            LOG.error("Cannot deserialize value for key=" + key + " value=" + v + " exception=" + e);
        } catch (IOException e) {
            LOG.error("Cannot deserialize value for key=" + key + " value=" + v + " exception=" + e);
        }
    } else {
        LOG.error("No record for key = " + key);
    }
    return null;
}
Also used : Checkpoint(com.linkedin.databus.core.Checkpoint) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) ZNRecord(org.apache.helix.ZNRecord)

Example 64 with JsonParseException

use of org.codehaus.jackson.JsonParseException in project databus by linkedin.

the class PhysicalSourceConfigBuilder method build.

@Override
public PhysicalSourceStaticConfig[] build() throws InvalidConfigException {
    ObjectMapper mapper = new ObjectMapper();
    PhysicalSourceStaticConfig[] list = new PhysicalSourceStaticConfig[null == _fileNames ? 0 : _fileNames.length];
    if (_fileNames == null)
        return list;
    for (int i = 0; i < _fileNames.length; ++i) {
        File sourceJson = _fileNames[i];
        PhysicalSourceConfig pConfig = null;
        Exception e = null;
        try {
            pConfig = mapper.readValue(sourceJson, PhysicalSourceConfig.class);
        } catch (JsonParseException jpe) {
            e = jpe;
        } catch (JsonMappingException jme) {
            e = jme;
        } catch (IOException ioe) {
            e = ioe;
        }
        if (e != null || pConfig == null) {
            throw new InvalidConfigException(e);
        }
        pConfig.checkForNulls();
        LOG.info("Generated Physical source config: name= " + pConfig.getId());
        list[i] = pConfig.build();
    }
    /*
    for(PhysicalSourceStaticConfig pCfg : pConfigs) {
      for(LogicalSourceStaticConfig lSC : pCfg.getSources()) {
        config.setSourceName("" + lSC.getId(), lSC.getName());
      }
    }
    */
    return list;
}
Also used : PhysicalSourceStaticConfig(com.linkedin.databus2.relay.config.PhysicalSourceStaticConfig) PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) File(java.io.File) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JsonParseException(org.codehaus.jackson.JsonParseException) IOException(java.io.IOException)

Example 65 with JsonParseException

use of org.codehaus.jackson.JsonParseException in project databus by linkedin.

the class DbusEventSerializable method getErrorEventFromDbusEvent.

public static DbusErrorEvent getErrorEventFromDbusEvent(DbusEventInternalReadable event) {
    if (!event.isErrorEvent()) {
        throw new RuntimeException("Event is expected to be an error event: " + event);
    }
    ByteBuffer valueBuffer = event.value();
    byte[] valueBytes = new byte[valueBuffer.limit()];
    valueBuffer.get(valueBytes);
    try {
        DbusErrorEvent errorEvent = DbusErrorEvent.createDbusErrorEvent(new String(valueBytes));
        return errorEvent;
    } catch (JsonParseException e) {
        throw new RuntimeException(e);
    } catch (JsonMappingException e) {
        throw new RuntimeException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) ByteBuffer(java.nio.ByteBuffer)

Aggregations

JsonParseException (org.codehaus.jackson.JsonParseException)68 IOException (java.io.IOException)59 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)56 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)30 ArrayList (java.util.ArrayList)19 HashMap (java.util.HashMap)9 TypeReference (org.codehaus.jackson.type.TypeReference)9 List (java.util.List)7 Map (java.util.Map)7 ClientResponse (com.sun.jersey.api.client.ClientResponse)5 CertificationChargingList (com.itrus.portal.entity.CertificationChargingList)3 CertificationChargingWrap (com.itrus.portal.entity.CertificationChargingWrap)3 ChargingPriceList (com.itrus.portal.entity.ChargingPriceList)3 ServiceNameList (com.itrus.portal.entity.ServiceNameList)3 JsonParser (org.codehaus.jackson.JsonParser)3 JSONArray (org.json.JSONArray)3 JSONException (org.json.JSONException)3 JSONObject (org.json.JSONObject)3 TransactionStatus (org.springframework.transaction.TransactionStatus)3 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)3