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

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

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

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;/*from  w w w  .  jav  a  2 s. 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;//from   ww w  .  j  a  v  a  2 s. 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  av  a  2 s.  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());
        }
    }
}

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;//ww w . jav 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;/* www  .jav  a  2 s.  co  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 {//from  w  w w.  ja  v a 2  s.c  om
            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
 *//*w ww  .j  a v  a2s.co  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();
}

From source file:org.apache.streams.plugins.elasticsearch.StreamsElasticsearchResourceGenerator.java

/**
 * generateResource String from schema and resourceId.
 * @param schema Schema/*from  ww  w  .  ja v a 2 s . c om*/
 * @param resourceId String
 * @return mapping
 */
public String generateResource(Schema schema, String resourceId) {
    StringBuilder resourceBuilder = new StringBuilder();

    ObjectNode rootNode = (ObjectNode) schema.getContent();

    // remove java*
    // remove description
    // resolve all $ref
    // replace format: date with type: date
    // replace format: date-time with type: date
    // replace array of primitive with just primitive

    try {
        String objectString = MAPPER.writeValueAsString(rootNode);
        resourceBuilder.append(objectString);
    } catch (JsonProcessingException ex) {
        LOGGER.error("{}: {}", ex.getClass().getName(), ex);
    }
    return resourceBuilder.toString();
}