Example usage for java.text ParseException getMessage

List of usage examples for java.text ParseException getMessage

Introduction

In this page you can find the example usage for java.text ParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.entrystore.repository.impl.ContextManagerImpl.java

private Date parseTimestamp(String timestamp) {
    Date date = null;// www  . ja  v  a 2  s .c  o m
    DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
    formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
    try {
        date = formatter.parse(timestamp);
    } catch (ParseException pe) {
        log.error(pe.getMessage());
    }
    return date;
}

From source file:fll.scheduler.SchedulerUI.java

/**
 * Load the specified schedule file and select the schedule tab.
 * //from w  w w.  ja  v  a 2  s.  co m
 * @param selectedFile
 * @param subjectiveStations if not null, use as the subjective stations,
 *          otherwise prompt the user for the subjective stations
 */
private void loadScheduleFile(final File selectedFile, final List<SubjectiveStation> subjectiveStations) {
    FileInputStream fis = null;
    try {
        final boolean csv = selectedFile.getName().endsWith("csv");
        final CellFileReader reader;
        final String sheetName;
        if (csv) {
            reader = new CSVCellReader(selectedFile);
            sheetName = null;
        } else {
            sheetName = promptForSheetName(selectedFile);
            if (null == sheetName) {
                return;
            }
            fis = new FileInputStream(selectedFile);
            reader = new ExcelCellReader(fis, sheetName);
        }

        final List<SubjectiveStation> newSubjectiveStations;
        if (null == subjectiveStations) {
            final ColumnInformation columnInfo = TournamentSchedule.findColumns(reader,
                    new LinkedList<String>());
            newSubjectiveStations = gatherSubjectiveStationInformation(SchedulerUI.this, columnInfo);
        } else {
            newSubjectiveStations = subjectiveStations;
        }

        if (null != fis) {
            fis.close();
            fis = null;
        }

        mSchedParams = new SchedParams(newSubjectiveStations, SchedParams.DEFAULT_PERFORMANCE_MINUTES,
                SchedParams.MINIMUM_CHANGETIME_MINUTES, SchedParams.MINIMUM_PERFORMANCE_CHANGETIME_MINUTES);
        final List<String> subjectiveHeaders = new LinkedList<String>();
        for (final SubjectiveStation station : newSubjectiveStations) {
            subjectiveHeaders.add(station.getName());
        }

        final String name = Utilities.extractBasename(selectedFile);

        final TournamentSchedule schedule;
        if (csv) {
            schedule = new TournamentSchedule(name, selectedFile, subjectiveHeaders);
        } else {
            fis = new FileInputStream(selectedFile);
            schedule = new TournamentSchedule(name, fis, sheetName, subjectiveHeaders);
        }
        mScheduleFile = selectedFile;
        mScheduleSheetName = sheetName;
        setScheduleData(schedule);

        setTitle(BASE_TITLE + " - " + mScheduleFile.getName() + ":" + mScheduleSheetName);

        mWriteSchedulesAction.setEnabled(true);
        mDisplayGeneralScheduleAction.setEnabled(true);
        mRunOptimizerAction.setEnabled(true);
        mReloadFileAction.setEnabled(true);
        mScheduleFilename.setText(mScheduleFile.getName());

        mTabbedPane.setSelectedIndex(1);
    } catch (final ParseException e) {
        final Formatter errorFormatter = new Formatter();
        errorFormatter.format("Error reading file %s: %s", selectedFile.getAbsolutePath(), e.getMessage());
        LOGGER.error(errorFormatter, e);
        JOptionPane.showMessageDialog(SchedulerUI.this, errorFormatter, "Error reading file",
                JOptionPane.ERROR_MESSAGE);
        return;
    } catch (final IOException e) {
        final Formatter errorFormatter = new Formatter();
        errorFormatter.format("Error reading file %s: %s", selectedFile.getAbsolutePath(), e.getMessage());
        LOGGER.error(errorFormatter, e);
        JOptionPane.showMessageDialog(SchedulerUI.this, errorFormatter, "Error reading file",
                JOptionPane.ERROR_MESSAGE);
        return;
    } catch (final InvalidFormatException e) {
        final Formatter errorFormatter = new Formatter();
        errorFormatter.format("Unknown file format %s: %s", selectedFile.getAbsolutePath(), e.getMessage());
        LOGGER.error(errorFormatter, e);
        JOptionPane.showMessageDialog(SchedulerUI.this, errorFormatter, "Error reading file",
                JOptionPane.ERROR_MESSAGE);
        return;
    } catch (final ScheduleParseException e) {
        final Formatter errorFormatter = new Formatter();
        errorFormatter.format("Error parsing file %s: %s", selectedFile.getAbsolutePath(), e.getMessage());
        LOGGER.error(errorFormatter, e);
        JOptionPane.showMessageDialog(SchedulerUI.this, errorFormatter, "Error parsing file",
                JOptionPane.ERROR_MESSAGE);
        return;
    } catch (final FLLRuntimeException e) {
        final Formatter errorFormatter = new Formatter();
        errorFormatter.format("Error parsing file %s: %s", selectedFile.getAbsolutePath(), e.getMessage());
        LOGGER.error(errorFormatter, e);
        JOptionPane.showMessageDialog(SchedulerUI.this, errorFormatter, "Error parsing file",
                JOptionPane.ERROR_MESSAGE);
        return;
    } finally {
        try {
            if (null != fis) {
                fis.close();
            }
        } catch (final IOException e) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Error closing stream", e);
            }
        }
    }
}

From source file:com.ushahidi.swiftriver.core.api.controller.BucketsController.java

/**
 * Get drops in the bucket./*  ww w.j  ava 2  s. co  m*/
 * 
 * @param body
 * @return
 */
@RequestMapping(value = "/{id}/drops", method = RequestMethod.GET)
@ResponseBody
public List<GetDropDTO> getDrops(@PathVariable Long id,
        @RequestParam(value = "count", required = false, defaultValue = "50") Integer count,
        @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
        @RequestParam(value = "max_id", required = false) Long maxId,
        @RequestParam(value = "since_id", required = false) Long sinceId,
        @RequestParam(value = "date_from", required = false) String dateFromS,
        @RequestParam(value = "date_to", required = false) String dateToS,
        @RequestParam(value = "keywords", required = false) String keywords,
        @RequestParam(value = "channels", required = false) String channels,
        @RequestParam(value = "photos", required = false) Boolean photos,
        @RequestParam(value = "state", required = false) String state,
        @RequestParam(value = "locations", required = false) String locations, Principal principal) {

    if (maxId == null) {
        maxId = Long.MAX_VALUE;
    }

    List<ErrorField> errors = new ArrayList<ErrorField>();

    List<String> channelList = new ArrayList<String>();
    if (channels != null) {
        channelList.addAll(Arrays.asList(channels.split(",")));
    }

    Boolean isRead = null;
    if (state != null) {
        if (!state.equals("read") && !state.equals("unread")) {
            errors.add(new ErrorField("state", "invalid"));
        } else {
            isRead = state.equals("read");
        }
    }

    DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy");
    Date dateFrom = null;
    if (dateFromS != null) {
        try {
            dateFrom = dateFormat.parse(dateFromS);
        } catch (ParseException e) {
            errors.add(new ErrorField("date_from", "invalid"));
        }
    }

    Date dateTo = null;
    if (dateToS != null) {
        try {
            dateTo = dateFormat.parse(dateToS);
        } catch (ParseException e) {
            errors.add(new ErrorField("date_to", "invalid"));
        }
    }

    if (!errors.isEmpty()) {
        BadRequestException e = new BadRequestException("Invalid parameter.");
        e.setErrors(errors);
        throw e;
    }

    DropFilter dropFilter = new DropFilter();
    dropFilter.setMaxId(maxId);
    dropFilter.setSinceId(sinceId);
    dropFilter.setChannels(channelList);
    try {
        dropFilter.setDateFrom(dateFrom);
    } catch (InvalidFilterException e) {
        errors.add(new ErrorField("date_from", e.getMessage()));
    }

    try {
        dropFilter.setDateTo(dateTo);
    } catch (InvalidFilterException e) {
        errors.add(new ErrorField("date_to", e.getMessage()));
    }
    dropFilter.setRead(isRead);
    dropFilter.setPhotos(photos);
    dropFilter.setKeywords(keywords);
    dropFilter.setBoundingBox(locations);

    // Check for errors
    if (!errors.isEmpty()) {
        BadRequestException exception = new BadRequestException();
        exception.setErrors(errors);
        throw exception;
    }

    return bucketService.getDrops(id, dropFilter, page, count, principal.getName());
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractChannelController.java

@RequestMapping(value = ("/viewcataloghistory"), method = RequestMethod.GET)
public String viewCatalogHistory(@RequestParam(value = "channelId", required = true) String channelId,
        @RequestParam(value = "historyDate", required = false, defaultValue = "") String historyDate,
        @RequestParam(value = "dateFormat", required = false) String dateFormat,
        @RequestParam(value = "showProductHistory", required = false) String showProductHistory, ModelMap map) {
    logger.debug("### viewCatalogHistory method starting...(GET)");

    Channel channel = channelService.getChannelById(channelId);
    Catalog catalog = channel.getCatalog();

    List<Date> historyDatesForCatalog = productService.getHistoryDates(catalog);

    map.addAttribute("noHistory", false);
    map.addAttribute("supportedCurrencies", catalog.getSupportedCurrencyValuesByOrder());
    map.addAttribute("catalogHistoryDates", historyDatesForCatalog);

    if (historyDatesForCatalog == null || historyDatesForCatalog.size() == 0) {
        map.addAttribute("noHistory", true);
    } else {//from  ww w  .  j a  v  a 2 s.  c  o  m
        Date historyDateObj = null;
        if (historyDate != null && !historyDate.isEmpty()) {
            DateFormat formatter = new SimpleDateFormat(dateFormat);
            try {
                historyDateObj = formatter.parse(historyDate);
            } catch (ParseException e) {
                throw new InvalidAjaxRequestException(e.getMessage());
            }
        } else {
            historyDateObj = historyDatesForCatalog.get(0);
        }

        Map<Product, Map<CurrencyValue, Map<String, ProductCharge>>> fullProductPricingMap = getProductChargeMap(
                channel, "history", historyDateObj, false);

        Map<ProductBundleRevision, Map<CurrencyValue, Map<String, RateCardCharge>>> fullBundlePricingMap = getBundlePricingMap(
                channel, "history", historyDateObj, false);

        map.addAttribute("noOfProducts", fullProductPricingMap.size());
        map.addAttribute("fullProductPricingMap", fullProductPricingMap);
        map.addAttribute("productBundleRevisions", fullBundlePricingMap.keySet());
        map.addAttribute("fullBundlePricingMap", fullBundlePricingMap);
        map.addAttribute("chosenHistoryDate", historyDateObj);
    }
    if (showProductHistory != null) {
        map.addAttribute("showProductHistory", true);
    } else {
        map.addAttribute("showProductHistory", false);
    }
    logger.debug("### viewCatalogHistory method ending...(GET)");
    return "catalog.history";
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractChannelController.java

@RequestMapping(value = "/getfulllistingofcharges", method = RequestMethod.GET)
public String getFullChargeListing(@RequestParam(value = "channelId", required = true) String channelId,
        @RequestParam(value = "currentHistoryPlanned", required = true, defaultValue = "") String currentHistoryPlanned,
        @RequestParam(value = "bundleId", required = false, defaultValue = "") String bundleId,
        @RequestParam(value = "dateFormat", required = false, defaultValue = "") String dateFormat,
        @RequestParam(value = "historyDate", required = false, defaultValue = "") String date, ModelMap map) {
    logger.debug("### getfulllistingofcharges method starting...(GET)");

    Channel channel = channelService.getChannelById(channelId);
    Catalog catalog = channel.getCatalog();
    Date historyDate = null;//from  ww  w  .  jav a2  s  . c  o  m
    if (currentHistoryPlanned.equals("history")) {
        DateFormat formatter = new SimpleDateFormat(dateFormat);
        try {
            historyDate = formatter.parse(date);
        } catch (ParseException e) {
            throw new InvalidAjaxRequestException(e.getMessage());
        }
    }

    if (bundleId == null || bundleId.equals("")) {
        List<Product> productsList = new ArrayList<Product>();
        Map<Product, Map<CurrencyValue, Map<String, ProductCharge>>> fullProductPricingMap = null;
        if (currentHistoryPlanned.equals("current")) {
            fullProductPricingMap = getProductChargeMap(channel, "current", null, false);
            productsList = productService.listProducts(null, null, channelService.getCurrentRevision(channel));
        } else if (currentHistoryPlanned.equals("planned")) {
            fullProductPricingMap = getProductChargeMap(channel, "planned", null, false);
            productsList = productService.listProducts(null, null, channelService.getFutureRevision(channel));
        } else if (currentHistoryPlanned.equals("history")) {
            fullProductPricingMap = getProductChargeMap(channel, "history", historyDate, false);
            productsList = productService.listProducts(null, null,
                    channelService.getRevisionForTheDateGiven(historyDate, channel));
        }

        map.addAttribute("fullProductPricingMap", fullProductPricingMap);
        map.addAttribute("currencies", catalog.getSupportedCurrencyValuesByOrder());
        map.addAttribute("totalproducts", productsList.size());
        map.addAttribute("noDialog", false);

        logger.debug("### getfulllistingofcharges method end...(GET)");
        return "catalog.utilities";

    } else {

        ProductBundle bundle = productBundleService.getProductBundleById(Long.parseLong(bundleId));
        ProductBundleRevision productBundleRevision = null;
        Map<ProductBundleRevision, Map<CurrencyValue, Map<String, RateCardCharge>>> fullBundlePricingMap = null;
        if (currentHistoryPlanned.equals("current")) {
            fullBundlePricingMap = getBundlePricingMap(channel, "current", null, false);
            productBundleRevision = channelService.getCurrentChannelRevision(channel, false)
                    .getProductBundleRevisionsMap().get(bundle);
        } else if (currentHistoryPlanned.equals("planned")) {
            fullBundlePricingMap = getBundlePricingMap(channel, "planned", null, false);
            productBundleRevision = channelService.getFutureChannelRevision(channel, false)
                    .getProductBundleRevisionsMap().get(bundle);
        } else if (currentHistoryPlanned.equals("history")) {
            fullBundlePricingMap = getBundlePricingMap(channel, "history", historyDate, false);
            channelService.getChannelRevision(channel, historyDate, false);
            productBundleRevision = channelService.getChannelRevision(channel, historyDate, false)
                    .getProductBundleRevisionsMap().get(bundle);
        }

        map.addAttribute("productBundleRevision", productBundleRevision);
        map.addAttribute("fullBundlePricingMap", fullBundlePricingMap);
        map.addAttribute("productBundle", bundle);
        map.addAttribute("currencies", channel.getCatalog().getSupportedCurrencyValuesByOrder());
        map.addAttribute("noDialog", false);

        logger.debug("### getfulllistingofcharges method end...(GET)");
        return "catalog.bundle";
    }
}

From source file:web.Controller.ModificationController.java

@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object commandModif,
        BindException errors) throws Exception {

    CommandModification command = (CommandModification) commandModif;

    try {/*from w  w w.j  a  v a2  s. c  om*/
        Utilisateur u = service.getUtilisateur(Integer.parseInt(request.getParameter("id")));
        //Utilisateur u=service.getUtilisateur(1);

        SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
        try {
            u.setDateNaissance(
                    (command.getDateNaissance() == null & command.getDateNaissance().isEmpty()) ? null
                            : myFormatter.parse(command.getDateNaissance()));
        } catch (ParseException e) {
            u.setDateNaissance(null);
        }
        u.setAdresse(command.getAdresse() == null ? null : command.getAdresse());
        u.setCin(command.getCin() == null ? null : command.getCin());
        u.setEnabled(command.getEnabled() == null ? !command.getEnabled().equals("true")
                : command.getEnabled().equals("true"));
        u.setLogin(command.getLogin());
        u.setNom(command.getNom() == null ? null : command.getNom());
        u.setPass(command.getPass());
        u.setPernom(command.getPernom() == null ? null : command.getPernom());
        u.setProfession(command.getProfession() == null ? null : command.getProfession());
        u.setRole(command.getRole() == null ? null : command.getRole());
        u.setTelephone(command.getTelephone() == null ? null : Double.parseDouble(command.getTelephone()));
        System.out.println("before");
        System.out.println(u.toString());
        service.updateUtilisateur(u);
        System.out.println("********" + u.toString());
        HashMap<String, Object> map = new HashMap<>(2);
        map.put("id", 1);
        map.put("commandModification", command);
        System.out.println(command.getProfession());
        System.out.println("on submit controller");
        return new ModelAndView("modification", "commandModification", command);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        errors.reject("Inexistant User", "No users found");
        return showForm(request, response, errors);

    }

}

From source file:io.hops.hopsworks.api.jobs.JobService.java

@GET
@Path("/getLogByJobId/{jobId}/{submissionTime}/{type}")
@Produces(MediaType.APPLICATION_JSON)/*from   w  ww . j  av  a  2 s .  c o m*/
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
public Response getLogByJobId(@PathParam("jobId") Integer jobId,
        @PathParam("submissionTime") String submissionTime, @PathParam("type") String type)
        throws GenericException, JobException {
    if (jobId == null || jobId <= 0) {
        throw new IllegalArgumentException("jobId must be a non-null positive integer number.");
    }
    if (submissionTime == null) {
        throw new IllegalArgumentException("submissionTime was not provided.");
    }
    Jobs job = jobFacade.find(jobId);
    if (job == null) {
        throw new JobException(RESTCodes.JobErrorCode.JOB_NOT_FOUND, Level.FINE, "JobId:" + jobId);
    }
    SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy");
    Date date;
    try {
        date = sdf.parse(submissionTime);
    } catch (ParseException ex) {
        throw new GenericException(RESTCodes.GenericErrorCode.INCOMPLETE_REQUEST, Level.WARNING,
                "Cannot get log. Incorrect submission time. Error offset:" + ex.getErrorOffset(),
                ex.getMessage(), ex);
    }
    Execution execution = exeFacade.findByJobIdAndSubmissionTime(date, job);
    if (execution == null) {
        throw new JobException(RESTCodes.JobErrorCode.JOB_EXECUTION_NOT_FOUND, Level.FINE, "JobId " + jobId);
    }
    if (!execution.getState().isFinalState()) {
        throw new JobException(RESTCodes.JobErrorCode.JOB_EXECUTION_INVALID_STATE, Level.FINE,
                "Job still running.");
    }
    if (!execution.getJob().getProject().equals(this.project)) {
        throw new JobException(RESTCodes.JobErrorCode.JOB_ACCESS_ERROR, Level.FINE,
                "Requested execution does not belong to a job of project: " + project.getName());
    }

    JsonObjectBuilder arrayObjectBuilder = Json.createObjectBuilder();
    DistributedFileSystemOps dfso = null;
    try {
        dfso = dfs.getDfsOps();
        readLog(execution, type, dfso, arrayObjectBuilder);
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    } finally {
        if (dfso != null) {
            dfso.close();
        }
    }
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(arrayObjectBuilder.build())
            .build();
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocumentTest.java

/**
 * Regression test for bug 2919853 (format of <tt>document.lastModified</tt> was incorrect).
 * @throws Exception if an error occurs//from w  ww  .j a v  a 2  s  .co m
 */
@Test
public void lastModified_format() throws Exception {
    final String html = "<html><body onload='document.getElementById(\"i\").value = document.lastModified'>\n"
            + "<input id='i'></input></body></html>";

    final WebDriver driver = loadPageWithAlerts2(html);
    final String lastModified = driver.findElement(By.id("i")).getAttribute("value");

    try {
        new SimpleDateFormat("MM/dd/yyyy HH:mm:ss", Locale.ROOT).parse(lastModified);
    } catch (final ParseException e) {
        fail(e.getMessage());
    }
}

From source file:com.netcrest.pado.tools.pado.PadoShell.java

public CommandLine cliParseCommandLine(Options options, String[] args) throws Exception {
    // Parse the program arguments
    CommandLine commandLine = null;/*from  www .ja v a  2s  . c  o m*/
    try {
        commandLine = parser.parse(options, args);
    } catch (org.apache.commons.cli.ParseException e) {
        throw new Exception(e.getMessage());
    }
    return commandLine;
}

From source file:org.kuali.coeus.propdev.impl.print.NIHResearchAndRelatedXmlStream.java

private IndirectCostRateDetails getIndirectCostDetails(DevelopmentProposal developmentProposal) {
    IndirectCostRateDetails indirectCost = IndirectCostRateDetails.Factory.newInstance();
    String dhhsAgreementFlag = getParameterService()
            .getParameterValueAsString(ProposalDevelopmentDocument.class, "DHHS_AGREEMENT");
    Organization orgBean = developmentProposal.getApplicantOrganization().getOrganization();
    try {//from w  w w.j  ava  2  s .  c  om
        if (dhhsAgreementFlag.equals("0")) {
            // agreement is not with DHHS
            NoDHHSAgreement noAgreement = NoDHHSAgreement.Factory.newInstance();
            noAgreement.setAgencyName(getCognizantFedAgency(developmentProposal));
            if (orgBean.getIndirectCostRateAgreement() == null) {
                noAgreement.setAgreementDate(
                        getDateTimeService().getCalendar(getDateTimeService().convertToDate("1900-01-01")));
            } else
                noAgreement.setAgreementDate(getDateTimeService().getCalendar(
                        getDateTimeService().convertToDate(orgBean.getIndirectCostRateAgreement())));
            indirectCost.setNoDHHSAgreement(noAgreement);
        } else {
            // agreement is with DHHS
            // check agreement date . If there is no date, assume that negotiations are in process,
            // and take the agency with whom negotiations are being conducted from the rolodex entry of the
            // cognizant auditor
            if (orgBean.getIndirectCostRateAgreement() != null) {
                indirectCost.setDHHSAgreementDate(getDateTimeService().getCalendar(
                        getDateTimeService().convertToDate(orgBean.getIndirectCostRateAgreement())));
            } else {
                indirectCost.setDHHSAgreementNegotiationOffice(getCognizantFedAgency(developmentProposal));
            }
        }
    } catch (ParseException e) {
        LOG.error(e.getMessage(), e);
    }
    return indirectCost;
}