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

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

Introduction

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

Prototype

@Override
public String getMessage() 

Source Link

Document

Default method overridden so that we can add location information

Usage

From source file:com.liferay.nativity.test.TestDriver.java

public static void main(String[] args) {
    _intitializeLogging();//from  w w w  .j  ava 2  s . c o  m

    List<String> items = new ArrayList<String>();

    items.add("ONE");

    NativityMessage message = new NativityMessage("BLAH", items);

    try {
        _logger.debug(_objectMapper.writeValueAsString(message));
    } catch (JsonProcessingException jpe) {
        _logger.error(jpe.getMessage(), jpe);
    }

    _logger.debug("main");

    NativityControl nativityControl = NativityControlUtil.getNativityControl();

    FileIconControl fileIconControl = FileIconControlUtil.getFileIconControl(nativityControl,
            new TestFileIconControlCallback());

    ContextMenuControlUtil.getContextMenuControl(nativityControl, new TestContextMenuControlCallback());

    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

    nativityControl.connect();

    String read = "";
    boolean stop = false;

    try {
        while (!stop) {
            _list = !_list;

            _logger.debug("Loop start...");

            _logger.debug("_enableFileIcons");
            _enableFileIcons(fileIconControl);

            _logger.debug("_registerFileIcon");
            _registerFileIcon(fileIconControl);

            _logger.debug("_setFilterPath");
            _setFilterPath(nativityControl);

            _logger.debug("_setSystemFolder");
            _setSystemFolder(nativityControl);

            _logger.debug("_updateFileIcon");
            _updateFileIcon(fileIconControl);

            _logger.debug("_clearFileIcon");
            _clearFileIcon(fileIconControl);

            _logger.debug("Ready?");

            if (bufferedReader.ready()) {
                _logger.debug("Reading...");

                read = bufferedReader.readLine();

                _logger.debug("Read {}", read);

                if (read.length() > 0) {
                    stop = true;
                }

                _logger.debug("Stopping {}", stop);
            }
        }
    } catch (IOException e) {
        _logger.error(e.getMessage(), e);
    }

    _logger.debug("Done");
}

From source file:org.apache.streams.sysomos.provider.SysomosProvider.java

/**
 * To use from command line:/*from ww w .  j a  v a  2 s .  c  om*/
 * <p/>
 * Supply configuration similar to src/test/resources/rss.conf
 * <p/>
 * Launch using:
 * <p/>
 * mvn exec:java -Dexec.mainClass=org.apache.streams.rss.provider.RssStreamProvider -Dexec.args="rss.conf articles.json"
 * @param args args
 * @throws Exception Exception
 */
public static void main(String[] args) throws Exception {

    Preconditions.checkArgument(args.length >= 2);

    String configfile = args[0];
    String outfile = args[1];

    Config reference = ConfigFactory.load();
    File file = new File(configfile);
    assert (file.exists());
    Config testResourceConfig = ConfigFactory.parseFileAnySyntax(file,
            ConfigParseOptions.defaults().setAllowMissing(false));

    Config typesafe = testResourceConfig.withFallback(reference).resolve();

    StreamsConfiguration streamsConfiguration = StreamsConfigurator.detectConfiguration(typesafe);
    SysomosConfiguration config = new ComponentConfigurator<>(SysomosConfiguration.class)
            .detectConfiguration(typesafe, "rss");
    SysomosProvider provider = new SysomosProvider(config);

    ObjectMapper mapper = StreamsJacksonMapper.getInstance();

    PrintStream outStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(outfile)));
    provider.prepare(config);
    provider.startStream();
    do {
        Uninterruptibles.sleepUninterruptibly(streamsConfiguration.getBatchFrequencyMs(),
                TimeUnit.MILLISECONDS);
        for (StreamsDatum datum : provider.readCurrent()) {
            String json;
            try {
                json = mapper.writeValueAsString(datum.getDocument());
                outStream.println(json);
            } catch (JsonProcessingException ex) {
                System.err.println(ex.getMessage());
            }
        }
    } while (provider.isRunning());
    provider.cleanUp();
    outStream.flush();
}

From source file:org.apache.streams.twitter.provider.TwitterTimelineProvider.java

/**
 * To use from command line://  w w w  . jav a  2 s. com
 *
 * <p/>
 * Supply (at least) the following required configuration in application.conf:
 *
 * <p/>
 * twitter.oauth.consumerKey
 * twitter.oauth.consumerSecret
 * twitter.oauth.accessToken
 * twitter.oauth.accessTokenSecret
 * twitter.info
 *
 * <p/>
 * Launch using:
 *
 * <p/>
 * mvn exec:java -Dexec.mainClass=org.apache.streams.twitter.provider.TwitterTimelineProvider -Dexec.args="application.conf tweets.json"
 *
 * @param args args
 * @throws Exception Exception
 */
public static void main(String[] args) throws Exception {

    Preconditions.checkArgument(args.length >= 2);

    String configfile = args[0];
    String outfile = args[1];

    Config reference = ConfigFactory.load();
    File file = new File(configfile);
    assert (file.exists());
    Config testResourceConfig = ConfigFactory.parseFileAnySyntax(file,
            ConfigParseOptions.defaults().setAllowMissing(false));

    Config typesafe = testResourceConfig.withFallback(reference).resolve();

    StreamsConfiguration streamsConfiguration = StreamsConfigurator.detectConfiguration(typesafe);
    TwitterTimelineProviderConfiguration config = new ComponentConfigurator<>(
            TwitterTimelineProviderConfiguration.class).detectConfiguration(typesafe, "twitter");
    TwitterTimelineProvider provider = new TwitterTimelineProvider(config);

    ObjectMapper mapper = new StreamsJacksonMapper(
            Stream.of(TwitterDateTimeFormat.TWITTER_FORMAT).collect(Collectors.toList()));

    PrintStream outStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(outfile)));
    provider.prepare(config);
    provider.startStream();
    do {
        Uninterruptibles.sleepUninterruptibly(streamsConfiguration.getBatchFrequencyMs(),
                TimeUnit.MILLISECONDS);
        for (StreamsDatum datum : provider.readCurrent()) {
            String json;
            try {
                json = mapper.writeValueAsString(datum.getDocument());
                outStream.println(json);
            } catch (JsonProcessingException ex) {
                System.err.println(ex.getMessage());
            }
        }
    } while (provider.isRunning());
    provider.cleanUp();
    outStream.flush();
}

From source file:org.apache.streams.twitter.provider.TwitterUserInformationProvider.java

/**
 * To use from command line:/*from w w  w.j  a  v  a 2 s . co m*/
 *
 * <p/>
 * Supply (at least) the following required configuration in application.conf:
 *
 * <p/>
 * twitter.oauth.consumerKey
 * twitter.oauth.consumerSecret
 * twitter.oauth.accessToken
 * twitter.oauth.accessTokenSecret
 * twitter.info
 *
 * <p/>
 * Launch using:
 *
 * <p/>
 * mvn exec:java -Dexec.mainClass=org.apache.streams.twitter.provider.TwitterUserInformationProvider -Dexec.args="application.conf tweets.json"
 *
 * @param args args
 * @throws Exception Exception
 */
public static void main(String[] args) throws Exception {

    Preconditions.checkArgument(args.length >= 2);

    String configfile = args[0];
    String outfile = args[1];

    Config reference = ConfigFactory.load();
    File file = new File(configfile);
    assert (file.exists());
    Config testResourceConfig = ConfigFactory.parseFileAnySyntax(file,
            ConfigParseOptions.defaults().setAllowMissing(false));

    Config typesafe = testResourceConfig.withFallback(reference).resolve();

    StreamsConfiguration streamsConfiguration = StreamsConfigurator.detectConfiguration(typesafe);
    TwitterUserInformationConfiguration config = new ComponentConfigurator<>(
            TwitterUserInformationConfiguration.class).detectConfiguration(typesafe, "twitter");
    TwitterUserInformationProvider provider = new TwitterUserInformationProvider(config);

    PrintStream outStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(outfile)));
    provider.prepare(config);
    provider.startStream();
    do {
        Uninterruptibles.sleepUninterruptibly(streamsConfiguration.getBatchFrequencyMs(),
                TimeUnit.MILLISECONDS);
        for (StreamsDatum datum : provider.readCurrent()) {
            String json;
            try {
                json = MAPPER.writeValueAsString(datum.getDocument());
                outStream.println(json);
            } catch (JsonProcessingException ex) {
                System.err.println(ex.getMessage());
            }
        }
    } while (provider.isRunning());
    provider.cleanUp();
    outStream.flush();
}

From source file:org.ojbc.policyacknowledgement.util.JSONUtil.java

public static String toJsonString(Object object) {
    String json = "";
    try {//from  w  ww  . ja  v a2  s .co  m
        json = objectWriter.writeValueAsString(object);
    } catch (JsonProcessingException e) {
        log.warn(e.getMessage());
        json = e.getMessage();
    }
    return json;
}

From source file:org.apereo.openlrs.utils.JsonUtils.java

/**
 * Creates a JSON string from the given map
 * /*from   w ww . jav  a2 s.  c  o  m*/
 * @param jsonMap the map holding the objects to be converted to JSON the JSON string representing the map
 * @return
 */
public static String parseJsonMapToString(Map<String, ?> jsonMap) {
    assert jsonMap != null;

    ObjectMapper om = new ObjectMapper();
    String rawJson = null;
    try {
        rawJson = om.writer().writeValueAsString(jsonMap);
    } catch (JsonProcessingException e) {
        log.error(e.getMessage(), e);
    }
    return rawJson;
}

From source file:de.thingweb.servient.impl.HypermediaIndex.java

public static Content createContent(List<HyperMediaLink> links) {
    String json = null;/*from w  ww. j  a  va 2  s  .c  o m*/
    try {
        json = ow.writeValueAsString(links);
    } catch (JsonProcessingException e) {
        json = "{ \"error\" : \" " + e.getMessage() + "\"  }";
    }
    return new Content(json.getBytes(), MediaType.APPLICATION_JSON);
}

From source file:io.fabric8.arquillian.utils.Routes.java

public static Route createRouteForService(String routeDomainPostfix, String namespace, Service service,
        Logger log) {//from ww  w  .jav a  2 s .co m
    Route route = null;
    String id = KubernetesHelper.getName(service);
    if (Strings.isNotBlank(id) && shouldCreateRouteForService(log, service, id)) {
        route = new Route();
        String routeId = id;
        KubernetesHelper.setName(route, namespace, routeId);
        RouteSpec routeSpec = new RouteSpec();
        RouteTargetReference objectRef = new RouteTargetReferenceBuilder().withName(id).build();
        //objectRef.setNamespace(namespace);
        routeSpec.setTo(objectRef);
        if (Strings.isNotBlank(routeDomainPostfix)) {
            // Let Openshift determine the route host when the domain is not set
            String host = Strings.stripSuffix(Strings.stripSuffix(id, "-service"), ".");
            String namespaceSuffix = "-" + namespace;
            routeSpec.setHost(host + namespaceSuffix + "." + Strings.stripPrefix(routeDomainPostfix, "."));
        }
        route.setSpec(routeSpec);
        String json = null;
        try {
            json = KubernetesHelper.toJson(route);
        } catch (JsonProcessingException e) {
            json = e.getMessage() + ". object: " + route;
        }
    }
    return route;
}

From source file:com.goodow.realtime.json.util.Yaml.java

public static String toYaml(Object obj) {
    if (obj instanceof JreJsonElement) {
        obj = ((JreJsonElement) obj).toNative();
    }//  w  w w .ja  v a 2s  .com
    try {
        return mapper.writeValueAsString(obj);
    } catch (JsonProcessingException e) {
        throw new JsonException("Failed to encode as YAML: " + e.getMessage());
    }
}

From source file:com.goodow.realtime.json.util.Xml.java

public static String toXml(Object obj) {
    if (obj instanceof JreJsonElement) {
        obj = ((JreJsonElement) obj).toNative();
    }//from w w w  .  j  av a  2  s .c o m
    try {
        return mapper.writeValueAsString(obj);
    } catch (JsonProcessingException e) {
        throw new JsonException("Failed to encode as XML: " + e.getMessage());
    }
}