List of usage examples for java.lang NumberFormatException getMessage
public String getMessage()
From source file:com.appeligo.showfiles.ShowFile.java
/** * @param request/*from w w w. j a va 2 s . com*/ * @param out * @param filename * @throws IOException * @throws FileNotFoundException */ private void showPreview(HttpServletRequest request, PrintWriter out, String path, String filename) { if (filename.endsWith("/")) { filename = filename.substring(0, filename.length() - 1); } int lastslash = filename.lastIndexOf('/'); int comma = filename.lastIndexOf(','); int minus = filename.lastIndexOf('-'); int dot = filename.lastIndexOf('.'); String programID = filename.substring(lastslash + 1, comma); long clipStartSecs = 0; long clipLengthSecs = 0; try { clipStartSecs = Long.parseLong(filename.substring(comma + 1, minus)); clipLengthSecs = Long.parseLong(filename.substring(minus + 1, dot)); } catch (NumberFormatException e) { log.error("Can't parse the filename into a start time!", e); throw e; } catch (StringIndexOutOfBoundsException e) { log.error("Can't parse the filename for preview time info", e); throw e; } out.println("<a href=\"" + request.getContextPath() + "/ShowFlv" + path + filename + "?start=" + 0 + "&duration=" + clipLengthSecs + "\">" + "<img src=\"" + request.getContextPath() + "/skins/default/videoIcon.gif\" alt=\"video\"/>" + (clipStartSecs / 60) + ":" + String.format("%02d", (clipStartSecs % 60)) + "</a>"); File titleFile = new File(documentRoot + path + programID + ".title"); if (titleFile.exists()) { try { FileReader titleReader = new FileReader(titleFile); BufferedReader lineReader = new BufferedReader(titleReader); out.println(" " + lineReader.readLine()); titleReader.close(); } catch (IOException e) { out.println("(Error reading title file) " + e.getMessage()); } } }
From source file:gda.gui.mca.McaGUI.java
protected void setPresetValues() { // System.out.println("inside preset set values"); double preliveTime = 0.0; double preRealTime = 0.0; try {//from w w w .j a v a 2s. c o m EpicsMCAPresets preset = (EpicsMCAPresets) analyser.getPresets(); preliveTime = preset.getPresetLiveTime(); preRealTime = preset.getPresetRealTime(); preset.setPresetLiveTime(Float.parseFloat(presetLiveTimeField.getText())); preset.setPresetRealTime(Float.parseFloat(presetRealTimeField.getText())); analyser.setPresets(preset); } catch (DeviceException e) { logger.error("Unable to set Preset time values"); } catch (NumberFormatException nme) { JOptionPane.showMessageDialog(this, "Invalid Analyser Preset live/real times values : " + nme.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); presetRealTimeField.setText(String.valueOf(preRealTime)); presetLiveTimeField.setText(String.valueOf(preliveTime)); } }
From source file:com.dell.asm.asmcore.asmmanager.snmp.utils.SNMPTrapFrameworkUtils.java
/** * Creates and starts the SNMP trap listener * //from ww w. j a v a 2 s . c o m * @return ISNMPTrapListener * * @throws SNMPTrapListenerException * */ public static ISNMPTrapListener createAndStartListener() throws SNMPTrapListenerException { SNMPTrapListenerProtocolEnum protocol = null; ISNMPTrapListener listener = null; URL propFileURL = null; String host = null; String value = null; int port = 0; Set<ISNMPTrapHandler> handlers = new HashSet<ISNMPTrapHandler>(); SNMPTrapListenerSpec spec = new SNMPTrapListenerSpec(); try { // Load the properties file propFileURL = SNMPTrapFrameworkUtils.class.getClassLoader() .getResource(SNMPTrapListnerConstants.SNMP_PROPERTIES_FILE); // Read the properties file Properties props = getPropertiesFromFile(propFileURL); // Read Host MonitoringSettingModel monitoringSetting = MonitoringSettingMgr.getInstance().getMonitoringSettings(); if (null == monitoringSetting) { String msg = "Host is null."; throw new SNMPTrapListenerException(msg); } List<TrapSettingModel> trapSettings = monitoringSetting.getTrapSettings().getTrapSetting(); for (TrapSettingModel trapSetting : trapSettings) { if (trapSetting.isDefaultIp()) { host = trapSetting.getDestinationIPAddress(); break; } } if (StringUtils.isBlank(host)) { String msg = "Host is null."; throw new SNMPTrapListenerException(msg); } // Read Port value = props.getProperty(SNMPTrapListnerConstants.PROP_PORT); if (StringUtils.isBlank(value)) { String msg = "Port is null."; throw new SNMPTrapListenerException(msg); } try { port = Integer.parseInt(value); } catch (NumberFormatException e) { throw new SNMPTrapListenerException("Port (" + value + ") is not valid."); } // Read Protocol value = props.getProperty(SNMPTrapListnerConstants.PROP_PROTOCOL); if (StringUtils.isBlank(value)) { throw new SNMPTrapListenerException("Protocol is null."); } try { protocol = Enum.valueOf(SNMPTrapListenerProtocolEnum.class, value); } catch (IllegalArgumentException e) { throw new SNMPTrapListenerException("Protocol (" + value + ") is not valid."); } // Add the listener specifications spec.setListenerHost(host); spec.setListenerPort(port); spec.setProtocol(protocol); // Read snmp supported versions if (StringUtils.isBlank(props.getProperty(SNMPTrapListnerConstants.PROP_SNMP_V1)) & StringUtils.isBlank(props.getProperty(SNMPTrapListnerConstants.PROP_SNMP_V1)) & StringUtils.isBlank(props.getProperty(SNMPTrapListnerConstants.PROP_SNMP_V1))) { throw new SNMPTrapListenerException("SNMP version is null."); } // Add the supported versions to the listener specifications if (Boolean.valueOf(props.getProperty(SNMPTrapListnerConstants.PROP_SNMP_V1))) { spec.getSupportedSNMPVersions().add(SNMPVersionEnum.VERSION1); } if (Boolean.valueOf(props.getProperty(SNMPTrapListnerConstants.PROP_SNMP_V2))) { spec.getSupportedSNMPVersions().add(SNMPVersionEnum.VERSION2); } if (Boolean.valueOf(props.getProperty(SNMPTrapListnerConstants.PROP_SNMP_V3))) { spec.getSupportedSNMPVersions().add(SNMPVersionEnum.VERSION3); } listener = SNMPTrapListenerFactory.createTrapListener(spec, handlers); logger.info("SNMP trap listener started successfully at Host " + host + " , on Port " + port + " ,using " + protocol + " Protocol."); } catch (SecurityException e) { throw new SNMPTrapListenerException("Unable to start the SNMP trap listener. " + e.getMessage()); } catch (SNMPTrapListenerException e) { throw new SNMPTrapListenerException("Unable to start the SNMP trap listener. " + e.getMessage()); } catch (AsmCheckedException e) { throw new SNMPTrapListenerException("Unable to start the SNMP trap listener. " + e.getMessage()); } catch (IOException e) { throw new SNMPTrapListenerException("Unable to start the SNMP trap listener. " + e.getMessage()); } return listener; }
From source file:de.thorstenberger.taskmodel.view.SaveStudentAnnotationAction.java
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages msgs = new ActionMessages(); ActionMessages errors = new ActionMessages(); long id;/* w ww . j a va2 s.c o m*/ try { id = Long.parseLong(request.getParameter("id")); } catch (NumberFormatException e) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("invalid.parameter")); saveErrors(request, errors); return mapping.findForward("error"); } TaskModelViewDelegateObject delegateObject = (TaskModelViewDelegateObject) TaskModelViewDelegate .getDelegateObject(request.getSession().getId(), id); if (delegateObject == null) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("no.session")); saveErrors(request, errors); return mapping.findForward("error"); } ComplexTasklet ct; try { ct = (ComplexTasklet) delegateObject.getTasklet(); } catch (ClassCastException e1) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("only.complexTasks.supported")); saveErrors(request, errors); return mapping.findForward("error"); } catch (TaskApiException e3) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("misc.error", e3.getMessage())); saveErrors(request, errors); log.error(e3); return mapping.findForward("error"); } logPostData(request, ct); boolean saved; try { saved = ct.studentAnnotatesCorrection(request.getParameter("studentAnnotation")); } catch (IllegalStateException e) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getMessage())); saveErrors(request, errors); log.info(e); return mapping.findForward("error"); } if (saved) { msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("studentAnnotation.successful")); saveMessages(request, msgs); } else { errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage("studentAnnotation.no_comment")); saveErrors(request, errors); } return mapping.findForward("success"); }
From source file:de.bangl.lm.LotManagerPlugin.java
public void updateLotGroup(String id, String limit, String price, CommandSender sender) { try {//from w w w .java 2 s .co m if (!this.lots.existsLotGroup(id)) { sendError(sender, "\"" + id + "\" is not defined as a LotGroup."); return; } if (!isInteger(limit)) { sendError(sender, "\"" + limit + "\" is not a number."); return; } if (!isDouble(price)) { sendError(sender, "\"" + price + "\" is not a valid price."); return; } this.lots.updateLotGroup(id, Integer.parseInt(limit), Double.parseDouble(price)); sendInfo(sender, "LotGroup \"" + id + "\" is now updated."); } catch (NumberFormatException e) { logError(e.getMessage()); sendError(sender, e.getMessage()); } catch (Exception e) { logError(e.getMessage()); sendError(sender, e.getMessage()); } }
From source file:de.bangl.lm.LotManagerPlugin.java
public void defineLotGroup(String id, String limit, String price, CommandSender sender) { try {/*from w w w. j a v a 2s . co m*/ if (this.lots.existsLotGroup(id)) { sendError(sender, "\"" + id + "\" is already defined as a lot group."); return; } if (!isInteger(limit)) { sendError(sender, "\"" + limit + "\" is not a number."); return; } if (!isDouble(price)) { sendError(sender, "\"" + price + "\" is not a valid price."); return; } this.lots.defineLotGroup(id, Integer.parseInt(limit), Double.parseDouble(price)); if (this.Signs.containsKey(id)) { refreshSigns(id); } sendInfo(sender, "\"" + id + "\" is now defined as a lot group."); } catch (NumberFormatException e) { logError(e.getMessage()); sendError(sender, e.getMessage()); } catch (Exception e) { logError(e.getMessage()); sendError(sender, e.getMessage()); } }
From source file:com.xhsoft.framework.common.utils.ClassUtil.java
/** * @param type/* w ww .j a v a 2s . c o m*/ * @param s * @return Object * @author lizj */ public static Object cast(Class<?> type, String s) { if (s == null || type == null) { return null; } Object value = null; if (type == char.class || type == Character.class) { value = (s.length() > 0 ? Character.valueOf(s.charAt(0)) : null); } else if (type == boolean.class || type == Boolean.class) { String x = s.toLowerCase(); boolean b = ("1".equals(x) || "y".equals(x) || "on".equals(x) || "yes".equals(x) || "true".equals(x)); value = new Boolean(b); } else if (type == byte.class || type == Byte.class) { try { value = Byte.parseByte(s); } catch (NumberFormatException e) { } } else if (type == short.class || type == Short.class) { try { value = Short.parseShort(s); } catch (NumberFormatException e) { } } else if (type == int.class || type == Integer.class) { try { value = Integer.parseInt(s); } catch (NumberFormatException e) { } } else if (type == float.class || type == Float.class) { try { value = Float.parseFloat(s); } catch (NumberFormatException e) { } } else if (type == double.class || type == Double.class) { try { value = Double.parseDouble(s); } catch (NumberFormatException e) { } } else if (type == long.class || type == Long.class) { try { value = Long.parseLong(s); } catch (NumberFormatException e) { } } else if (type == String.class) { value = s; } else if (type == StringBuilder.class) { value = new StringBuilder(s); } else if (type == StringBuffer.class) { value = new StringBuffer(s); } else if (type == java.io.Reader.class) { value = new java.io.StringReader(s); } else if (type == java.util.Date.class) { if (s.length() > 0) { try { String format = (s.length() == "yyyy-MM-dd".length() ? "yyyy-MM-dd" : "yyyy-MM-dd HH:mm:ss SSS"); SimpleDateFormat dateFormat = new SimpleDateFormat(format); value = dateFormat.parse(s); } catch (java.text.ParseException e) { if (DEBUG) { log.debug("Exception: " + e.getMessage()); } } } } else if (type == java.sql.Date.class) { if (s.length() > 0) { try { String format = (s.length() == "yyyy-MM-dd".length() ? "yyyy-MM-dd" : "yyyy-MM-dd HH:mm:ss SSS"); SimpleDateFormat dateFormat = new SimpleDateFormat(format); java.util.Date date = dateFormat.parse(s); value = new java.sql.Date(date.getTime()); } catch (java.text.ParseException e) { if (DEBUG) { log.debug("Exception: " + e.getMessage()); } } } } else if (type == java.sql.Timestamp.class) { if (s.length() > 0) { try { String format = (s.length() == "yyyy-MM-dd".length() ? "yyyy-MM-dd" : "yyyy-MM-dd HH:mm:ss SSS"); SimpleDateFormat dateFormat = new SimpleDateFormat(format); java.util.Date date = dateFormat.parse(s); value = new java.sql.Timestamp(date.getTime()); } catch (java.text.ParseException e) { if (DEBUG) { log.debug("Exception: " + e.getMessage()); } } } } return value; }
From source file:de.thorstenberger.taskmodel.view.AJAXSaveStudentAnnotationAction.java
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionMessages msgs = new ActionMessages(); ActionMessages errors = new ActionMessages(); // FIXME: error handling long id;/*from w w w .j ava 2 s .c o m*/ try { id = Long.parseLong(request.getParameter("id")); } catch (NumberFormatException e) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("invalid.parameter")); saveErrors(request, errors); return mapping.findForward("error"); } TaskModelViewDelegateObject delegateObject = (TaskModelViewDelegateObject) TaskModelViewDelegate .getDelegateObject(request.getSession().getId(), id); if (delegateObject == null) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("no.session")); saveErrors(request, errors); return mapping.findForward("error"); } ComplexTasklet ct; try { ct = (ComplexTasklet) delegateObject.getTasklet(); } catch (ClassCastException e1) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("only.complexTasks.supported")); saveErrors(request, errors); return mapping.findForward("error"); } catch (TaskApiException e3) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("misc.error", e3.getMessage())); saveErrors(request, errors); log.error(e3); return mapping.findForward("error"); } logPostData(request, ct); boolean saved; String annotation = request.getParameter("studentAnnotation"); try { saved = ct.studentAnnotatesCorrection(annotation); } catch (IllegalStateException e) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getMessage())); saveErrors(request, errors); log.info(e); return mapping.findForward("error"); } if (saved) { msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("studentAnnotation.successful")); saveMessages(request, msgs); } else { errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage("studentAnnotation.no_comment")); saveErrors(request, errors); } request.setAttribute("contentType", "text/plain"); request.setAttribute(AjaxResponseServlet.RESPONSE, annotation); return mapping.findForward("success"); }
From source file:net.o3s.beans.registering.RegisteringBean.java
/** * Create new label/*from www . j a v a2 s.c om*/ * @param labelValue * @throws RegisteringException */ private IEntityLabel createLabel(IEntityCompetition competition, String labelValue, String rfid) throws AlreadyExistException, RegisteringException { int labelNumber = 0; // label format is DDDDCCC with d:digit try { labelNumber = Integer.parseInt(labelValue.substring(0, labelValue.length() - 3)); } catch (NumberFormatException ne1) { throw new RegisteringException(ne1.getMessage()); } IEntityLabel label = findLabelFromNumber(labelNumber); if (label != null) { throw new AlreadyExistException("Dossard deja existant [" + label + "]"); } label = new Label(); label.setNumber(labelNumber); label.setValue(labelValue); label.setRfid(rfid); IEntityEvent event = admin.findDefaultEvent(); label.setEvent(event); this.entityManager.persist(label); return label; }
From source file:at.ac.tuwien.inso.subcat.miner.MinerRunner.java
public static void main(String[] args) { Options options = new Options(); options.addOption("h", "help", false, "Show this options"); options.addOption("m", "miner-help", false, "Show miner specific options"); options.addOption("d", "db", true, "The database to process (required)"); options.addOption("p", "project", true, "The project ID to process"); options.addOption("P", "list-projects", false, "List all registered projects"); options.addOption("v", "verbose", false, "Show details"); options.addOption(null, "bug-repo", true, "Bug Repository URL"); options.addOption(null, "bug-product", true, "Bug Product Name"); options.addOption(null, "bug-tracker", true, "Bug Tracker name (e.g. bugzilla)"); options.addOption(null, "bug-account", true, "Bug account name"); options.addOption(null, "bug-passwd", true, "Bug account password"); options.addOption(null, "bug-enable-untrusted", false, "Accept untrusted certificates"); options.addOption(null, "bug-threads", true, "Thread count used in bug miners"); options.addOption(null, "bug-cooldown-time", true, "Bug cooldown time"); options.addOption(null, "bug-miner-option", true, "Bug miner specific option. Format: <option-name>:value"); options.addOption(null, "bug-update", false, "Mine all changes since the last run"); options.getOption("bug-miner-option").setArgs(Option.UNLIMITED_VALUES); options.addOption(null, "src-path", true, "Local source repository path"); options.addOption(null, "src-remote", true, "Remote address"); options.addOption(null, "src-passwd", true, "Source repository account password"); options.addOption(null, "src-account", true, "Source repository account name"); options.addOption(null, "src-miner-option", true, "Source miner specific option. Format: <option-name>:value"); options.getOption("src-miner-option").setArgs(Option.UNLIMITED_VALUES); final Reporter reporter = new Reporter(true); reporter.startTimer();/*from ww w . jav a2 s .c o m*/ boolean printTraces = false; Settings settings = new Settings(); ModelPool pool = null; CommandLineParser parser = new PosixParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("postprocessor", options); return; } if (cmd.hasOption("miner-help")) { init(); for (MetaData meta : registeredMiner) { System.out.println(meta.name()); for (Entry<String, ParamType> opt : meta.getSpecificParams().entrySet()) { System.out.println(" - " + opt.getKey() + " (" + opt.getValue() + ")"); } } return; } if (cmd.hasOption("db") == false) { reporter.error("miner", "Option --db is required"); reporter.printSummary(); return; } printTraces = cmd.hasOption("verbose"); pool = new ModelPool(cmd.getOptionValue("db"), 2); if (cmd.hasOption("list-projects")) { Model model = pool.getModel(); for (Project proj : model.getProjects()) { System.out.println(" " + proj.getId() + ": " + proj.getDate()); } model.close(); return; } Project project; Model model = pool.getModel(); boolean hasSrcInfos = false; boolean hasBugInfos = false; if (cmd.hasOption("project")) { try { int projId = Integer.parseInt(cmd.getOptionValue("project")); project = model.getProject(projId); } catch (NumberFormatException e) { reporter.error("post-processor", "Invalid project ID"); reporter.printSummary(); return; } if (project == null) { reporter.error("post-processor", "Invalid project ID"); reporter.printSummary(); return; } List<String> flags = model.getFlags(project); hasBugInfos = flags.contains(Model.FLAG_BUG_INFO); hasSrcInfos = flags.contains(Model.FLAG_SRC_INFO); } else { project = model.addProject(new Date(), null, settings.bugTrackerName, settings.bugRepository, settings.bugProductName, null); } model.close(); // // Source Repository Mining: // settings.srcLocalPath = cmd.getOptionValue("src-path"); settings.srcRemote = cmd.getOptionValue("src-remote"); settings.srcRemotePw = cmd.getOptionValue("src-passwd"); settings.srcRemoteUser = cmd.getOptionValue("src-account"); if (settings.srcRemotePw == null || settings.srcRemoteUser == null) { if (settings.srcRemotePw != null) { reporter.error("miner", "--src-passwd should only be used in combination with --src-account"); reporter.printSummary(); return; } else if (settings.srcRemoteUser != null) { reporter.error("miner", "--src-account should only be used in combination with --src-passwd"); reporter.printSummary(); return; } } if (settings.srcRemoteUser != null && settings.srcRemote == null) { reporter.error("miner", "--src-account should only be used in combination with --src-remote"); reporter.printSummary(); return; } if (settings.srcLocalPath != null && hasSrcInfos) { reporter.error("miner", "Source repository updates are not supported yet."); reporter.printSummary(true); return; } // // Bug Repository Mining: // settings.bugRepository = cmd.getOptionValue("bug-repo"); settings.bugProductName = cmd.getOptionValue("bug-product"); settings.bugTrackerName = cmd.getOptionValue("bug-tracker"); settings.bugEnableUntrustedCertificates = cmd.hasOption("bug-enable-untrusted"); settings.bugLoginUser = cmd.getOptionValue("bug-account"); settings.bugLoginPw = cmd.getOptionValue("bug-passwd"); settings.bugUpdate = cmd.hasOption("bug-update"); boolean includeBugs = false; if (settings.bugUpdate) { if (project.getBugTracker() == null || project.getDomain() == null) { reporter.error("miner", "flag --bug-update is requires previously mined bugs. Use --bug-repository, --bug-product and --bug-tracker."); reporter.printSummary(true); return; } if (settings.bugTrackerName != null) { reporter.warning("miner", "flag --bug-tracker without effect"); } if (settings.bugProductName != null) { reporter.warning("miner", "flag --bug-product without effect"); } if (settings.bugRepository != null) { reporter.warning("miner", "flag --bug-repository without effect"); } settings.bugTrackerName = project.getBugTracker(); settings.bugProductName = project.getProduct(); settings.bugRepository = project.getDomain(); includeBugs = true; } else if (settings.bugRepository != null && settings.bugProductName != null && settings.bugTrackerName != null) { if (hasBugInfos == false) { // The user is trying to append bug tracker information to a existing project. } else if (!settings.bugTrackerName.equalsIgnoreCase(project.getBugTracker()) || !settings.bugProductName.equalsIgnoreCase(project.getProduct()) || !settings.bugRepository.equalsIgnoreCase(project.getDomain())) { reporter.error("miner", "There are already previously mined bugs for this project. Use --bug-update to update the database."); reporter.printSummary(true); return; } if (settings.bugRepository == null) { reporter.error("miner", "flag --bug-repository is required"); reporter.printSummary(true); return; } if (settings.bugProductName == null) { reporter.error("miner", "flag --bug-product is required"); reporter.printSummary(true); return; } includeBugs = true; } if (includeBugs) { if (settings.bugLoginPw == null || settings.bugLoginUser == null) { if (settings.bugLoginPw != null) { reporter.error("miner", "--bug-passwd should only be used in combination with --bug-account"); reporter.printSummary(); return; } else if (settings.bugLoginUser != null) { reporter.error("miner", "--bug-account should only be used in combination with --bug-passwd"); reporter.printSummary(); return; } } if (cmd.hasOption("bug-threads")) { try { settings.bugThreads = Integer.parseInt(cmd.getOptionValue("bug-threads")); } catch (Exception e) { reporter.error("miner", "--bug-threads: Invalid parameter type"); reporter.printSummary(); return; } } if (cmd.hasOption("bug-cooldown-time")) { try { settings.bugCooldownTime = Integer.parseInt(cmd.getOptionValue("bug-cooldown-time")); } catch (Exception e) { reporter.error("miner", "--bug-cooldown-time: Invalid parameter type"); reporter.printSummary(); return; } } if (cmd.hasOption("bug-miner-option")) { for (String str : cmd.getOptionValues("bug-miner-option")) { addSpecificParameter(settings.bugSpecificParams, str); } } if (cmd.hasOption("src-miner-option")) { for (String str : cmd.getOptionValues("src-miner-option")) { addSpecificParameter(settings.srcSpecificParams, str); } } } else { if (settings.bugLoginPw != null) { reporter.error("miner", "--bug-passwd should only be used in combination with --bug-account"); reporter.printSummary(); return; } if (settings.bugLoginUser != null) { reporter.error("miner", "--bug-account should only be used in combination with --bug-account"); reporter.printSummary(); return; } if (settings.bugRepository != null) { reporter.error("miner", "--bug-repo should only be used in combination with --bug-product and --bug-tracker"); reporter.printSummary(); return; } if (settings.bugProductName != null) { reporter.error("miner", "--bug-product should only be used in combination with --bug-repo and --bug-tracker"); reporter.printSummary(); return; } if (settings.bugTrackerName != null) { reporter.error("miner", "--bug-tracker should only be used in combination with --bug-repo and --bug-product"); reporter.printSummary(); return; } if (settings.bugEnableUntrustedCertificates) { reporter.error("miner", "--bug-enable-untrusted should only be used in combination with --bug-repo, --bug-tracker and --bug-product"); reporter.printSummary(); return; } if (settings.bugUpdate) { reporter.error("miner", "--bug-update should only be used in combination with --bug-repo, --bug-tracker and --bug-product"); reporter.printSummary(); return; } if (cmd.hasOption("bug-threads")) { reporter.error("miner", "--bug-threads should only be used in combination with --bug-repo, --bug-tracker and --bug-product"); reporter.printSummary(); return; } if (cmd.hasOption("bug-cooldown-time")) { reporter.error("miner", "--bug-cooldown-time should only be used in combination with --bug-repo, --bug-tracker and --bug-product"); reporter.printSummary(); return; } if (cmd.hasOption("bug-miner-option")) { reporter.error("miner", "--bug-miner-option should only be used in combination with --bug-repo, --bug-tracker and --bug-product"); reporter.printSummary(); return; } } // // Run: // MinerRunner runner = new MinerRunner(pool, project, settings, reporter); if (cmd.hasOption("verbose")) { runner.addListener(new MinerListener() { private Map<Miner, Integer> totals = new HashMap<Miner, Integer>(); @Override public void start(Miner miner) { } @Override public void end(Miner miner) { } @Override public void stop(Miner miner) { } @Override public void tasksTotal(Miner miner, int count) { totals.put(miner, count); } @Override public void tasksProcessed(Miner miner, int processed) { Integer total = totals.get(miner); reporter.note(miner.getName(), "status: " + processed + "/" + ((total == null) ? "0" : total)); } }); } runner.run(); } catch (ParameterException e) { reporter.error(e.getMiner().getName(), e.getMessage()); } catch (ParseException e) { reporter.error("miner", "Parsing failed: " + e.getMessage()); if (printTraces == true) { e.printStackTrace(); } } catch (ClassNotFoundException e) { reporter.error("miner", "Failed to create a database connection: " + e.getMessage()); if (printTraces == true) { e.printStackTrace(); } } catch (SQLException e) { reporter.error("miner", "Failed to create a database connection: " + e.getMessage()); if (printTraces == true) { e.printStackTrace(); } } catch (MinerException e) { reporter.error("miner", "Mining Error: " + e.getMessage()); if (printTraces == true) { e.printStackTrace(); } } finally { if (pool != null) { pool.close(); } } reporter.printSummary(true); }