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.filesystem.client.FilesystemClient.java

public void localDelete(String destFolderPath, boolean ignoreNotExists) throws FilesystemClientException {
    Path destination = Paths.get(destFolderPath);

    try {/*from   w  w  w.j av a 2 s.co m*/
        if (!Files.exists(destination)) {
            if (ignoreNotExists) {
                logger.debug("Destination directory " + destFolderPath + " does not exist, ignoring...");
            } else {
                throw new FilesystemClientException(
                        "Destination directory " + destFolderPath + " does not exist");
            }
        } else {
            FileUtils.deleteDirectory(destination.toFile());
        }

    } catch (IOException e) {
        logger.debug(e.getLocalizedMessage());
        throw new FilesystemClientException(e.getLocalizedMessage());
    }

}

From source file:com.ibm.rpe.web.template.ui.servlet.SaveTemplateLayout.java

@GET
@Path("/generate")
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public Response generateTemplate(@Context HttpServletRequest request,
        @QueryParam("layoutjson") String layoutJson, @QueryParam("title") String title) {
    try {//from  w w w.j ava 2 s .c  o m
        if (title == null) {
            title = UUID.randomUUID().toString() + ".dta";
        } else {
            title += ".dta";
        }

        TemplateLayoutUIModel uiModel = (TemplateLayoutUIModel) JSONUtils.readValue(layoutJson,
                TemplateLayoutUIModel.class);

        System.out.println(JSONUtils.writeValue(uiModel));
        String serviceUrl = getServiceUrl(request);

        TemplateBuilderUIImpl tBuilder = new TemplateBuilderUIImpl(uiModel, serviceUrl);
        String templateJson = tBuilder.buildTemplateJson();

        String templatePath = tBuilder.buildTemplate(templateJson);

        return Utils.downloadResponse(new FileInputStream(templatePath), title);
    } catch (IOException e) {
        e.printStackTrace();
        Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getLocalizedMessage()).build();
    } catch (Exception e) {
        e.printStackTrace();
        Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getLocalizedMessage()).build();
    }
    return null;
}

From source file:com.serena.rlc.provider.filesystem.client.FilesystemClient.java

public void localCopy(String srcFolderPath, String destFolderPath, boolean preserveDates)
        throws FilesystemClientException {
    File source = new File(srcFolderPath);
    File destination = new File(destFolderPath);

    try {// w  ww  . ja v a  2s  .c  o m
        if (!source.exists()) {
            throw new FilesystemClientException("Source directory " + srcFolderPath + " does not exist");
        }

        if (!destination.exists()) {
            logger.debug("Target directory " + destFolderPath + " does not exist, but it will be created...");
        }

        FileUtils.copyDirectory(source, destination, preserveDates);

    } catch (IOException e) {
        logger.debug(e.getLocalizedMessage());
        throw new FilesystemClientException(e.getLocalizedMessage());
    }

}

From source file:com.civis.utils.html.parser.HtmlParserTest.java

private String getMailContent(String fileName) {
    String mailContent = "";
    try (InputStream inputStream = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream(fileName)) {
        mailContent = IOUtils.toString(inputStream, "UTF-8");
        inputStream.close();// w ww  .  j av  a  2  s .  c o  m
    } catch (IOException e) {
        System.out.println(e.getLocalizedMessage());
    }

    return mailContent;
}

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

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setSiteIdUI.getValues();
    Vector<String> samples = this.setSiteIdUI.getSamples();
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
    if (stsmf == null) {
        this.setSiteIdUI.displayMessage("Error: no subject to sample mapping file");
    }//from   w ww  .  ja va 2s .c om
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

        try {
            BufferedReader br = new BufferedReader(new FileReader(stsmf));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                String[] fields = line.split("\t", -1);
                String sample = fields[3];
                String site;
                if (samples.contains(sample)) {
                    site = values.get(samples.indexOf(sample));
                } else {
                    br.close();
                    return;
                }
                out.write(fields[0] + "\t" + site + "\t" + fields[2] + "\t" + sample + "\t" + fields[4] + "\t"
                        + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n");
            }
            br.close();
        } catch (Exception e) {
            this.setSiteIdUI.displayMessage("Error: " + e.getLocalizedMessage());
            out.close();
            e.printStackTrace();
        }
        out.close();
        try {
            File fileDest;
            if (stsmf != null) {
                String fileName = stsmf.getName();
                stsmf.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
        } catch (IOException ioe) {
            this.setSiteIdUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setSiteIdUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setSiteIdUI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:ca.phon.query.script.QueryScript.java

/**
 * Setup library folders for 'require'//from   ww w  .j  ava2  s .c  o m
 */
private void setupLibraryFolders() {
    final ClassLoader cl = PluginManager.getInstance();
    Enumeration<URL> libUrls;
    try {
        libUrls = cl.getResources("ca/phon/query/script/");
        while (libUrls.hasMoreElements()) {
            final URL url = libUrls.nextElement();
            try {
                final URI uri = url.toURI();
                super.addRequirePath(uri);
            } catch (URISyntaxException e) {
                LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
            }
        }
    } catch (IOException e1) {
        LOGGER.log(Level.SEVERE, e1.getLocalizedMessage(), e1);
    }

    super.addPackageImport("Packages.ca.phon.orthography");
    super.addPackageImport("Packages.ca.phon.ipa");
    super.addPackageImport("Packages.ca.phon.ipa.features");
    super.addPackageImport("Packages.ca.phon.phonex");
    super.addPackageImport("Packages.ca.phon.syllable");
    super.addPackageImport("Packages.ca.phon.util");
    super.addPackageImport("Packages.ca.phon.project");
    super.addPackageImport("Packages.ca.phon.session");

    super.addClassImport("Packages.org.apache.commons.lang3.StringUtils");
}

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

public boolean geneateModel(String savePath, boolean save) {
    System.out.println("Rule geneateModel");
    boolean status = false;
    try {/*from   w  w  w.  j  av  a2 s.  c  om*/

        instances = csv.getDataSet();
        if (!save) {

            loadSaveModel(savePath, save);
        } else {

            ruleMoldel = new JRip();
        }
        instances.setClassIndex(instances.numAttributes() - 1);
        ruleMoldel.buildClassifier(instances);
        loadSaveModel(savePath, true);
        status = true;
    } catch (IOException e) {
        status = false;
        log.error("Error occurred:" + e.getLocalizedMessage());
    } catch (Exception e) {
        status = false;
        log.error("Error occurred:" + e.getLocalizedMessage());
    }
    return status;
}

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

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setAttribute1UI.getValues();
    Vector<String> samples = this.setAttribute1UI.getSamples();
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
    if (stsmf == null) {
        this.setAttribute1UI.displayMessage("Error: no subject to sample mapping file");
    }/*w w  w.  j  a v a 2s.com*/
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

        try {
            BufferedReader br = new BufferedReader(new FileReader(stsmf));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                String[] fields = line.split("\t", -1);
                String sample = fields[3];
                String attribute;
                if (samples.contains(sample)) {
                    attribute = values.get(samples.indexOf(sample));
                } else {
                    br.close();
                    return;
                }
                out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4]
                        + "\t" + fields[5] + "\t" + attribute + "\t" + fields[7] + "\t" + fields[8] + "\n");
            }
            br.close();
        } catch (Exception e) {
            setAttribute1UI.displayMessage("File error: " + e.getLocalizedMessage());
            out.close();
            e.printStackTrace();
        }
        out.close();
        try {
            File fileDest;
            if (stsmf != null) {
                String fileName = stsmf.getName();
                stsmf.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
        } catch (IOException ioe) {
            this.setAttribute1UI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setAttribute1UI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setAttribute1UI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

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

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setAttribute2UI.getValues();
    Vector<String> samples = this.setAttribute2UI.getSamples();
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
    if (stsmf == null) {
        this.setAttribute2UI.displayMessage("Error: no subject to sample mapping file");
    }//from  w  ww . j a  v a  2  s .c  om
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

        try {
            BufferedReader br = new BufferedReader(new FileReader(stsmf));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                String[] fields = line.split("\t", -1);
                String sample = fields[3];
                String attribute;
                if (samples.contains(sample)) {
                    attribute = values.get(samples.indexOf(sample));
                } else {
                    br.close();
                    return;
                }
                out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4]
                        + "\t" + fields[5] + "\t" + fields[6] + "\t" + attribute + "\t" + fields[8] + "\n");
            }
            br.close();
        } catch (Exception e) {
            this.setAttribute2UI.displayMessage("File error: " + e.getLocalizedMessage());
            out.close();
            e.printStackTrace();
        }
        out.close();
        try {
            File fileDest;
            if (stsmf != null) {
                String fileName = stsmf.getName();
                stsmf.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
        } catch (IOException ioe) {
            this.setAttribute2UI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setAttribute2UI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setAttribute2UI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

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

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setPlatformsUI.getValues();
    Vector<String> samples = this.setPlatformsUI.getSamples();
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
    if (stsmf == null) {
        this.setPlatformsUI.displayMessage("Error: no subject to sample mapping file");
    }//  w  ww. j  a va2 s . c o  m
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

        try {
            BufferedReader br = new BufferedReader(new FileReader(stsmf));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                String[] fields = line.split("\t", -1);
                String sample = fields[3];
                String platform;
                if (samples.contains(sample)) {
                    platform = values.get(samples.indexOf(sample));
                } else {
                    br.close();
                    return;
                }
                out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + platform
                        + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n");
            }
            br.close();
        } catch (Exception e) {
            this.setPlatformsUI.displayMessage("Error: " + e.getLocalizedMessage());
            out.close();
            e.printStackTrace();
        }
        out.close();
        try {
            File fileDest;
            if (stsmf != null) {
                String fileName = stsmf.getName();
                stsmf.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
        } catch (IOException ioe) {
            this.setPlatformsUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setPlatformsUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setPlatformsUI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}