List of usage examples for java.io IOException getLocalizedMessage
public String getLocalizedMessage()
From source file:com.yoctopuce.YoctoAPI.YCallbackHub.java
YCallbackHub(YAPIContext yctx, int idx, HTTPParams httpParams, InputStream request, OutputStream response) throws YAPI_Exception { super(yctx, httpParams, idx, true); _http_params = httpParams;//ww w .j av a2 s .com _out = response; if (request == null || _out == null) { throw new YAPI_Exception(YAPI.INVALID_ARGUMENT, "Use RegisterHub(String url, BufferedReader request, PrintWriter response) to start api in callback"); } try { loadCallbackCache(request); } catch (IOException ex) { throw new YAPI_Exception(YAPI.IO_ERROR, ex.getLocalizedMessage()); } }
From source file:fr.fastconnect.factory.tibco.bw.maven.packaging.GenerateXMLFromPropertiesMojo.java
public void execute() throws MojoExecutionException { if (super.skip()) { if (deploymentDescriptorFinal != null && !deploymentDescriptorFinal.exists() && touchFinalDeploymentDescriptorIfSkipped) { // final deployment descriptor was not created because packaging is skipped // however we "touch" the final deployment descriptor file so there is an empty final deployment descriptor file created try { deploymentDescriptorFinal.getParentFile().mkdirs(); deploymentDescriptorFinal.createNewFile(); } catch (IOException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); }//from w w w . j a v a2s. c o m } if (deploymentDescriptorFinal != null && deploymentDescriptorFinal.exists()) { attachFile(deploymentDescriptorFinal, XML_TYPE, "final"); } else { getLog().warn(WARN_NO_ARTIFACT_ATTACHED); } return; } init(); mergeGlobalVariables(); mergeServices(); updateRepoInstances(); updateMonitoringRules(); updateAdditionalInfo(); try { application.save(); } catch (JAXBException e) { throw new MojoExecutionException(APPLICATION_MANAGEMENT_MERGE_FAILURE + " '" + deploymentServices + "'", e); } attachFile(deploymentDescriptorFinal, XML_TYPE, "final"); getLog().info(APPLICATION_MANAGEMENT_MERGE_SUCCESS + " '" + deploymentDescriptorFinal + "'"); }
From source file:at.bitfire.davdroid.App.java
public void reinitLogger() { // don't use Android default logging, we have our own handlers log.setUseParentHandlers(false);//from w w w . jav a2 s . co m @Cleanup ServiceDB.OpenHelper dbHelper = new ServiceDB.OpenHelper(this); Settings settings = new Settings(dbHelper.getReadableDatabase()); boolean logToFile = settings.getBoolean(LOG_TO_EXTERNAL_STORAGE, false), logVerbose = logToFile || Log.isLoggable(log.getName(), Log.DEBUG); // set logging level according to preferences log.setLevel(logVerbose ? Level.ALL : Level.INFO); // remove all handlers for (Handler handler : log.getHandlers()) log.removeHandler(handler); // add logcat handler log.addHandler(LogcatHandler.INSTANCE); NotificationManagerCompat nm = NotificationManagerCompat.from(this); // log to external file according to preferences if (logToFile) { NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.drawable.ic_sd_storage_light).setLargeIcon(getLauncherBitmap(this)) .setContentTitle(getString(R.string.logging_davdroid_file_logging)).setLocalOnly(true); File dir = getExternalFilesDir(null); if (dir != null) try { String fileName = new File(dir, "davdroid-" + android.os.Process.myPid() + "-" + DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd-HHmmss") + ".txt") .toString(); log.info("Logging to " + fileName); FileHandler fileHandler = new FileHandler(fileName); fileHandler.setFormatter(PlainTextFormatter.DEFAULT); log.addHandler(fileHandler); builder.setContentText(dir.getPath()) .setSubText(getString(R.string.logging_to_external_storage_warning)) .setCategory(NotificationCompat.CATEGORY_STATUS) .setPriority(NotificationCompat.PRIORITY_HIGH) .setStyle(new NotificationCompat.BigTextStyle() .bigText(getString(R.string.logging_to_external_storage, dir.getPath()))) .setOngoing(true); } catch (IOException e) { log.log(Level.SEVERE, "Couldn't create external log file", e); builder.setContentText(getString(R.string.logging_couldnt_create_file, e.getLocalizedMessage())) .setCategory(NotificationCompat.CATEGORY_ERROR); } else builder.setContentText(getString(R.string.logging_no_external_storage)); nm.notify(Constants.NOTIFICATION_EXTERNAL_FILE_LOGGING, builder.build()); } else nm.cancel(Constants.NOTIFICATION_EXTERNAL_FILE_LOGGING); }
From source file:ca.phon.media.FFMpegMediaExporter.java
private List<String> getCmdLine() { List<String> cmdLine = new ArrayList<String>(); cmdLine.add(getFFMpegBinary());/*from w w w . j a v a 2 s .c o m*/ // setup options cmdLine.add("-i"); cmdLine.add(inputFile); if (startTime >= 0L) { cmdLine.add("-ss"); cmdLine.add("" + (startTime / 1000.0f)); } if (duration > 0L) { cmdLine.add("-t"); cmdLine.add("" + (duration / 1000.0f)); } if (isIncludeAudio()) { String ac = getAudioCodec(); if (ac.equalsIgnoreCase("wav") || ac.equalsIgnoreCase("raw")) { ac = "pcm_s16le"; } cmdLine.add("-acodec"); cmdLine.add(ac); } else { cmdLine.add("-an"); } if (isIncludeVideo()) { cmdLine.add("-vcodec"); cmdLine.add(getAudioCodec()); } else { cmdLine.add("-vn"); } if (StringUtils.strip(additionalArgs).length() > 0) { BufferedReader argsReader = new BufferedReader( new InputStreamReader(new ByteArrayInputStream(additionalArgs.getBytes()))); String line = null; try { while ((line = argsReader.readLine()) != null) { if (StringUtils.strip(line).length() == 0 || line.matches("^#.*")) { continue; } // allow for a single pair of arguments to be added // for example -ac 1 // otherwise it's one argument per line int spaceIdx = line.indexOf(" "); if (spaceIdx > 0) { String arg1 = line.substring(0, spaceIdx); String arg2 = line.substring(spaceIdx + 1); cmdLine.add(arg1); cmdLine.add(arg2); } else cmdLine.add(StringUtils.strip(line)); } argsReader.close(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex); } } cmdLine.add("-y"); cmdLine.add(outputFile); return cmdLine; }
From source file:com.jaspersoft.jasperserver.rest.services.RESTUser.java
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { try {/* w ww . ja v a 2 s . c o m*/ String userName = restUtils.extractResourceName(req.getPathInfo()); WSUser user = restUtils.populateServiceObject(restUtils.unmarshal(WSUser.class, req.getInputStream())); if (log.isDebugEnabled()) { log.debug("un Marshaling OK"); } if (validateUserForPutOrUpdate(user)) { if (!isAlreadyAUser(user)) { userAndRoleManagementService.putUser(user); restUtils.setStatusAndBody(HttpServletResponse.SC_CREATED, resp, ""); } else { throw new ServiceException(HttpServletResponse.SC_FORBIDDEN, "user " + user.getUsername() + "already exists"); } } else throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, "check request parameters"); } catch (AxisFault axisFault) { throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, axisFault.getLocalizedMessage()); } catch (IOException e) { throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, e.getLocalizedMessage()); } catch (JAXBException e) { throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, e.getLocalizedMessage()); } }
From source file:grisu.frontend.view.swing.files.preview.fileViewers.JobStatusGridFileViewer.java
private synchronized void generateGraph() { cpusSeries.clear();/* w w w . ja v a 2 s . c o m*/ licensesUserSeries.clear(); licensesAllSeries.clear(); ligandsSeries.clear(); List<String> lines; try { lines = FileUtils.readLines(this.csvFile); } catch (final IOException e) { myLogger.error(e.getLocalizedMessage(), e); return; } for (int i = 0; i < lines.size(); i++) { final String[] tokens = lines.get(i).split(","); final Date date = new Date(Long.parseLong(tokens[0]) * 1000); int cpus = Integer.parseInt(tokens[1]); if (cpus < 0) { cpus = 0; } int licensesUser = Integer.parseInt(tokens[2]); if (licensesUser < 0) { licensesUser = 0; } int licensesAll = Integer.parseInt(tokens[3]); if (licensesAll < 0) { licensesAll = 0; } final int ligands = Integer.parseInt(tokens[4]); RegularTimePeriod p = null; if (showMinutes) { p = new Minute(date); } else { p = new Hour(date); } cpusSeries.addOrUpdate(p, cpus); licensesUserSeries.addOrUpdate(p, licensesUser); licensesAllSeries.addOrUpdate(p, licensesAll); ligandsSeries.addOrUpdate(p, ligands); } }
From source file:ca.phon.app.workspace.ExtractProjectArchiveTask.java
/** * Extract contents of a zip file to the destination directory. *///from w w w. j a v a2s . com private void extractArchive(File archive, File destDir) throws IOException { BufferedOutputStream out = null; BufferedInputStream in = null; try (ZipFile zip = new ZipFile(archive)) { // create output directory if it does not exist if (destDir.exists() && !destDir.isDirectory()) { throw new IOException("'" + destDir.getAbsolutePath() + "' is not a directory."); } if (!destDir.exists()) { setProperty(STATUS_PROP, "Creating output directory"); destDir.mkdirs(); } Tuple<ZippedProjectType, String> zipDetect = getZipDetect(); ZipEntry entry = null; Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { if (isShutdown()) { return; } entry = entries.nextElement(); String entryName = entry.getName(); File outFile = null; if (zipDetect.getObj1() == ZippedProjectType.PROJECT_BASE_INCLUDED) { // dest dir has already b outFile = new File(destDir, entryName.replaceFirst(zipDetect.getObj2(), "")); } else { outFile = new File(destDir, entryName); } if (entry.isDirectory()) { if (!outFile.exists()) outFile.mkdirs(); } else { LOGGER.info("Extracting: " + entry); setProperty(STATUS_PROP, "Extracting: " + entry); in = new BufferedInputStream(zip.getInputStream(entry)); int count = -1; byte data[] = new byte[ZIP_BUFFER]; if (outFile.exists()) { LOGGER.warning("Overwriting file '" + outFile.getAbsolutePath() + "'"); } File parentFile = outFile.getParentFile(); if (!parentFile.exists()) parentFile.mkdirs(); FileOutputStream fos = new FileOutputStream(outFile); out = new BufferedOutputStream(fos, ZIP_BUFFER); while ((count = in.read(data, 0, ZIP_BUFFER)) != -1) { out.write(data, 0, count); } out.flush(); out.close(); in.close(); } } } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); throw e; } setProperty(STATUS_PROP, "Finished"); }
From source file:com.jaspersoft.jasperserver.rest.services.RESTUser.java
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { try {//from w w w. j a v a 2 s . c om WSUserSearchCriteria c = restUtils.getWSUserSearchCriteria(getUserSearchInformation(req.getPathInfo())); WSUser userToDelete = new WSUser(); userToDelete.setUsername(c.getName()); userToDelete.setTenantId(c.getTenantId()); if (isLoggedInUser(restUtils.getCurrentlyLoggedUser(), userToDelete)) { throw new ServiceException(HttpServletResponse.SC_FORBIDDEN, "user: " + userToDelete.getUsername() + " can not to delete himself"); } else if (validateUserForGetOrDelete(userToDelete)) { if (isAlreadyAUser(userToDelete)) { userAndRoleManagementService.deleteUser(userToDelete); } else { throw new ServiceException(HttpServletResponse.SC_NOT_FOUND, "user: " + userToDelete.getUsername() + " was not found"); } } else { throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, "check request parameters"); } if (log.isDebugEnabled()) { log.debug(userToDelete.getUsername() + " was deleted"); } restUtils.setStatusAndBody(HttpServletResponse.SC_OK, resp, ""); } catch (AxisFault axisFault) { throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, axisFault.getLocalizedMessage()); } catch (IOException e) { throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, e.getLocalizedMessage()); } }
From source file:ar.com.aleatoria.ue.rest.SimpleClientHttpResponse.java
public String getStatusText() throws IOException { try {//from w w w . j a va 2 s . c o m return this.connection.getResponseMessage(); } catch (IOException ex) { /* * If credentials are incorrect or not provided for Basic Auth, then * Android throws this exception when an HTTP 401 is received. Checking * for this response and returning the proper status. */ if (ex.getLocalizedMessage().equals(AUTHENTICATION_ERROR)) { return HttpStatus.UNAUTHORIZED.getReasonPhrase(); } else { throw ex; } } }
From source file:ar.com.aleatoria.ue.rest.SimpleClientHttpResponse.java
@Override public HttpStatus getStatusCode() throws IOException { try {/*from w ww . ja v a 2 s . c o m*/ return HttpStatus.valueOf(getRawStatusCode()); } catch (IOException ex) { /* * If credentials are incorrect or not provided for Basic Auth, then * Android throws this exception when an HTTP 401 is received. Checking * for this response and returning the proper status. */ if (ex.getLocalizedMessage().equals(AUTHENTICATION_ERROR)) { return HttpStatus.UNAUTHORIZED; } else { throw ex; } } }