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.eclipse.cdt.arduino.core.internal.board.ArduinoBoardManager.java

public ArduinoBoardManager() {
    new Job(Messages.ArduinoBoardManager_0) {
        protected IStatus run(IProgressMonitor monitor) {
            try (CloseableHttpClient client = HttpClients.createDefault()) {
                HttpGet get = new HttpGet("http://downloads.arduino.cc/packages/package_index.json"); //$NON-NLS-1$
                try (CloseableHttpResponse response = client.execute(get)) {
                    if (response.getStatusLine().getStatusCode() >= 400) {
                        return new Status(IStatus.ERROR, Activator.getId(),
                                response.getStatusLine().getReasonPhrase());
                    } else {
                        HttpEntity entity = response.getEntity();
                        if (entity == null) {
                            return new Status(IStatus.ERROR, Activator.getId(), Messages.ArduinoBoardManager_1);
                        }/* ww  w  . j  av  a2  s .  co m*/
                        Files.createDirectories(packageIndexPath.getParent());
                        Files.copy(entity.getContent(), packageIndexPath, StandardCopyOption.REPLACE_EXISTING);
                    }
                }
            } catch (IOException e) {
                return new Status(IStatus.ERROR, Activator.getId(), e.getLocalizedMessage(), e);
            }
            return Status.OK_STATUS;
        }
    }.schedule();
}

From source file:org.lobid.lodmill.JsonDecoder.java

@Override
public void process(final Reader reader) {
    STARTED = false;/*from w  w  w.ja v  a  2 s  .  c o m*/
    LOG.debug("############################ New");
    try {
        JsonToken currentToken = parseJson(reader);
        if (currentToken == null)
            return;
        processTokens(currentToken);
    } catch (final IOException e) {
        try {
            LOG.warn(e.getLocalizedMessage() + "while computing " + this.jsonParser.getText());
        } catch (JsonParseException e1) {
            e1.printStackTrace();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }
}

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

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    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.setStudyTreeUI.displayMessage("Error: no subject to sample mapping file");
    }/*from w  w w  .j a  v  a2  s.co m*/
    String category = "";
    TreeNode node = this.setStudyTreeUI.getRoot();
    if (!node.hasChildren()) {
        this.setStudyTreeUI.displayMessage("You have to set a category code");
        return;
    }
    node = node.getChildren().get(0);
    while (node != null) {
        if (category.compareTo("") == 0) {
            category += node.toString().replace(' ', '_');
        } else {
            category += "+" + node.toString().replace(' ', '_');
        }
        if (node.hasChildren()) {
            node = node.getChildren().get(0);
        } else {
            node = null;
        }
    }
    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);
                out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + fields[3] + "\t" + fields[4]
                        + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + category + "\n");
            }
            br.close();
        } catch (Exception e) {
            this.setStudyTreeUI.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.setStudyTreeUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setStudyTreeUI.displayMessage("Eerror: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setStudyTreeUI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:fr.fastconnect.factory.tibco.bw.maven.run.LaunchDesignerMojo.java

public void execute() throws MojoExecutionException {
    enableTestScope();/*  w w w  .j a  va  2  s. co  m*/

    super.execute();

    if (adaptAliases) {
        try {
            updateAliasesFile();
        } catch (IOException e) {
            throw new MojoExecutionException(e.getLocalizedMessage(), e);
        }
    }

    try {
        launchDesigner();
    } catch (IOException e) {
        throw new MojoExecutionException(LAUNCH_DESIGNER_FAILED, e);
    }
}

From source file:com.amazonaws.mturk.cmd.EvaluateQualificationRequests.java

protected void runCommand(CommandLine cmdLine) throws Exception {
    if (!cmdLine.hasOption(QUAL_TYPE) && !cmdLine.hasOption(INPUT_FILE)) {

        log.error("Either -" + QUAL_TYPE + " or -" + INPUT_FILE + " should be passed");

        System.exit(-1);/*from w  w w.  j a v a  2s. c o  m*/

    } else {
        String qualIds[] = null;
        if (cmdLine.hasOption(QUAL_TYPE)) {
            qualIds = new String[1];
            qualIds[0] = cmdLine.getOptionValue(QUAL_TYPE);
        } else {
            try {
                qualIds = super.getFieldValuesFromFile(cmdLine.getOptionValue(INPUT_FILE), QUAL_TYPE);
            } catch (IOException e) {
                log.error("error occured reading file: " + e.getLocalizedMessage(), e);
                System.exit(-1);
            }
            if (qualIds.length == 0) {
                log.error("qualtypeid must be present in the -" + INPUT_FILE + " file");
                System.exit(-1);
            }
        }

        for (String qualId : qualIds) {
            evaluateQualificationRequests(qualId, cmdLine.getOptionValue("answers"),
                    cmdLine.hasOption("preview"));
        }
    }
}

From source file:org.angrycamel.ivydav.DavResource.java

/**
 * Get a list of direct descendents of the given resource. Note that attempts to get a list of
 * children does <emphasize>not</emphasize> result in an error. Instead an error message is
 * logged and an empty ArrayList returned.
 *//*ww w  .  j  ava  2 s . c o  m*/
public List<String> getChildren() {
    init();
    Existence type = existence();
    if (Existence.ABSENT.equals(type)) {
        Message.error(uri + " does not exist; cannot enumerate children!");
        return Collections.emptyList();
    } else if (Existence.FILE.equals(type)) {
        Message.error(uri + " exists but is not a directory; cannot enumerate children");
        return Collections.emptyList();
    }
    List<String> list = null;
    try {
        list = repository.getDirectoryResources(uri);
    } catch (IOException e) {
        Message.verbose(e.getLocalizedMessage());
    }
    return list;
}

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

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setSubjectsIdUI.getValues();
    Vector<String> samples = this.setSubjectsIdUI.getSamples();
    for (String v : values) {
        if (v.compareTo("") == 0) {
            this.setSubjectsIdUI.displayMessage("All identifiers have to be set");
            return;
        }//from ww w.j  a  va  2 s. c  om
    }

    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    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");

        File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
        if (stsmf == null) {
            for (int i = 0; i < samples.size(); i++) {
                out.write(this.dataType.getStudy().toString() + "\t" + "\t" + values.elementAt(i) + "\t"
                        + samples.elementAt(i) + "\t" + "\t" + "\t" + "\t" + "\t" + "\n");
            }
        } else {
            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 subject;
                    if (samples.contains(sample)) {
                        subject = values.get(samples.indexOf(sample));
                    } else {
                        br.close();
                        return;
                    }
                    out.write(fields[0] + "\t" + fields[1] + "\t" + subject + "\t" + sample + "\t" + fields[4]
                            + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n");
                }
                br.close();
            } catch (Exception e) {
                this.setSubjectsIdUI.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.setSubjectsIdUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setSubjectsIdUI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
    UsedFilesPart.sendFilesChanged(dataType);
}

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

@Override
public void handleEvent(Event event) {
    //write in a new file
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".columns.tmp");
    try {/*  w  w w .ja va 2s . c  o m*/
        Vector<String> subjectIds = this.setSubjectsIdUI.getSubjectIds();
        for (String s : subjectIds) {
            if (s.compareTo("") == 0) {
                this.setSubjectsIdUI.displayMessage("Subjects identifier columns have to be choosen");
                return;
            }
        }

        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n");

        //subject identifier
        Vector<File> rawFiles = ((ClinicalData) this.dataType).getRawFiles();
        for (int i = 0; i < rawFiles.size(); i++) {
            int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), subjectIds.elementAt(i));
            if (columnNumber != -1) {
                out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tSUBJ_ID\t\t\n");
            }
        }
        if (((ClinicalData) this.dataType).getCMF() == null) {
            out.close();
            File fileDest = new File(this.dataType.getPath().toString() + File.separator
                    + this.dataType.getStudy().toString() + ".columns");
            FileUtils.moveFile(file, fileDest);
            ((ClinicalData) this.dataType).setCMF(fileDest);
            WorkPart.updateSteps();
        } else {
            try {
                BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF()));
                String line = br.readLine();
                while ((line = br.readLine()) != null) {
                    String[] s = line.split("\t", -1);
                    if (s[3].compareTo("SUBJ_ID") != 0) {
                        out.write(line + "\n");
                    }
                }
                br.close();
            } catch (Exception e) {
                this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage());
                e.printStackTrace();
                out.close();
            }
            out.close();
            try {
                String fileName = ((ClinicalData) this.dataType).getCMF().getName();
                ((ClinicalData) this.dataType).getCMF().delete();
                File fileDest = new File(this.dataType.getPath() + File.separator + fileName);
                FileUtils.moveFile(file, fileDest);
                ((ClinicalData) this.dataType).setCMF(fileDest);
            } catch (IOException ioe) {
                this.setSubjectsIdUI.displayMessage("File errorrror: " + ioe.getLocalizedMessage());
                return;
            }

        }
    } catch (Exception e) {
        this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setSubjectsIdUI.displayMessage("Column mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
    UsedFilesPart.sendFilesChanged(dataType);
}

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

@Override
public void handleEvent(Event event) {
    Vector<File> files = this.selectRawFilesUI.getSelectedRemovedFile();
    if (files.size() < 1) {
        this.selectRawFilesUI.displayMessage("No file selected");
        return;//from  www.  j  a va 2 s.c om
    }
    File mapping = ((GeneExpressionData) this.dataType).getStsmf();
    boolean confirm = this.selectRawFilesUI.confirm(
            "The column mapping file and the word mapping file will be removed consequently.\nAre you sure to remove these files?");
    for (File file : files) {
        if (file == null) {
            return;
        }
        if (((GeneExpressionData) this.dataType).getRawFiles().size() == files.size()) {
            if (mapping != null) {
                if (confirm) {
                    ((GeneExpressionData) this.dataType).setSTSMF(null);
                    try {
                        FileUtils.forceDelete(mapping);
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        this.selectRawFilesUI.displayMessage("File error: " + e.getLocalizedMessage());
                        e.printStackTrace();
                    }

                    ((GeneExpressionData) this.dataType).getRawFiles().remove(file);
                    FileUtils.deleteQuietly(file);
                    UsedFilesPart.sendFilesChanged(dataType);
                }
            } else {
                if (confirm) {
                    ((GeneExpressionData) this.dataType).getRawFiles().remove(file);
                    FileUtils.deleteQuietly(file);
                    UsedFilesPart.sendFilesChanged(dataType);
                }
            }
        }
    }
    this.selectRawFilesUI.updateViewer();
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:ru.codemine.ccms.service.DataFileService.java

@Transactional
public void delete(DataFile file) {
    File f = new File(file.getFilename());
    try {/*from w  ww .j ava2s  .c  o  m*/
        Files.deleteIfExists(f.toPath());
    } catch (IOException ex) {
        log.warn("    ? ?: " + file.getViewName() + "("
                + file.getFilename() + "), : " + ex.getLocalizedMessage());
    }
    dataFileDAO.delete(file);
}