List of usage examples for java.io FileNotFoundException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.signserver.client.cli.defaultimpl.SignDocumentCommand.java
/** * Execute the signing operation./*from ww w . ja v a 2s .c om*/ * @param manager for managing the threads * @param inFile directory * @param outFile directory */ protected void runBatch(TransferManager manager, final File inFile, final File outFile) { FileInputStream fin = null; try { final byte[] bytes; Map<String, Object> requestContext = new HashMap<String, Object>(); if (inFile == null) { bytes = data.getBytes(); } else { requestContext.put("FILENAME", inFile.getName()); fin = new FileInputStream(inFile); bytes = new byte[(int) inFile.length()]; fin.read(bytes); } runFile(manager, requestContext, inFile, bytes, outFile); } catch (FileNotFoundException ex) { LOG.error(MessageFormat.format(TEXTS.getString("FILE_NOT_FOUND:"), ex.getLocalizedMessage())); } catch (IOException ex) { LOG.error(ex); } finally { if (fin != null) { try { fin.close(); } catch (IOException ex) { LOG.error("Error closing file", ex); } } } }
From source file:br.com.nordestefomento.jrimum.bopepo.view.guia.ViewerPDF.java
/** * /*from ww w . j ava 2 s.co m*/ * @param pathName * @return * @throws IllegalArgumentException */ protected File getFile(String pathName) { File file = null; try { processarPdf(); file = FileUtil.bytes2File(pathName, outputStream.toByteArray()); } catch (FileNotFoundException e) { log.error("Erro ao tentar acessar arquivo inexistente. " + e.getLocalizedMessage(), e); throw new JRimumException("Erro ao tentar acessar arquivo inexistente: [" + pathName + "]. " + "Causado por " + e.getLocalizedMessage(), e); } catch (IOException e) { log.error("Erro durante a criao do arquivo. " + e.getLocalizedMessage(), e); throw new JRimumException("Erro durante a criao do arquivo: [" + pathName + "]. " + "Causado por " + e.getLocalizedMessage(), e); } catch (DocumentException e) { log.error("Erro durante a criao do arquivo. " + e.getLocalizedMessage(), e); throw new JRimumException("Erro durante a criao do arquivo: [" + pathName + "]. " + "Causado por " + e.getLocalizedMessage(), e); } return file; }
From source file:net.sf.housekeeper.swing.MainFrame.java
/** * //ww w. ja v a 2 s .c om */ private void loadDomainData() { try { PersistenceController.instance().replaceDomainWithSaved(); } catch (FileNotFoundException exception) { LOG.error("Could not load domain data", exception); final String error = LocalisationManager.INSTANCE.getText("gui.error"); final String nodata = LocalisationManager.INSTANCE.getText("gui.mainFrame.nodata"); JOptionPane.showMessageDialog(view, nodata, error, JOptionPane.ERROR_MESSAGE); } catch (Exception exception) { LOG.error("Could not load domain data", exception); final String error = LocalisationManager.INSTANCE.getText("gui.error"); JOptionPane.showMessageDialog(view, exception.getLocalizedMessage(), error, JOptionPane.ERROR_MESSAGE); } }
From source file:org.signserver.client.cli.defaultimpl.SignDocumentCommand.java
/** * Runs the signing operation for one file. * * @param manager for the threads/*from w ww . j a v a 2 s . c o m*/ * @param requestContext for the request * @param inFile directory * @param bytes to sign * @param outFile directory */ private void runFile(TransferManager manager, Map<String, Object> requestContext, final File inFile, final byte[] bytes, final File outFile) { // TODO: merge with runBatch ?, inFile here is only used when removing the file try { OutputStream outStream = null; try { if (outFile == null) { outStream = System.out; } else { outStream = new FileOutputStream(outFile); } final DocumentSigner signer = createSigner(manager == null ? password : manager.getPassword()); // Take start time final long startTime = System.nanoTime(); // Get the data signed signer.sign(bytes, outStream, requestContext); // Take stop time final long estimatedTime = System.nanoTime() - startTime; if (LOG.isInfoEnabled()) { LOG.info("Wrote " + outFile + "."); LOG.info("Processing " + (inFile == null ? "" : inFile.getName()) + " took " + TimeUnit.NANOSECONDS.toMillis(estimatedTime) + " ms."); } } finally { if (outStream != null && outStream != System.out) { outStream.close(); } } if (removeFromIndir && inFile != null && inFile.exists()) { if (inFile.delete()) { LOG.info("Removed " + inFile); } else { LOG.error("Could not remove " + inFile); if (manager != null) { manager.registerFailure(); } } } if (manager != null) { manager.registerSuccess(); // Login must have worked } } catch (FileNotFoundException ex) { LOG.error("Failure for " + (inFile == null ? "" : inFile.getName()) + ": " + MessageFormat.format(TEXTS.getString("FILE_NOT_FOUND:"), ex.getLocalizedMessage())); if (manager != null) { manager.registerFailure(); } } catch (IllegalRequestException ex) { LOG.error("Failure for " + (inFile == null ? "" : inFile.getName()) + ": " + ex.getMessage()); if (manager != null) { manager.registerFailure(); } } catch (CryptoTokenOfflineException ex) { LOG.error("Failure for " + (inFile == null ? "" : inFile.getName()) + ": " + ex.getMessage()); if (manager != null) { manager.registerFailure(); } } catch (SignServerException ex) { LOG.error("Failure for " + (inFile == null ? "" : inFile.getName()) + ": " + ex.getMessage()); if (manager != null) { manager.registerFailure(); } } catch (SOAPFaultException ex) { if (ex.getCause() instanceof AuthorizationRequiredException) { final AuthorizationRequiredException authEx = (AuthorizationRequiredException) ex.getCause(); LOG.error("Authorization failure for " + (inFile == null ? "" : inFile.getName()) + ": " + authEx.getMessage()); } else if (ex.getCause() instanceof AccessDeniedException) { final AccessDeniedException authEx = (AccessDeniedException) ex.getCause(); LOG.error("Access defined failure for " + (inFile == null ? "" : inFile.getName()) + ": " + authEx.getMessage()); } LOG.error(ex); } catch (HTTPException ex) { LOG.error("Failure for " + (inFile == null ? "" : inFile.getName()) + ": HTTP Error " + ex.getResponseCode() + ": " + ex.getResponseMessage()); if (manager != null) { if (ex.getResponseCode() == 401) { // Only abort for authentication failure if (promptForPassword) { // If password was not specified at command line, ask again for it manager.tryAgainWithNewPassword(inFile); } else { manager.abort(); } } else { manager.registerFailure(); } } } catch (IOException ex) { LOG.error("Failure for " + (inFile == null ? "" : inFile.getName()) + ": " + ex.getMessage()); if (manager != null) { manager.registerFailure(); } } }
From source file:com.qut.middleware.deployer.logic.RegisterESOELogic.java
public void execute(DeploymentBean bean) throws RegisterESOEException { configureDataLayer(bean);/*from www .j av a 2s . co m*/ /* Setup Crypto Processor with additional details */ this.cryptoProcessor.setCertIssuerDN(bean.getCertIssuerDN()); this.cryptoProcessor.setCertIssuerEmail(bean.getCertIssuerEmailAddress()); try { //Ensure ESOE EntID gets set first (ie to 1) bean.setEsoeEntID(this.esoeDAO.getNextEntID()); /* Create all crypto */ createKeyStores(bean); /* Create XML descriptors for ESOE and ESOE Manager webapp */ createESOEDescriptors(bean); createESOEManagerDescriptors(bean); /* Set expiry date of PKI data */ Calendar expiryDate = Calendar.getInstance(); expiryDate.add(Calendar.YEAR, this.cryptoProcessor.getCertExpiryIntervalInYears()); /* Store all crypto in data repository */ /* ESOE */ this.esoeDAO.insertPKIData(bean.getEsoeIdpDescID(), expiryDate.getTime(), bean.getEsoeKeystore(), bean.getEsoeKeyStorePassphrase(), bean.getEsoeKeyPairName(), bean.getEsoeKeyPairPassphrase()); this.esoeDAO.insertPKIData(bean.getEsoeAADescID(), expiryDate.getTime(), bean.getEsoeKeystore(), bean.getEsoeKeyStorePassphrase(), bean.getEsoeKeyPairName(), bean.getEsoeKeyPairPassphrase()); this.esoeDAO.insertPKIData(bean.getEsoeLxacmlDescID(), expiryDate.getTime(), bean.getEsoeKeystore(), bean.getEsoeKeyStorePassphrase(), bean.getEsoeKeyPairName(), bean.getEsoeKeyPairPassphrase()); this.esoeDAO.insertPublicKey(bean.getEsoeIdpDescID(), expiryDate.getTime(), bean.getEsoeKeyPairName(), this.cryptoProcessor.convertPublicKeyByteArray(bean.getEsoeKeyPair().getPublic())); this.esoeDAO.insertPublicKey(bean.getEsoeAADescID(), expiryDate.getTime(), bean.getEsoeKeyPairName(), this.cryptoProcessor.convertPublicKeyByteArray(bean.getEsoeKeyPair().getPublic())); this.esoeDAO.insertPublicKey(bean.getEsoeLxacmlDescID(), expiryDate.getTime(), bean.getEsoeKeyPairName(), this.cryptoProcessor.convertPublicKeyByteArray(bean.getEsoeKeyPair().getPublic())); /* ESOE Manager SPEP */ this.esoeDAO.insertPKIData(bean.getManagerDescID(), expiryDate.getTime(), bean.getEsoeManagerKeystore(), bean.getEsoeManagerKeyStorePassphrase(), bean.getEsoeManagerKeyPairName(), bean.getEsoeManagerKeyPairPassphrase()); this.esoeDAO.insertPublicKey(bean.getManagerDescID(), expiryDate.getTime(), bean.getEsoeManagerKeyPairName(), this.cryptoProcessor.convertPublicKeyByteArray(bean.getEsoeManagerKeyPair().getPublic())); /* Authentication network Metadata crypto */ this.esoeDAO.insertMetadataPKIData(expiryDate.getTime(), bean.getEsoeMetadataKeystore(), bean.getEsoeMetadataKeyStorePassphrase(), bean.getEsoeMetadataKeyPairName(), bean.getEsoeMetadataKeyPairPassphrase()); /* * Dynamically create config files for user deployments so they dont need to do manual config, nice chaps * aren't we. */ writeESOEContent(bean); writeESOEManagerContent(bean); writeSPEPContent(bean); } catch (FileNotFoundException e) { this.logger.error( "FileNotFoundException when attempting to configure ESOE details " + e.getLocalizedMessage()); this.logger.debug(e.toString()); throw new RegisterESOEException( "FileNotFoundException when attempting to configure ESOE details " + e.getLocalizedMessage()); } catch (KeyStoreException e) { this.logger.error( "KeyStoreException when attempting to configure ESOE details " + e.getLocalizedMessage()); this.logger.debug(e.toString()); throw new RegisterESOEException( "KeyStoreException when attempting to configure ESOE details " + e.getLocalizedMessage()); } catch (NoSuchAlgorithmException e) { this.logger.error("NoSuchAlgorithmException when attempting to configure ESOE details " + e.getLocalizedMessage()); this.logger.debug(e.toString()); throw new RegisterESOEException("NoSuchAlgorithmException when attempting to configure ESOE details " + e.getLocalizedMessage()); } catch (CertificateException e) { this.logger.error( "CertificateException when attempting to configure ESOE details " + e.getLocalizedMessage()); this.logger.debug(e.toString()); throw new RegisterESOEException( "CertificateException when attempting to configure ESOE details " + e.getLocalizedMessage()); } catch (CryptoException e) { this.logger .error("CryptoException when attempting to configure ESOE details " + e.getLocalizedMessage()); this.logger.debug(e.toString()); throw new RegisterESOEException( "CryptoException when attempting to configure ESOE details " + e.getLocalizedMessage()); } catch (IOException e) { this.logger.error("IOException when attempting to configure ESOE details " + e.getLocalizedMessage()); this.logger.debug(e.toString()); throw new RegisterESOEException( "IOException when attempting to configure ESOE details " + e.getLocalizedMessage()); } catch (RenderConfigException e) { this.logger.error( "RenderConfigException when attempting to configure ESOE details " + e.getLocalizedMessage()); this.logger.debug(e.toString()); throw new RegisterESOEException( "RenderConfigException when attempting to configure ESOE details " + e.getLocalizedMessage()); } catch (ESOEDAOException e) { this.logger .error("ESOEDAOException when attempting to configure ESOE details " + e.getLocalizedMessage()); this.logger.debug(e.toString()); throw new RegisterESOEException( "ESOEDAOException when attempting to configure ESOE details " + e.getLocalizedMessage()); } }
From source file:org.geotools.utils.imagemosaic.MosaicIndexBuilder.java
/** * @param globEnvelope//from ww w .j a v a2s. c o m * @param doneSomething */ private void createPropertiesFiles(GeneralEnvelope globEnvelope, boolean doneSomething) { StringBuffer message; if (numFiles > 0 && doneSomething) { // ///////////////////////////////////////////////////////////////////// // // FINAL STEP // // CREATING GENERAL INFO FILE // // ///////////////////////////////////////////////////////////////////// message = new StringBuffer("Creating final properties file "); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } fireEvent(message.toString(), 99.9); // envelope final Properties properties = new Properties(); properties.setProperty("AbsolutePath", Boolean.toString(absolute)); properties.setProperty("NumFiles", Integer.toString(numFiles)); properties.setProperty("Envelope2D", new StringBuffer(Double.toString(globEnvelope.getMinimum(0))).append(",") .append(Double.toString(globEnvelope.getMinimum(1))).append(" ") .append(Double.toString(globEnvelope.getMaximum(0))).append(",") .append(Double.toString(globEnvelope.getMaximum(1))).toString()); properties.setProperty("LevelsNum", Integer.toString(numberOfLevels)); final StringBuffer levels = new StringBuffer(); for (int k = 0; k < numberOfLevels; k++) { levels.append(Double.toString(resolutionLevels[0][k])).append(",") .append(Double.toString(resolutionLevels[1][k])); if (k < numberOfLevels - 1) levels.append(" "); } properties.setProperty("Levels", levels.toString()); properties.setProperty("Name", indexName); properties.setProperty("ExpandToRGB", Boolean.toString(mustConvertToRGB)); OutputStream outStream = null; try { outStream = new BufferedOutputStream( new FileOutputStream(locationPath + "/" + indexName + ".properties")); properties.store(outStream, ""); } catch (FileNotFoundException e) { fireEvent(e.getLocalizedMessage(), 0); } catch (IOException e) { fireEvent(e.getLocalizedMessage(), 0); } finally { try { if (outStream != null) outStream.close(); } catch (Throwable e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); } } // processing information message = new StringBuffer("Done!!!"); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } fireEvent(message.toString(), 100); } else { // processing information message = new StringBuffer("No file to process!!!"); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(message.toString()); } fireEvent(message.toString(), 100); } }
From source file:org.geotools.gce.imagemosaic.ImageMosaicConfigHandler.java
/** * Creates the final properties file./*from w w w.j av a2 s .co m*/ */ private void createPropertiesFiles(MosaicConfigurationBean mosaicConfiguration) { // // FINAL STEP // // CREATING GENERAL INFO FILE // CatalogConfigurationBean catalogConfigurationBean = mosaicConfiguration.getCatalogConfigurationBean(); // envelope final Properties properties = new Properties(); properties.setProperty(Utils.Prop.ABSOLUTE_PATH, Boolean.toString(catalogConfigurationBean.isAbsolutePath())); properties.setProperty(Utils.Prop.LOCATION_ATTRIBUTE, catalogConfigurationBean.getLocationAttribute()); // Time final String timeAttribute = mosaicConfiguration.getTimeAttribute(); if (timeAttribute != null) { properties.setProperty(Utils.Prop.TIME_ATTRIBUTE, mosaicConfiguration.getTimeAttribute()); } // Elevation final String elevationAttribute = mosaicConfiguration.getElevationAttribute(); if (elevationAttribute != null) { properties.setProperty(Utils.Prop.ELEVATION_ATTRIBUTE, mosaicConfiguration.getElevationAttribute()); } // Additional domains final String additionalDomainAttribute = mosaicConfiguration.getAdditionalDomainAttributes(); if (additionalDomainAttribute != null) { properties.setProperty(Utils.Prop.ADDITIONAL_DOMAIN_ATTRIBUTES, mosaicConfiguration.getAdditionalDomainAttributes()); } final int numberOfLevels = mosaicConfiguration.getLevelsNum(); final double[][] resolutionLevels = mosaicConfiguration.getLevels(); properties.setProperty(Utils.Prop.LEVELS_NUM, Integer.toString(numberOfLevels)); final StringBuilder levels = new StringBuilder(); for (int k = 0; k < numberOfLevels; k++) { levels.append(Double.toString(resolutionLevels[k][0])).append(",") .append(Double.toString(resolutionLevels[k][1])); if (k < numberOfLevels - 1) { levels.append(" "); } } properties.setProperty(Utils.Prop.LEVELS, levels.toString()); properties.setProperty(Utils.Prop.NAME, mosaicConfiguration.getName()); properties.setProperty(Utils.Prop.TYPENAME, mosaicConfiguration.getName()); properties.setProperty(Utils.Prop.EXP_RGB, Boolean.toString(mosaicConfiguration.isExpandToRGB())); properties.setProperty(Utils.Prop.CHECK_AUXILIARY_METADATA, Boolean.toString(mosaicConfiguration.isCheckAuxiliaryMetadata())); properties.setProperty(Utils.Prop.HETEROGENEOUS, Boolean.toString(catalogConfigurationBean.isHeterogeneous())); if (cachedReaderSPI != null) { // suggested spi properties.setProperty(Utils.Prop.SUGGESTED_SPI, cachedReaderSPI.getClass().getName()); } // write down imposed bbox if (imposedBBox != null) { properties.setProperty(Utils.Prop.ENVELOPE2D, imposedBBox.getMinX() + "," + imposedBBox.getMinY() + " " + imposedBBox.getMaxX() + "," + imposedBBox.getMaxY()); } properties.setProperty(Utils.Prop.CACHING, Boolean.toString(catalogConfigurationBean.isCaching())); if (mosaicConfiguration.getAuxiliaryFilePath() != null) { properties.setProperty(Utils.Prop.AUXILIARY_FILE, mosaicConfiguration.getAuxiliaryFilePath()); } OutputStream outStream = null; String filePath = runConfiguration.getParameter(Prop.ROOT_MOSAIC_DIR) + "/" // + runConfiguration.getIndexName() + ".properties")); + mosaicConfiguration.getName() + ".properties"; try { outStream = new BufferedOutputStream(new FileOutputStream(filePath)); properties.store(outStream, "-Automagically created from GeoTools-"); } catch (FileNotFoundException e) { eventHandler.fireEvent(Level.SEVERE, e.getLocalizedMessage(), 0); } catch (IOException e) { eventHandler.fireEvent(Level.SEVERE, e.getLocalizedMessage(), 0); } finally { if (outStream != null) { IOUtils.closeQuietly(outStream); } } }
From source file:br.com.nordestefomento.jrimum.bopepo.view.ViewerPDF.java
/** * //ww w .j a v a2 s .co m * @param pathName * @return * @throws IllegalArgumentException */ protected File getFile(String pathName) { File file = null; try { processarPdf(); file = FileUtil.bytes2File(pathName, outputStream.toByteArray()); } catch (FileNotFoundException e) { log.error("Erro ao tentar acessar arquivo inexistente. " + e.getLocalizedMessage(), e); throw new JRimumException("Erro ao tentar acessar arquivo inexistente: [" + pathName + "]. " + "Causado por " + e.getLocalizedMessage(), e); } catch (IOException e) { log.error("Erro durante a criao do arquivo. " + e.getLocalizedMessage(), e); throw new JRimumException("Erro durante a criao do arquivo: [" + pathName + "]. " + "Causado por " + e.getLocalizedMessage(), e); } catch (DocumentException e) { log.error("Erro durante a criao do arquivo. " + e.getLocalizedMessage(), e); throw new JRimumException("Erro durante a criao do arquivo: [" + pathName + "]. " + "Causado por " + e.getLocalizedMessage(), e); } return file; }
From source file:org.pentaho.platform.repository.solution.filebased.FileBasedSolutionRepository.java
protected boolean publishIcon(final String dirPath, final String iconPath) { File iconSource = new File(dirPath + File.separator + iconPath); if (iconSource.exists()) { File tmpDir = getFile("system/tmp/icons", true); //$NON-NLS-1$ tmpDir.mkdirs();/*from ww w . j a v a2 s. c o m*/ File iconDestintation = new File(tmpDir.getAbsoluteFile() + File.separator + iconPath); if (iconDestintation.exists()) { iconDestintation.delete(); } try { InputStream stream = new BufferedInputStream(new FileInputStream(iconSource)); OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(iconDestintation)); try { IOUtils.copy(stream, outputStream); } finally { outputStream.close(); stream.close(); } } catch (FileNotFoundException e) { // this one is not very likey error(e.getLocalizedMessage()); } catch (IOException e) { error(e.getLocalizedMessage()); } return true; } else { return false; } }
From source file:com.microsoft.rightsmanagement.sampleapp.MsipcTaskFragment.java
/** * Start content protection and serialize protected content to my own file format. * /*from w ww . j a v a 2 s. c o m*/ * @param contentToProtect the content to protect */ public void startContentProtectionToMyOwnProtectedTextFileFormat(final byte[] contentToProtect) { if (mUserPolicy == null) { Runnable onPolicyCreationCallback = new Runnable() { @Override public void run() { try { createMyOwnFormatFileForProtectedText(contentToProtect); } catch (FileNotFoundException e) { updateTaskStatus(new TaskStatus(TaskState.Faulted, e.getLocalizedMessage(), true)); } } }; startMsipcPolicyCreationByTakingEmailId(false, onPolicyCreationCallback); } else { try { createMyOwnFormatFileForProtectedText(contentToProtect); } catch (FileNotFoundException e) { updateTaskStatus(new TaskStatus(TaskState.Faulted, e.getLocalizedMessage(), true)); } } }