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:de.xirp.mail.MailManager.java

/**
 * Prints the corresponding {@link de.xirp.mail.Mail}
 * of the given {@link de.xirp.mail.MailDescriptor}.
 * //w  w  w .ja  va 2s  .c  om
 * @param md
 *            The mail descriptor.
 * @throws MessagingException
 *             if something went wrong while printing.
 * @see de.xirp.mail.MailDescriptor
 * @see de.xirp.mail.Mail
 */
public static void printMail(MailDescriptor md) throws MessagingException {
    try {
        Mail mail = getMail(md);

        List<File> docs = new ArrayList<File>();

        long millis = System.currentTimeMillis();

        File text = new File(Constants.TMP_DIR, millis + "_printtmp_mailtext.txt"); //$NON-NLS-1$
        text.createNewFile();
        docs.add(text);
        DeleteManager.deleteOnShutdown(text);
        FileUtils.writeStringToFile(text, md.getSubject(), "Unicode"); //$NON-NLS-1$

        for (Attachment a : mail.getAttachments()) {
            if (a.isPrintable()) {
                File attachment = new File(Constants.TMP_DIR, millis + "_printtmp_" + a.getFileName()); //$NON-NLS-1$
                attachment.createNewFile();
                docs.add(attachment);
                DeleteManager.deleteOnShutdown(attachment);
                FileUtils.writeByteArrayToFile(attachment, a.getAttachmentFileContent());
            }
        }
        PrintManager.print(docs);
    } catch (FileNotFoundException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
        throw new MessagingException(e.getMessage());
    } catch (SerializationException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
        throw new MessagingException(e.getMessage());
    } catch (IOException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
        throw new MessagingException(e.getMessage());
    }
}

From source file:io.druid.indexer.IndexGeneratorJob.java

public static List<DataSegment> getPublishedSegments(HadoopDruidIndexerConfig config) {
    final Configuration conf = JobHelper.injectSystemProperties(new Configuration());
    final ObjectMapper jsonMapper = HadoopDruidIndexerConfig.jsonMapper;

    ImmutableList.Builder<DataSegment> publishedSegmentsBuilder = ImmutableList.builder();

    final Path descriptorInfoDir = config.makeDescriptorInfoDir();

    try {//from w  w w  .j a v  a  2s .  c o  m
        FileSystem fs = descriptorInfoDir.getFileSystem(conf);

        for (FileStatus status : fs.listStatus(descriptorInfoDir)) {
            final DataSegment segment = jsonMapper.readValue(fs.open(status.getPath()), DataSegment.class);
            publishedSegmentsBuilder.add(segment);
            log.info("Adding segment %s to the list of published segments", segment.getIdentifier());
        }
    } catch (FileNotFoundException e) {
        log.error(
                "[%s] SegmentDescriptorInfo is not found usually when indexing process did not produce any segments meaning"
                        + " either there was no input data to process or all the input events were discarded due to some error",
                e.getMessage());
        Throwables.propagate(e);
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
    List<DataSegment> publishedSegments = publishedSegmentsBuilder.build();

    return publishedSegments;
}

From source file:edu.harvard.iq.dvn.ingest.dsb.DSBWrapper.java

private static Boolean parseLabelFile(File extendedLabelsFile) {

    // open the text file supplied, check that they are at least 
    // parseable.

    BufferedReader labelsFileReader = null;

    try {//w  ww  .  java  2s  . c o m
        labelsFileReader = new BufferedReader(new InputStreamReader(new FileInputStream(extendedLabelsFile)));

        String inLine = null;
        String[] valueTokens = new String[2];

        while ((inLine = labelsFileReader.readLine()) != null) {
            valueTokens = inLine.split("\t", 2);

            if (!(valueTokens[0] != null && !"".equals(valueTokens[0]) && valueTokens[1] != null
                    && !"".equals(valueTokens[1]))) {

                return false;
            }
        }

    } catch (java.io.FileNotFoundException fnfex) {
        dbgLog.warning("Ingest: could not open Extended Labels file");
        dbgLog.warning(fnfex.getMessage());
        return false;
    } catch (IOException ioex) {
        dbgLog.warning("Ingest: caught exception trying to process Labels File");
        dbgLog.warning(ioex.getMessage());
        return false;
    } finally {
        if (labelsFileReader != null) {
            try {
                labelsFileReader.close();
            } catch (Exception x) {
            }
            ;
        }
    }

    return true;

}

From source file:com.ephesoft.dcma.da.common.UpgradePatchPreparation.java

private static void createPatchForDependencies() {
    List<Plugin> pluginsList = pluginService.getAllPlugins();

    for (Plugin plugin : pluginsList) {
        ArrayList<Dependency> pluginDependencies = new ArrayList<Dependency>(plugin.getDependencies());
        changePluginIdToName(pluginDependencies);
        pluginNameVsDependencyMap.put(plugin.getPluginName(), pluginDependencies);
    }//from  www  .  ja v a2  s. c om

    try {
        File serializedExportFile = new File(upgradePatchFolderPath + File.separator
                + DataAccessConstant.DEPENDENCY_UPDATE + SERIALIZATION_EXT);
        SerializationUtils.serialize(pluginNameVsDependencyMap, new FileOutputStream(serializedExportFile));
    } catch (FileNotFoundException e) {
        LOG.error(ERROR_OCCURRED_WHILE_CREATING_THE_SERIALIZABLE_FILE + e.getMessage(), e);
    }
}

From source file:backtype.storm.utils.Utils.java

private static Map loadProperty(String prop) {
    Map ret = new HashMap<Object, Object>();
    Properties properties = new Properties();

    try {//from  w w  w .ja va  2s .c  om
        InputStream stream = new FileInputStream(prop);
        properties.load(stream);
        if (properties.size() == 0) {
            System.out.println("WARN: Config file is empty");
            return null;
        } else {
            ret.putAll(properties);
        }
    } catch (FileNotFoundException e) {
        System.out.println("No such file " + prop);
        throw new RuntimeException(e.getMessage());
    } catch (Exception e1) {
        e1.printStackTrace();
        throw new RuntimeException(e1.getMessage());
    }

    return ret;
}

From source file:com.ephesoft.dcma.da.common.UpgradePatchPreparation.java

private static void createPatchForBatchClassModuleConfigs(BatchClassService service) {
    List<BatchClass> batchClassList = service.getAllBatchClassesExcludeDeleted();
    if (batchClassList != null && !batchClassList.isEmpty()) {
        BatchClass batchClass = service.getLoadedBatchClassByIdentifier(batchClassList.get(0).getIdentifier());
        service.evict(batchClass);// w w w  . j a  va 2 s  . c  om
        List<BatchClassModule> batchClassModules = batchClass.getBatchClassModules();
        for (BatchClassModule bcm : batchClassModules) {
            if (bcm != null && bcm.getBatchClassModuleConfig() != null
                    && !bcm.getBatchClassModuleConfig().isEmpty()) {
                ArrayList<BatchClassModuleConfig> batchClassModuleConfigList = new ArrayList<BatchClassModuleConfig>();
                List<BatchClassModuleConfig> bcmcList = bcm.getBatchClassModuleConfig();
                for (BatchClassModuleConfig bcmc : bcmcList) {
                    bcmc.setId(0);
                    bcmc.setBatchClassModule(null);
                    batchClassModuleConfigList.add(bcmc);
                }
                Module module = moduleService
                        .getModulePropertiesForModuleId(Long.valueOf(bcm.getModule().getId()));
                moduleNameVsBatchClassModuleConfigMap.put(module.getName(), batchClassModuleConfigList);
            }
        }

        try {
            File serializedExportFile = new File(
                    upgradePatchFolderPath + File.separator + "ModuleConfigUpdate" + SERIALIZATION_EXT);
            SerializationUtils.serialize(moduleNameVsBatchClassModuleConfigMap,
                    new FileOutputStream(serializedExportFile));
        } catch (FileNotFoundException e) {
            LOG.error(ERROR_OCCURRED_WHILE_CREATING_THE_SERIALIZABLE_FILE + e.getMessage(), e);
        }
    }
}

From source file:com.glaf.oa.reports.web.springmvc.OAReportController.java

public static void exportExcel(String fileName, String targetName, Map<String, Object> datas,
        HttpServletResponse response) {//w  w w  .  j a v a 2s. c om
    fileName = SystemProperties.getAppPath() + "/WEB-INF/conf/templates/oa/" + fileName + ".xls";
    XLSTransformer transformer = new XLSTransformer();
    FileInputStream fis = null;
    OutputStream os = null;
    Workbook workbook = null;
    try {
        fis = new FileInputStream(fileName);
        workbook = transformer.transformXLS(fis, datas);
        response.reset();
        response.setHeader("content-disposition", "attachment; filename=" + targetName + ".xls");
        response.setContentType("application/msexcel");
        os = response.getOutputStream();
        if (os != null) {
            workbook.write(os);
        }
    } catch (FileNotFoundException e) {
        logger.error("exportExcel:" + e.getMessage());
    } catch (ParsePropertyException e) {
        logger.error("exportExcel:" + e.getMessage());
    } catch (InvalidFormatException e) {
        logger.error("exportExcel:" + e.getMessage());
    } catch (IOException e) {
        logger.error("exportExcel:" + e.getMessage());
    } finally {
        try {
            if (fis != null)
                fis.close();
            if (os != null) {
                os.flush();
                os.close();
            }
        } catch (IOException e) {
            logger.debug("exportExcel:" + e.getMessage());
        }
    }

}

From source file:com.websqrd.catbot.setting.CatbotSettings.java

private static Properties getXmlProperties(String xmlFilename) {
    String configFile = getKey(xmlFilename);
    logger.debug("Read properties = {}", configFile);
    Properties result = new Properties();
    try {//from  w  w  w .  j  av  a2 s.com
        result.loadFromXML(new FileInputStream(configFile));
        putToCache(result, xmlFilename);
        return result;
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage(), e);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return null;
}

From source file:com.ephesoft.dcma.da.common.UpgradePatchPreparation.java

/**
 * This method creates patch for scanner config.
 * //from w ww .j  a v a 2 s. co  m
 * @param service {@link BatchClassService}
 * @param scannerConfigInfo {@link String}
 */
private static void createPatchForScannerConfig(BatchClassService service, String scannerConfigInfo) {
    String batchClassId = scannerConfigInfo.trim();
    BatchClass batchClass = service.getLoadedBatchClassByIdentifier(batchClassId);
    List<BatchClassScannerConfiguration> batchClassScannerConfigs = batchClass
            .getBatchClassScannerConfiguration();
    service.evict(batchClass);
    for (BatchClassScannerConfiguration scannerConfig : batchClassScannerConfigs) {
        if (scannerConfig.getParent() == null) {
            scannerConfig.setBatchClass(null);
            scannerConfig.setId(0);
            ScannerMasterConfiguration masterConfig = scannerConfig.getScannerMasterConfig();
            masterConfig.setId(0);
            scannerConfig.setScannerMasterConfig(masterConfig);
            for (BatchClassScannerConfiguration childScannerConfig : scannerConfig.getChildren()) {
                childScannerConfig.setParent(null);
                childScannerConfig.setBatchClass(null);
                childScannerConfig.setId(0);
                ScannerMasterConfiguration childMasterConfig = childScannerConfig.getScannerMasterConfig();
                childMasterConfig.setId(0);
                childScannerConfig.setScannerMasterConfig(childMasterConfig);
                LOG.info("Getting the child configs of parent scanner configs...");
            }
            LOG.info("Adding the parent scanner configs to the list...");
            batchClassScannerConfigList.add(scannerConfig);
        }
    }
    try {
        File serializedExportFile = new File(
                upgradePatchFolderPath + File.separator + "ScannerConfigUpdate" + SERIALIZATION_EXT);
        SerializationUtils.serialize((Serializable) batchClassScannerConfigList,
                new FileOutputStream(serializedExportFile));
    } catch (FileNotFoundException e) {
        // Unable to create serializable file
        LOG.error(ERROR_OCCURRED_WHILE_CREATING_THE_SERIALIZABLE_FILE + e.getMessage(), e);
    }

}

From source file:com.websqrd.catbot.setting.CatbotSettings.java

private static Properties getProperties(String filename) {
    String configFile = HOME + "conf" + FILE_SEPARATOR + filename;
    Properties result = new Properties();
    try {//from www. ja v  a 2s .c om
        File f = new File(configFile);
        if (!f.exists()) {
            f.createNewFile();
        }
        result.load(new FileInputStream(f));
        putToCache(result, filename);
        return result;

    } catch (FileNotFoundException e) {
        logger.error(e.getMessage(), e);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return null;
}