Example usage for java.io FileNotFoundException getMessage

List of usage examples for java.io FileNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.cws.esolutions.security.listeners.SecurityServiceListener.java

/**
 * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
 *//*from  w  ww.  ja  v a 2s  . c  o  m*/
public void contextInitialized(final ServletContextEvent sContextEvent) {
    final String methodName = SecurityServiceListener.CNAME
            + "#contextInitialized(final ServletContextEvent sContextEvent)";

    if (DEBUG) {
        DEBUGGER.debug(methodName);
        DEBUGGER.debug("ServletContextEvent: {}", sContextEvent);
    }

    URL xmlURL = null;
    JAXBContext context = null;
    Unmarshaller marshaller = null;
    SecurityConfigurationData configData = null;

    final ServletContext sContext = sContextEvent.getServletContext();
    final ClassLoader classLoader = SecurityServiceListener.class.getClassLoader();

    if (DEBUG) {
        DEBUGGER.debug("ServletContext: {}", sContext);
        DEBUGGER.debug("ClassLoader: {}", classLoader);
    }

    try {
        if (sContext != null) {
            if (StringUtils.isBlank(SecurityServiceListener.INIT_SYSLOGGING_FILE)) {
                System.err.println("Logging configuration not found. No logging enabled !");
            } else {
                DOMConfigurator.configure(Loader
                        .getResource(sContext.getInitParameter(SecurityServiceListener.INIT_SYSLOGGING_FILE)));
            }

            if (StringUtils.isBlank(SecurityServiceListener.INIT_SYSCONFIG_FILE)) {
                xmlURL = classLoader
                        .getResource(sContext.getInitParameter(SecurityServiceListener.INIT_SYSCONFIG_FILE));

            } else {
                ERROR_RECORDER.error("System configuration not found. Shutting down !");

                throw new SecurityServiceException(
                        "System configuration file location not provided by application. Cannot continue.");
            }

            if (DEBUG) {
                DEBUGGER.debug("xmlURL: {}", xmlURL);
            }

            if (xmlURL != null) {
                context = JAXBContext.newInstance(SecurityConfigurationData.class);
                marshaller = context.createUnmarshaller();
                configData = (SecurityConfigurationData) marshaller.unmarshal(xmlURL);

                SecurityServiceListener.svcBean.setConfigData(configData);

                Context initContext = new InitialContext();
                Context envContext = (Context) initContext.lookup(SecurityServiceConstants.DS_CONTEXT);

                DAOInitializer.configureAndCreateAuthConnection(
                        new FileInputStream(FileUtils.getFile(configData.getSecurityConfig().getAuthConfig())),
                        false, SecurityServiceListener.svcBean);

                Map<String, DataSource> dsMap = new HashMap<String, DataSource>();

                for (DataSourceManager mgr : configData.getResourceConfig().getDsManager()) {
                    dsMap.put(mgr.getDsName(), (DataSource) envContext.lookup(mgr.getDataSource()));
                }

                SecurityServiceListener.svcBean.setDataSources(dsMap);
            } else {
                throw new SecurityServiceException("Unable to load configuration. Cannot continue.");
            }
        } else {
            throw new SecurityServiceException("Unable to load configuration. Cannot continue.");
        }
    } catch (NamingException nx) {
        ERROR_RECORDER.error(nx.getMessage(), nx);
    } catch (SecurityServiceException ssx) {
        ERROR_RECORDER.error(ssx.getMessage(), ssx);
    } catch (JAXBException jx) {
        ERROR_RECORDER.error(jx.getMessage(), jx);
    } catch (FileNotFoundException fnfx) {
        ERROR_RECORDER.error(fnfx.getMessage(), fnfx);
    }
}

From source file:org.jenkinsci.plugins.fortifycloudscan.RulepackResolver.java

/**
 * If the specified file is a ZIP archive, the archive will be extracted to the
 * parent directory and the original file deleted.
 * @param file the archive to extract/*from   w ww . j  av a 2  s .  c o m*/
 * @return the parent directory where the file was extracted to
 */
private File extractArchive(File file) {
    if (!isArchive(file)) {
        return file;
    }
    try {
        logger.log("Extracting rulepack archive");
        File extractedDir = new File(file.getParentFile().getAbsolutePath());
        ArchiveUtil.unzip(extractedDir, file);
        return extractedDir;
    } catch (FileNotFoundException e) {
        logger.log("ERROR: The file to extract could not be found");
        logger.log(e.getMessage());
    } catch (IOException e) {
        logger.log("ERROR: An unknown error occurred while extracting archive");
        logger.log(e.getMessage());
    } finally {
        if (file.delete()) {
            logger.log("Removed original archive");
        }
    }
    return null;
}

From source file:epsi.i5.datamining.JsonBuilder.java

/**
 * This method return un DataEntity with only comment attribute filled from
 * the json file/*www.  j  a va  2s  .  co m*/
 *
 * @return
 */
public List<DataEntity> getSimpleCommentaires(File file) {
    List<DataEntity> listeCommentaires = new ArrayList();
    try {
        Object objFile = parser.parse(new FileReader(file.getAbsolutePath()));

        JSONArray jsonArray = (JSONArray) objFile;
        for (Object obj : jsonArray) {
            JSONObject jsonObject = (JSONObject) obj;
            DataEntity commentaire = new DataEntity();
            commentaire.setId(jsonObject.get("id"));
            commentaire.setCommentaires((String) jsonObject.get("commentaires"));

            listeCommentaires.add(commentaire);
        }
    } catch (FileNotFoundException e) {
        System.out.println("Une erreur est survenue lors de lecture du ficheir JSON");
        System.out.println("Cause : " + e.getCause());
        System.out.println("Message : " + e.getMessage());
    } catch (IOException | ParseException ex) {
        Logger.getLogger(JsonBuilder.class.getName()).log(Level.SEVERE, null, ex);
    }
    return listeCommentaires;
}

From source file:fi.aluesarjat.prototype.DataService.java

public void importData(String datasetDef, boolean reload) {
    try {/* ww w. j  a  v a 2  s.  c o m*/
        ScovoExtDatasetHandler handler = new ScovoExtDatasetHandler(repository, namespaceHandler, baseURI);
        PCAxisParser parser = new PCAxisParser(handler);

        if (StringUtils.isNotBlank(datasetDef)) {
            List<String> values = splitDatasetDef(datasetDef);
            String[] protAndPath = values.get(0).split(":");
            String protocol = protAndPath[0];
            String path = protAndPath[1];
            String datasetName = path.substring(path.lastIndexOf('/') + 1, path.lastIndexOf('.'));
            List<String> ignoredValues = Collections.emptyList();
            if (values.size() > 1) {
                ignoredValues = values.subList(1, values.size());
            }

            UID uid = ScovoExtDatasetHandler.datasetUID(baseURI, datasetName);
            UID datasetsContext = ScovoExtDatasetHandler.datasetsContext(baseURI);
            boolean load;
            RDFConnection conn = repository.openConnection();
            try {
                // TODO: reload -> first delete existing triples
                load = !conn.exists(uid, DCTERMS.modified, null, datasetsContext, false);
            } finally {
                conn.close();
            }
            if (load) {
                handler.setIgnoredValues(ignoredValues.toArray(new String[ignoredValues.size()]));
                logger.info("Loading " + datasetName + "...");
                long time = System.currentTimeMillis();
                InputStream in;
                if ("classpath".equals(protocol)) {
                    in = getStream(path);
                } else {
                    URLConnection urlConnection = new URL(values.get(0)).openConnection();
                    urlConnection.setConnectTimeout(3000);
                    urlConnection.setReadTimeout(3000);
                    in = urlConnection.getInputStream();
                }
                try {
                    parser.parse(datasetName, in);
                } finally {
                    in.close();
                }
                logger.info(
                        "Done loading " + datasetName + " in " + (System.currentTimeMillis() - time) + " ms");
            } else {
                logger.info("Skipping existing " + datasetName);
            }
        }
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage(), e);
    } catch (IOException e) {
        logger.error(datasetDef + " " + e.getMessage(), e);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:ca.simplegames.micro.viewers.mustache.MustacheViewRenderer.java

@Override
public long render(String path, Repository repository, MicroContext context, Writer out)
        throws FileNotFoundException, ViewException {

    if (repository != null && out != null) {

        try {//from  www  .j a va2  s. com
            Mustache mustache;
            String key = repository.getName() + KEY_SEP + path;

            StringWriter sw = new StringWriter();
            StringReader source = new StringReader(repository.read(path));
            if (mustaches != null) {
                Element mustacheElement = (Element) mustaches.get(key);
                if (mustacheElement == null) {
                    mustache = mf.compile(source, key);
                    mustaches.put(key, new Element(NAME, mustache));
                } else {
                    mustache = (Mustache) mustacheElement.getObjectValue();
                }
            } else {
                mustache = mf.compile(source, key);
            }

            if (!CollectionUtils.isEmpty(context.getMap())) {
                mustache.execute(sw, context.getMap());
            }

            return IO.copy(new StringReader(sw.toString()), out);

        } catch (FileNotFoundException e) {
            throw new FileNotFoundException(String.format("%s not found.", path));
        } catch (Exception e) {
            throw new ViewException(e.getMessage());
        }
    }
    return 0;
}

From source file:br.edu.ufcg.lsd.commune.context.PropertiesFileParser.java

public Map<Object, Object> parseContext() {
    Properties properties = new Properties();

    /** Get an abstraction for the properties file */
    File propertiesFile = new File(fileName);

    if (!propertiesFile.exists()) {
        return getDefaultProperties(propertiesFile);
    }//  w  w w . ja v a2 s . c om

    /* load the properties file, if it exists */
    FileInputStream fileInputStream = null;
    try {
        fileInputStream = new FileInputStream(propertiesFile);
    } catch (FileNotFoundException e) {
        throw new CommuneRuntimeException("Context couldn't be loaded. " + fileName
                + " does not exist. Please check this file. Exception: " + e.getMessage());
    }
    try {
        properties.load(fileInputStream);
    } catch (IOException e) {
        throw new CommuneRuntimeException("Context couldn't be loaded. " + fileName
                + " is corrupted. Please check this file. Exception: " + e.getMessage());
    } catch (IllegalArgumentException iae) {
        throw new CommuneRuntimeException("Context couldn't be loaded. " + fileName
                + " isn't a properties file. Please use correct file format.");
    } finally {
        try {
            fileInputStream.close();
        } catch (IOException e) {
            throw new CommuneRuntimeException("Context couldn't be loaded. " + fileName
                    + " is corrupeed. Please check this file. Exception: " + e.getMessage());
        }
    }

    Map<Object, Object> responseMap = new LinkedHashMap<Object, Object>();

    for (Object key : properties.keySet()) {
        if (!properties.get(key).toString().trim().equals("")) {
            responseMap.put(key, properties.get(key));
        }
    }

    return responseMap;
}

From source file:de.xirp.ui.util.HelpManager.java

/**
 * Writes the navigation HTML-file. The links for existing plugins
 * are added to the existing links of the standard program help.
 *///  w w w.j  a  v  a  2  s.  c om
private void createNavigationHTML() {
    StringBuilder naviPage = new StringBuilder();
    naviPage.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">") //$NON-NLS-1$
            .append(Constants.LINE_SEPARATOR);
    naviPage.append("<HTML>").append(Constants.LINE_SEPARATOR); //$NON-NLS-1$
    naviPage.append("<HEAD>").append(Constants.LINE_SEPARATOR); //$NON-NLS-1$
    naviPage.append("   <META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=windows-1252\">") //$NON-NLS-1$
            .append(Constants.LINE_SEPARATOR);
    naviPage.append("   <TITLE>nav frame</TITLE>").append(Constants.LINE_SEPARATOR); //$NON-NLS-1$
    naviPage.append("</HEAD>").append(Constants.LINE_SEPARATOR); //$NON-NLS-1$
    naviPage.append("<BODY>").append(Constants.LINE_SEPARATOR); //$NON-NLS-1$
    // naviPage.append("<UL>"+Constants.LINE_SEPARATOR);

    createXirpLinks(naviPage);
    createPluginLinks(naviPage);

    // naviPage.append("</UL>"+Constants.LINE_SEPARATOR);
    naviPage.append("</BODY>").append(Constants.LINE_SEPARATOR); //$NON-NLS-1$
    naviPage.append("</HTML>").append(Constants.LINE_SEPARATOR); //$NON-NLS-1$

    File f = new File(Constants.HELP_DIR + File.separator + "nav_frame.html"); //$NON-NLS-1$
    try {
        FileWriter fw = new FileWriter(f);
        fw.write(naviPage.toString());
        fw.close();

    } catch (FileNotFoundException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
    } catch (IOException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
    }
}

From source file:com.sliit.normalize.NormalizeDataset.java

private void writeToNewFile(String directory) {

    try {/*from   w  ww  .  j a  v a 2 s. co m*/

        BufferedReader reader = new BufferedReader(new FileReader(outputFile));
        PrintWriter writer = new PrintWriter(new File(directory + "norm" + csvFile.getName()));
        String output = "";
        int count = 0;
        while ((output = reader.readLine()) != null) {

            if (count == 0) {

                count++;
                continue;
            }
            writer.println(output);
        }
        writer.flush();
        writer.close();
        reader.close();
    } catch (FileNotFoundException e) {

        log.error("Error occurred:" + e.getMessage());
    } catch (IOException e) {

        log.error("Error occurred:" + e.getMessage());
    }
}

From source file:com.example.cuisoap.agrimac.machineRegister.machineInfoFragment.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        Uri uri = data.getData();/*from   w w  w.ja  v  a 2 s .c o  m*/
        Log.e("uri", uri.toString());
        ContentResolver cr = context.getContentResolver();
        try {
            Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri));
            bitmap = ImageUtils.comp(bitmap);
            switch (requestCode) {
            case 1:
                license_pic1.setImageBitmap(bitmap);
                license_path1 = ImageUtils.saveMyBitmap(bitmap, "machineinfo");
                license_pic1.setVisibility(View.VISIBLE);
                license1.setVisibility(View.GONE);
                license_pic1.setOnClickListener(myOnClickListener);
                break;
            case 2:
                license_pic2.setImageBitmap(bitmap);
                license_path2 = ImageUtils.saveMyBitmap(bitmap, "machineinfo");
                license_pic2.setVisibility(View.VISIBLE);
                license2.setVisibility(View.GONE);
                license_pic2.setOnClickListener(myOnClickListener);
                break;
            }
        } catch (FileNotFoundException e) {
            Log.e("Exception", e.getMessage(), e);
        }
    } else {
        Toast.makeText(context, "?", Toast.LENGTH_SHORT).show();
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService.java

public ServiceSettings getDefaultServiceSettings(DeploymentConfiguration deploymentConfiguration) {
    File userSettingsFile = new File(halconfigDirectoryStructure
            .getUserServiceSettingsPath(deploymentConfiguration.getName()).toString(),
            getCanonicalName() + ".yml");

    if (userSettingsFile.exists()) {
        try {/*from w  w  w .  j  a v  a  2 s.  com*/
            log.info("Reading user provided service settings from " + userSettingsFile);
            return objectMapper.convertValue(yamlParser.load(new FileInputStream(userSettingsFile)),
                    ServiceSettings.class);
        } catch (FileNotFoundException e) {
            throw new HalException(Problem.Severity.FATAL,
                    "Unable to read provided user settings: " + e.getMessage(), e);
        }
    } else {
        return new ServiceSettings();
    }
}