List of usage examples for com.fasterxml.jackson.core JsonProcessingException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.tomahawk.libtomahawk.infosystem.InfoSystem.java
private void sendSocialActionPostStruct(AuthenticatorUtils authenticatorUtils, String trackString, String artistString, String albumString, String type, boolean action) { long timeStamp = System.currentTimeMillis(); HatchetSocialAction socialAction = new HatchetSocialAction(); socialAction.type = type;//from w w w. j av a 2 s . co m socialAction.action = String.valueOf(action); socialAction.trackString = trackString; socialAction.artistString = artistString; socialAction.albumString = albumString; socialAction.timestamp = new Date(timeStamp); HatchetSocialActionPostStruct socialActionPostStruct = new HatchetSocialActionPostStruct(); socialActionPostStruct.socialAction = socialAction; String requestId = TomahawkMainActivity.getSessionUniqueStringId(); try { String jsonString = InfoSystemUtils.getObjectMapper().writeValueAsString(socialActionPostStruct); InfoRequestData infoRequestData = new InfoRequestData(requestId, InfoRequestData.INFOREQUESTDATA_TYPE_SOCIALACTIONS, null, InfoRequestData.HTTPTYPE_POST, jsonString); DatabaseHelper.getInstance().addOpToInfoSystemOpLog(infoRequestData, (int) (timeStamp / 1000)); sendLoggedOps(authenticatorUtils); } catch (JsonProcessingException e) { Log.e(TAG, "sendSocialActionPostStruct: " + e.getClass() + ": " + e.getLocalizedMessage()); } }
From source file:org.tomahawk.libtomahawk.infosystem.InfoSystem.java
public void sendPlaylistEntriesPostStruct(AuthenticatorUtils authenticatorUtils, String localPlaylistId, String trackName, String artistName, String albumName) { long timeStamp = System.currentTimeMillis(); HatchetPlaylistEntryRequest request = new HatchetPlaylistEntryRequest(); request.trackString = trackName;//from w w w . j a v a 2s . c o m request.artistString = artistName; request.albumString = albumName; HatchetPlaylistEntryPostStruct struct = new HatchetPlaylistEntryPostStruct(); struct.playlistEntry = request; String requestId = TomahawkMainActivity.getSessionUniqueStringId(); try { String jsonString = InfoSystemUtils.getObjectMapper().writeValueAsString(struct); QueryParams params = new QueryParams(); params.playlist_local_id = localPlaylistId; InfoRequestData infoRequestData = new InfoRequestData(requestId, InfoRequestData.INFOREQUESTDATA_TYPE_PLAYLISTS_PLAYLISTENTRIES, params, InfoRequestData.HTTPTYPE_POST, jsonString); DatabaseHelper.getInstance().addOpToInfoSystemOpLog(infoRequestData, (int) (timeStamp / 1000)); sendLoggedOps(authenticatorUtils); } catch (JsonProcessingException e) { Log.e(TAG, "sendPlaylistEntriesPostStruct: " + e.getClass() + ": " + e.getLocalizedMessage()); } }
From source file:org.tomahawk.libtomahawk.infosystem.InfoSystem.java
public void sendPlaybackEntryPostStruct(AuthenticatorUtils authenticatorUtils) { if (mNowPlaying != null && mNowPlaying != mLastPlaybackLogEntry) { mLastPlaybackLogEntry = mNowPlaying; long timeStamp = System.currentTimeMillis(); HatchetPlaybackLogEntry playbackLogEntry = new HatchetPlaybackLogEntry(); playbackLogEntry.albumString = mLastPlaybackLogEntry.getAlbum().getName(); playbackLogEntry.artistString = mLastPlaybackLogEntry.getArtist().getName(); playbackLogEntry.trackString = mLastPlaybackLogEntry.getName(); playbackLogEntry.timestamp = new Date(timeStamp); HatchetPlaybackLogPostStruct playbackLogPostStruct = new HatchetPlaybackLogPostStruct(); playbackLogPostStruct.playbackLogEntry = playbackLogEntry; String requestId = TomahawkMainActivity.getSessionUniqueStringId(); try {//w w w .java 2s . com String jsonString = InfoSystemUtils.getObjectMapper().writeValueAsString(playbackLogPostStruct); InfoRequestData infoRequestData = new InfoRequestData(requestId, InfoRequestData.INFOREQUESTDATA_TYPE_PLAYBACKLOGENTRIES, null, InfoRequestData.HTTPTYPE_POST, jsonString); DatabaseHelper.getInstance().addOpToInfoSystemOpLog(infoRequestData, (int) (timeStamp / 1000)); sendLoggedOps(authenticatorUtils); } catch (JsonProcessingException e) { Log.e(TAG, "sendPlaybackEntryPostStruct: " + e.getClass() + ": " + e.getLocalizedMessage()); } } }
From source file:org.tomahawk.libtomahawk.database.DatabaseHelper.java
/** * Add an operation to the log. This operation log is being used to store pending operations, so * that this operation can be executed, if we have the opportunity to do so. * * @param opToLog InfoRequestData object containing the type of the operation, which * determines where and how to send the data to the API. Contains also the * JSON-String which contains the data to send. * @param timeStamp a timestamp indicating when this operation has been added to the oplog *//*ww w.ja va2 s . c o m*/ public void addOpToInfoSystemOpLog(InfoRequestData opToLog, int timeStamp) { ContentValues values = new ContentValues(); mDatabase.beginTransaction(); values.put(TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_TYPE, opToLog.getType()); values.put(TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_HTTPTYPE, opToLog.getHttpType()); values.put(TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_TIMESTAMP, timeStamp); if (opToLog.getJsonStringToSend() != null) { values.put(TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_JSONSTRING, opToLog.getJsonStringToSend()); } if (opToLog.getQueryParams() != null) { String paramsJsonString = null; try { paramsJsonString = InfoSystemUtils.getObjectMapper().writeValueAsString(opToLog.getQueryParams()); } catch (JsonProcessingException e) { Log.e(TAG, "addOpToInfoSystemOpLog: " + e.getClass() + ": " + e.getLocalizedMessage()); } values.put(TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_PARAMS, paramsJsonString); } mDatabase.insert(TomahawkSQLiteHelper.TABLE_INFOSYSTEMOPLOG, null, values); mDatabase.setTransactionSuccessful(); mDatabase.endTransaction(); }