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:com.photon.phresco.framework.impl.CIManagerImpl.java

@Override
public CIJobStatus buildJob(CIJob job) throws PhrescoException {
    S_LOGGER.debug("Entering Method CIManagerImpl.buildJob(CIJob job)");
    cli = getCLI(job);//from  w  w  w.j a  va 2s .  co  m

    List<String> argList = new ArrayList<String>();
    argList.add(FrameworkConstants.CI_BUILD_JOB_COMMAND);
    argList.add(job.getName());
    try {
        int status = cli.execute(argList);
        String message = FrameworkConstants.CI_BUILD_STARTED;
        if (status == FrameworkConstants.JOB_STATUS_NOTOK) {
            message = FrameworkConstants.CI_BUILD_STARTING_ERROR;
        }
        return new CIJobStatus(status, message);
    } finally {
        if (cli != null) {
            try {
                cli.close();
            } catch (IOException e) {
                if (debugEnabled) {
                    S_LOGGER.error(e.getLocalizedMessage());
                }
            } catch (InterruptedException e) {
                if (debugEnabled) {
                    S_LOGGER.error(e.getLocalizedMessage());
                }
            }
        }
    }
}

From source file:com.kylinolap.cube.CubeManager.java

private void afterCubeDroped(CubeInstance droppedCube, List<ProjectInstance> projects) {
    MetadataManager.getInstance(config).reload();
    removeCubeCache(droppedCube);//  ww w.ja  v  a  2 s .co m

    if (null != projects) {
        for (ProjectInstance project : projects) {
            try {
                ProjectManager.getInstance(config).loadProjectCache(project, true);
            } catch (IOException e) {
                logger.error(e.getLocalizedMessage(), e);
            }
        }
    }
}

From source file:net.sf.logsaw.ui.impl.LogResourceManagerImpl.java

@Override
public synchronized void saveState() throws CoreException {
    XMLMemento rootElem = XMLMemento.createWriteRoot(ELEM_ROOT);
    rootElem.putInteger(ATTRIB_COMPAT, COMPAT_VERSION);
    for (ILogResource log : logSet) {
        IMemento logElem = rootElem.createChild(ELEM_LOG_RESOURCE);
        logElem.createChild(ELEM_NAME).putTextData(log.getName());
        IMemento dialectElem = logElem.createChild(ELEM_DIALECT);
        dialectElem.putString(ATTRIB_FACTORY, log.getDialect().getFactory().getId());
        // Save config options of dialect
        saveConfigOptions(dialectElem,//from ww  w  .  ja  v a2s .  c  o  m
                (IConfigurableObject) log.getDialect().getAdapter(IConfigurableObject.class));
        logElem.createChild(ELEM_PK).putTextData(log.getPK());
        // Save config options of resource
        saveConfigOptions(logElem, (IConfigurableObject) log.getAdapter(IConfigurableObject.class));
    }
    try {
        // Save to state file
        rootElem.save(new BufferedWriter(
                new OutputStreamWriter(FileUtils.openOutputStream(stateFile.toFile()), "UTF-8"))); //$NON-NLS-1$
    } catch (IOException e) {
        // Unexpected exception; wrap with CoreException
        throw new CoreException(new Status(IStatus.ERROR, UIPlugin.PLUGIN_ID,
                NLS.bind(Messages.LogResourceManager_error_failedToUpdateState,
                        new Object[] { e.getLocalizedMessage() }),
                e));
    }
}

From source file:jeplus.gui.EPlusEditorPanel.java

public void validateJSON(final String json) {
    boolean valid = false;
    String msg = null;/*from   w  ww .  j av  a  2  s .  co  m*/
    try {
        final JsonParser parser = new ObjectMapper().getJsonFactory().createJsonParser(json);
        while (parser.nextToken() != null) {
        }
        valid = true;
    } catch (JsonParseException jpe) {
        msg = jpe.getLocalizedMessage();
    } catch (IOException ioe) {
        msg = ioe.getLocalizedMessage();
    }
    if (!valid) {
        JOptionPane.showMessageDialog(this, "<html><p>JSON contents is not valid. Please check:</p><p>" + msg,
                "Success", JOptionPane.ERROR_MESSAGE);
    } else {
        JOptionPane.showMessageDialog(this, "JSON contents is valid!", "Success",
                JOptionPane.INFORMATION_MESSAGE);
    }
}

From source file:com.ravi.apps.android.newsbytes.sync.NewsSyncAdapter.java

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
        SyncResult syncResult) {/*from  ww  w.  j  a  v  a  2 s . c  om*/
    Log.d(LOG_TAG, getContext().getString(R.string.log_on_perform_sync));

    HttpURLConnection httpURLConnection = null;
    BufferedReader bufferedReader = null;

    try {
        String newsJsonStr = null;

        // Get the news category preference from shared preferences.
        String newsCategoryPreference = Utility.getNewsCategoryPreference(getContext(), null);

        // Set the news section query param value based on preference.
        String newsCategory = null;
        if (newsCategoryPreference.equals(getContext().getString(R.string.pref_news_category_favorites))) {
            // If favorites category is selected, no need to do a sync - simply return.
            return;
        } else if (newsCategoryPreference.equals(getContext().getString(R.string.pref_news_category_world))) {
            newsCategory = NYT_SECTION_WORLD;
        } else if (newsCategoryPreference
                .equals(getContext().getString(R.string.pref_news_category_business))) {
            newsCategory = NYT_SECTION_BUSINESS;
        } else if (newsCategoryPreference
                .equals(getContext().getString(R.string.pref_news_category_technology))) {
            newsCategory = NYT_SECTION_TECHNOLOGY;
        } else if (newsCategoryPreference.equals(getContext().getString(R.string.pref_news_category_health))) {
            newsCategory = NYT_SECTION_HEALTH;
        } else if (newsCategoryPreference.equals(getContext().getString(R.string.pref_news_category_travel))) {
            newsCategory = NYT_SECTION_TRAVEL;
        } else if (newsCategoryPreference.equals(getContext().getString(R.string.pref_news_category_sports))) {
            newsCategory = NYT_SECTION_SPORTS;
        }

        // Build the uri for querying data from NYT api.
        Uri uri = Uri.parse(NYT_BASE_URL + newsCategory + NYT_RESPONSE_FORMAT).buildUpon()
                .appendQueryParameter(NYT_API_KEY_PARAM, NYT_API_KEY).build();

        // Create the url for connecting to NYT server.
        URL url = new URL(uri.toString());
        Log.d(LOG_TAG, url.toString());

        // Create the request to NYT server and open the connection.
        httpURLConnection = (HttpURLConnection) url.openConnection();
        httpURLConnection.setRequestMethod("GET");
        httpURLConnection.connect();

        // Read the response input stream into a string buffer.
        InputStream inputStream = httpURLConnection.getInputStream();
        bufferedReader = new BufferedReader(new InputStreamReader(inputStream));

        StringBuffer stringBuffer = new StringBuffer();
        String line = null;
        while ((line = bufferedReader.readLine()) != null) {
            stringBuffer.append(line);
        }

        // Convert the string buffer to string.
        newsJsonStr = stringBuffer.toString();
        Log.d(LOG_TAG, newsJsonStr);

        // Parse the JSON string and extract the news data.
        getNewsDataFromJson(newsJsonStr);

        // Send a local broadcast informing the widget to refresh it's data.
        Utility.sendDataUpdatedBroadcast(getContext());

        // Send a notification to the user that fresh news updates are now available.
        if (Utility.getNewsNotificationsPreference(getContext(), null)) {
            sendNewsNotification(getContext());
        }
    } catch (IOException e) {
        Log.e(LOG_TAG, getContext().getString(R.string.log_on_perform_sync_io_error) + e.getLocalizedMessage());
    } catch (JSONException e) {
        Log.e(LOG_TAG,
                getContext().getString(R.string.log_on_perform_sync_json_error) + e.getLocalizedMessage());
    } finally {
        // Close url connection, if open.
        if (httpURLConnection != null) {
            httpURLConnection.disconnect();
        }

        // Close the buffered reader, if open.
        if (bufferedReader != null) {
            try {
                bufferedReader.close();
            } catch (final IOException e) {
                Log.e(LOG_TAG, getContext().getString(R.string.log_on_perform_sync_io_error)
                        + e.getLocalizedMessage());
            }
        }
    }
    return;
}

From source file:es.juntadeandalucia.panelGestion.negocio.vo.TaskVO.java

private void closeFileManager() {
    if (fileProcessor != null) {
        try {/*from   ww w.  j  a  v  a  2s  . co  m*/
            fileProcessor.end();
        } catch (IOException e) {
            log.warn("Error al intentar cerrar el procesador de archivo" + e.getLocalizedMessage());
        }
    }
}

From source file:com.jkoolcloud.tnt4j.streams.outputs.AbstractJKCloudOutput.java

/**
 * Sends activity data package to JKool Cloud using the specified tracker. Performs resend after defined period of
 * time if initial sending fails.//from w ww .ja v a 2  s .  co m
 * 
 * @param tracker
 *            communication gateway to use to record activity
 * @param retryPeriod
 *            period in milliseconds between activity resubmission in case of failure
 * @param activityData
 *            activity data to send
 * @throws Exception
 *             indicates an error when sending activity data to JKool Cloud
 */
protected void recordActivity(Tracker tracker, long retryPeriod, O activityData) throws Exception {
    if (tracker == null) {
        throw new IllegalArgumentException(
                StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityInfo.tracker.null"));
    }

    if (activityData == null) {
        logger().log(OpLevel.TRACE, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                "TNTStreamOutput.null.activity"));
        return;
    }

    StreamsThread thread = null;
    if (Thread.currentThread() instanceof StreamsThread) {
        thread = (StreamsThread) Thread.currentThread();
    }

    boolean retryAttempt = false;
    do {
        try {
            sendActivity(tracker, activityData);

            if (retryAttempt) {
                logger().log(OpLevel.INFO, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                        "TNTStreamOutput.retry.successful"));
            }
            return;
        } catch (IOException ioe) {
            logger().log(OpLevel.ERROR, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                    "TNTStreamOutput.recording.failed"), ioe.getLocalizedMessage());
            logger().log(OpLevel.INFO, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                    "TNTStreamOutput.recording.failed.activity"), activityData); // TODO: maybe use some formatter?
            logger().log(OpLevel.TRACE, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                    "TNTStreamOutput.recording.failed.trace"), ioe);
            resetTracker(tracker);
            if (thread == null) {
                throw ioe;
            }
            retryAttempt = true;
            if (!thread.isStopRunning()) {
                logger().log(OpLevel.INFO, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                        "TNTStreamOutput.will.retry"), TimeUnit.MILLISECONDS.toSeconds(retryPeriod));
                StreamsThread.sleep(retryPeriod);
            }
        }
    } while (thread != null && !thread.isStopRunning());
}

From source file:com.searchbox.collection.oppfin.TopicCollection.java

public ItemProcessor<JSONObject, FieldMap> topicProcessor() {
    return new ItemProcessor<JSONObject, FieldMap>() {

        public FieldMap process(JSONObject topicObject) throws IOException {

            /**/*  w  w  w .j a  v a 2  s . c o m*/
             * Sample Topic object { "tags":[], "callTitle": "Marie
             * Skaodowska-Curie Research and Innovation Staff Exchange
             * (RISE) " , "title": "Marie Skaodowska-Curie Research and
             * Innovation Staff Exchange (RISE)" ,
             * "flags":["Gender","IntlCoop","SSH"],
             * "callIdentifier":"H2020-MSCA-RISE-2014", "description":
             * "Objective:\r\n\r\nThe RISE scheme will promote international
             * and inter-sector collaboration \r\nthrough" ,
             * "callFileName":"h2020-msca-rise-2014",
             * "callDeadline":1398351600000, "callStatus":"Open",
             * "topicFileName":"59-msca-rise-2014",
             * "identifier":"MSCA-RISE-2014" }
             */
            // Populating useful variables
            String topicIdentifier = (String) topicObject.get("identifier");
            String topicFileName = (String) topicObject.get("topicFileName");
            String callFileName = (String) topicObject.get("callFileName");

            // Pulling full HTML description from the web
            String topicDetailHtml = getTopicDescription(topicFileName);
            // Converting HTML to plain text for Solr
            String topicDetailRaw = new HtmlToPlainText().getPlainText(Jsoup.parse(topicDetailHtml));

            // Creating a new enhancedTopic
            JSONObject enhancedTopic = new JSONObject();
            enhancedTopic.put("eur_topic_description_html", topicDetailHtml);
            enhancedTopic.put("eur_topic_description_raw", topicDetailRaw);
            enhancedTopic.put("eur_topic_timestamp", Calendar.getInstance().getTime());
            enhancedTopic.put("eur_topic_topicFileName", topicFileName);
            enhancedTopic.put("eur_topic_identifier", topicIdentifier);

            // Saving the enhanced file
            try {
                File file = new File("output/topics/" + topicFileName + ".json");
                file.getParentFile().mkdirs();

                FileWriter writer = new FileWriter(file);
                writer.write(enhancedTopic.toJSONString());
                writer.flush();
                writer.close();
                LOGGER.debug("File saved under " + file.getAbsolutePath());

                // Saving the list of calls identifiers
                File file2 = new File("output/topics/call_identifiers.txt");
                FileWriter writer2 = new FileWriter(file2, true);
                writer2.write(topicObject.get("callIdentifier") + "\n");
                writer2.flush();
                writer2.close();
            } catch (IOException e) {
                LOGGER.error(e.getLocalizedMessage());
            }

            // Creating the Field Map
            FieldMap doc = new FieldMap();

            // Lazzy Load the call description:
            //TODO check if not found 
            if (callList == null || callList.get(callFileName) == null)
                return null;
            //end check 
            if (!callList.get(callFileName).containsKey("callDescriptionHtml")) {
                getCallDescription(callFileName);
            }

            // Merging
            for (Entry<String, List<Object>> entry : callList.get(callFileName).entrySet()) {
                doc.put(entry.getKey(), entry.getValue());
            }

            LOGGER.info("Inserting call {} into topic {}", callFileName, topicFileName);

            doc.put("docSource", "H2020");
            doc.put("docType", "Funding");
            doc.put("programme", "H2020");

            doc.put("topicIdentifier", topicIdentifier);
            doc.put("topicFileName", topicFileName);
            doc.put("topicTitle", (String) topicObject.get("title"));
            doc.put("topicDescriptionRaw", topicDetailRaw);
            doc.put("topicDescriptionHtml", topicDetailHtml);

            doc.put("topicTags", (JSONArray) topicObject.get("tags"));
            doc.put("topicFlags", (JSONArray) topicObject.get("keywords"));
            //TODO: add debug 
            JSONArray arrDeadline = (JSONArray) topicObject.get("deadlineDatesLong");
            Long lDate = (Long) arrDeadline.get(0);
            String utcDate = df.format(new Date(lDate));
            doc.put("callDeadline", utcDate);
            doc.put("callIdentifier", (String) topicObject.get("callIdentifier"));

            if (LOGGER.isDebugEnabled()) {
                for (String key : doc.keySet()) {
                    LOGGER.debug("field: {}\t{}", key, doc.get(key));
                }
            }

            /*
            * LOGGER.info("***************************");
            * LOGGER.info(doc.toString());
            * LOGGER.info("***************************"); System.exit(0);
             */
            return doc;
        }
    };
}

From source file:com.tc.config.schema.setup.StandardXMLFileConfigurationCreator.java

private TcConfiguration getConfigFromSourceStream(InputStream in, boolean trustedSource, String descrip,
        String source, ClassLoader loader) throws ConfigurationSetupException {
    TcConfiguration tcConfigDoc;/*from w  w  w  . j av  a 2s  .  c o m*/
    try {
        ByteArrayOutputStream dataCopy = new ByteArrayOutputStream();
        IOUtils.copy(in, dataCopy);
        in.close();

        InputStream copyIn = new ByteArrayInputStream(dataCopy.toByteArray());
        BeanWithErrors beanWithErrors = beanFactory.createBean(copyIn, descrip, source, loader);

        if (beanWithErrors.errors() != null && beanWithErrors.errors().length > 0) {
            logger.debug("Configuration didn't parse; it had " + beanWithErrors.errors().length + " error(s).");

            StringBuffer buf = new StringBuffer();
            for (int i = 0; i < beanWithErrors.errors().length; ++i) {
                SAXParseException error = beanWithErrors.errors()[i];
                buf.append("  [" + i + "]: Line " + error.getLineNumber() + ", column "
                        + error.getColumnNumber() + ": " + error.getMessage() + "\n");
            }

            throw new ConfigurationSetupException("The configuration data in the " + descrip
                    + " does not obey the Terracotta schema:\n" + buf);
        } else {
            logger.debug("Configuration is valid.");
        }

        tcConfigDoc = ((TcConfiguration) beanWithErrors.bean());
        this.providedTcConfigDocument = tcConfigDoc;
    } catch (IOException ioe) {
        throw new ConfigurationSetupException("We were unable to read configuration data from the " + descrip
                + ": " + ioe.getLocalizedMessage(), ioe);
    } catch (SAXException saxe) {
        throw new ConfigurationSetupException("The configuration data in the " + descrip
                + " is not well-formed XML: " + saxe.getLocalizedMessage(), saxe);
    } catch (ParserConfigurationException pce) {
        throw Assert.failure("The XML parser can't be configured correctly; this should not happen.", pce);
    }

    return tcConfigDoc;
}

From source file:net.sf.jabref.logic.importer.fileformat.MedlineImporter.java

@Override
public List<BibEntry> parseEntries(InputStream inputStream) throws ParseException {
    try {//  w ww .ja  va 2 s . co m
        return importDatabase(new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)))
                .getDatabase().getEntries();

    } catch (IOException e) {
        LOGGER.error(e.getLocalizedMessage(), e);
    }
    return Collections.emptyList();
}