List of usage examples for java.io FileNotFoundException getCause
public synchronized Throwable getCause()
From source file:fr.paris.lutece.plugins.updater.service.catalog.CatalogService.java
/** * Retrieve all plugin releases from a repository * @return A CatalogInfos list/*from w ww . j ava 2 s .c om*/ */ public List<CatalogInfos> getCatalogInfos() { // clear catalogs data _listCatalogs.clear(); _listInfos.clear(); try { // load catalogs list File fileCatalogs = new File(AppPathService.getWebAppPath() + FILE_CATALOGS_LIST); FileReader readerFile = new FileReader(fileCatalogs); loadCatalogsList(readerFile); HttpAccess httpAccess = new HttpAccess(); for (Catalog catalog : _listCatalogs) { String strXmlCatalog = httpAccess.doGet(catalog.getUrl()); Reader reader = new StringReader(strXmlCatalog); load(reader); } } catch (FileNotFoundException e) { AppLogService.error(EXCEPTION_MESSAGE + e.getMessage(), e); } catch (HttpAccessException e) { AppLogService.error(EXCEPTION_MESSAGE + e.getMessage(), e.getCause()); } return _listInfos; }
From source file:com.kahlon.guard.controller.PersonImageManager.java
/** * Crop Image/*from ww w.ja v a 2 s . c om*/ * @return */ public String crop() { if (croppedImage == null) { return null; } setNewImageName(getRandomImageName()); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext() .getContext(); String newFileName = servletContext.getRealPath("") + File.separator + "resources" + File.separator + "image" + File.separator + "temp" + File.separator + getNewImageName() + ".png"; if (fileNames == null) { fileNames = new ArrayList<>(); } fileNames.add(newFileName); FileImageOutputStream imageOutput; try { imageOutput = new FileImageOutputStream(new File(newFileName)); imageOutput.write(croppedImage.getBytes(), 0, croppedImage.getBytes().length); imageOutput.close(); } catch (FileNotFoundException e) { throw new FacesException("File not found.", e.getCause()); } catch (IOException e) { throw new FacesException("IO Exception found.", e.getCause()); } return null; }
From source file:org.wso2.carbon.registry.synchronization.operation.CheckInCommand.java
private void restoreFromFile(Registry registry) throws SynchronizationException { String workingLocation = this.workingLocation; if (workingLocation != null) { inputFile = workingLocation + File.separator + inputFile; }//from w w w. j a v a2 s . co m // do the restoring try { ZipInputStream zis = new ZipInputStream(new FileInputStream(inputFile)); zis.getNextEntry(); Reader reader = new InputStreamReader(zis); registry.restore(checkInPath, reader); } catch (FileNotFoundException e) { throw new SynchronizationException(MessageCode.FILE_DOES_NOT_EXIST, e, new String[] { "Output file" + inputFile }); } catch (Exception e) { if (e.getCause() instanceof UnknownHostException) { throw new SynchronizationException(MessageCode.ERROR_IN_CONNECTING_REGISTRY, e, new String[] { " registry url:" + registryUrl }); } throw new SynchronizationException(MessageCode.ERROR_IN_RESTORING, e, new String[] { "path: " + checkInPath, "registry url: " + registryUrl, "username: " + username }); } if (cleanRegistry && registryUrl == null) { Utils.cleanEmbeddedRegistry(); } }
From source file:org.apache.hadoop.util.TestShell.java
/** * This test takes advantage of the invariant winutils path is valid * or access to it will raise an exception holds on Linux, and without * any winutils binary even if HADOOP_HOME points to a real hadoop * directory, the exception reporting can be validated *//*from w w w. ja v a2s .c o m*/ @Test public void testNoWinutilsOnUnix() throws Throwable { Assume.assumeFalse(WINDOWS); try { getWinUtilsFile(); } catch (FileNotFoundException ex) { assertExContains(ex, E_NOT_A_WINDOWS_SYSTEM); } try { getWinUtilsPath(); } catch (RuntimeException ex) { assertExContains(ex, E_NOT_A_WINDOWS_SYSTEM); if (ex.getCause() == null || !(ex.getCause() instanceof FileNotFoundException)) { throw ex; } } }
From source file:org.kramerius.replications.SecondPhase.java
private void processIterate(String url, String userName, String pswd) throws PhaseException { try {//from w w w.j a v a 2 s. c o m PIDsListLexer lexer = new PIDsListLexer(new FileReader(getIterateFile())); PIDsListParser parser = new PIDsListParser(lexer); parser.setPidsListCollect(new Emitter(url, userName, pswd)); parser.pids(); } catch (FileNotFoundException e) { throw new PhaseException(this, e); } catch (RecognitionException e) { throw new PhaseException(this, e); } catch (TokenStreamException e) { throw new PhaseException(this, e); } catch (RuntimeException e) { Throwable thr = e.getCause(); if ((thr != null) && (thr instanceof PhaseException)) { throw ((PhaseException) thr); } else if (thr != null) { throw new PhaseException(this, thr); } else throw new PhaseException(this, e); } }
From source file:org.signserver.client.cli.defaultimpl.ValidateDocumentCommand.java
/** * Execute the signing operation.//from ww w . j a va2s .co m */ public final void run() { FileInputStream fin = null; try { final byte[] bytes; final 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); } createValidator().validate(bytes, requestContext); } catch (FileNotFoundException ex) { LOG.error(MessageFormat.format(TEXTS.getString("FILE_NOT_FOUND:"), ex.getLocalizedMessage())); } catch (IllegalRequestException ex) { LOG.error(ex); } catch (CryptoTokenOfflineException ex) { LOG.error(ex); } catch (SignServerException ex) { LOG.error(ex); } catch (SOAPFaultException ex) { if (ex.getCause() instanceof AuthorizationRequiredException) { final AuthorizationRequiredException authEx = (AuthorizationRequiredException) ex.getCause(); LOG.error("Authorization required: " + authEx.getMessage()); } LOG.error(ex); } 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:com.liteoc.bean.extract.odm.MetaDataReportBean.java
private String handleLoadCastor(RulesPostImportContainer rpic) { try {/* www. ja va2 s . c o m*/ // Create Mapping Mapping mapping = new Mapping(); mapping.loadMapping(getCoreResources().getURL("mappingMarshallerMetadata.xml")); // Create XMLContext XMLContext xmlContext = new XMLContext(); xmlContext.setProperty(XMLConfiguration.NAMESPACES, "true"); xmlContext.addMapping(mapping); StringWriter writer = new StringWriter(); Marshaller marshaller = xmlContext.createMarshaller(); // marshaller.setNamespaceMapping("castor", "http://castor.org/sample/mapping/"); marshaller.setWriter(writer); marshaller.marshal(rpic); String result = writer.toString(); String newResult = result.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", ""); return newResult; } catch (FileNotFoundException ex) { throw new OpenClinicaSystemException(ex.getMessage(), ex.getCause()); } catch (IOException ex) { throw new OpenClinicaSystemException(ex.getMessage(), ex.getCause()); } catch (MarshalException e) { throw new OpenClinicaSystemException(e.getMessage(), e.getCause()); } catch (ValidationException e) { throw new OpenClinicaSystemException(e.getMessage(), e.getCause()); } catch (MappingException e) { throw new OpenClinicaSystemException(e.getMessage(), e.getCause()); } catch (Exception e) { throw new OpenClinicaSystemException(e.getMessage(), e.getCause()); } }
From source file:org.gluu.com.ox_push2.u2f.v2.ProcessManager.java
public void onOxPushRequest(final Boolean isDeny) { // runOnUiThread(new Runnable() { // @Override // public void run() { // if (isDeny){ // setFinalStatus(R.string.process_deny_start); // } else { // setFinalStatus(R.string.process_authentication_start); // } // } // }); final boolean oneStep = Utils.isEmpty(oxPush2Request.getUserName()); final Map<String, String> parameters = new HashMap<String, String>(); parameters.put("application", oxPush2Request.getApp()); parameters.put("session_state", oxPush2Request.getState()); if (!oneStep) { parameters.put("username", oxPush2Request.getUserName()); }// w ww . j a v a 2s . c o m new Thread(new Runnable() { @Override public void run() { try { final U2fMetaData u2fMetaData = getU2fMetaData(); // dataStore = oxPush2RequestListener.onGetDataStore(); final List<byte[]> keyHandles = dataStore .getKeyHandlesByIssuerAndAppId(oxPush2Request.getIssuer(), oxPush2Request.getApp()); final boolean isEnroll = (keyHandles.size() == 0) || oxPush2Request.getMethod().equals("enroll"); final String u2fEndpoint; if (isEnroll) { u2fEndpoint = u2fMetaData.getRegistrationEndpoint(); if (BuildConfig.DEBUG) Log.i(TAG, "Authentication method: enroll"); } else { u2fEndpoint = u2fMetaData.getAuthenticationEndpoint(); if (BuildConfig.DEBUG) Log.i(TAG, "Authentication method: authenticate"); } final String challengeJsonResponse; if (oneStep && (keyHandles.size() > 0)) { // Try to get challenge using all keyHandles associated with issuer and application String validChallengeJsonResponse = null; for (byte[] keyHandle : keyHandles) { parameters.put("keyhandle", Utils.base64UrlEncode(keyHandle)); try { validChallengeJsonResponse = CommunicationService.get(u2fEndpoint, parameters); break; } catch (FileNotFoundException ex) { Log.i(TAG, "Found invalid keyHandle: " + Utils.base64UrlEncode(keyHandle)); } } challengeJsonResponse = validChallengeJsonResponse; if (BuildConfig.DEBUG) Log.d(TAG, "Get U2F JSON response: " + challengeJsonResponse); } else { challengeJsonResponse = CommunicationService.get(u2fEndpoint, parameters); if (BuildConfig.DEBUG) Log.d(TAG, "Get U2F JSON response: " + challengeJsonResponse); } if (Utils.isEmpty(challengeJsonResponse)) { setFinalStatus(StringsUtil.NO_VALID_KEY_HANDLES); } else { try { onChallengeReceived(isEnroll, u2fMetaData, u2fEndpoint, challengeJsonResponse, isDeny); } catch (Exception ex) { Log.e(TAG, "Failed to process challengeJsonResponse: " + challengeJsonResponse, ex); setFinalStatus(StringsUtil.FAILED_PROCESS_CHALLENGE); } } } catch (final Exception ex) { Log.e(TAG, "Failed to get Fido U2F metadata", ex); if (ex.getCause().getMessage() != null) { setFinalStatus(ex.getCause().getMessage()); } else { setFinalStatus(StringsUtil.WRONG_U2F_METADATA); } } } }).start(); }
From source file:org.signserver.client.cli.defaultimpl.SignDocumentCommand.java
/** * Runs the signing operation for one file. * * @param manager for the threads// w ww.j av a2 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(); } } }