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.serena.rlc.provider.servicenow.client.ApprovalWaiter.java

synchronized void notifyRLC(String status) {
    try {// www.j  a  va 2 s.  co m
        String uri = callbackUrl + executionId + "/" + status;
        logger.debug("Start executing RLC PUT request to url=\"{}\"", uri);
        DefaultHttpClient rlcParams = new DefaultHttpClient();
        HttpPut put = new HttpPut(uri);
        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(callbackUsername,
                callbackPassword);
        put.addHeader(BasicScheme.authenticate(credentials, "US-ASCII", false));
        //put.addHeader("Content-Type", "application/x-www-form-urlencoded");
        //put.addHeader("Accept", "application/json");
        logger.info(credentials.toString());
        HttpResponse response = rlcParams.execute(put);
        if (response.getStatusLine().getStatusCode() != 200) {
            logger.error("HTTP Status Code: " + response.getStatusLine().getStatusCode());
        }
    } catch (IOException ex) {
        logger.error(ex.getLocalizedMessage());
    }
}

From source file:de.wintercloud.CompileJinjaMojo.java

public void execute() throws MojoExecutionException {
    try {/* w w  w  . j a v  a2 s . com*/
        // Load the parameters
        Yaml yaml = new Yaml();
        Map<String, Object> context = (Map<String, Object>) yaml
                .load(FileUtils.readFileToString(varFile, (Charset) null));

        // Load template
        Jinjava jinjava = new Jinjava();
        String template = FileUtils.readFileToString(templateFile, (Charset) null);

        // Render and save
        String rendered = jinjava.render(template, context);
        FileUtils.writeStringToFile(outputFile, rendered, (Charset) null);
    } catch (IOException e) {
        // Print error and exit with -1
        throw new MojoExecutionException(e.getLocalizedMessage(), e);
    }
}

From source file:org.openxdata.server.engine.OpenXDataLoggingEngineImpl.java

@Override
public void clearLogFiles() {
    try {//from  w ww  .  j av a 2 s.  c  o m
        LoggingEngineUtil.clearLogFiles();
    } catch (IOException ex) {
        log.error(ex.getLocalizedMessage(), ex);
    }
}

From source file:it.geosolutions.geobatch.imagemosaic.ImageMosaicUpdater.java

/**
 * return the datastore or null/*from ww w  . j  a va2  s . c  o  m*/
 * 
 * @param mosaicProp
 * @param dataStoreProp
 * @param mosaicDescriptor
 * @param cmd
 * @return
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 *             if datastoreProp is null
 * @throws InstantiationException
 * @throws IOException
 */
private static DataStore getDataStore(Properties dataStoreProp) throws IllegalArgumentException,
        InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
    if (dataStoreProp == null) {
        throw new IllegalArgumentException("Unable to get datastore properties.");
    }

    DataStore dataStore = null;

    // SPI
    final String SPIClass = dataStoreProp.getProperty("SPI");
    try {
        DataStoreFactorySpi spi = (DataStoreFactorySpi) Class.forName(SPIClass).newInstance();

        final Map<String, Serializable> params = Utils.createDataStoreParamsFromPropertiesFile(dataStoreProp,
                spi);

        // datastore creation
        dataStore = spi.createDataStore(params);

    } catch (IOException ioe) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error("Problems setting up (creating or connecting) the datasource. The message is: "
                    + ioe.getLocalizedMessage(), ioe);
        }
        throw ioe;
    }

    if (dataStore == null) {
        throw new NullPointerException(
                "The required resource (DataStore) was not found or if insufficent parameters were given.");
    }
    return dataStore;
}

From source file:rmblworx.tools.timey.ApplicationProperties.java

/**
 * @return Versionskennung oder {@code null}, wenn sie nicht ermittelt werden kann.
 *///from   w  w w .  jav  a  2 s.com
public String getVersion() {
    try {
        if (inputStream == null) {
            inputStream = new ClassPathResource(PROPERTY_FILENAME).getInputStream();
        }

        if (properties == null) {
            properties = new Properties();
        }

        properties.load(inputStream);

        return properties.getProperty(PROP_APP_VERSION);
    } catch (final IOException e) {
        log.error("Error while trying to read the property file: " + e.getLocalizedMessage());
        return null;
    } finally {
        TimeyUtils.closeQuietly(inputStream);
    }
}

From source file:org.umit.icm.mobile.connectivity.ServiceHTTP.java

/**
 * Returns a an HTTP Response String./*from  ww w  .ja va 2s.c  om*/
 * 
 *                                                                                                 
              
@return      String
 *
         
@see HttpClient
 */
@Override
public String connect() {

    HttpClient httpClient = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet(getServiceURL());

    try {
        HttpResponse httpResponse = httpClient.execute(httpGet);
        StatusLine statusLine = httpResponse.getStatusLine();
        if (statusLine.getStatusCode() != 200) {
            return "blocked";
        }
        HttpEntity httpEntity = httpResponse.getEntity();
        InputStream inputStream = httpEntity.getContent();
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        int bytes = 0;
        byte[] buffer = new byte[1024];
        while ((bytes = inputStream.read(buffer)) != -1) {
            byteArrayOutputStream.write(buffer, 0, bytes);
        }
        if (new String(byteArrayOutputStream.toByteArray()) != null)
            return "normal";
        else
            return "blocked";
    } catch (IOException e) {
        Log.w("ServiceHTTPException: ", e.getLocalizedMessage());
        return "blocked";
    }
}

From source file:it.geosolutions.geobatch.imagemosaic.ImageMosaicUpdater.java

/**
 * Removes from the passed addFileList already present (into the passed
 * dataStore) features //from w w  w  .  j  a  va 2s . c  o m
 * 
 * TODO this can be skipped to perform update (instead
 * of perform remove+update)
 */
private static boolean purgeAddFileList(List<File> addFileList, DataStore dataStore, String store,
        final String locationKey, final File baseDir, boolean absolute) {

    if (addFileList.isEmpty()) {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Add list is empty");
        }
        // we're not expecting empty list here
        return false;
    }

    Filter addFilter = null;
    // calculate the query
    try {
        addFilter = getQuery(addFileList, absolute, locationKey);

        if (addFilter == null) { //
            if (LOGGER.isInfoEnabled()) {
                LOGGER.info("The ADD query is null. Should not happen");
            }
            return false;
        }

    } catch (IllegalArgumentException e) {
        if (LOGGER.isWarnEnabled()) {
            LOGGER.warn(e.getLocalizedMessage());
        }
    } catch (CQLException e) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error("Unable to build a query. Message: " + e, e);
        }
        return false;
    }

    final String handle = "ImageMosaic:" + Thread.currentThread().getId();
    final Transaction transaction = new DefaultTransaction(handle);
    /*
     * CHECK IF ADD FILES ARE ALREADY INTO THE LAYER
     */

    FeatureReader<SimpleFeatureType, SimpleFeature> fr = null;
    try {

        // get the schema if this feature
        final SimpleFeatureType schema = dataStore.getSchema(store);
        /*
         * TODO to save time we could use the store name which should be the
         * same
         */

        final Query q = new Query(schema.getTypeName(), addFilter);
        fr = dataStore.getFeatureReader(q, transaction);
        if (fr == null) {
            if (LOGGER.isErrorEnabled()) {
                LOGGER.error("The FeatureReader is null, it's impossible to get a reader on the dataStore: "
                        + dataStore.toString());
            }
            return false;
        }
        while (fr.hasNext()) {
            SimpleFeature feature = fr.next();
            if (feature != null) {
                String path = (String) feature.getAttribute(locationKey);

                // remove from the list the image which is already
                // into the layer
                if (absolute) {
                    File added = new File(baseDir, path);
                    addFileList.remove(added);
                    if (LOGGER.isWarnEnabled()) {
                        LOGGER.warn("The file: " + path
                                + " is removed from the addFiles list because it is already present into the layer");
                    }
                } else {
                    // check relative paths
                    Iterator<File> it = addFileList.iterator();
                    while (it.hasNext()) {
                        File file = it.next();
                        if (file.getName().equals(path)) {
                            it.remove();
                            if (LOGGER.isWarnEnabled()) {
                                LOGGER.warn("The file: " + path
                                        + " is removed from the addFiles list because it is already present into the layer");
                            }
                        }
                    }
                }
            } else {
                if (LOGGER.isErrorEnabled()) {
                    LOGGER.error("Problem getting the next feature: it is null!");
                }
            }

        }

        //commit
        transaction.commit();
    } catch (Exception e) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error(e.getLocalizedMessage(), e);
        }

        try {
            transaction.rollback();
        } catch (IOException ioe) {
            if (LOGGER.isErrorEnabled()) {
                LOGGER.error(ioe.getLocalizedMessage(), ioe);
            }
        }

        return false;
    } finally {
        try {
            transaction.close();

        } catch (Throwable t) {
            if (LOGGER.isWarnEnabled()) {
                LOGGER.warn("problem closing transaction: " + t.getLocalizedMessage(), t);
            }
        }
        try {
            if (fr != null) {
                fr.close();
                fr = null;
            }
        } catch (Throwable t) {
            if (LOGGER.isWarnEnabled()) {
                LOGGER.warn("problem closing transaction: " + t.getLocalizedMessage(), t);
            }
        }
    }

    return true;
}

From source file:com.sliit.rules.RuleContainer.java

public RuleContainer(String filePath) {

    try {/*from   w w w .  j a v a2  s .c  om*/
        csvFile = new File(filePath);
        csv = new CSVLoader();
        csv.setSource(csvFile);
    } catch (IOException e) {

        log.error("Error occurred:" + e.getLocalizedMessage());
    }
}

From source file:com.dchq.docker.volume.driver.adaptor.LocalVolumeAdaptorImpl.java

public LocalVolumeAdaptorImpl() {
    try {/*from w w w  .  j a v a  2 s . c om*/
        File file = new File(TMP_LOC, "/volumes");
        FileUtils.forceMkdir(file);

        this.TMP_LOC = file.getAbsolutePath();

    } catch (IOException e) {
        logger.warn(e.getLocalizedMessage(), e);
    }
    logger.info("Temp directory location [{}]", TMP_LOC);
}

From source file:com.tapontikes.java.doUpload.java

public String uploadSingleFile() {

    try {/*from www. jav a  2s  .co  m*/

        ftpInitiate();

        local_file = new File(_path);
        remote_file = "public_html/" + local_file.getName();

        checkExist();

        input = new FileInputStream(local_file);

        complete = _ftp.storeFile(remote_file, input);

        input.close();

        _done = isComplete();

    } catch (IOException ex) {
        disconnect();
        return ex.getLocalizedMessage();

    }

    return _done;

}