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:de.fraunhofer.iosb.ilt.stc.FXMLController.java

@FXML
private void actionLoad(ActionEvent event) {
    fileChooser.setTitle("Load Config");
    File file = fileChooser.showOpenDialog(paneConfig.getScene().getWindow());
    try {/*from   w  w w .j  a v  a  2 s .  c  o  m*/
        String config = FileUtils.readFileToString(file, "UTF-8");
        JsonElement json = new JsonParser().parse(config);
        copier.configure(json, null, null);
    } catch (IOException ex) {
        LOGGER.error("Failed to read file", ex);
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle("failed to read file");
        alert.setContentText(ex.getLocalizedMessage());
        alert.showAndWait();
    }
}

From source file:es.urjc.mctwp.bbeans.research.image.DownloadBean.java

public String accDownloadStudyImages() {
    Study study = getSession().getStudy();

    try {/*from w w w  . ja va2 s .  c o m*/
        if (study != null) {
            ZipOutputStream zos = prepareZOS(studyHeader + study.getDescription());
            downloadStudyImages(study, zos, null);
            if (zos != null)
                zos.close();
            completeResponse();
        }
    } catch (IOException e) {
        setErrorMessage(e.getLocalizedMessage());
        e.printStackTrace();
    }

    return null;
}

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

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    String path = this.selectCMFUI.getPath();
    if (path == null)
        return;/* w ww.  j  av a2 s .c o m*/
    if (path.contains("%")) {
        this.selectCMFUI.displayMessage("File name can not contain percent ('%') symbol.");
        return;
    }
    File file = new File(path);
    if (file.exists()) {
        if (file.isFile()) {
            if (!this.checkFormat(file))
                return;
            String newPath;
            if (file.getName().endsWith(".columns")) {
                newPath = this.dataType.getPath().getAbsolutePath() + File.separator + file.getName();
            } else {
                newPath = this.dataType.getPath().getAbsolutePath() + File.separator + file.getName()
                        + ".columns";
            }

            File copiedFile = new File(newPath);
            try {
                FileUtils.copyFile(file, copiedFile);
                ((ClinicalData) this.dataType).setCMF(copiedFile);

                this.selectCMFUI.displayMessage("File has been added");
                WorkPart.updateSteps();
                //to do: update files list
                UsedFilesPart.sendFilesChanged(dataType);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                this.selectCMFUI.displayMessage("File error: " + e.getLocalizedMessage());
                e.printStackTrace();
            }
        } else {
            this.selectCMFUI.displayMessage("This is a directory");
        }
    } else {
        this.selectCMFUI.displayMessage("This path does no exist");
    }
}

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

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    HTableInterface htable = null;/* w w  w .  j a  va 2 s.c  o m*/
    try {
        htable = HBaseConnection.get(hbaseUrl).getTable(userTableName);

        Get get = new Get(Bytes.toBytes(username));
        get.addFamily(Bytes.toBytes(USER_AUTHORITY_FAMILY));
        Result result = htable.get(get);

        Collection<? extends GrantedAuthority> authorities = null;
        if (null != result && !result.isEmpty()) {
            byte[] gaBytes = result.getValue(Bytes.toBytes(USER_AUTHORITY_FAMILY),
                    Bytes.toBytes(USER_AUTHORITY_COLUMN));
            authorities = Arrays.asList(ugaSerializer.deserialize(gaBytes));
        } else {
            throw new UsernameNotFoundException("User " + username + " not found.");
        }

        return new User(username, "N/A", authorities);
    } catch (IOException e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new RuntimeException(e);
    } finally {
        IOUtils.closeQuietly(htable);
    }
}

From source file:com.clough.android.adbv.manager.ADBManager.java

/**
 * Executing the adb commands given in var-args
 * @param args adb command in var-args//from   w w w.  j  a v  a 2 s .  c  o  m
 */
private synchronized void adb(final String... args) {
    String[] commands = new String[args.length + 1];
    commands[0] = adbPath;
    System.arraycopy(args, 0, commands, 1, args.length);
    try {
        Runtime.getRuntime().exec(commands).waitFor();
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, ex.getLocalizedMessage(), "Android DB Viewer",
                JOptionPane.ERROR_MESSAGE);
    } catch (InterruptedException ex) {
        JOptionPane.showMessageDialog(null, ex.getLocalizedMessage(), "Android DB Viewer",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:fr.fastconnect.factory.tibco.bw.maven.packaging.pom.AbstractPOMGenerator.java

public void execute() throws MojoExecutionException {
    if (deploymentProperties == null) {
        deploymentProperties = new ArrayList<String>();
    }/*  ww w.j  ava 2  s .  co  m*/

    Boolean skipParent = super.skip();
    if (skipParent || getSkipGeneratePOM()) {
        if (!skipParent) {
            getLog().info(SKIPPING);
        }

        File outputFile = getOutputFile();
        if (outputFile != null && !outputFile.exists() && getTouchWhenSkipped()) {
            // deployment POM was not created because packaging is skipped
            // however we "touch" the deployment POM file so there is an empty deployment POM file created
            try {
                outputFile.getParentFile().mkdirs();
                outputFile.createNewFile();
            } catch (IOException e) {
                throw new MojoExecutionException(e.getLocalizedMessage(), e);
            }
        }
        if (outputFile != null && outputFile.exists()) {
            attachFile(outputFile, POM_TYPE, getClassifier());
        } else if (getTouchWhenSkipped()) {
            getLog().warn(WARN_NO_ARTIFACT_ATTACHED);
        }
        return;
    }

    if (!packageDirectory.exists()) {
        packageDirectory.mkdirs();
    }

    generateDeployPOM(getProject());
}

From source file:de.fraunhofer.iosb.ilt.stc.FXMLController.java

@FXML
private void actionSave(ActionEvent event) {
    JsonElement json = configEditor.getConfig();
    String config = new GsonBuilder().setPrettyPrinting().create().toJson(json);
    fileChooser.setTitle("Save Config");
    File file = fileChooser.showSaveDialog(paneConfig.getScene().getWindow());

    try {/*from ww  w .j  a  v  a  2  s.c  o m*/
        FileUtils.writeStringToFile(file, config, "UTF-8");
    } catch (IOException ex) {
        LOGGER.error("Failed to write file.", ex);
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle("failed to write file");
        alert.setContentText(ex.getLocalizedMessage());
        alert.showAndWait();
    }
}

From source file:gov.va.med.pharmacy.peps.presentation.common.displaytag.DefaultHssfExportView.java

/**
 * escapeColumnValue//  w  w w  . j  a va2  s  .c om
 * @param rawValue unmodified text
 * @return String with html/xml removed
 */
protected String escapeColumnValue(Object rawValue) {

    if (rawValue == null) {
        return null;
    }

    String returnString = ObjectUtils.toString(rawValue);

    // Extract text
    try {
        returnString = extractText(returnString);
    } catch (IOException e) {
        LOG.warn(e.getLocalizedMessage());
    }

    // escape the String to get the tabs, returns, newline explicit as \t \r \n
    returnString = StringEscapeUtils.escapeJava(StringUtils.trimToEmpty(returnString));

    // remove tabs, insert four whitespaces instead
    returnString = StringUtils.replace(StringUtils.trim(returnString), "\\t", "    ");

    // remove the return, only newline valid in excel
    returnString = StringUtils.replace(StringUtils.trim(returnString), "\\r", " ");

    // unescape so that \n gets back to newline
    returnString = StringEscapeUtils.unescapeJava(returnString);

    return returnString;
}

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

@Override
public List<String> getUserAuthorities() {
    Scan s = new Scan();
    s.addColumn(Bytes.toBytes(USER_AUTHORITY_FAMILY), Bytes.toBytes(USER_AUTHORITY_COLUMN));

    List<String> authorities = new ArrayList<String>();
    HTableInterface htable = null;/*  www.  jav a  2  s  .com*/
    ResultScanner scanner = null;
    try {
        htable = HBaseConnection.get(hbaseUrl).getTable(userTableName);
        scanner = htable.getScanner(s);

        for (Result result = scanner.next(); result != null; result = scanner.next()) {
            byte[] uaBytes = result.getValue(Bytes.toBytes(USER_AUTHORITY_FAMILY),
                    Bytes.toBytes(USER_AUTHORITY_COLUMN));
            Collection<? extends GrantedAuthority> authCollection = Arrays
                    .asList(ugaSerializer.deserialize(uaBytes));

            for (GrantedAuthority auth : authCollection) {
                if (!authorities.contains(auth.getAuthority())) {
                    authorities.add(auth.getAuthority());
                }
            }
        }
    } catch (IOException e) {
        logger.error(e.getLocalizedMessage(), e);
    } finally {
        IOUtils.closeQuietly(scanner);
        IOUtils.closeQuietly(htable);
    }

    return authorities;
}

From source file:com.liferay.ide.project.core.util.ProjectUtil.java

public static boolean collectProjectsFromDirectory(Collection<File> eclipseProjectFiles,
        Collection<File> liferayProjectDirs, File directory, Set<String> directoriesVisited, boolean recurse,
        IProgressMonitor monitor) {//  ww  w. j  av a 2 s.c  om
    if (monitor.isCanceled()) {
        return false;
    }

    monitor.subTask(NLS.bind(Msgs.checking, directory.getPath()));

    File[] contents = directory.listFiles();

    if (contents == null) {
        return false;
    }

    // Initialize recursion guard for recursive symbolic links
    if (directoriesVisited == null) {
        directoriesVisited = new HashSet<String>();

        try {
            directoriesVisited.add(directory.getCanonicalPath());
        } catch (IOException exception) {
            ProjectCore.logError(exception.getLocalizedMessage(), exception);
        }
    }

    // first look for project description files
    final String dotProject = IProjectDescription.DESCRIPTION_FILE_NAME;

    for (int i = 0; i < contents.length; i++) {
        File file = contents[i];

        if (isLiferaySDKProjectDir(file)) {
            // recurse to see if it has project file
            int currentSize = eclipseProjectFiles.size();

            collectProjectsFromDirectory(eclipseProjectFiles, liferayProjectDirs, contents[i],
                    directoriesVisited, false, monitor);

            int newSize = eclipseProjectFiles.size();

            if (newSize == currentSize) {
                liferayProjectDirs.add(file);
            }
        } else if (file.isFile() && file.getName().equals(dotProject)) {
            if (!eclipseProjectFiles.contains(file) && isLiferaySDKProjectDir(file.getParentFile())) {
                eclipseProjectFiles.add(file);

                // don't search sub-directories since we can't have nested
                // projects

                return true;
            }
        }
    }

    // no project description found, so recurse into sub-directories
    for (int i = 0; i < contents.length; i++) {
        if (contents[i].isDirectory()) {
            if (!contents[i].getName().equals(METADATA_FOLDER)) {
                try {
                    String canonicalPath = contents[i].getCanonicalPath();

                    if (!directoriesVisited.add(canonicalPath)) {

                        // already been here --> do not recurse
                        continue;
                    }
                } catch (IOException exception) {
                    ProjectCore.logError(exception.getLocalizedMessage(), exception);
                }

                // dont recurse directories that we have already determined
                // are Liferay projects
                if (!liferayProjectDirs.contains(contents[i]) && recurse) {
                    collectProjectsFromDirectory(eclipseProjectFiles, liferayProjectDirs, contents[i],
                            directoriesVisited, recurse, monitor);
                }
            }
        }
    }

    return true;
}