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:com.moz.fiji.mapreduce.lib.bulkimport.CSVBulkImporter.java

/** {@inheritDoc} */
@Override/*from  w  ww .  j a v a 2  s  .  com*/
public void setupImporter(FijiTableContext context) throws IOException {
    // Validate that the passed in delimiter is one of the supported options.
    List<String> validDelimiters = Lists.newArrayList(CSV_DELIMITER, TSV_DELIMITER);
    if (!validDelimiters.contains(mColumnDelimiter)) {
        throw new IOException(String.format("Invalid delimiter '%s' specified.  Valid options are: '%s'",
                mColumnDelimiter, StringUtils.join(validDelimiters, "','")));
    }

    // If the header row is specified in the configuration, use that.
    if (getConf().get(CONF_INPUT_HEADER_ROW) != null) {
        List<String> fields = null;
        String confInputHeaderRow = getConf().get(CONF_INPUT_HEADER_ROW);
        try {
            fields = split(confInputHeaderRow);
        } catch (ParseException pe) {
            LOG.error("Unable to parse header row: {} with exception {}", confInputHeaderRow, pe.getMessage());
            throw new IOException("Unable to parse header row: " + confInputHeaderRow);
        }
        initializeHeader(fields);
    }
}

From source file:com.zimbra.common.calendar.ZoneInfo2iCalendar.java

/**
 * @param zoneLines - Only the zoneLines related to a time zone that might be relevant from the reference date.
 *///w  ww.  java 2  s  .  c o  m
private static String getTimeZoneForZoneLines(String tzid, Set<String> aliases, List<ZoneLine> zoneLines,
        Params params, Set<String> zoneIDs, Map<String, VTimeZone> oldTimeZones) {
    if ((zoneLines == null) || (zoneLines.isEmpty())) {
        return "";
    }
    boolean isPrimary = sPrimaryTZIDs.contains(tzid);
    Integer matchScore = sMatchScores.get(tzid);
    if (matchScore == null) {
        if (isPrimary) {
            matchScore = Integer.valueOf(TZIDMapper.DEFAULT_MATCH_SCORE_PRIMARY);
        } else {
            matchScore = Integer.valueOf(TZIDMapper.DEFAULT_MATCH_SCORE_NON_PRIMARY);
        }
    }
    Iterator<String> aliasesIter = aliases.iterator();
    while (aliasesIter.hasNext()) {
        String curr = aliasesIter.next();
        if (zoneIDs.contains(curr)) {
            aliasesIter.remove();
        }
    }
    ZoneLine zline = zoneLines.get(0);
    VTimeZone oldVtz = oldTimeZones.get(zline.getName());
    Property oldLastModProp = null;
    if (null != oldVtz) {
        oldLastModProp = oldVtz.getProperties().getProperty(Property.LAST_MODIFIED);
    }
    LastModified newLastModified = getLastModified(params.lastModified);
    LastModified trialLastModified;
    if (null != oldLastModProp && oldLastModProp instanceof LastModified) {
        trialLastModified = (LastModified) oldLastModProp;
    } else {
        trialLastModified = newLastModified;
    }
    VTimeZone vtz = toVTimeZoneComp(params.referenceDate, zoneLines, trialLastModified, aliases, isPrimary,
            matchScore);
    String asText = vtz.toString();
    if ((null != oldVtz) && (trialLastModified != newLastModified)) {
        String oldText = oldVtz.toString();
        if (!asText.equals(oldText)) {
            /* Work around non-round tripped entries where the original source has:
             *     X-ZIMBRA-TZ-ALIAS:(GMT+12.00) Anadyr\, Petropavlovsk-Kamchatsky (RTZ 11)
             * but in this we have:
             *     X-ZIMBRA-TZ-ALIAS:(GMT+12.00) Anadyr\\\, Petropavlovsk-Kamchatsky (RTZ 11)
             * suspect that is a bug in libical which may be fixed in a later revision
             */
            String oldText2 = oldText.replace("\\\\\\,", "\\,");
            if (!asText.equals(oldText2)) {
                LastModified lastModProp = (LastModified) vtz.getProperties()
                        .getProperty(Property.LAST_MODIFIED);
                try {
                    lastModProp.setValue(newLastModified.getValue());
                    asText = vtz.toString();
                } catch (ParseException e) {
                    System.err.println("Problem assigning LAST-MODIFIED - " + e.getMessage());
                }
            }
        }
    }
    return asText;
}

From source file:com.persistent.cloudninja.scheduler.Scheduler.java

/**
 * Register a task in TaskSchedule table.
 * //from ww  w  . ja v  a2 s  .co  m
 * @param taskId : ID of task.
 * @param frequencyInMin : frequency in minutes.
 */
private void registerTask(String taskId, long frequencyInMin) {
    try {
        TaskScheduleEntity taskScheduleEntity = new TaskScheduleEntity();
        taskScheduleEntity.setTaskId(taskId);
        taskScheduleEntity.setFrequency(frequencyInMin);

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.SECOND, (int) frequencyInMin * 60);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z");
        dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        String nextScheduledStartTime = dateFormat.format(calendar.getTime());

        taskScheduleEntity.setNextScheduledStartTime(dateFormat.parse(nextScheduledStartTime));
        taskScheduleDao.updateTaskSchedule(taskScheduleEntity);
        taskList.add(taskId);

        storageUtility.initializeQueue(TASK_SCHEDULER_PREFIX + taskId.toLowerCase());
    } catch (ParseException e) {
        LOGGER.error(e.getMessage(), e);
    } catch (URISyntaxException e) {
        LOGGER.error(e.getMessage(), e);
    } catch (StorageException e) {
        LOGGER.error(e.getMessage(), e);
    }
}

From source file:org.apache.archiva.metadata.repository.stats.DefaultRepositoryStatisticsManager.java

@Override
public List<RepositoryStatistics> getStatisticsInRange(MetadataRepository metadataRepository,
        String repositoryId, Date startTime, Date endTime) throws MetadataRepositoryException {
    List<RepositoryStatistics> results = new ArrayList<>();
    List<String> list = metadataRepository.getMetadataFacets(repositoryId, RepositoryStatistics.FACET_ID);
    Collections.sort(list, Collections.reverseOrder());
    for (String name : list) {
        try {/*w w w .j  a v  a2 s . com*/
            Date date = createNameFormat().parse(name);
            if ((startTime == null || !date.before(startTime)) && (endTime == null || !date.after(endTime))) {
                RepositoryStatistics stats = (RepositoryStatistics) metadataRepository
                        .getMetadataFacet(repositoryId, RepositoryStatistics.FACET_ID, name);
                results.add(stats);
            }
        } catch (ParseException e) {
            log.error("Invalid scan result found in the metadata repository: " + e.getMessage());
            // continue and ignore this one
        }
    }
    return results;
}

From source file:org.apache.hcatalog.hcatmix.HCatMixSetup.java

@Override
public int run(String[] args) throws Exception {
    CmdLineParser opts = new CmdLineParser(args);
    opts.registerOpt('f', "file", CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('m', "mappers", CmdLineParser.ValueExpected.OPTIONAL);
    opts.registerOpt('o', "output-dir", CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('p', "pig-script-output-dir", CmdLineParser.ValueExpected.REQUIRED);
    opts.registerOpt('a', "pig-data-output-dir", CmdLineParser.ValueExpected.REQUIRED);

    opts.registerOpt('t', "create-table", CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('d', "generate-data", CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('s', "generate-pig-scripts", CmdLineParser.ValueExpected.NOT_ACCEPTED);
    opts.registerOpt('e', "do-everything", CmdLineParser.ValueExpected.NOT_ACCEPTED);

    HCatMixSetupConf.Builder builder = new HCatMixSetupConf.Builder();

    char opt;//  ww w. j  a  v a  2  s .c  om
    try {
        while ((opt = opts.getNextOpt()) != CmdLineParser.EndOfOpts) {
            switch (opt) {
            case 'f':
                builder.confFileName(opts.getValStr());
                break;

            case 'o':
                builder.outputDir(opts.getValStr());
                break;

            case 'm':
                builder.numMappers(Integer.valueOf(opts.getValStr()));
                break;

            case 'p':
                builder.pigScriptDir(opts.getValStr());
                break;

            case 'e':
                builder.doEverything();
                break;

            case 't':
                builder.createTable();
                break;

            case 's':
                builder.generatePigScripts();
                break;

            case 'd':
                builder.generateData();
                break;

            case 'a':
                builder.pigDataOutputDir(opts.getValStr());
                break;

            default:
                usage();
                break;
            }
        }
    } catch (ParseException pe) {
        System.err.println("Couldn't parse the command line arguments, " + pe.getMessage());
        usage();
    }

    try {
        setupFromConf(builder.build());
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 0;
}

From source file:org.apache.flume.sink.customhdfs.add.ImpalaTableFill.java

private TimeStage getTimeStage(String nowTimeStr) {
    TimeStage timestage = new TimeStage();
    try {/*from  w  ww. ja va  2s  .co  m*/
        Date date = new SimpleDateFormat(this.partitionFormat).parse(nowTimeStr);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        timestage.end = calendar.getTimeInMillis();
        Calendar calendarStart = (Calendar) calendar.clone();
        setLastTime(calendarStart);
        timestage.start = calendarStart.getTimeInMillis();
    } catch (ParseException e) {
        LOG.error("impalaTableFillError:" + e.getMessage());
    }
    LOG.info("time range:" + timestage.toString());
    return timestage;
}

From source file:org.hyperic.hq.plugin.zimbra.five.ZimbraCollector.java

public void collect() {
    if (log.isDebugEnabled()) {
        log.debug("collect() (" + getProperties() + ")");
    }//w w w .  j a  v  a2 s  . com
    if (log.isTraceEnabled()) {
        log.trace("[collect] (" + getProperties().getProperty("statsfile") + ") myLastLine=" + lastLine);
    }
    try {
        if (lastLine == null) {
            return;
        }
        String[] metrics = lastLine.split(",");
        // start at column 1 to ignore the timestamp
        for (int i = 1; i < metrics.length; i++) {
            // remove some spaces
            metrics[i] = metrics[i].trim();
            String alias = null;
            if (null == metrics[i] || metrics[i].matches("^\\s*$")
                    || null == (alias = (String) myAliasMap.get(new Integer(i)))) {
                continue;
            }
            try {
                Number v = nf.parse(metrics[i]);
                if (percentage) {
                    v = new Double(v.doubleValue() / 100d);
                }
                if (acumulate != null) {
                    Number va = (Number) acumulate.get(alias);
                    if (va != null) {
                        Integer vf = new Integer(v.intValue() + va.intValue());
                        acumulate.put(alias, vf);
                        //if (log.isTraceEnabled())
                        //   log.trace("read(v)='" + v + "' - prev(va)='"+va+"' - final(vf)='"+vf+"'");
                        v = vf;
                    }
                }
                setValue(alias, v.toString());
                /*if (log.isTraceEnabled()) {
                log.trace(alias + "= '" + metrics[i] + "' --> '" + v.toString() + "'");
                }*/
            } catch (ParseException e) {
                if (log.isTraceEnabled()) {
                    log.trace(alias + "=" + metrics[i] + "-->" + e.getMessage());
                }
                setValue(alias, metrics[i]);
            }
        }
    } finally {
        lastLine = null;
    }
}

From source file:com.moz.fiji.mapreduce.lib.bulkimport.CSVBulkImporter.java

/** {@inheritDoc} */
@Override//from   www . j  a v  a2  s.  c o m
public void produce(Text value, FijiTableContext context) throws IOException {
    // This is the header line since fieldList isn't populated
    if (mFieldMap == null) {
        List<String> fields = null;
        try {
            fields = split(value.toString());
        } catch (ParseException pe) {
            LOG.error("Unable to parse header row: {} with exception {}", value.toString(), pe.getMessage());
            throw new IOException("Unable to parse header row: " + value.toString());
        }
        initializeHeader(fields);
        // Don't actually import this line
        return;
    }

    List<String> fields = null;
    try {
        fields = split(value.toString());
    } catch (ParseException pe) {
        reject(value, context, pe.toString());
        return;
    }

    List<String> emptyFields = Lists.newArrayList();
    for (FijiColumnName fijiColumnName : getDestinationColumns()) {
        final EntityId eid = getEntityId(fields, context);
        String source = getSource(fijiColumnName);

        if (mFieldMap.get(source) < fields.size()) {
            String fieldValue = fields.get(mFieldMap.get(source));
            if (!fieldValue.isEmpty()) {
                String family = fijiColumnName.getFamily();
                String qualifier = fijiColumnName.getQualifier();
                if (isOverrideTimestamp()) {
                    // Override the timestamp from the imported source
                    Long timestamp = getTimestamp(fields);
                    context.put(eid, family, qualifier, timestamp, convert(fijiColumnName, fieldValue));
                } else {
                    // Use the system time as the timestamp
                    context.put(eid, family, qualifier, convert(fijiColumnName, fieldValue));
                }
            } else {
                emptyFields.add(source);
            }
        }
    }
    if (!emptyFields.isEmpty()) {
        incomplete(value, context, "Record is missing fields: " + StringUtils.join(emptyFields, ","));
    }

}

From source file:org.geoserver.security.iride.identity.IrideIdentityValidator.java

/**
 * Validates <code>Timestamp</code> token.
 *
 * @param value//  w w  w .j  a  v a  2s .  c  om
 * @return
 */
private boolean isValidTimestamp(String value) {
    if (value == null) {
        return false;
    }

    try {
        this.dateFormat.parse(value);

        return true;
    } catch (ParseException e) {
        LOGGER.severe("Invalid date format: " + e.getMessage());

        return false;
    }
}

From source file:fr.paris.lutece.portal.service.search.LuceneSearchEngine.java

/**
 * Convert a list of Lucene items into a list of generic search items
 * @param listSource The list of Lucene items
 * @return A list of generic search items
 *//*from   w  w w  .  jav a 2s  .c o  m*/
private List<SearchResult> convertList(List<SearchItem> listSource) {
    List<SearchResult> listDest = new ArrayList<SearchResult>();

    for (SearchItem item : listSource) {
        SearchResult result = new SearchResult();
        result.setId(item.getId());

        try {
            result.setDate(DateTools.stringToDate(item.getDate()));
        } catch (ParseException e) {
            AppLogService
                    .error("Bad Date Format for indexed item \"" + item.getTitle() + "\" : " + e.getMessage());
        }

        result.setUrl(item.getUrl());
        result.setTitle(item.getTitle());
        result.setSummary(item.getSummary());
        result.setType(item.getType());
        listDest.add(result);
    }

    return listDest;
}