Example usage for java.io FileNotFoundException getLocalizedMessage

List of usage examples for java.io FileNotFoundException getLocalizedMessage

Introduction

In this page you can find the example usage for java.io FileNotFoundException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.apache.zeppelin.interpreter.InterpreterSettingManager.java

private void loadInterpreterDependencies(final InterpreterSetting setting) {
    setting.setStatus(InterpreterSetting.Status.DOWNLOADING_DEPENDENCIES);
    setting.setErrorReason(null);/*from   w w w  . j  av  a  2s.  c  o  m*/
    interpreterSettings.put(setting.getId(), setting);
    synchronized (interpreterSettings) {
        final Thread t = new Thread() {
            public void run() {
                try {
                    // dependencies to prevent library conflict
                    File localRepoDir = new File(
                            zeppelinConfiguration.getInterpreterLocalRepoPath() + "/" + setting.getId());
                    if (localRepoDir.exists()) {
                        try {
                            FileUtils.cleanDirectory(localRepoDir);
                        } catch (FileNotFoundException e) {
                            logger.info("A file that does not exist cannot be deleted, nothing to worry", e);
                        }
                    }

                    // load dependencies
                    List<Dependency> deps = setting.getDependencies();
                    if (deps != null) {
                        for (Dependency d : deps) {
                            File destDir = new File(
                                    zeppelinConfiguration.getRelativeDir(ConfVars.ZEPPELIN_DEP_LOCALREPO));

                            if (d.getExclusions() != null) {
                                dependencyResolver.load(d.getGroupArtifactVersion(), d.getExclusions(),
                                        new File(destDir, setting.getId()));
                            } else {
                                dependencyResolver.load(d.getGroupArtifactVersion(),
                                        new File(destDir, setting.getId()));
                            }
                        }
                    }

                    setting.setStatus(InterpreterSetting.Status.READY);
                    setting.setErrorReason(null);
                } catch (Exception e) {
                    logger.error(String.format(
                            "Error while downloading repos for interpreter group : %s,"
                                    + " go to interpreter setting page click on edit and save it again to make "
                                    + "this interpreter work properly. : %s",
                            setting.getGroup(), e.getLocalizedMessage()), e);
                    setting.setErrorReason(e.getLocalizedMessage());
                    setting.setStatus(InterpreterSetting.Status.ERROR);
                } finally {
                    interpreterSettings.put(setting.getId(), setting);
                }
            }
        };
        t.start();
    }
}

From source file:org.opencms.setup.CmsSetupBean.java

/**
 * Reads all components from the given location, a folder or a zip file.<p>
 * /* w  ww .j  a v  a  2 s .c o m*/
 * @param fileName the location to read the components from
 * 
 * @throws CmsConfigurationException if something goes wrong 
 */
protected void addComponentsFromPath(String fileName) throws CmsConfigurationException {

    CmsParameterConfiguration configuration;
    try {
        configuration = getComponentsProperties(fileName);
    } catch (FileNotFoundException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug(e.getLocalizedMessage(), e);
        }
        return;
    }

    for (String componentId : configuration.getList(PROPKEY_COMPONENTS)) {
        CmsSetupComponent componentBean = new CmsSetupComponent();
        componentBean.setId(componentId);
        componentBean.setName(configuration.get(PROPKEY_COMPONENT + componentId + PROPKEY_NAME));
        componentBean.setDescription(configuration.get(PROPKEY_COMPONENT + componentId + PROPKEY_DESCRIPTION));
        componentBean.setModulesRegex(configuration.get(PROPKEY_COMPONENT + componentId + PROPKEY_MODULES));
        componentBean
                .setDependencies(configuration.getList(PROPKEY_COMPONENT + componentId + PROPKEY_DEPENDENCIES));
        componentBean.setPosition(
                configuration.getInteger(PROPKEY_COMPONENT + componentId + PROPKEY_POSITION, DEFAULT_POSITION));
        componentBean
                .setChecked(configuration.getBoolean(PROPKEY_COMPONENT + componentId + PROPKEY_CHECKED, false));
        m_components.addIdentifiableObject(componentBean.getId(), componentBean, componentBean.getPosition());
    }
}

From source file:com.photon.phresco.framework.impl.SCMManagerImpl.java

private ProjectInfo getRepoProjectInfo(File dotProjectFile) throws PhrescoException {
    if (debugEnabled) {
        S_LOGGER.debug("Entering Method  SCMManagerImpl.getGitAppInfo()");
    }/*w ww . ja v a2  s  . c o  m*/

    BufferedReader reader = null;
    try {
        if (debugEnabled) {
            S_LOGGER.debug(dotProjectFile.getAbsolutePath());
            S_LOGGER.debug("dotProjectFile" + dotProjectFile);
        }
        if (!dotProjectFile.exists()) {
            return null;
        }
        reader = new BufferedReader(new FileReader(dotProjectFile));
        return new Gson().fromJson(reader, ProjectInfo.class);
    } catch (FileNotFoundException e) {
        if (debugEnabled) {
            S_LOGGER.error("Entering into catch block of getGitAppInfo() " + e.getLocalizedMessage());
        }
        throw new PhrescoException(INVALID_FOLDER);
    } finally {
        Utility.closeStream(reader);
    }
}

From source file:com.photon.phresco.framework.impl.ProjectAdministratorImpl.java

/**
 * Creates a project based on the given project information
 *
 * @return Project based on the given information
 *///from  w w w  . j av a2 s.c o  m
public Project createProject(ProjectInfo info, File path, User userInfo) throws PhrescoException {

    S_LOGGER.debug("Entering Method ProjectAdministratorImpl.createProject(ProjectInfo info, File path)");
    S_LOGGER.debug("createProject() > info name : " + info.getName());

    File projectPath = new File(Utility.getProjectHome() + File.separator + info.getCode());
    String techId = info.getTechnology().getId();
    if (StringUtils.isEmpty(info.getVersion())) {
        info.setVersion(PROJECT_VERSION); // TODO: Needs to be fixed
    }
    ClientResponse response = PhrescoFrameworkFactory.getServiceManager().createProject(info, userInfo);

    S_LOGGER.debug("createProject response code " + response.getStatus());

    if (response.getStatus() == 200) {
        try {
            extractArchive(response, info);
            updateProjectPOM(info);
        } catch (FileNotFoundException e) {
            throw new PhrescoException(e);
        } catch (IOException e) {
            throw new PhrescoException(e);
        }
    } else if (response.getStatus() == 401) {
        throw new PhrescoException("Session Expired ! Please Relogin.");
    } else {
        throw new PhrescoException("Project creation failed");
    }
    boolean flag1 = techId.equals(TechnologyTypes.JAVA_WEBSERVICE)
            || techId.equals(TechnologyTypes.JAVA_STANDALONE) || techId.equals(TechnologyTypes.HTML5_WIDGET)
            || techId.equals(TechnologyTypes.HTML5_MOBILE_WIDGET)
            || techId.equals(TechnologyTypes.HTML5_MULTICHANNEL_JQUERY_WIDGET);
    if (flag1) {
        File pomPath = new File(projectPath, POM_FILE);
        ServerPluginUtil spUtil = new ServerPluginUtil();
        spUtil.addServerPlugin(info, pomPath);
    }
    boolean drupal = techId.equals(TechnologyTypes.PHP_DRUPAL7) || techId.equals(TechnologyTypes.PHP_DRUPAL6);
    try {
        if (drupal) {
            updateDrupalVersion(projectPath, info);
            excludeModule(info);
        }
    } catch (IOException e1) {
        throw new PhrescoException(e1);
    } catch (JAXBException e1) {
        throw new PhrescoException(e1);
    } catch (ParserConfigurationException e1) {
        throw new PhrescoException(e1);
    }

    // Creating configuration file, after successfull creation of project
    try {
        createConfigurationXml(info.getCode());
    } catch (Exception e) {
        S_LOGGER.error("Entered into the catch block of Configuration creation failed Exception"
                + e.getLocalizedMessage());
        throw new PhrescoException("Configuration creation failed");
    }
    return new ProjectImpl(info);
}

From source file:edu.cmu.cylab.starslinger.view.HomeActivity.java

private boolean saveFileAtLocation(File downloadedFile, MessageData recvMsg) {
    try {/*from w  ww  .  ja  v a2  s  .  c  om*/
        File saveFile = downloadedFile;

        // make sure filename is unique
        int index = 1;
        while (saveFile.exists()) {
            saveFile = new File(SSUtil.getEnumeratedFilename(downloadedFile.getAbsolutePath(), index));
            index++;
        }

        FileOutputStream f = new FileOutputStream(saveFile);
        ByteArrayInputStream in = new ByteArrayInputStream(recvMsg.getFileData());
        byte[] buffer = new byte[1024];
        int len1 = 0;
        while ((len1 = in.read(buffer)) > 0) {
            f.write(buffer, 0, len1);
        }
        f.close();

        MessageDbAdapter dbMessage = MessageDbAdapter.openInstance(getApplicationContext());
        if (!dbMessage.updateMessageFileLocation(recvMsg.getRowId(), saveFile.getName(), saveFile.getPath())) {
            showNote(R.string.error_UnableToUpdateMessageInDB);
        }

        // always show file automatically...
        showFileActionChooser(saveFile, recvMsg.getFileType());

        return true;
    } catch (FileNotFoundException e) {
        showNote(e.getLocalizedMessage());
        return false;
    } catch (SecurityException e) {
        showNote(e.getLocalizedMessage());
        return false;
    } catch (IOException e) {
        showNote(e.getLocalizedMessage());
        return false;
    }
}

From source file:canreg.client.gui.analysis.TableBuilderInternalFrame.java

private void generateTablesAction(FileTypes filetype) {
    boolean filterError = false;

    TableBuilderListElement tble = (TableBuilderListElement) tableTypeList.getSelectedValue();

    if (tble == null) {
        JOptionPane.showMessageDialog(this,
                java.util.ResourceBundle
                        .getBundle("canreg/client/gui/analysis/resources/TableBuilderInternalFrame")
                        .getString("NO_TABLE_TYPE_SELECTED"),
                java.util.ResourceBundle
                        .getBundle("canreg/client/gui/analysis/resources/TableBuilderInternalFrame")
                        .getString("NO_TABLE_TYPE_SELECTED"),
                JOptionPane.ERROR_MESSAGE);
        return;//from   w w w .  j  av  a  2  s .  com
    } else {
        try {
            tableBuilder = TableBuilderFactory.getTableBuilder(tble);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(TableBuilderInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    Set<DatabaseVariablesListElement> variables = new LinkedHashSet<>();
    DistributedTableDescription tableDatadescription;
    JChartTableBuilderInterface chartBuilder;

    if (tableBuilder == null) {
        JOptionPane.showMessageDialog(this,
                java.util.ResourceBundle
                        .getBundle("canreg/client/gui/analysis/resources/TableBuilderInternalFrame")
                        .getString("TABLE_TYPE_NOT_YET_IMPLEMENTED"),
                java.util.ResourceBundle
                        .getBundle("canreg/client/gui/analysis/resources/TableBuilderInternalFrame")
                        .getString("TABLE_TYPE_NOT_YET_IMPLEMENTED"),
                JOptionPane.ERROR_MESSAGE);
        return;
    } else {
        String heading = headerOfTableTextField.getText();
        int startYear = startYearChooser.getValue();
        int endYear = endYearChooser.getValue();
        PopulationDataset[] populations;
        if (dontUsePopulationDatasetCheckBox.isSelected()) {
            populations = generateDummyPopulationDatasets();
        } else {
            populations = getSelectedPopulations();
        }
        PopulationDataset[] standardPopulations = new PopulationDataset[populations.length];
        tableBuilder.setUnknownAgeCode(CanRegClientApp.getApplication().getGlobalToolBox().getUnknownAgeCode());

        if (tableBuilder.areThesePopulationDatasetsCompatible(populations)) {
            String fileName = null;
            // Choose file name;
            if (filetype != FileTypes.jchart) {
                if (chooser == null) {
                    path = localSettings.getProperty(LocalSettings.TABLES_PATH_KEY);
                    if (path == null) {
                        chooser = new JFileChooser();
                    } else {
                        chooser = new JFileChooser(path);
                    }
                }
                int returnVal = chooser.showSaveDialog(this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    try {
                        localSettings.setProperty(LocalSettings.TABLES_PATH_KEY,
                                chooser.getSelectedFile().getParentFile().getCanonicalPath());
                        fileName = chooser.getSelectedFile().getAbsolutePath();
                    } catch (IOException ex) {
                        Logger.getLogger(TableBuilderInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } else {
                    // cancelled
                    return;
                }
            }

            setCursor(hourglassCursor);

            int i = 0;
            String populationFilterString = "";
            for (PopulationDataset pop : populations) {
                if (pop != null) {
                    int stdPopID = pop.getReferencePopulationID();
                    standardPopulations[i++] = populationDatasetsMap.get(stdPopID);
                    if (populationFilterString.trim().length() == 0) {
                        populationFilterString = pop.getFilter();
                    } else if (!populationFilterString.equalsIgnoreCase(pop.getFilter())) {
                        // population filters not matching on all the pds...
                        filterError = true;
                    }
                }
            }

            Globals.StandardVariableNames[] variablesNeeded = tableBuilder.getVariablesNeeded();
            if (variablesNeeded != null) {
                for (Globals.StandardVariableNames standardVariableName : variablesNeeded) {
                    variables.add(canreg.client.CanRegClientApp.getApplication().getGlobalToolBox()
                            .translateStandardVariableNameToDatabaseListElement(
                                    standardVariableName.toString()));
                }
            }
            DatabaseFilter filter = new DatabaseFilter();
            String tableName = Globals.TUMOUR_AND_PATIENT_JOIN_TABLE_NAME;
            String filterString = rangeFilterPanel.getFilter().trim();

            if (filterString.length() != 0) {
                filterString += " AND ";
            }

            if (populationFilterString.length() != 0) {
                filterString += "( " + populationFilterString + " ) AND ";
            }

            // add the years to the filter
            DatabaseVariablesListElement incidenceDate = canreg.client.CanRegClientApp.getApplication()
                    .getGlobalToolBox().translateStandardVariableNameToDatabaseListElement(
                            Globals.StandardVariableNames.IncidenceDate.toString());
            filterString += incidenceDate.getDatabaseVariableName() + " BETWEEN '" + startYear * 10000
                    + "' AND '" + ((endYear + 1) * 10000 - 1) + "'";

            // filter only the confirmed cases
            DatabaseVariablesListElement recordStatus = canreg.client.CanRegClientApp.getApplication()
                    .getGlobalToolBox().translateStandardVariableNameToDatabaseListElement(
                            Globals.StandardVariableNames.TumourRecordStatus.toString());
            filterString += " AND " + recordStatus.getDatabaseVariableName() + " = '1'";

            // filter away obsolete cases
            DatabaseVariablesListElement recordObsoleteStatus = canreg.client.CanRegClientApp.getApplication()
                    .getGlobalToolBox().translateStandardVariableNameToDatabaseListElement(
                            Globals.StandardVariableNames.ObsoleteFlagTumourTable.toString());
            filterString += " AND " + recordObsoleteStatus.getDatabaseVariableName() + " != '1'";

            filter.setFilterString(filterString);

            System.out.println(filterString);

            filter.setQueryType(DatabaseFilter.QueryType.FREQUENCIES_BY_YEAR);
            filter.setDatabaseVariables(variables);
            DistributedTableDataSourceClient tableDataSource;
            Object[][] incidenceData = null;
            try {
                tableDatadescription = canreg.client.CanRegClientApp.getApplication()
                        .getDistributedTableDescription(filter, tableName);
                tableDataSource = new DistributedTableDataSourceClient(tableDatadescription);
                if (tableDatadescription.getRowCount() > 0) {
                    incidenceData = tableDataSource.retrieveRows(0, tableDatadescription.getRowCount());
                } else {
                    // display error - no lines
                    JOptionPane.showMessageDialog(this,
                            "No incidence data available correspondign to the current filter, period and population.",
                            "No incidence data", JOptionPane.ERROR_MESSAGE);
                }

                // Build the table(s)
                LinkedList<String> filesGenerated = tableBuilder.buildTable(heading, fileName, startYear,
                        endYear, incidenceData, populations, standardPopulations, tble.getConfigFields(),
                        tble.getEngineParameters(), filetype);

                if (filetype != FileTypes.jchart) {

                    String filesGeneratedList = new String();
                    filesGeneratedList = filesGenerated.stream().map((fileN) -> "\n" + fileN)
                            .reduce(filesGeneratedList, String::concat);

                    setCursor(normalCursor);

                    // Opening the resulting files if the list is not empty...
                    if (filesGenerated.isEmpty()) {
                        JOptionPane.showMessageDialog(this,
                                "Please use \"View work files\" in the \"File\"-menu to open them",
                                java.util.ResourceBundle.getBundle(
                                        "canreg/client/gui/analysis/resources/TableBuilderInternalFrame")
                                        .getString("TABLE(S)_BUILT."),
                                JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(this, filesGeneratedList,
                                java.util.ResourceBundle.getBundle(
                                        "canreg/client/gui/analysis/resources/TableBuilderInternalFrame")
                                        .getString("TABLE(S)_BUILT."),
                                JOptionPane.INFORMATION_MESSAGE);
                        filesGenerated.stream().filter((resultFileName) -> (new File(resultFileName).exists()))
                                .forEachOrdered((resultFileName) -> {
                                    try {
                                        canreg.common.Tools.openFile(resultFileName);
                                    } catch (IOException ex) {
                                        JOptionPane.showMessageDialog(this, "Unable to open: " + resultFileName
                                                + "\n" + ex.getLocalizedMessage());
                                        Logger.getLogger(TableBuilderInternalFrame.class.getName())
                                                .log(Level.SEVERE, null, ex);
                                    }
                                });
                    }
                } else {
                    chartBuilder = (JChartTableBuilderInterface) tableBuilder;
                    JFreeChart[] charts = chartBuilder.getCharts();
                    for (JFreeChart chart : charts) {
                        JChartViewerInternalFrame chartViewerInternalFrame = new JChartViewerInternalFrame();
                        chartViewerInternalFrame.setChart(chart);
                        CanRegClientView.showAndPositionInternalFrame(
                                CanRegClientApp.getApplication().getDesktopPane(), chartViewerInternalFrame);
                    }
                    setCursor(normalCursor);
                }

            } catch (SQLException ex) {
                setCursor(normalCursor);
                JOptionPane.showMessageDialog(this,
                        "Something wrong with the SQL query: \n" + ex.getLocalizedMessage(), "Error",
                        JOptionPane.ERROR_MESSAGE);
                Logger.getLogger(TableBuilderInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (RemoteException | SecurityException | NotCompatibleDataException
                    | DistributedTableDescriptionException | UnknownTableException ex) {
                Logger.getLogger(TableBuilderInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (TableErrorException ex) {
                setCursor(normalCursor);
                Logger.getLogger(TableBuilderInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(this,
                        "Something went wrong while building the table: \n" + ex.getMessage(), "Error",
                        JOptionPane.ERROR_MESSAGE);
            } finally {
                setCursor(normalCursor);
            }
        } else {
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle
                            .getBundle("canreg/client/gui/analysis/resources/TableBuilderInternalFrame")
                            .getString("POPULATION_SET_NOT_COMPATIBLE"),
                    java.util.ResourceBundle
                            .getBundle("canreg/client/gui/analysis/resources/TableBuilderInternalFrame")
                            .getString("NO_TABLES_BUILT"),
                    JOptionPane.ERROR_MESSAGE);
        }
    }
}