Example usage for com.fasterxml.jackson.core JsonProcessingException printStackTrace

List of usage examples for com.fasterxml.jackson.core JsonProcessingException printStackTrace

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonProcessingException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.skubit.android.transactions.TransactionsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.wallet_transactions_fragment, null);
    TextView balanceLabel = (TextView) view.findViewById(R.id.wallet_balance_label);
    balanceLabel.setTypeface(FontManager.CONDENSED_REGULAR);

    mBalance = (TextView) view.findViewById(R.id.wallet_balance);

    ListView list = (ListView) view.findViewById(R.id.list);
    list.setAdapter(mAdapter);//from   w w  w .  j a  va  2 s . c  o  m

    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapter, View arg1, int position, long arg3) {
            TransactionDto transactionDto = (TransactionDto) adapter.getItemAtPosition(position);
            ObjectMapper mapper = new ObjectMapper();
            String value;
            try {
                value = mapper.writeValueAsString(transactionDto);
                startActivity(TransactionDetailsActivity.newIntent(value, getActivity().getPackageName()));
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
        }

    });

    return view;
}

From source file:com.flipkart.ranger.model.ServiceProviderExtCuratorTest.java

private void registerService(String host, int port, int shardId) throws Exception {
    final ServiceProvider<TestShardInfo> serviceProvider = ServiceProviderBuilders
            .<TestShardInfo>shardedServiceProviderBuilder().withCuratorFramework(curatorFramework)
            .withNamespace("test").withServiceName("test-service")
            .withSerializer(new Serializer<TestShardInfo>() {
                @Override//from   ww w  .  ja va2  s  .  c o  m
                public byte[] serialize(ServiceNode<TestShardInfo> data) {
                    try {
                        return objectMapper.writeValueAsBytes(data);
                    } catch (JsonProcessingException e) {
                        e.printStackTrace();
                    }
                    return null;
                }
            }).withHostname(host).withPort(port).withNodeData(new TestShardInfo(shardId))
            .withHealthcheck(new Healthcheck() {
                @Override
                public HealthcheckStatus check() {
                    return HealthcheckStatus.healthy;
                }
            }).buildServiceDiscovery();
    serviceProvider.start();
    serviceProviders.add(serviceProvider);
}

From source file:org.o3project.ocnrm.lib.flow.AbstractFlowCreator.java

public List<String> createFlow(OptFlow optFlow, RmData data, String seqNo) {
    logger.info(seqNo + "\t" + "createFlow() Start");

    JSONParser jsonParse = new JSONParser();
    JSONArray jsonArrayFlow = new JSONArray();
    try {/*from ww  w  .  ja va 2s  . c  om*/
        List<FlowData> flowList = new ArrayList<>();
        for (TerminationPoints point : optFlow.getTerminationPointPairs()) {
            logger.debug(seqNo + "\t" + "target termination point : " + point.toString());

            FlowData flowData = new FlowData();

            MappingData srcMappingData = data.getBindMap().get(point.getInPoint());
            if (srcMappingData.getDpid() == null) {
                logger.error("dpid is empty.");
            } else {
                flowData.setDpid(srcMappingData.getDpid());
            }

            flowData.setMatch(makeMatch(data, point));

            flowData.setActions(makeActions(data, point));

            flowList.add(flowData);
        }
        jsonArrayFlow = new JSONArray(jsonParse.convertToJson(flowList, seqNo));

        logger.info(seqNo + "\t" + "createFlow() End");
        return removeDoubleQuotes(jsonParse.convertToList(jsonArrayFlow, seqNo));
    } catch (JsonProcessingException e) {
        logger.error(seqNo + "\t" + "JsonProcessingException occured.");
        e.printStackTrace();
        List<String> list = new ArrayList<>();
        return list;
    } catch (JSONException e) {
        logger.error(seqNo + "\t" + "JSONException occured.");
        e.printStackTrace();
        List<String> list = new ArrayList<>();
        return list;
    }
}

From source file:org.n52.tamis.core.test.serialize.ExecuteInputSerializer_Test.java

@Test
public void testReferenceInputSerialization() {

    try {//from   w  ww.  j av a  2s .  c  om
        String sosJsonOutput = mapper.writeValueAsString(sosInput);

        JsonNode parsedJsonReference = mapper.readTree(sosJsonOutput);
        JsonNode sosNode = parsedJsonReference.get("Data");

        /*
         * the expected structure of the parsed JSON node looks like:
         * 
         *  {
                "Data": {
                    "_text": "http://fluggs.wupperverband.de/sos2/service?service=SOS&request=GetObservation&version=2.0.0&offering=Zeitreihen_2m_Tiefe&observedProperty=Grundwasserstand&responseFormat=http%3A//www.opengis.net/om/2.0"
                },
                "_id": "gw1"
            }
                
         */

        Assert.assertTrue(sosNode.has("_text"));
        Assert.assertTrue(parsedJsonReference.has("_id"));

        Assert.assertEquals(
                "http://fluggs.wupperverband.de/sos2/service?service=SOS&request=GetObservation&version=2.0.0&offering=Zeitreihen_2m_Tiefe&observedProperty=Grundwasserstand&responseFormat=http%3A//www.opengis.net/om/2.0",
                sosNode.get("_text").asText());
        Assert.assertEquals("sosInputID", parsedJsonReference.get("_id").asText());
    } catch (JsonProcessingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.apache.drill.exec.store.mpjdbc.MPJdbcFormatPlugin.java

public MPJdbcFormatPlugin(MPJdbcFormatConfig storageConfig, DrillbitContext context, String name) {
    this.context = context;
    this.storageConfig = storageConfig;
    ObjectMapper mapper = new ObjectMapper();
    try {/*from   w ww  .j  av a2s. c  o  m*/
        String result = mapper.writeValueAsString(storageConfig);
        logger.info(result);
    } catch (JsonProcessingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    this.name = name;
}

From source file:org.venice.piazza.servicecontroller.messaging.handlers.DescribeServiceHandlerTest.java

/**
 * Test that the service metadata could not be retrieved 
 * due to a marshalling error/* w  w w . j a  v  a2s .  c  o  m*/
 */
@Test
public void testUnSuccessDescribeServiceException() {
    String testServiceId = "a842aae2-bd74-4c4b-9a65-c45e8cd9060";
    ResponseEntity<String> responseEntity = new ResponseEntity<String>("null", HttpStatus.OK);
    try {
        Mockito.when(omMock.writeValueAsString(Mockito.anyString())).thenThrow(new JsonProcessingException("") {
        });
    } catch (JsonProcessingException jpe) {
        jpe.printStackTrace();
    }
    ResponseEntity<String> result = dsHandler.handle(testServiceId);

    assertEquals("The response entity was correct for this describe request", responseEntity, result);
    assertEquals("The response code is 200", responseEntity.getStatusCode(), HttpStatus.OK);
    assertEquals("The body of the response is correct", responseEntity.getBody(), "null");

}

From source file:com.flipkart.ranger.model.CustomShardSelectorTest.java

private void registerService(String host, int port, int a, int b) throws Exception {
    final ServiceProvider<TestShardInfo> serviceProvider = ServiceProviderBuilders
            .<TestShardInfo>shardedServiceProviderBuilder()
            .withConnectionString(testingCluster.getConnectString()).withNamespace("test")
            .withServiceName("test-service").withSerializer(new Serializer<TestShardInfo>() {
                @Override//www  .j  a  v a2 s  . c  om
                public byte[] serialize(ServiceNode<TestShardInfo> data) {
                    try {
                        return objectMapper.writeValueAsBytes(data);
                    } catch (JsonProcessingException e) {
                        e.printStackTrace();
                    }
                    return null;
                }
            }).withHostname(host).withPort(port).withNodeData(new TestShardInfo(a, b))
            .withHealthcheck(new Healthcheck() {
                @Override
                public HealthcheckStatus check() {
                    return HealthcheckStatus.healthy;
                }
            }).buildServiceDiscovery();
    serviceProvider.start();
    serviceProviders.add(serviceProvider);
}

From source file:org.venice.piazza.servicecontroller.messaging.handlers.DescribeServiceHandlerTest.java

/**
 * Test that the service metadata can be retrieved.
 *//*w  w  w.ja  v a2s  .c  o m*/
@Test
public void testSuccessDescribeService() {
    String testServiceId = "a842aae2-bd74-4c4b-9a65-c45e8cd9060";
    try {
        ObjectMapper mapper = new ObjectMapper();
        String responseServiceString = mapper.writeValueAsString(service);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(responseServiceString,
                HttpStatus.OK);

        Mockito.doReturn(service).when(accessorMock).getServiceById(testServiceId);
        ResponseEntity<String> result = dsHandler.handle(testServiceId);

        assertEquals("The response entity was correct for this describe request", responseEntity, result);
        assertEquals("The response code is 200", responseEntity.getStatusCode(), HttpStatus.OK);
        assertEquals("The body of the response is correct", responseEntity.getBody(), responseServiceString);

    } catch (JsonProcessingException jpe) {
        jpe.printStackTrace();
    }

}

From source file:net.sf.smbt.ui.btc.views.AbstractBlockchainView.java

public AbstractBlockchainView() {
    blockchainEngine = QuanticMojo.INSTANCE.createHttpPipe("blockchain", "http://blockchain.info");
    blockchainEngine.addQxEventHandler(new AbstractQxEventHandlerImpl() {
        public synchronized void handleQxEvent(net.sf.xqz.model.engine.Event event) {
            if (event.getKind().equals(EVENT_KIND.RX_DONE)) {
                Cmd cmd = event.getCmd();
                if (cmd instanceof BlockchainCmd) {
                    BlockchainCmd btcCmd = (BlockchainCmd) cmd;
                    final String jsonRcv = btcCmd.getJsonRcv();
                    //System.out.println(jsonRcv);
                    new UbiJob("refresh text") {
                        @Override
                        public IStatus runInUIThread(IProgressMonitor monitor) {
                            Object obj;
                            try {
                                obj = new ObjectMapper().readTree(jsonRcv);
                                XYSeries serie = BlockChainUiUtils.INSTANCE.createSeriesFromJson("serie",
                                        (JsonNode) obj);
                                final XYSeriesCollection dataset = new XYSeriesCollection();
                                dataset.addSeries(serie);
                                chart.getXYPlot().setDataset(dataset);
                            } catch (JsonProcessingException e) {
                                e.printStackTrace();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }/*from   w w w  .j  av  a  2  s.  c o m*/
                            return Status.OK_STATUS;
                        }
                    }.schedule();
                }
            }
        };
    });
    blockchainEngine.setLocked(true);
    refreshJob = new RefreshJob();
    refreshJob.schedule();
}

From source file:edu.usc.ir.visualization.NLTKandCoreNLP.java

private void countNER(String memexUrl, String username, String password)
        throws JsonParseException, JsonMappingException, IOException {

    JsonNode node;//from  w  w w  .  ja  v a  2s .  co  m
    JsonNode dataset = null;
    String url;
    String response;

    for (int c = 0; c < 101; c += 100) {

        url = memexUrl + "/select?q=gunsamerica&start=" + c
                + "&rows=100&fl=content%2Corganizations%2Cpersons%2Cdates%2Clocations&wt=json&indent=true";
        response = WebClient.create(url, username, password, null).accept(MediaType.APPLICATION_JSON).get()
                .readEntity(String.class);

        try {
            node = mapper.readTree(response);
            dataset = node.get("response").get("docs");
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        Iterator<JsonNode> datasetElements = dataset.iterator();

        while (datasetElements.hasNext()) {
            datasetElement = datasetElements.next();
            String content = datasetElement.get("content").asText();
            md = new Metadata();
            try (InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) {
                tika.parse(stream, md);
            } catch (IOException e) {
                e.printStackTrace();
            }

            if (datasetElement.has("locations")) {
                extract("locations");
            }

            if (datasetElement.has("dates")) {
                extract("organizations");
            }

            if (datasetElement.has("organizations")) {
                extract("organizations");
            }

            if (datasetElement.has("persons")) {
                extract("persons");
            }

            if (md.getValues("NER_NAMES").length > 0) {
                for (String ner_name : Arrays.asList(md.getValues("NER_NAMES"))) {
                    if (!freq.contains(ner_name)) {
                        freq.add(ner_name);
                    }
                    if (nltk.containsKey(ner_name)) {
                        nltk.put(ner_name, nltk.get(ner_name) + 1);
                    } else {
                        nltk.put(ner_name, 1);
                    }
                }
            }
        }
    }
}