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.kylinolap.rest.service.UserService.java

@Override
public void deleteUser(String username) {
    HTableInterface htable = null;/*from w  w w  .java2 s  .co m*/
    try {
        htable = HBaseConnection.get(hbaseUrl).getTable(userTableName);
        Delete delete = new Delete(Bytes.toBytes(username));

        htable.delete(delete);
        htable.flushCommits();
    } catch (IOException e) {
        logger.error(e.getLocalizedMessage(), e);
    } finally {
        IOUtils.closeQuietly(htable);
    }
}

From source file:de.egore911.drilog.tasks.JsonLoadTask.java

@Override
protected String doInBackground(String... params) {
    exceptionMessage = null;//from w  w  w. ja  v a2s .co m
    String url = (String) params[0];
    try {
        Pair<String, URL> result = HttpUtil.getPlainTextFromUrl(url);
        return result.first;
    } catch (IOException e) {
        Log.e(getClass().getSimpleName(), e.getMessage(), e);
        exceptionMessage = e.getClass().getSimpleName() + ": " + e.getLocalizedMessage();
        return null;
    }
}

From source file:com.kylinolap.rest.service.UserService.java

@Override
public boolean userExists(String username) {
    HTableInterface htable = null;//from w w  w .j  a v  a 2s. c  o m
    try {
        htable = HBaseConnection.get(hbaseUrl).getTable(userTableName);
        Result result = htable.get(new Get(Bytes.toBytes(username)));

        return null != result && !result.isEmpty();
    } catch (IOException e) {
        logger.error(e.getLocalizedMessage(), e);
    } finally {
        IOUtils.closeQuietly(htable);
    }

    return false;
}

From source file:com.kylinolap.rest.service.UserService.java

@Override
public void updateUser(UserDetails user) {
    byte[] userAuthorities = serialize(user.getAuthorities());
    HTableInterface htable = null;//from   w ww. j  av a2  s.  c o  m
    try {
        htable = HBaseConnection.get(hbaseUrl).getTable(userTableName);
        Put put = new Put(Bytes.toBytes(user.getUsername()));
        put.add(Bytes.toBytes(USER_AUTHORITY_FAMILY), Bytes.toBytes(USER_AUTHORITY_COLUMN), userAuthorities);

        htable.put(put);
        htable.flushCommits();
    } catch (IOException e) {
        logger.error(e.getLocalizedMessage(), e);
    } finally {
        IOUtils.closeQuietly(htable);
    }
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.LoadClinicalDataListener.java

public void writeLog(String text) {
    File log = new File(this.dataType.getPath() + File.separator + "kettle.log");
    try {/*from  ww w.  java  2  s .c o m*/
        FileWriter fw = new FileWriter(log);
        BufferedWriter output = new BufferedWriter(fw);
        output.write(text);
        output.close();
        ((ClinicalData) this.dataType).setLogFile(log);
    } catch (IOException ioe) {
        this.loadDataUI.displayMessage("File error: " + ioe.getLocalizedMessage());
        ioe.printStackTrace();
    }
}

From source file:com.kylinolap.rest.service.UserService.java

private byte[] serialize(Collection<? extends GrantedAuthority> auths) {
    if (null == auths) {
        return null;
    }//from w  w w  .j  a  v  a2s . com

    ByteArrayOutputStream buf = new ByteArrayOutputStream();
    DataOutputStream dout = new DataOutputStream(buf);

    try {
        ObjectMapper mapper = new ObjectMapper();
        mapper.writeValue(dout, auths);
        dout.close();
        buf.close();
    } catch (IOException e) {
        logger.error(e.getLocalizedMessage(), e);
    }

    return buf.toByteArray();
}

From source file:ratpack.codahale.metrics.internal.WebSocketReporter.java

@Override
@SuppressWarnings("rawtypes")
public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
        SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters,
        SortedMap<String, Timer> timers) {
    try {/*from w w  w  .j  a  v a 2  s .c om*/
        OutputStream out = new ByteArrayOutputStream();
        JsonGenerator json = factory.createGenerator(out);

        json.writeStartObject();
        json.writeNumberField("timestamp", clock.getTime());
        writeTimers(json, timers);
        writeGauges(json, gauges);
        writeMeters(json, meters);
        writeCounters(json, counters);
        writeHistograms(json, histograms);
        json.writeEndObject();

        json.flush();
        json.close();

        metricsBroadcaster.broadcast(out.toString());
    } catch (IOException e) {
        LOGGER.log(Level.WARNING, "Exception encountered while reporting metrics: " + e.getLocalizedMessage());
    }
}

From source file:com.thalesgroup.hudson.plugins.klocwork.KloSource.java

private void initializeContent() {

    InputStream is = null;/* w  ww .  j a  v  a2 s .c  om*/
    try {

        File tempFile = new File(kloWorkspaceFile.getTempName(owner));
        if (tempFile.exists()) {
            is = new FileInputStream(tempFile);
        } else {

            if (kloWorkspaceFile.getFileName() == null) {
                throw new IOException("The file doesn't exist.");
            }

            File file = new File(kloWorkspaceFile.getFileName());
            if (!file.exists()) {
                throw new IOException("Can't access the file: " + file.toURI());
            }
            is = new FileInputStream(file);
        }

        splitSourceFile(highlightSource(is));
    } catch (IOException exception) {
        sourceCode = "Can't read file: " + exception.getLocalizedMessage();
    } catch (RuntimeException re) {
        sourceCode = "Problem for display the source code content: " + re.getLocalizedMessage();
    } finally {
        IOUtils.closeQuietly(is);
    }

}

From source file:com.sastix.cms.server.services.content.impl.ZipHandlerServiceImpl.java

public String findStartPage(final Path metadataPath) {
    final String json;
    try {/*w ww  .jav a  2  s .c o m*/
        json = new String(Files.readAllBytes(metadataPath), "UTF-8");
    } catch (IOException e) {
        LOG.error("Error in determining if it is a cms zip resource: {}", e.getLocalizedMessage());
        throw new ResourceAccessError("Zip " + metadataPath.getFileName() + " cannot be read. ");
    }

    final Map<String, Object> map = gsonJsonParser.parseMap(json);

    String startPage;
    if (map.get(METADATA_STARTPAGE) != null) {
        startPage = (String) map.get(METADATA_STARTPAGE);
    } else if (map.get(METADATA_STARTPAGE_CAMEL) != null) {
        startPage = (String) map.get(METADATA_STARTPAGE_CAMEL);
    } else {
        throw new ResourceAccessError("Start page in Zip " + metadataPath.getFileName() + " cannot be found");
    }

    return startPage;
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.LoadAnnotationListener.java

public void writeLog(String text) {
    File log = new File(dataType.getPath() + File.separator + "annotation.kettle.log");
    try {/*from w  w  w .  ja  va  2 s . c  o m*/
        FileWriter fw = new FileWriter(log);
        BufferedWriter output = new BufferedWriter(fw);
        output.write(text);
        output.close();
        ((GeneExpressionData) dataType).setLogFile(log);
    } catch (IOException ioe) {
        loadAnnotationUI.setMessage("File error: " + ioe.getLocalizedMessage());
        ioe.printStackTrace();
    }
}