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.azyva.dragom.tool.WorkspaceManagerTool.java

/**
 * Implements the "build-clean-module-version" command.
 *///  w  ww .j a  v a  2 s.c om
private void buildCleanModuleVersionCommand() {
    ModuleVersion moduleVersion;
    WorkspaceDirUserModuleVersion workspaceDirUserModuleVersion;
    Set<WorkspaceDir> setWorkspaceDir;

    if (this.commandLine.getArgs().length != 2) {
        throw new RuntimeExceptionUserError(MessageFormat.format(
                CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_ARGUMENT_COUNT),
                CliUtil.getHelpCommandLineOption()));
    }

    // Here moduleVersion may not be complete: it may not contain the Version. If that
    // is so and the WorkspacePlugin implementation allows for multiple different
    // Version's of the same Module, setWorkspaceDir below will contain all these
    // occurrences. But in general it is expected that it contains only one
    // ModuleVersion.
    try {
        moduleVersion = ModuleVersion.parse(this.commandLine.getArgs()[1]);
    } catch (ParseException pe) {
        throw new RuntimeExceptionUserError(pe.getMessage());
    }

    workspaceDirUserModuleVersion = new WorkspaceDirUserModuleVersion(moduleVersion);

    setWorkspaceDir = this.workspacePlugin.getSetWorkspaceDir(workspaceDirUserModuleVersion);

    if (setWorkspaceDir.isEmpty()) {
        this.userInteractionCallbackPlugin.provideInfo(MessageFormat.format(
                WorkspaceManagerTool.resourceBundle.getString(
                        WorkspaceManagerTool.MSG_PATTERN_KEY_NO_WORKSPACE_DIRECTORY_FOR_MODULE_VERSION),
                moduleVersion));
    }

    for (WorkspaceDir workspaceDir : setWorkspaceDir) {
        Module module;
        BuilderPlugin builderPlugin;
        ScmPlugin scmPlugin;
        Path pathWorkspaceDir;

        module = this.model
                .getModule(((WorkspaceDirUserModuleVersion) workspaceDir).getModuleVersion().getNodePath());
        builderPlugin = module.getNodePlugin(BuilderPlugin.class, null);
        scmPlugin = module.getNodePlugin(ScmPlugin.class, null);

        pathWorkspaceDir = this.workspacePlugin.getWorkspaceDir(workspaceDir,
                WorkspacePlugin.GetWorkspaceDirMode.ENUM_SET_GET_EXISTING,
                WorkspacePlugin.WorkspaceDirAccessMode.READ_WRITE);

        try (Writer writerLog = this.userInteractionCallbackPlugin.provideInfoWithWriter(MessageFormat.format(
                WorkspaceManagerTool.resourceBundle.getString(WorkspaceManagerTool.MSG_PATTERN_KEY_CLEAN),
                pathWorkspaceDir, scmPlugin.getScmUrl(pathWorkspaceDir),
                ((WorkspaceDirUserModuleVersion) workspaceDir).getModuleVersion()))) {
            builderPlugin.clean(pathWorkspaceDir, writerLog);
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        } finally {
            this.workspacePlugin.releaseWorkspaceDir(pathWorkspaceDir);
        }
    }
}

From source file:org.kuali.coeus.common.framework.person.KcPerson.java

/**
 * Gets the value of age. Will return null if not set.
 *
 * @return the value of age// ww  w.  j av  a2s  . co m
 */
@Override
public Integer getAge() {
    final EntityBioDemographicsContract bio = this.entity.getBioDemographics();
    if (bio == null) {
        return null;
    }
    Date birthDate = null;

    try {
        birthDate = (bio.getBirthDate() != null)
                ? DateUtils.parseDate(bio.getBirthDate(), new String[] { "mm/dd/yyyy" })
                : null;
    } catch (ParseException e) {
        LOG.warn(e.getMessage(), e);
    }

    return birthDate != null ? this.calcAge(birthDate) : null;

}

From source file:org.eclipse.smarthome.core.scheduler.CronExpression.java

@Override
protected void populateWithSeeds() {

    YearsExpressionPart thePart = null;/*from  w w  w  .  j a  va2 s .c o m*/

    for (ExpressionPart part : getExpressionParts()) {
        if (part instanceof YearsExpressionPart) {
            thePart = (YearsExpressionPart) part;
            break;
        }
    }

    YearsExpressionPart yep = null;
    try {
        yep = new YearsExpressionPart("");
    } catch (ParseException e) {
        logger.error("An exception occurred while creating an expression part : '{}'", e.getMessage());
        return;
    }

    if (thePart == null) {
        BoundedIntegerSet set = yep.getValueSet();
        Calendar cal = Calendar.getInstance(getTimeZone());
        cal.setTime(getStartDate());
        int currentYear = cal.get(Calendar.YEAR);

        for (int i = 0; i < 10; i++) {
            set.add(currentYear++);
        }

        yep.setValueSet(set);
        getExpressionParts().add(yep);

    } else {
        BoundedIntegerSet set = thePart.getValueSet();
        int maxYear = set.last();
        for (int i = 0; i < 10; i++) {
            if (maxYear < YearsExpressionPart.MAX_YEAR) {
                set.add(maxYear++);
            }
        }
    }

}

From source file:org.azyva.dragom.tool.WorkspaceManagerTool.java

/**
 * Implements the "remove-module-version" command.
 *///from   w w w  .j  a v a2s  .c  o  m
private void removeModuleVersionCommand() {
    ModuleVersion moduleVersion;
    WorkspaceDirUserModuleVersion workspaceDirUserModuleVersion;
    Set<WorkspaceDir> setWorkspaceDir;

    if (this.commandLine.getArgs().length != 2) {
        throw new RuntimeExceptionUserError(MessageFormat.format(
                CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_ARGUMENT_COUNT),
                CliUtil.getHelpCommandLineOption()));
    }

    // Here moduleVersion may not be complete: it may not contain the Version. If that
    // is so and the WorkspacePlugin implementation allows for multiple different
    // Version's of the same Module, setWorkspaceDir below will contain all these
    // occurrences. But in general it is expected that it contains only one
    // ModuleVersion.
    try {
        moduleVersion = ModuleVersion.parse(this.commandLine.getArgs()[1]);
    } catch (ParseException pe) {
        throw new RuntimeExceptionUserError(pe.getMessage());
    }

    workspaceDirUserModuleVersion = new WorkspaceDirUserModuleVersion(moduleVersion);

    setWorkspaceDir = this.workspacePlugin.getSetWorkspaceDir(workspaceDirUserModuleVersion);

    if (setWorkspaceDir.isEmpty()) {
        this.userInteractionCallbackPlugin.provideInfo(MessageFormat.format(
                WorkspaceManagerTool.resourceBundle.getString(
                        WorkspaceManagerTool.MSG_PATTERN_KEY_NO_WORKSPACE_DIRECTORY_FOR_MODULE_VERSION),
                moduleVersion));
    }

    for (WorkspaceDir workspaceDir : setWorkspaceDir) {
        Module module;
        ScmPlugin scmPlugin;
        Path pathWorkspaceDir;

        module = this.model
                .getModule(((WorkspaceDirUserModuleVersion) workspaceDir).getModuleVersion().getNodePath());
        scmPlugin = module.getNodePlugin(ScmPlugin.class, null);
        pathWorkspaceDir = this.workspacePlugin.getWorkspaceDir(workspaceDir,
                WorkspacePlugin.GetWorkspaceDirMode.ENUM_SET_GET_EXISTING,
                WorkspacePlugin.WorkspaceDirAccessMode.PEEK);

        if (!this.commandLine.hasOption("ind-skip-check-unsync-local-changes")
                && !scmPlugin.isSync(pathWorkspaceDir, ScmPlugin.IsSyncFlag.LOCAL_CHANGES_ONLY)) {
            this.userInteractionCallbackPlugin.provideInfo(MessageFormat.format(
                    WorkspaceManagerTool.resourceBundle.getString(
                            WorkspaceManagerTool.MSG_PATTERN_KEY_DELETE_WORKSPACE_DIRECTORY_UNSYNC_LOCAL_CHANGES),
                    pathWorkspaceDir, scmPlugin.getScmUrl(pathWorkspaceDir),
                    ((WorkspaceDirUserModuleVersion) workspaceDir).getModuleVersion()));

            if (!Util.handleDoYouWantToContinueWithIndividualNo(
                    WorkspaceManagerTool.DO_YOU_WANT_TO_CONTINUE_CONTEXT_DELETE_WORKSPACE_DIRECTORY_WITH_UNSYNC_LOCAL_CHANGES)) {
                if (Util.isAbort()) {
                    return;
                }

                continue;
            }
        } else {
            this.userInteractionCallbackPlugin.provideInfo(MessageFormat.format(
                    WorkspaceManagerTool.resourceBundle
                            .getString(WorkspaceManagerTool.MSG_PATTERN_KEY_DELETE_WORKSPACE_DIRECTORY),
                    pathWorkspaceDir, scmPlugin.getScmUrl(pathWorkspaceDir),
                    ((WorkspaceDirUserModuleVersion) workspaceDir).getModuleVersion()));

            if (!Util.handleDoYouWantToContinueWithIndividualNo(
                    WorkspaceManagerTool.DO_YOU_WANT_TO_CONTINUE_CONTEXT_DELETE_WORKSPACE_DIRECTORY)) {
                if (Util.isAbort()) {
                    return;
                }

                continue;
            }
        }

        // We do not need to store the Path to the workspace directory, but we still need
        // need to call WorkspacePlugin.getWorkspaceDir in order to reserve access before
        // deleting it.
        this.workspacePlugin.getWorkspaceDir(workspaceDir,
                WorkspacePlugin.GetWorkspaceDirMode.ENUM_SET_GET_EXISTING,
                WorkspacePlugin.WorkspaceDirAccessMode.READ_WRITE);

        this.workspacePlugin.deleteWorkspaceDir(workspaceDir);
    }
}

From source file:org.apache.jackrabbit.spi.commons.query.sql.JCRSQLQueryBuilder.java

/**
 * Creates a new {@link org.apache.jackrabbit.spi.commons.query.RelationQueryNode}.
 *
 * @param parent        the parent node for the created <code>RelationQueryNode</code>.
 * @param propertyName  the property name for the relation.
 * @param operationType the operation type.
 * @param literal       the literal value for the relation or
 *                      <code>null</code> if the relation does not have a
 *                      literal (e.g. IS NULL).
 * @return a <code>RelationQueryNode</code>.
 * @throws IllegalArgumentException if the literal value does not conform
 *                                  to its type. E.g. a malformed String representation of a date.
 *///from  w  w w .j a  v  a 2  s  . c o  m
private RelationQueryNode createRelationQueryNode(QueryNode parent, Name propertyName, int operationType,
        ASTLiteral literal) throws IllegalArgumentException {

    RelationQueryNode node = null;

    try {
        Path relPath = null;
        if (propertyName != null) {
            PathBuilder builder = new PathBuilder();
            builder.addLast(propertyName);
            relPath = builder.getPath();
        }
        if (literal == null) {
            node = factory.createRelationQueryNode(parent, operationType);
            node.setRelativePath(relPath);
        } else if (literal.getType() == QueryConstants.TYPE_DATE) {
            SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN);
            Date date = format.parse(literal.getValue());
            node = factory.createRelationQueryNode(parent, operationType);
            node.setRelativePath(relPath);
            node.setDateValue(date);
        } else if (literal.getType() == QueryConstants.TYPE_DOUBLE) {
            double d = Double.parseDouble(literal.getValue());
            node = factory.createRelationQueryNode(parent, operationType);
            node.setRelativePath(relPath);
            node.setDoubleValue(d);
        } else if (literal.getType() == QueryConstants.TYPE_LONG) {
            long l = Long.parseLong(literal.getValue());
            node = factory.createRelationQueryNode(parent, operationType);
            node.setRelativePath(relPath);
            node.setLongValue(l);
        } else if (literal.getType() == QueryConstants.TYPE_STRING) {
            node = factory.createRelationQueryNode(parent, operationType);
            node.setRelativePath(relPath);
            node.setStringValue(literal.getValue());
        } else if (literal.getType() == QueryConstants.TYPE_TIMESTAMP) {
            Calendar c = ISO8601.parse(literal.getValue());
            node = factory.createRelationQueryNode(parent, operationType);
            node.setRelativePath(relPath);
            node.setDateValue(c.getTime());
        }
    } catch (java.text.ParseException e) {
        throw new IllegalArgumentException(e.toString());
    } catch (NumberFormatException e) {
        throw new IllegalArgumentException(e.toString());
    } catch (MalformedPathException e) {
        // path is always valid, but throw anyway
        throw new IllegalArgumentException(e.getMessage());
    }

    if (node == null) {
        throw new IllegalArgumentException("Unknown type for literal: " + literal.getType());
    }
    return node;
}

From source file:fr.dutra.confluence2wordpress.action.SyncAction.java

@Override
public void validate() {

    // Conversion Options

    // ignored confluence macros
    List<String> ignoredConfluenceMacros = CollectionUtils.split(ignoredConfluenceMacrosAsString, ",");
    getMetadata().setIgnoredConfluenceMacros(ignoredConfluenceMacros);

    //replace tags
    for (int i = 0; i < tagReplacementsFrom.size(); i++) {
        String tagName = tagReplacementsFrom.get(i);
        if (StringUtils.isBlank(tagName)) {
            addActionError(getText(ERRORS_REPLACE_TAG_FROM_EMPTY_KEY, new Object[] { i + 1 }));
        } else if (!TAG_NAME_PATTERN.matcher(tagName).matches()) {
            addActionError(getText(ERRORS_REPLACE_TAG_FROM_INVALID_KEY, new Object[] { tagName, i + 1 }));
        }// w ww  .  j  a va2s .c  om
    }
    for (int i = 0; i < tagReplacementsTo.size(); i++) {
        String tagName = tagReplacementsTo.get(i);
        if (StringUtils.isBlank(tagName)) {
            addActionError(getText(ERRORS_REPLACE_TAG_TO_EMPTY_KEY, new Object[] { i + 1 }));
        } else if (!TAG_NAME_PATTERN.matcher(tagName).matches()) {
            addActionError(getText(ERRORS_REPLACE_TAG_TO_INVALID_KEY, new Object[] { tagName, i + 1 }));
        }
    }
    Map<String, String> replacementsMap = new LinkedHashMap<String, String>();
    for (int i = 0; i < tagReplacementsFrom.size(); i++) {
        replacementsMap.put(tagReplacementsFrom.get(i), tagReplacementsTo.get(i));
    }
    getMetadata().setReplaceTags(replacementsMap);

    // automatic tag attributes
    for (int i = 0; i < tagNames.size(); i++) {
        String tagName = tagNames.get(i);
        if (StringUtils.isBlank(tagName)) {
            addActionError(getText(ERRORS_TAG_NAME_EMPTY_KEY, new Object[] { i + 1 }));
        } else if (!TAG_NAME_PATTERN.matcher(tagName).matches()) {
            addActionError(getText(ERRORS_TAG_NAME_INVALID_KEY, new Object[] { tagName, i + 1 }));
        }
    }
    for (int i = 0; i < tagAttributes.size(); i++) {
        String tagAttribute = tagAttributes.get(i);
        if (StringUtils.isBlank(tagAttribute)) {
            addActionError(getText(ERRORS_TAG_ATTRIBUTE_EMPTY_KEY, new Object[] { i + 1 }));
        }
    }
    Map<String, String> tagAttributesMap = new LinkedHashMap<String, String>();
    for (int i = 0; i < tagNames.size(); i++) {
        tagAttributesMap.put(tagNames.get(i), tagAttributes.get(i));
    }
    getMetadata().setTagAttributes(tagAttributesMap);

    //remove empty tags
    List<String> removeEmptyTags = CollectionUtils.split(removeEmptyTagsAsString, ",");
    for (int i = 0; i < removeEmptyTags.size(); i++) {
        String tagName = removeEmptyTags.get(i);
        if (!TAG_NAME_PATTERN.matcher(tagName).matches()) {
            addActionError(getText(ERRORS_REMOVE_TAG_INVALID_KEY, new Object[] { tagName }));
        }
    }
    getMetadata().setRemoveEmptyTags(removeEmptyTags);

    //strip tags
    List<String> stripTags = CollectionUtils.split(stripTagsAsString, ",");
    for (int i = 0; i < stripTags.size(); i++) {
        String tagName = stripTags.get(i);
        if (!TAG_NAME_PATTERN.matcher(tagName).matches()) {
            addActionError(getText(ERRORS_STRIP_TAG_INVALID_KEY, new Object[] { tagName }));
        }
    }
    getMetadata().setStripTags(stripTags);

    // Synchronisation Options

    // title
    if (StringUtils.isBlank(getMetadata().getPageTitle())) {
        addActionError(getText(ERRORS_PAGE_TITLE_EMPTY_KEY));
    }

    // author
    if (getMetadata().getAuthorId() == null) {
        addActionError(getText(ERRORS_AUTHOR_ID_EMPTY_KEY));
    }

    // categories
    if (getMetadata().getCategoryNames() == null || getMetadata().getCategoryNames().isEmpty()) {
        addActionError(getText(ERRORS_CATEGORIES_EMPTY_KEY));
    }

    // tags
    List<String> tagNames = CollectionUtils.split(tagNamesAsString, ",");
    getMetadata().setTagNames(tagNames);

    // date created
    if (StringUtils.isNotBlank(dateCreated)) {
        try {
            String pattern = getText(JS_DATEPICKER_FORMAT_KEY);
            Date dateCreated = new SimpleDateFormat(pattern).parse(this.dateCreated);
            getMetadata().setDateCreated(dateCreated);
        } catch (ParseException e) {
            addActionError(getText(ERRORS_DATE_CREATED_KEY));
        }
    }

    // post slug
    try {
        if (StringUtils.isNotBlank(getMetadata().getPostSlug())) {
            checkPostSlugSyntax();
            checkPostSlugAvailability();
        }
        if (getMetadata().getDigest() != null && !isAllowPostOverride()) {
            checkConcurrentPostModification();
        }
    } catch (WordpressXmlRpcException e) {
        addActionError(getText(ERRORS_XMLRPC), e.getMessage());
    }

}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.common.source.TestCswCqlFilter.java

private Date getDate() {
    String dateString = "Jun 11 2002";
    SimpleDateFormat formatter = new SimpleDateFormat("MMM d yyyy");
    Date aDate = null;//from  w w  w  . j  a va2 s. c  om
    try {
        aDate = formatter.parse(dateString);
    } catch (ParseException e) {
        LOGGER.error(e.getMessage(), e);
    }
    return aDate;
}

From source file:com.vip.saturn.job.console.service.impl.JobDimensionServiceImpl.java

@Override
public Long getNextFireTimeAfterSpecifiedTimeExcludePausePeriod(long nextFireTimeAfterThis, String jobName,
        CuratorRepository.CuratorFrameworkOp curatorFrameworkOp) {
    String cronPath = JobNodePath.getConfigNodePath(jobName, "cron");
    String cronVal = curatorFrameworkOp.getData(cronPath);
    CronExpression cronExpression = null;
    try {/*from ww  w  .  j a va  2s  .c o m*/
        cronExpression = new CronExpression(cronVal);
    } catch (ParseException e) {
        log.error(e.getMessage(), e);
        return null;
    }

    Date nextFireTime = cronExpression.getTimeAfter(new Date(nextFireTimeAfterThis));
    String pausePeriodDatePath = JobNodePath.getConfigNodePath(jobName, "pausePeriodDate");
    String pausePeriodDate = curatorFrameworkOp.getData(pausePeriodDatePath);
    String pausePeriodTimePath = JobNodePath.getConfigNodePath(jobName, "pausePeriodTime");
    String pausePeriodTime = curatorFrameworkOp.getData(pausePeriodTimePath);

    while (nextFireTime != null && isInPausePeriod(nextFireTime, pausePeriodDate, pausePeriodTime)) {
        nextFireTime = cronExpression.getTimeAfter(nextFireTime);
    }
    if (null == nextFireTime) {
        return null;
    }
    return nextFireTime.getTime();
}

From source file:au.org.ala.biocache.web.OccurrenceController.java

/**
 * Returns the records uuids that have been deleted since the fromDate inclusive.
 *
 * @param fromDate//from  w  w  w.  j  av a  2s.c  o m
 * @param response
 * @return
 * @throws Exception
 */
@RequestMapping(value = { "/occurrence/deleted" }, method = RequestMethod.GET)
public @ResponseBody String[] getDeleteOccurrences(
        @RequestParam(value = "date", required = true) String fromDate, HttpServletResponse response)
        throws Exception {

    String[] deletedRecords = new String[0];
    try {
        //date must be in a yyyy-MM-dd format
        Date date = org.apache.commons.lang.time.DateUtils.parseDate(fromDate, new String[] { "yyyy-MM-dd" });
        deletedRecords = Store.getDeletedRecords(date);
        if (deletedRecords == null) {
            deletedRecords = new String[0];
        }
    } catch (java.text.ParseException e) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                "Invalid date format.  Please provide date as yyyy-MM-dd.");
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        response.sendError(500, "Problem retrieving details of deleted records.");
    }
    return deletedRecords;
}

From source file:org.kuali.ole.select.document.OleOrderQueueDocument.java

/**
 * This method converts specified timestamp to String
 *
 * @param dateTime//from   www  .ja  va2  s.  c  o  m
 * @return
 */
public String convertTimestampToString(Timestamp timestamp) {
    LOG.debug("Inside convertTimestampToString of OleRequisitionItemLookupableHelperServiceImpl");
    String dateString = null;
    if (ObjectUtils.isNotNull(timestamp)) {
        try {
            DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
            java.sql.Date date = dateTimeService.convertToSqlDate(timestamp);
            dateString = dateTimeService.toDateString(date);
        } catch (ParseException exception) {
            GlobalVariables.getMessageMap().putError(OLEConstants.OrderQueue.REQUISITIONS,
                    RiceKeyConstants.ERROR_CUSTOM, exception.getMessage());
        }
    }
    LOG.debug("Leaving convertTimestampToString of OleRequisitionItemLookupableHelperServiceImpl");
    return dateString;
}