List of usage examples for com.fasterxml.jackson.core JsonProcessingException getLocalizedMessage
public String getLocalizedMessage()
From source file:com.wealdtech.configuration.ConfigurationGenerator.java
public static String generate(final Configuration configuration) { String result = null;/*from ww w . j ava 2 s.co m*/ ObjectMapper mapper = ObjectMapperFactory.getDefaultMapper(); try { result = mapper.writeValueAsString(configuration); } catch (JsonProcessingException e) { System.err.println("Failed to generate configuration file: " + e.getLocalizedMessage()); } return result; }
From source file:org.neo4j.ogm.session.request.SessionRequestHandler.java
@Override public Neo4jResponse<String> execute(List<ParameterisedStatement> statementList, String url) { try {/*from w w w . j a va2s .c o m*/ String json = mapper.writeValueAsString(new ParameterisedStatements(statementList)); // ugh. if (!json.contains("statement\":\"\"")) { // not an empty statement logger.debug(json); return request.execute(url, json); } return new EmptyResponse(); } catch (JsonProcessingException jpe) { throw new MappingException(jpe.getLocalizedMessage()); } }
From source file:com.netflix.genie.common.model.Auditable.java
/** * Convert this object to a string representation. * * @return This application data represented as a JSON structure */// ww w. java 2s. com @Override public String toString() { try { final ObjectMapper mapper = new ObjectMapper(); return mapper.writeValueAsString(this); } catch (final JsonProcessingException ioe) { LOG.error(ioe.getLocalizedMessage(), ioe); return ioe.getLocalizedMessage(); } }
From source file:org.neo4j.ogm.drivers.http.request.HttpRequest.java
private String cypherRequest(Statements statements) { try {/*w w w . ja v a2 s . c o m*/ return OBJECT_MAPPER.writeValueAsString(statements); } catch (JsonProcessingException jpe) { throw new ResultProcessingException("Could not create JSON due to " + jpe.getLocalizedMessage(), jpe); } }
From source file:org.neo4j.ogm.drivers.http.request.HttpRequest.java
private String cypherRequest(Statement statement) { List<Statement> statementList = new ArrayList<>(); statementList.add(statement);//from w ww. j av a 2 s.c o m try { return OBJECT_MAPPER.writeValueAsString(new Statements(statementList)); } catch (JsonProcessingException jpe) { throw new ResultProcessingException("Could not create JSON due to " + jpe.getLocalizedMessage(), jpe); } }
From source file:com.kylinolap.jdbc.stub.KylinClient.java
/** * @param sql//from www. java2s .co m * @return * @throws IOException */ private SQLResponseStub runKylinQuery(String sql, List<StateParam> params) throws SQLException { String url = conn.getQueryUrl(); String project = conn.getProject(); QueryRequest request = null; if (null != params) { request = new PreQueryRequest(); ((PreQueryRequest) request).setParams(params); url += "/prestate"; } else { request = new QueryRequest(); } request.setSql(sql); request.setProject(project); PostMethod post = new PostMethod(url); addPostHeaders(post); HttpClient httpClient = new HttpClient(); if (conn.getQueryUrl().toLowerCase().startsWith("https://")) { registerSsl(); } String postBody = null; ObjectMapper mapper = new ObjectMapper(); try { postBody = mapper.writeValueAsString(request); logger.debug("Post body:\n " + postBody); } catch (JsonProcessingException e) { logger.error(e.getLocalizedMessage(), e); } String response = null; SQLResponseStub queryRes = null; try { StringRequestEntity requestEntity = new StringRequestEntity(postBody, "application/json", "UTF-8"); post.setRequestEntity(requestEntity); httpClient.executeMethod(post); response = post.getResponseBodyAsString(); if (post.getStatusCode() != 200 && post.getStatusCode() != 201) { logger.error("Failed to query", response); throw new SQLException(response); } queryRes = new ObjectMapper().readValue(response, SQLResponseStub.class); } catch (HttpException e) { logger.error(e.getLocalizedMessage(), e); throw new SQLException(e.getLocalizedMessage()); } catch (IOException e) { logger.error(e.getLocalizedMessage(), e); throw new SQLException(e.getLocalizedMessage()); } return queryRes; }
From source file:com.marklogic.semantics.sesame.client.MarkLogicClient.java
/** * TupleQuery//from www. j ava 2s . c o m * * @param queryString * @param bindings * @param start * @param pageLength * @param includeInferred * @param baseURI * @return * @throws RepositoryException * @throws MalformedQueryException * @throws UnauthorizedException * @throws QueryInterruptedException */ public TupleQueryResult sendTupleQuery(String queryString, SPARQLQueryBindingSet bindings, long start, long pageLength, boolean includeInferred, String baseURI) throws RepositoryException, MalformedQueryException, QueryInterruptedException { InputStream stream = null; try { stream = getClient().performSPARQLQuery(queryString, bindings, start, pageLength, this.tx, includeInferred, baseURI); } catch (JsonProcessingException e) { logger.error(e.getLocalizedMessage()); throw new MarkLogicSesameException("Issue processing json."); } TupleQueryResultParser parser = QueryResultIO.createParser(format, getValueFactory()); MarkLogicBackgroundTupleResult tRes = new MarkLogicBackgroundTupleResult(parser, stream); execute(tRes); return tRes; }
From source file:org.tomahawk.libtomahawk.infosystem.InfoSystem.java
public void sendPlaylistPostStruct(AuthenticatorUtils authenticatorUtils, String localId, String title) { long timeStamp = System.currentTimeMillis(); HatchetPlaylistRequest request = new HatchetPlaylistRequest(); request.title = title;/* www. j a v a2s . c o m*/ HatchetPlaylistPostStruct struct = new HatchetPlaylistPostStruct(); struct.playlist = request; String requestId = TomahawkMainActivity.getSessionUniqueStringId(); try { String jsonString = InfoSystemUtils.getObjectMapper().writeValueAsString(struct); QueryParams params = new QueryParams(); params.playlist_local_id = localId; InfoRequestData infoRequestData = new InfoRequestData(requestId, InfoRequestData.INFOREQUESTDATA_TYPE_PLAYLISTS, params, InfoRequestData.HTTPTYPE_POST, jsonString); DatabaseHelper.getInstance().addOpToInfoSystemOpLog(infoRequestData, (int) (timeStamp / 1000)); sendLoggedOps(authenticatorUtils); } catch (JsonProcessingException e) { Log.e(TAG, "sendPlaylistPostStruct: " + e.getClass() + ": " + e.getLocalizedMessage()); } }
From source file:org.tomahawk.libtomahawk.infosystem.InfoSystem.java
public String sendRelationshipPostStruct(AuthenticatorUtils authenticatorUtils, User targetUser) { HatchetRelationshipStruct relationship = new HatchetRelationshipStruct(); relationship.targetUser = targetUser.getId(); relationship.type = "follow"; HatchetRelationshipPostStruct struct = new HatchetRelationshipPostStruct(); struct.relationShip = relationship;//w w w .ja v a 2s .c o m String requestId = TomahawkMainActivity.getSessionUniqueStringId(); try { String jsonString = InfoSystemUtils.getObjectMapper().writeValueAsString(struct); InfoRequestData infoRequestData = new InfoRequestData(requestId, InfoRequestData.INFOREQUESTDATA_TYPE_RELATIONSHIPS, null, InfoRequestData.HTTPTYPE_POST, jsonString); send(infoRequestData, authenticatorUtils); return infoRequestData.getRequestId(); } catch (JsonProcessingException e) { Log.e(TAG, "sendRelationshipPostStruct: " + e.getClass() + ": " + e.getLocalizedMessage()); } return null; }
From source file:org.tomahawk.libtomahawk.infosystem.InfoSystem.java
public void sendNowPlayingPostStruct(AuthenticatorUtils authenticatorUtils, Query query) { if (mNowPlaying != query) { sendPlaybackEntryPostStruct(authenticatorUtils); mNowPlaying = query;//from w ww . j a va2s .c o m HatchetNowPlaying nowPlaying = new HatchetNowPlaying(); nowPlaying.album = query.getAlbum().getName(); nowPlaying.artist = query.getArtist().getName(); nowPlaying.track = query.getName(); HatchetNowPlayingPostStruct nowPlayingPostStruct = new HatchetNowPlayingPostStruct(); nowPlayingPostStruct.nowPlaying = nowPlaying; String requestId = TomahawkMainActivity.getSessionUniqueStringId(); try { String jsonString = InfoSystemUtils.getObjectMapper().writeValueAsString(nowPlayingPostStruct); InfoRequestData infoRequestData = new InfoRequestData(requestId, InfoRequestData.INFOREQUESTDATA_TYPE_PLAYBACKLOGENTRIES_NOWPLAYING, null, InfoRequestData.HTTPTYPE_POST, jsonString); send(infoRequestData, authenticatorUtils); } catch (JsonProcessingException e) { Log.e(TAG, "sendNowPlayingPostStruct: " + e.getClass() + ": " + e.getLocalizedMessage()); } } }