Example usage for java.io IOException getLocalizedMessage

List of usage examples for java.io IOException getLocalizedMessage

Introduction

In this page you can find the example usage for java.io IOException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

public void addTrackResultsString(final String results) {
    ThreadManager.getInstance().execute(new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_REPORTING) {
        @Override/*from   w w w.  j  a  v a  2s.  co m*/
        public void run() {
            ScriptResolverResult result = null;
            try {
                result = mObjectMapper.readValue(results, ScriptResolverResult.class);
            } catch (IOException e) {
                Log.e(TAG, "addTrackResultsString: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            if (result != null) {
                ArrayList<Result> parsedResults = parseResultList(result.results, result.qid);
                PipeLine.getInstance().reportResults(mQueryKeys.get(result.qid), parsedResults, mId);
            }
            mTimeOutHandler.removeCallbacksAndMessages(null);
            mStopped = true;
        }
    });
}

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

public void addAlbumResultsString(final String results) {
    ThreadManager.getInstance().execute(new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_REPORTING) {
        @Override//from   ww  w .  j  av a  2  s  .  co  m
        public void run() {
            ScriptResolverAlbumResult result = null;
            try {
                result = mObjectMapper.readValue(results, ScriptResolverAlbumResult.class);
            } catch (IOException e) {
                Log.e(TAG, "addAlbumResultsString: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            if (result != null) {
                ScriptResolverCollection collection = (ScriptResolverCollection) CollectionManager.getInstance()
                        .getCollection(result.qid);
                if (collection != null) {
                    Artist artist = Artist.get(result.artist);
                    ArrayList<Album> albums = new ArrayList<Album>();
                    for (String albumName : result.albums) {
                        albums.add(Album.get(albumName, artist));
                    }
                    collection.addAlbumResults(albums);
                }
            }
            mTimeOutHandler.removeCallbacksAndMessages(null);
            mStopped = true;
        }
    });
}

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

public void addArtistResultsString(final String results) {
    ThreadManager.getInstance().execute(new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_REPORTING) {
        @Override//www . j  a  v a 2s. c o m
        public void run() {
            ScriptResolverArtistResult result = null;
            try {
                result = mObjectMapper.readValue(results, ScriptResolverArtistResult.class);
            } catch (IOException e) {
                Log.e(TAG, "addArtistResultsString: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            if (result != null) {
                ScriptResolverCollection collection = (ScriptResolverCollection) CollectionManager.getInstance()
                        .getCollection(result.qid);
                if (collection != null) {
                    ArrayList<Artist> artists = new ArrayList<Artist>();
                    for (String artistName : result.artists) {
                        artists.add(Artist.get(artistName));
                    }
                    collection.addArtistResults(artists);
                }
            }
            mTimeOutHandler.removeCallbacksAndMessages(null);
            mStopped = true;
        }
    });
}

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

public void addAlbumTrackResultsString(final String results) {
    ThreadManager.getInstance().execute(new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_REPORTING) {
        @Override//from w  w  w .j  a  va  2  s.  c  o m
        public void run() {
            ScriptResolverAlbumTrackResult result = null;
            try {
                result = mObjectMapper.readValue(results, ScriptResolverAlbumTrackResult.class);
            } catch (IOException e) {
                Log.e(TAG, "addAlbumTrackResultsString: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            if (result != null) {
                ScriptResolverCollection collection = (ScriptResolverCollection) CollectionManager.getInstance()
                        .getCollection(result.qid);
                ArrayList<Result> parsedResults = parseResultList(result.results, result.qid);
                Artist artist = Artist.get(result.artist);
                Album album = Album.get(result.album, artist);
                collection.addAlbumTrackResults(album, parsedResults);
            }
            mTimeOutHandler.removeCallbacksAndMessages(null);
            mStopped = true;
        }
    });
}

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

/**
 * Initialize the WebView. Loads the .js script from the given path and sets the appropriate
 * base URL./*from w  ww.  j  a v a 2 s. c om*/
 *
 * @return the initialized WebView
 */
private synchronized WebView getWebView() {
    if (mWebView == null) {
        mWebView = new WebView(TomahawkApp.getContext());
        WebSettings settings = mWebView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setDatabaseEnabled(true);
        settings.setDatabasePath(TomahawkApp.getContext().getDir("databases", Context.MODE_PRIVATE).getPath());
        settings.setDomStorageEnabled(true);
        mWebView.setWebChromeClient(new TomahawkWebChromeClient());
        mWebView.setWebViewClient(new ScriptWebViewClient(ScriptResolver.this));
        final ScriptInterface scriptInterface = new ScriptInterface(ScriptResolver.this);
        mWebView.addJavascriptInterface(scriptInterface, SCRIPT_INTERFACE_NAME);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
        }

        final String baseurl = "file:///android_asset/test.html";
        String data = "<!DOCTYPE html>" + "<html><body>"
                + "<script src=\"file:///android_asset/js/cryptojs-core.js"
                + "\" type=\"text/javascript\"></script>";
        for (String scriptPath : mMetaData.manifest.scripts) {
            data += "<script src=\"file:///android_asset/" + mPath + "/" + scriptPath
                    + "\" type=\"text/javascript\"></script>";
        }
        try {
            String[] cryptoJsScripts = TomahawkApp.getContext().getAssets().list("js/cryptojs");
            for (String scriptPath : cryptoJsScripts) {
                data += "<script src=\"file:///android_asset/js/cryptojs/" + scriptPath
                        + "\" type=\"text/javascript\"></script>";
            }
        } catch (IOException e) {
            Log.e(TAG, "ScriptResolver: " + e.getClass() + ": " + e.getLocalizedMessage());
        }
        data += "<script src=\"file:///android_asset/js/tomahawk_android_pre.js"
                + "\" type=\"text/javascript\"></script>" + "<script src=\"file:///android_asset/js/tomahawk.js"
                + "\" type=\"text/javascript\"></script>"
                + "<script src=\"file:///android_asset/js/tomahawk_android_post.js"
                + "\" type=\"text/javascript\"></script>" + "<script src=\"file:///android_asset/" + mPath + "/"
                + mMetaData.manifest.main + "\" type=\"text/javascript\"></script>" + "</body></html>";
        final String finalData = data;
        mWebView.loadDataWithBaseURL(baseurl, finalData, "text/html", null, null);
    }
    return mWebView;
}

From source file:com.datascience.gal.service.Service.java

/**
 * a simple method to see if the service is awake
 * /*from  w w  w .j a  v  a2 s.c  o m*/
 * @return a string with the current time
 */
@GET
@Path("ping")
@Produces(MediaType.APPLICATION_JSON)
public Response test() {
    try {
        setup(context);
    } catch (IOException e) {
        logger.error("ioexception: " + e.getLocalizedMessage());
    } catch (ClassNotFoundException e) {
        logger.error("class not found exception: " + e.getLocalizedMessage());
    } catch (SQLException e) {
        logger.error("sql exception: " + e.getLocalizedMessage());
    }
    DateTime datetime = new DateTime();
    String cargo = "processing request at: " + datetime.toString();
    logger.info(cargo);
    return Response.ok(JSONUtils.gson.toJson(cargo)).build();
}

From source file:org.tomahawk.libtomahawk.database.DatabaseHelper.java

/**
 * @return an InfoRequestData object that contains all data that should be delivered to the API
 *///from  w w w .  j  a  v  a 2 s. c  o  m
public List<InfoRequestData> getLoggedOps() {
    List<InfoRequestData> loggedOps = new ArrayList<InfoRequestData>();
    String[] columns = new String[] { TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_ID,
            TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_TYPE,
            TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_HTTPTYPE,
            TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_JSONSTRING,
            TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_PARAMS };

    Cursor opLogCursor = mDatabase.query(TomahawkSQLiteHelper.TABLE_INFOSYSTEMOPLOG, columns, null, null, null,
            null, TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_TIMESTAMP + " DESC");
    opLogCursor.moveToFirst();
    while (!opLogCursor.isAfterLast()) {
        String requestId = TomahawkMainActivity.getSessionUniqueStringId();
        String paramJsonString = opLogCursor.getString(4);
        QueryParams params = null;
        if (paramJsonString != null) {
            try {
                params = InfoSystemUtils.getObjectMapper().readValue(paramJsonString, QueryParams.class);
            } catch (IOException e) {
                Log.e(TAG, "getLoggedOps: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
        }
        InfoRequestData infoRequestData = new InfoRequestData(requestId, opLogCursor.getInt(1), params,
                opLogCursor.getInt(0), opLogCursor.getInt(2), opLogCursor.getString(3));
        loggedOps.add(infoRequestData);
        opLogCursor.moveToNext();
    }
    opLogCursor.close();
    return loggedOps;
}

From source file:io.hops.hopsworks.apiV2.projects.DatasetsResource.java

private void changeDatasetPermissions(Dataset dataset, FsPermission fsPermission)
        throws AccessControlException, AppException {
    DistributedFileSystemOps dfso = null;
    try {/*from   w  w w  .  j a  v  a  2s.  c  om*/
        // change the permissions as superuser
        dfso = dfs.getDfsOps();
        datasetController.recChangeOwnershipAndPermission(datasetController.getDatasetPath(dataset),
                fsPermission, null, null, null, dfso);
    } catch (AccessControlException ex) {
        logger.log(Level.FINE, null, ex);
        throw new AccessControlException("Permission denied: Can not change the permission of this file.");
    } catch (IOException e) {
        throw new AppException(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
                "Error while creating directory: " + e.getLocalizedMessage());
    } finally {
        if (dfso != null) {
            dfso.close();
        }
    }
}

From source file:org.zenoss.zep.index.impl.lucene.LuceneEventIndexBackend.java

private void returnSearcher(IndexSearcher searcher) throws ZepException {
    try {/*from   w  ww.j ava  2 s . c o m*/
        if (searcher != null)
            this.searcherManager.release(searcher);
    } catch (IOException e) {
        throw new ZepException(e.getLocalizedMessage(), e);
    }
}

From source file:com.datascience.gal.service.Service.java

@GET
@Path("getDawidSkene")
@Produces(MediaType.APPLICATION_JSON)//from w w  w.  ja  v  a 2 s  .com
public Response getDawidSkene(@QueryParam("id") String idstr) {
    String id = "" + 0;
    if (null == idstr) {
        logger.info("no id input, using id 0");
    } else {
        id = idstr;
    }

    try {
        setup(context);
        DawidSkene ds = dscache.getDawidSkene(id);
        return Response.ok(JSONUtils.gson.toJson(ds)).build();
    } catch (IOException e) {
        logger.error("ioexception: " + e.getLocalizedMessage());
    } catch (ClassNotFoundException e) {
        logger.error("class not found exception: " + e.getLocalizedMessage());
    } catch (SQLException e) {
        logger.error("sql exception: " + e.getLocalizedMessage());
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage());
    }
    return Response.status(500).build();
}