Example usage for java.text DateFormat getDateInstance

List of usage examples for java.text DateFormat getDateInstance

Introduction

In this page you can find the example usage for java.text DateFormat getDateInstance.

Prototype

public static final DateFormat getDateInstance(int style, Locale aLocale) 

Source Link

Document

Gets the date formatter with the given formatting style for the given locale.

Usage

From source file:kolacer.Kolacer.java

private String[] ziskejDatumyPodleDne(String den) {
    String[] nedele = new String[2];

    Date date = new Date();
    int style = DateFormat.LONG;
    DateFormat df = DateFormat.getDateInstance(style, Locale.forLanguageTag("sk"));
    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
    int pocitadlo = 0;
    while (!den.equals(df.format(date).split(",")[0])) {
        date.setTime(date.getTime() - 1000 * 60 * 60 * 24);
        pocitadlo++;/*from  www.  j  a  va 2s .c o m*/
        if (pocitadlo == 7)
            break;
    }
    nedele[1] = sdf.format(date);
    date.setTime(date.getTime() - 14000 * 60 * 60 * 24);
    nedele[0] = sdf.format(date);
    return nedele;
}

From source file:org.hoteia.qalingo.core.service.EmailService.java

/**
 * @throws Exception //from   w w w. j a va2s  .co m
 */
public Email buildAndSaveNewOrderB2BConfirmationMail(final RequestData requestData, final User user,
        final String velocityPath, final OrderConfirmationEmailBean orderConfirmationEmailBean)
        throws Exception {
    Email email = null;
    try {
        final String contextNameValue = requestData.getContextNameValue();
        final Localization localization = requestData.getMarketAreaLocalization();
        final Locale locale = localization.getLocale();

        // SANITY CHECK
        checkEmailAddresses(orderConfirmationEmailBean);

        Map<String, Object> model = new HashMap<String, Object>();

        DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale);
        java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime());
        model.put(CURRENT_DATE, dateFormatter.format(currentDate));
        model.put(USER, user);
        model.put("orderConfirmationEmailBean", orderConfirmationEmailBean);
        model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale));

        String fromAddress = handleFromAddress(orderConfirmationEmailBean.getFromAddress(), contextNameValue);
        String fromName = handleFromName(orderConfirmationEmailBean.getFromName(), locale);
        String toEmail = user.getEmail();

        MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData,
                Email.EMAIl_TYPE_ORDER_CONFIRMATION, model);
        mimeMessagePreparator.setTo(toEmail);
        mimeMessagePreparator.setFrom(fromAddress);
        mimeMessagePreparator.setFromName(fromName);
        mimeMessagePreparator.setReplyTo(fromAddress);
        Object[] parameters = { user.getLastname(), user.getFirstname() };
        mimeMessagePreparator.setSubject(coreMessageSource
                .getMessage("email.store_new_order.confirmation_email_subject", parameters, locale));
        mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(getVelocityEngine(),
                velocityPath + "order-confirmation-html-content.vm", model));
        mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString(
                getVelocityEngine(), velocityPath + "order-confirmation-text-content.vm", model));

        email = new Email();
        email.setType(Email.EMAIl_TYPE_ORDER_CONFIRMATION);
        email.setStatus(Email.EMAIl_STATUS_PENDING);
        saveOrUpdateEmail(email, mimeMessagePreparator);

    } catch (MailException e) {
        logger.error("Error, can't save the message :", e);
        throw e;
    } catch (VelocityException e) {
        logger.error("Error, can't build the message :", e);
        throw e;
    } catch (IOException e) {
        logger.error("Error, can't serializable the message :", e);
        throw e;
    }
    return email;
}

From source file:org.hoteia.qalingo.core.service.EmailService.java

/**
 * @throws Exception //from  w ww .j  a v  a  2  s .  com
 */
public Email buildAndSaveOrderShippedConfirmationMail(final RequestData requestData, final Customer customer,
        final String velocityPath, final OrderSentConfirmationEmailBean orderSentConfirmationEmailBean)
        throws Exception {
    Email email = null;
    try {
        final String contextNameValue = requestData.getContextNameValue();
        final Localization localization = requestData.getMarketAreaLocalization();
        final Locale locale = localization.getLocale();

        // SANITY CHECK
        checkEmailAddresses(orderSentConfirmationEmailBean);

        Map<String, Object> model = new HashMap<String, Object>();

        DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale);
        java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime());
        model.put(CURRENT_DATE, dateFormatter.format(currentDate));
        model.put(CUSTOMER, customer);
        model.put("orderSentConfirmationEmailBean", orderSentConfirmationEmailBean);
        model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale));

        String fromAddress = handleFromAddress(orderSentConfirmationEmailBean.getFromAddress(),
                contextNameValue);
        String fromName = handleFromName(orderSentConfirmationEmailBean.getFromName(), locale);
        String toEmail = customer.getEmail();

        MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData,
                Email.EMAIl_TYPE_ORDER_SHIPPED, model);
        mimeMessagePreparator.setTo(toEmail);
        mimeMessagePreparator.setFrom(fromAddress);
        mimeMessagePreparator.setFromName(fromName);
        mimeMessagePreparator.setReplyTo(fromAddress);
        Object[] parameters = { customer.getLastname(), customer.getFirstname() };
        mimeMessagePreparator.setSubject(
                coreMessageSource.getMessage("email.order_shipped.shipped_email_subject", parameters, locale));
        mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(getVelocityEngine(),
                velocityPath + "order-shipped-html-content.vm", model));
        mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString(
                getVelocityEngine(), velocityPath + "order-shipped-text-content.vm", model));

        email = new Email();
        email.setType(Email.EMAIl_TYPE_ORDER_SHIPPED);
        email.setStatus(Email.EMAIl_STATUS_PENDING);
        saveOrUpdateEmail(email, mimeMessagePreparator);

    } catch (MailException e) {
        logger.error("Error, can't save the message :", e);
        throw e;
    } catch (VelocityException e) {
        logger.error("Error, can't build the message :", e);
        throw e;
    } catch (IOException e) {
        logger.error("Error, can't serializable the message :", e);
        throw e;
    }
    return email;
}

From source file:org.gvnix.web.screen.roo.addon.SeleniumServicesImpl.java

/**
 * Get test value for a field.//from   w w  w  . j a v  a2 s . c  o  m
 * 
 * @param field Field to auto generate a value
 * @param random Should be the initialized value generated randomly ?
 * @return Field test value
 */
private String convertToInitializer(FieldMetadata field, boolean random) {

    String initializer = " ";

    short index = 1;
    if (random) {
        index = (short) RANDOM_GENERATOR.nextInt();
    }

    AnnotationMetadata min = MemberFindingUtils.getAnnotationOfType(field.getAnnotations(),
            new JavaType("javax.validation.constraints.Min"));
    if (min != null) {
        AnnotationAttributeValue<?> value = min.getAttribute(new JavaSymbolName("value"));
        if (value != null) {
            index = Short.valueOf(value.getValue().toString());
        }
    }
    if (field.getFieldName().getSymbolName().contains("email")
            || field.getFieldName().getSymbolName().contains("Email")) {
        initializer = "some@email.com";
    } else if (field.getFieldType().equals(JavaType.STRING)) {
        initializer = "some" + field.getFieldName().getSymbolNameCapitalisedFirstLetter() + index;
    } else if (field.getFieldType().equals(new JavaType(Date.class.getName()))
            || field.getFieldType().equals(new JavaType(Calendar.class.getName()))) {
        Calendar cal = Calendar.getInstance();
        AnnotationMetadata dateTimeFormat = null;
        String style = null;
        if (null != (dateTimeFormat = MemberFindingUtils.getAnnotationOfType(field.getAnnotations(),
                new JavaType("org.springframework.format.annotation.DateTimeFormat")))) {
            AnnotationAttributeValue<?> value = dateTimeFormat.getAttribute(new JavaSymbolName("style"));
            if (value != null) {
                style = value.getValue().toString();
            }
        }
        if (null != MemberFindingUtils.getAnnotationOfType(field.getAnnotations(),
                new JavaType("javax.validation.constraints.Past"))) {
            cal.add(Calendar.YEAR, -1);
            cal.add(Calendar.MONTH, -1);
            cal.add(Calendar.DAY_OF_MONTH, -1);
        } else if (null != MemberFindingUtils.getAnnotationOfType(field.getAnnotations(),
                new JavaType("javax.validation.constraints.Future"))) {
            cal.add(Calendar.YEAR, +1);
            cal.add(Calendar.MONTH, +1);
            cal.add(Calendar.DAY_OF_MONTH, +1);
        }
        if (style != null) {
            if (style.startsWith("-")) {
                initializer = ((SimpleDateFormat) DateFormat
                        .getTimeInstance(DateTime.parseDateFormat(style.charAt(1)), Locale.getDefault()))
                                .format(cal.getTime());
            } else if (style.endsWith("-")) {
                initializer = ((SimpleDateFormat) DateFormat
                        .getDateInstance(DateTime.parseDateFormat(style.charAt(0)), Locale.getDefault()))
                                .format(cal.getTime());
            } else {
                initializer = ((SimpleDateFormat) DateFormat.getDateTimeInstance(
                        DateTime.parseDateFormat(style.charAt(0)), DateTime.parseDateFormat(style.charAt(1)),
                        Locale.getDefault())).format(cal.getTime());
            }
        } else {
            initializer = ((SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()))
                    .format(cal.getTime());
        }

    } else if (field.getFieldType().equals(JavaType.BOOLEAN_OBJECT)
            || field.getFieldType().equals(JavaType.BOOLEAN_PRIMITIVE)) {
        initializer = Boolean.FALSE.toString();
    } else if (field.getFieldType().equals(JavaType.INT_OBJECT)
            || field.getFieldType().equals(JavaType.INT_PRIMITIVE)) {
        initializer = Integer.valueOf(index).toString();
    } else if (field.getFieldType().equals(JavaType.DOUBLE_OBJECT)
            || field.getFieldType().equals(JavaType.DOUBLE_PRIMITIVE)) {
        initializer = Double.valueOf(index).toString();
    } else if (field.getFieldType().equals(JavaType.FLOAT_OBJECT)
            || field.getFieldType().equals(JavaType.FLOAT_PRIMITIVE)) {
        initializer = Float.valueOf(index).toString();
    } else if (field.getFieldType().equals(JavaType.LONG_OBJECT)
            || field.getFieldType().equals(JavaType.LONG_PRIMITIVE)) {
        initializer = Long.valueOf(index).toString();
    } else if (field.getFieldType().equals(JavaType.SHORT_OBJECT)
            || field.getFieldType().equals(JavaType.SHORT_PRIMITIVE)) {
        initializer = Short.valueOf(index).toString();
    } else if (field.getFieldType().equals(new JavaType("java.math.BigDecimal"))) {
        initializer = BigDecimal.valueOf(index).toString();
    }
    return initializer;
}

From source file:org.openmrs.util.OpenmrsUtil.java

/**
 * Get the current user's date format Will look similar to "mm-dd-yyyy". Depends on user's
 * locale./*  w w  w  . j  a  va  2 s . c  om*/
 * 
 * @return a simple date format
 * @should return a pattern with four y characters in it
 * @should not allow the returned SimpleDateFormat to be modified
 * @since 1.5
 */
public static SimpleDateFormat getDateFormat(Locale locale) {
    if (dateFormatCache.containsKey(locale)) {
        return (SimpleDateFormat) dateFormatCache.get(locale).clone();
    }

    // note that we are using the custom OpenmrsDateFormat class here which prevents erroneous parsing of 2-digit years
    SimpleDateFormat sdf = new OpenmrsDateFormat(
            (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale), locale);
    String pattern = sdf.toPattern();

    if (!pattern.contains("yyyy")) {
        // otherwise, change the pattern to be a four digit year
        pattern = pattern.replaceFirst("yy", "yyyy");
        sdf.applyPattern(pattern);
    }
    if (!pattern.contains("MM")) {
        // change the pattern to be a two digit month
        pattern = pattern.replaceFirst("M", "MM");
        sdf.applyPattern(pattern);
    }
    if (!pattern.contains("dd")) {
        // change the pattern to be a two digit day
        pattern = pattern.replaceFirst("d", "dd");
        sdf.applyPattern(pattern);
    }

    dateFormatCache.put(locale, sdf);

    return (SimpleDateFormat) sdf.clone();
}

From source file:org.hoteia.qalingo.core.service.EmailService.java

/**
 * @throws Exception //from   w  w w .  ja  v a2 s  . c o m
 */
public Email buildAndSaveAbandonedShoppingCartMail(final RequestData requestData, final Customer customer,
        final String velocityPath, final AbandonedShoppingCartEmailBean abandonedShoppingCartEmailBean)
        throws Exception {
    Email email = null;
    try {
        final String contextNameValue = requestData.getContextNameValue();
        final Localization localization = requestData.getMarketAreaLocalization();
        final Locale locale = localization.getLocale();

        // SANITY CHECK
        checkEmailAddresses(abandonedShoppingCartEmailBean);

        Map<String, Object> model = new HashMap<String, Object>();

        DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale);
        java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime());
        model.put(CURRENT_DATE, dateFormatter.format(currentDate));
        model.put(CUSTOMER, customer);
        model.put("abandonedShoppingCartEmailBean", abandonedShoppingCartEmailBean);
        model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale));

        String fromAddress = handleFromAddress(abandonedShoppingCartEmailBean.getFromAddress(),
                contextNameValue);
        String fromName = handleFromName(abandonedShoppingCartEmailBean.getFromName(), locale);
        String toEmail = customer.getEmail();

        MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData,
                Email.EMAIl_TYPE_ABANDONED_SHOPPING_CART, model);
        mimeMessagePreparator.setTo(toEmail);
        mimeMessagePreparator.setFrom(fromAddress);
        mimeMessagePreparator.setFromName(fromName);
        mimeMessagePreparator.setReplyTo(fromAddress);
        Object[] parameters = { customer.getLastname(), customer.getFirstname() };
        mimeMessagePreparator.setSubject(coreMessageSource
                .getMessage("email.abandoned_shopping_cart.email_subject", parameters, locale));
        mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(getVelocityEngine(),
                velocityPath + "abandoned-shopping-cart-html-content.vm", model));
        mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString(
                getVelocityEngine(), velocityPath + "abandoned-shopping-cart-text-content.vm", model));

        email = new Email();
        email.setType(Email.EMAIl_TYPE_ABANDONED_SHOPPING_CART);
        email.setStatus(Email.EMAIl_STATUS_PENDING);
        saveOrUpdateEmail(email, mimeMessagePreparator);

    } catch (MailException e) {
        logger.error("Error, can't save the message :", e);
        throw e;
    } catch (VelocityException e) {
        logger.error("Error, can't build the message :", e);
        throw e;
    } catch (IOException e) {
        logger.error("Error, can't serializable the message :", e);
        throw e;
    }
    return email;
}

From source file:gov.opm.scrd.batchprocessing.jobs.BatchProcessingJob.java

/**
 * Get log text of import status.//from w  ww.  ja  v a 2 s  . co m
 *
 * @param importStatus The import status.
 * @return The log text of import status.
 */
private String logImportStatus(ImportStatus importStatus) {
    Date now = new Date();
    StringBuilder sb = new StringBuilder(CRLF);
    sb.append("Service Credit imported a data file from the bank lockbox on ");
    sb.append(DateFormat.getDateInstance(DateFormat.LONG, Locale.US).format(now));
    sb.append(" at ");
    sb.append(DateFormat.getTimeInstance(DateFormat.LONG, Locale.US).format(now)).append(".").append(CRLF);
    sb.append("Lockbox data imported into the ").append(databaseString);
    sb.append(" database on server ").append(datasourceString);
    sb.append(" from computer ").append(workstationId).append(".");

    sb.append(CRLF).append(CRLF);

    sb.append("# Lines in file = ")
            .append(importStatus.getNumberDuplicateRecords() + importStatus.getNumberDiscreteRecords())
            .append(CRLF);

    if (importStatus.getNumberDiscreteRecords() > 0) {
        sb.append("# New Lines = ").append(importStatus.getNumberDiscreteRecords()).append(CRLF);
    }

    sb.append("# Duplicate Lines = ").append(importStatus.getNumberDuplicateRecords()).append(CRLF);
    sb.append(CRLF);

    int failedInserts = importStatus.getNumberBadChangeRecords() + importStatus.getNumberNoMatchChangeRecords()
            + importStatus.getNumberBadAchPayments() + importStatus.getNumberBadCheckPayments();

    int successfulInserts = importStatus.getNumberGoodChangeRecords() + importStatus.getNumberGoodAchPayments()
            + importStatus.getNumberGoodCheckPayments();

    sb.append("# Records Processed = ")
            .append(importStatus.getNumberBadDataRecords() + importStatus.getNumberGoodSummaryRecords()
                    + importStatus.getNumberBadSummaryRecords() + importStatus.getNumberDupeAchPayments()
                    + importStatus.getNumberDupeCheckPayments() + failedInserts + successfulInserts)
            .append(CRLF);

    sb.append("# Check Payments = ").append(importStatus.getNumberGoodCheckPayments()
            + importStatus.getNumberBadCheckPayments() + importStatus.getNumberDupeCheckPayments())
            .append(CRLF);
    sb.append("# Good Check Payments = ").append(importStatus.getNumberGoodCheckPayments()).append(CRLF);
    sb.append("# Bad Check Payments = ").append(importStatus.getNumberBadCheckPayments()).append(CRLF);
    sb.append("# Dupe Check Payments = ").append(importStatus.getNumberDupeCheckPayments()).append(CRLF);

    sb.append("# ACH Payments = ").append(importStatus.getNumberGoodAchPayments()
            + importStatus.getNumberBadAchPayments() + importStatus.getNumberDupeAchPayments()).append(CRLF);
    sb.append("# Good ACH Payments = ").append(importStatus.getNumberGoodAchPayments()).append(CRLF);
    sb.append("# Bad ACH Payments = ").append(importStatus.getNumberBadAchPayments()).append(CRLF);
    sb.append("# Dupe ACH Payments = ").append(importStatus.getNumberDupeAchPayments()).append(CRLF);

    sb.append("# Bad Change Records = ").append(importStatus.getNumberBadChangeRecords()).append(CRLF);
    sb.append("# Good Change Records = ").append(importStatus.getNumberGoodChangeRecords()).append(CRLF);
    sb.append("# No Match Change Records = ").append(importStatus.getNumberNoMatchChangeRecords()).append(CRLF);

    sb.append("# Invalid Summary Records = ").append(importStatus.getNumberBadSummaryRecords()).append(CRLF);
    sb.append("# Valid Summary Records = ").append(importStatus.getNumberGoodSummaryRecords()).append(CRLF);

    sb.append("# Successful Transactions = ").append(successfulInserts).append(CRLF);
    sb.append("# Failed Transactions = ").append(failedInserts).append(CRLF);
    sb.append("# Invalid Lines = ").append(importStatus.getNumberBadDataRecords()).append(CRLF);

    sb.append(CRLF);
    sb.append("Total Check Payments = ").append(importStatus.getTotalCheckPayments()).append(CRLF);
    sb.append("Total ACH Payments = ").append(importStatus.getTotalACHPayments()).append(CRLF);
    sb.append("Total of Accepted Payments = ")
            .append(importStatus.getTotalCheckPayments().add(importStatus.getTotalACHPayments())).append(CRLF);

    if (Double.compare(importStatus.getTransactionsTotal().doubleValue(),
            importStatus.getFileSummaryTotal().doubleValue()) == 0) {
        sb.append("Total in File = ").append(importStatus.getFileSummaryTotal()).append(CRLF);
    } else {
        sb.append("Total in File Summary (checksum) = ").append(importStatus.getFileSummaryTotal())
                .append(CRLF);
        sb.append("Total of Processed Transactions = ").append(importStatus.getTransactionsTotal())
                .append(CRLF);

        sb.append(CRLF).append(CRLF);

        sb.append("ERROR: THE BANK FILE CONTAINED ").append(importStatus.getFileSummaryTotal()).append(" BUT ")
                .append(importStatus.getTransactionsTotal())
                .append(" WAS IMPORTED INTO THE SERVICE CREDIT DATABASE. ");

        if (importStatus.getNumberGoodSummaryRecords() > 0) {
            if (Double.compare(importStatus.getTransactionsTotal().doubleValue(),
                    importStatus.getFileSummaryTotal().doubleValue()) > 0) {
                sb.append("THE PROGRAM IMPORTED ")
                        .append(importStatus.getTransactionsTotal()
                                .subtract(importStatus.getFileSummaryTotal()))
                        .append(" MORE THAN THE BANK TOTAL.").append(CRLF);
            } else if (Double.compare(importStatus.getTransactionsTotal().doubleValue(),
                    importStatus.getFileSummaryTotal().doubleValue()) < 0) {
                sb.append("THE PROGRAM IMPORTED ")
                        .append(importStatus.getFileSummaryTotal()
                                .subtract(importStatus.getTransactionsTotal()))
                        .append(" LESS THAN THE BANK TOTAL.").append(CRLF);
            }
        }
    }

    sb.append(CRLF);

    int failedCount = importStatus.getNumberBadDataRecords() + importStatus.getNumberBadSummaryRecords()
            + failedInserts;

    if (failedCount > 0) {
        sb.append("ERROR: ").append(failedCount).append(" RECORDS FAILED PROCESSING.").append(CRLF);
    } else {
        sb.append("No bad records in this batch.").append(CRLF);
    }

    if (failedInserts > 0) {
        sb.append("ERROR: ").append(failedInserts).append(" TRANSACTIONS COULD NOT BE READ INTO THE DATABASE!")
                .append(CRLF);
    }

    if (importStatus.getNumberBadSummaryRecords() > 0) {
        sb.append("ERROR: ").append(importStatus.getNumberBadSummaryRecords())
                .append(" CHECKSUMS COULD NOT BE PROCESSED!").append(CRLF);
    }

    if (importStatus.getNumberDuplicateRecords() > 0) {
        sb.append(importStatus.getNumberDuplicateRecords()).append(" DUPLICATE RECORDS FROM THE BANK")
                .append(CRLF);
    }

    sb.append(successfulInserts).append(" = number of successful calls to the ProcessImportRecord function.")
            .append(CRLF);

    if (failedInserts > 0) {
        sb.append(failedInserts).append(" NUMBER OF FAILED CALLS TO THE PROCESSIMPORTRECORD FUNCTION!")
                .append(CRLF);
    }

    sb.append(CRLF);

    // Log pending payment transactions collated
    sb.append("         Accepted Payments: ").append(
            importStatus.getNumberAcceptedCheckPayments() + importStatus.getNumberAcceptedAchPayments());
    sb.append(CRLF);
    sb.append("       Unresolved Payments: ").append(
            importStatus.getNumberUnresolvedCheckPayments() + importStatus.getNumberUnresolvedAchPayments());
    sb.append(CRLF);
    sb.append("        Suspended Payments: ").append(
            importStatus.getNumberSuspendedCheckPayments() + importStatus.getNumberSuspendedAchPayments());
    sb.append(CRLF);
    sb.append("-----------------------------------");
    sb.append(CRLF);
    sb.append("Pending payments processed: ").append(importStatus.getNumberAcceptedCheckPayments()
            + importStatus.getNumberAcceptedAchPayments() + importStatus.getNumberUnresolvedCheckPayments()
            + importStatus.getNumberUnresolvedAchPayments() + importStatus.getNumberSuspendedCheckPayments()
            + importStatus.getNumberSuspendedAchPayments());
    sb.append(CRLF);

    return sb.toString();
}

From source file:org.mifos.application.servicefacade.SavingsServiceFacadeWebTier.java

@Override
public void updateSavingsAccountDetails(Long savingsId, String recommendedOrMandatoryAmount,
        List<CustomFieldDto> customFields) {

    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);

    SavingsBO savingsAccount = this.savingsDao.findById(savingsId);
    savingsAccount.updateDetails(userContext);

    Set<AccountCustomFieldEntity> accountCustomFields = savingsAccount.getAccountCustomFields();
    for (CustomFieldDto view : customFields) {
        boolean fieldPresent = false;
        if (CustomFieldType.DATE.getValue().equals(view.getFieldType())
                && org.apache.commons.lang.StringUtils.isNotBlank(view.getFieldValue())) {
            try {
                SimpleDateFormat format = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT,
                        userContext.getPreferredLocale());
                String userfmt = DateUtils.convertToCurrentDateFormat(format.toPattern());
                view.setFieldValue(DateUtils.convertUserToDbFmt(view.getFieldValue(), userfmt));
            } catch (InvalidDateException e) {
                throw new BusinessRuleException(e.getMessage(), e);
            }/*from w ww.  ja  v a  2s.  c o  m*/
        }
        for (AccountCustomFieldEntity customFieldEntity : accountCustomFields) {
            if (customFieldEntity.getFieldId().equals(view.getFieldId())) {
                fieldPresent = true;
                customFieldEntity.setFieldValue(view.getFieldValue());
            }
        }
        if (!fieldPresent) {
            accountCustomFields
                    .add(new AccountCustomFieldEntity(savingsAccount, view.getFieldId(), view.getFieldValue()));
        }
    }

    Money amount = new Money(savingsAccount.getCurrency(), recommendedOrMandatoryAmount);

    try {
        this.transactionHelper.startTransaction();
        this.transactionHelper.beginAuditLoggingFor(savingsAccount);

        savingsAccount.update(amount, accountCustomFields);

        this.savingsDao.save(savingsAccount);
        this.transactionHelper.commitTransaction();
    } catch (BusinessRuleException e) {
        this.transactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getMessageKey(), e);
    } catch (Exception e) {
        this.transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        this.transactionHelper.closeSession();
    }
}

From source file:org.openstreetmap.josm.tools.Utils.java

/**
 * Returns the JRE expiration date.//from   w  w w  .  j  a v  a2s . c  o  m
 * @return the JRE expiration date, or null
 * @since 12219
 */
public static Date getJavaExpirationDate() {
    try {
        Object value = null;
        Class<?> c = Class.forName("com.sun.deploy.config.BuiltInProperties");
        try {
            value = c.getDeclaredField("JRE_EXPIRATION_DATE").get(null);
        } catch (NoSuchFieldException e) {
            // Field is gone with Java 9, there's a method instead
            Logging.trace(e);
            value = c.getDeclaredMethod("getProperty", String.class).invoke(null, "JRE_EXPIRATION_DATE");
        }
        if (value instanceof String) {
            return DateFormat.getDateInstance(3, Locale.US).parse((String) value);
        }
    } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException | ParseException e) {
        Logging.debug(e);
    }
    return null;
}

From source file:net.massbank.validator.RecordValidator.java

/**
 * ??// w  ww  . java 2s.c om
 * 
 * @param db
 *            DB
 * @param op
 *            PrintWriter?
 * @param dataPath
 *            ?
 * @param registPath
 *            
 * @param ver
 *            ?
 * @return ??Map<??, ?>
 * @throws IOException
 *             
 */
private static TreeMap<String, String> validationRecordOnline(DatabaseAccess db, PrintStream op,
        String dataPath, String registPath, int ver) throws IOException {

    op.println(msgInfo("validation archive is [" + UPLOAD_RECDATA_ZIP + "] or [" + UPLOAD_RECDATA_MSBK + "]."));
    if (ver == 1) {
        op.println(msgInfo("check record format version is [version 1]."));
    }

    final String[] dataList = (new File(dataPath)).list();
    TreeMap<String, String> validationMap = new TreeMap<String, String>();

    if (dataList.length == 0) {
        op.println(msgWarn("no file for validation."));
        return validationMap;
    }

    // ----------------------------------------------------
    // ???
    // ----------------------------------------------------
    String[] requiredList = new String[] { // Ver.2
            "ACCESSION: ", "RECORD_TITLE: ", "DATE: ", "AUTHORS: ", "LICENSE: ", "CH$NAME: ",
            "CH$COMPOUND_CLASS: ", "CH$FORMULA: ", "CH$EXACT_MASS: ", "CH$SMILES: ", "CH$IUPAC: ",
            "AC$INSTRUMENT: ", "AC$INSTRUMENT_TYPE: ", "AC$MASS_SPECTROMETRY: MS_TYPE ",
            "AC$MASS_SPECTROMETRY: ION_MODE ", "PK$NUM_PEAK: ", "PK$PEAK: " };
    if (ver == 1) { // Ver.1
        requiredList = new String[] { "ACCESSION: ", "RECORD_TITLE: ", "DATE: ", "AUTHORS: ", "COPYRIGHT: ",
                "CH$NAME: ", "CH$COMPOUND_CLASS: ", "CH$FORMULA: ", "CH$EXACT_MASS: ", "CH$SMILES: ",
                "CH$IUPAC: ", "AC$INSTRUMENT: ", "AC$INSTRUMENT_TYPE: ", "AC$ANALYTICAL_CONDITION: MODE ",
                "PK$NUM_PEAK: ", "PK$PEAK: " };
    }
    for (int i = 0; i < dataList.length; i++) {
        String name = dataList[i];
        String status = "";
        StringBuilder detailsErr = new StringBuilder();
        StringBuilder detailsWarn = new StringBuilder();

        // ????
        File file = new File(dataPath + name);
        if (file.isDirectory()) {
            // ??
            status = STATUS_ERR;
            detailsErr.append("[" + name + "] is directory.");
            validationMap.put(name, status + "\t" + detailsErr.toString());
            continue;
        } else if (file.isHidden()) {
            // ???
            status = STATUS_ERR;
            detailsErr.append("[" + name + "] is hidden.");
            validationMap.put(name, status + "\t" + detailsErr.toString());
            continue;
        } else if (name.lastIndexOf(REC_EXTENSION) == -1) {
            // ????
            status = STATUS_ERR;
            detailsErr.append("file extension of [" + name + "] is not [" + REC_EXTENSION + "].");
            validationMap.put(name, status + "\t" + detailsErr.toString());
            continue;
        }

        // ??
        boolean isEndTagRead = false;
        boolean isInvalidInfo = false;
        boolean isDoubleByte = false;
        ArrayList<String> fileContents = new ArrayList<String>();
        boolean existLicense = false; // LICENSE?Ver.1
        ArrayList<String> workChName = new ArrayList<String>(); // RECORD_TITLE??CH$NAME??Ver.1?
        String workAcInstrumentType = ""; // RECORD_TITLE??AC$INSTRUMENT_TYPE??Ver.1?
        String workAcMsType = ""; // RECORD_TITLE??AC$MASS_SPECTROMETRY:
        // MS_TYPE??Ver.2
        String line = "";
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader(file));
            while ((line = br.readLine()) != null) {
                if (isEndTagRead) {
                    if (!line.equals("")) {
                        isInvalidInfo = true;
                    }
                }

                // 
                if (line.startsWith("//")) {
                    isEndTagRead = true;
                }
                fileContents.add(line);

                // LICENSE?Ver.1
                if (line.startsWith("LICENSE: ")) {
                    existLicense = true;
                }
                // CH$NAME?Ver.1?
                else if (line.startsWith("CH$NAME: ")) {
                    workChName.add(line.trim().replaceAll("CH\\$NAME: ", ""));
                }
                // AC$INSTRUMENT_TYPE?Ver.1?
                else if (line.startsWith("AC$INSTRUMENT_TYPE: ")) {
                    workAcInstrumentType = line.trim().replaceAll("AC\\$INSTRUMENT_TYPE: ", "");
                }
                // AC$MASS_SPECTROMETRY: MS_TYPE?Ver.2
                else if (ver != 1 && line.startsWith("AC$MASS_SPECTROMETRY: MS_TYPE ")) {
                    workAcMsType = line.trim().replaceAll("AC\\$MASS_SPECTROMETRY: MS_TYPE ", "");
                }

                // ?
                if (!isDoubleByte) {
                    byte[] bytes = line.getBytes("MS932");
                    if (bytes.length != line.length()) {
                        isDoubleByte = true;
                    }
                }
            }
        } catch (IOException e) {
            Logger.getLogger("global").severe("file read failed." + NEW_LINE + "    " + file.getPath());
            e.printStackTrace();
            op.println(msgErr("server error."));
            validationMap.clear();
            return validationMap;
        } finally {
            try {
                if (br != null) {
                    br.close();
                }
            } catch (IOException e) {
            }
        }
        if (isInvalidInfo) {
            // ?????
            if (status.equals(""))
                status = STATUS_WARN;
            detailsWarn.append("invalid after the end tag [//].");
        }
        if (isDoubleByte) {
            // ?????
            if (status.equals(""))
                status = STATUS_ERR;
            detailsErr.append("double-byte character included.");
        }
        if (ver == 1 && existLicense) {
            // LICENSE???Ver.1
            if (status.equals(""))
                status = STATUS_ERR;
            detailsErr.append("[LICENSE: ] tag can not be used in record format  [version 1].");
        }

        // ----------------------------------------------------
        // ????
        // ----------------------------------------------------
        boolean isNameCheck = false;
        int peakNum = -1;
        for (int j = 0; j < requiredList.length; j++) {
            String requiredStr = requiredList[j];
            ArrayList<String> valStrs = new ArrayList<String>(); // 
            boolean findRequired = false; // 
            boolean findValue = false; // 
            boolean isPeakMode = false; // 
            for (int k = 0; k < fileContents.size(); k++) {
                String lineStr = fileContents.get(k);

                // ????RELATED_RECORD??????
                if (lineStr.startsWith("//")) { // Ver.1?
                    break;
                } else if (ver == 1 && lineStr.startsWith("RELATED_RECORD:")) { // Ver.1
                    break;
                }
                // ?????
                else if (isPeakMode) {
                    findRequired = true;
                    if (!lineStr.trim().equals("")) {
                        valStrs.add(lineStr);
                    }
                }
                // ??????
                else if (lineStr.indexOf(requiredStr) != -1) {
                    // 
                    findRequired = true;
                    if (requiredStr.equals("PK$PEAK: ")) {
                        isPeakMode = true;
                        findValue = true;
                        valStrs.add(lineStr.replace(requiredStr, ""));
                    } else {
                        // 
                        String tmpVal = lineStr.replace(requiredStr, "");
                        if (!tmpVal.trim().equals("")) {
                            findValue = true;
                            valStrs.add(tmpVal);
                        }
                        break;
                    }
                }
            }
            if (!findRequired) {
                // ??????
                status = STATUS_ERR;
                detailsErr.append("no required item [" + requiredStr + "].");
            } else {
                if (!findValue) {
                    // ?????
                    status = STATUS_ERR;
                    detailsErr.append("no value of required item [" + requiredStr + "].");
                } else {
                    // ???

                    // ----------------------------------------------------
                    // ??
                    // ----------------------------------------------------
                    String val = (valStrs.size() > 0) ? valStrs.get(0) : "";
                    // ACESSIONVer.1?
                    if (requiredStr.equals("ACCESSION: ")) {
                        if (!val.equals(name.replace(REC_EXTENSION, ""))) {
                            status = STATUS_ERR;
                            detailsErr.append("value of required item [" + requiredStr
                                    + "] not correspond to file name.");
                        }
                        if (val.length() != 8) {
                            status = STATUS_ERR;
                            detailsErr.append(
                                    "value of required item [" + requiredStr + "] is 8 digits necessary.");
                        }
                    }
                    // RECORD_TITLEVer.1?
                    else if (requiredStr.equals("RECORD_TITLE: ")) {
                        if (!val.equals(DEFAULT_VALUE)) {
                            if (val.indexOf(";") != -1) {
                                String[] recTitle = val.split(";");
                                if (!workChName.contains(recTitle[0].trim())) {
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], compound name is not included in the [CH$NAME].");
                                }
                                if (!workAcInstrumentType.equals(recTitle[1].trim())) {
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], instrument type is different from [AC$INSTRUMENT_TYPE].");
                                }
                                if (ver != 1 && !workAcMsType.equals(recTitle[2].trim())) { // Ver.2
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], ms type is different from [AC$MASS_SPECTROMETRY: MS_TYPE].");
                                }
                            } else {
                                if (status.equals(""))
                                    status = STATUS_WARN;
                                detailsWarn.append("value of required item [" + requiredStr
                                        + "] is not record title format.");

                                if (!workChName.contains(val)) {
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], compound name is not included in the [CH$NAME].");
                                }
                                if (!workAcInstrumentType.equals(DEFAULT_VALUE)) {
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], instrument type is different from [AC$INSTRUMENT_TYPE].");
                                }
                                if (ver != 1 && !workAcMsType.equals(DEFAULT_VALUE)) { // Ver.2
                                    detailsWarn.append("value of required item [" + requiredStr
                                            + "], ms type is different from [AC$MASS_SPECTROMETRY: MS_TYPE].");
                                }
                            }
                        } else {
                            if (!workAcInstrumentType.equals(DEFAULT_VALUE)) {
                                if (status.equals(""))
                                    status = STATUS_WARN;
                                detailsWarn.append("value of required item [" + requiredStr
                                        + "], instrument type is different from [AC$INSTRUMENT_TYPE].");
                            }
                            if (ver != 1 && !workAcMsType.equals(DEFAULT_VALUE)) { // Ver.2
                                if (status.equals(""))
                                    status = STATUS_WARN;
                                detailsWarn.append("value of required item [" + requiredStr
                                        + "], ms type is different from [AC$MASS_SPECTROMETRY: MS_TYPE].");
                            }
                        }
                    }
                    // DATEVer.1?
                    else if (requiredStr.equals("DATE: ") && !val.equals(DEFAULT_VALUE)) {
                        val = val.replace(".", "/");
                        val = val.replace("-", "/");
                        try {
                            DateFormat.getDateInstance(DateFormat.SHORT, Locale.JAPAN).parse(val);
                        } catch (ParseException e) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn
                                    .append("value of required item [" + requiredStr + "] is not date format.");
                        }
                    }
                    // CH$COMPOUND_CLASSVer.1?
                    else if (requiredStr.equals("CH$COMPOUND_CLASS: ") && !val.equals(DEFAULT_VALUE)) {
                        if (!val.startsWith("Natural Product") && !val.startsWith("Non-Natural Product")) {

                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr
                                    + "] is not compound class format.");
                        }
                    }
                    // CH$EXACT_MASSVer.1?
                    else if (requiredStr.equals("CH$EXACT_MASS: ") && !val.equals(DEFAULT_VALUE)) {
                        try {
                            Double.parseDouble(val);
                        } catch (NumberFormatException e) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr + "] is not numeric.");
                        }
                    }
                    // AC$INSTRUMENT_TYPEVer.1?
                    else if (requiredStr.equals("AC$INSTRUMENT_TYPE: ") && !val.equals(DEFAULT_VALUE)) {
                        if (val.trim().indexOf(" ") != -1) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn
                                    .append("value of required item [" + requiredStr + "] is space included.");
                        }
                        if (val.trim().indexOf(" ") != -1) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn
                                    .append("value of required item [" + requiredStr + "] is space included.");
                        }
                    }
                    // AC$MASS_SPECTROMETRY: MS_TYPEVer.2
                    else if (ver != 1 && requiredStr.equals("AC$MASS_SPECTROMETRY: MS_TYPE ")
                            && !val.equals(DEFAULT_VALUE)) {
                        boolean isMsType = true;
                        if (val.startsWith("MS")) {
                            val = val.replace("MS", "");
                            if (!val.equals("")) {
                                try {
                                    Integer.parseInt(val);
                                } catch (NumberFormatException e) {
                                    isMsType = false;
                                }
                            }
                        } else {
                            isMsType = false;
                        }
                        if (!isMsType) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr + "] is not \"MSn\".");
                        }
                    }
                    // AC$MASS_SPECTROMETRY:
                    // ION_MODEVer.2?AC$ANALYTICAL_CONDITION: MODEVer.1
                    else if ((ver != 1 && requiredStr.equals("AC$MASS_SPECTROMETRY: ION_MODE ")
                            && !val.equals(DEFAULT_VALUE))
                            || (ver == 1 && requiredStr.equals("AC$ANALYTICAL_CONDITION: MODE ")
                                    && !val.equals(DEFAULT_VALUE))) {
                        if (!val.equals("POSITIVE") && !val.equals("NEGATIVE")) {
                            if (status.equals(""))
                                status = STATUS_WARN;
                            detailsWarn.append("value of required item [" + requiredStr
                                    + "] is not \"POSITIVE\" or \"NEGATIVE\".");
                        }
                    }
                    // PK$NUM_PEAKVer.1?
                    else if (requiredStr.equals("PK$NUM_PEAK: ") && !val.equals(DEFAULT_VALUE)) {
                        try {
                            peakNum = Integer.parseInt(val);
                        } catch (NumberFormatException e) {
                            status = STATUS_ERR;
                            detailsErr.append("value of required item [" + requiredStr + "] is not numeric.");
                        }
                    }
                    // PK$PEAK:Ver.1?
                    else if (requiredStr.equals("PK$PEAK: ")) {
                        if (valStrs.size() == 0 || !valStrs.get(0).startsWith("m/z int. rel.int.")) {
                            status = STATUS_ERR;
                            detailsErr.append(
                                    "value of required item [PK$PEAK: ] , the first line is not \"PK$PEAK: m/z int. rel.int.\".");
                        } else {
                            boolean isNa = false;
                            String peak = "";
                            String mz = "";
                            String intensity = "";
                            boolean mzDuplication = false;
                            boolean mzNotNumeric = false;
                            boolean intensityNotNumeric = false;
                            boolean invalidFormat = false;
                            HashSet<String> mzSet = new HashSet<String>();
                            for (int l = 0; l < valStrs.size(); l++) {
                                peak = valStrs.get(l).trim();
                                // N/A
                                if (peak.indexOf(DEFAULT_VALUE) != -1) {
                                    isNa = true;
                                    break;
                                }
                                if (l == 0) {
                                    continue;
                                } // m/z int. rel.int.??????????

                                if (peak.indexOf(" ") != -1) {
                                    mz = peak.split(" ")[0];
                                    if (!mzSet.add(mz)) {
                                        mzDuplication = true;
                                    }
                                    try {
                                        Double.parseDouble(mz);
                                    } catch (NumberFormatException e) {
                                        mzNotNumeric = true;
                                    }
                                    intensity = peak.split(" ")[1];
                                    try {
                                        Double.parseDouble(intensity);
                                    } catch (NumberFormatException e) {
                                        intensityNotNumeric = true;
                                    }
                                } else {
                                    invalidFormat = true;
                                }
                                if (mzDuplication && mzNotNumeric && intensityNotNumeric && invalidFormat) {
                                    break;
                                }
                            }
                            if (isNa) {// PK$PEAK:?N/A??
                                if (peakNum != -1) { // PK$NUM_PEAK:N/A??
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn
                                            .append("value of required item [PK$NUM_PEAK: ] is mismatch or \""
                                                    + DEFAULT_VALUE + "\".");
                                }
                                if (valStrs.size() - 1 > 0) { // PK$PEAK:????????
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append(
                                            "value of required item [PK$NUM_PEAK: ] is invalid peak information exists.");
                                }
                            } else {
                                if (mzDuplication) {
                                    status = STATUS_ERR;
                                    detailsErr.append(
                                            "mz value of required item [" + requiredStr + "] is duplication.");
                                }
                                if (mzNotNumeric) {
                                    status = STATUS_ERR;
                                    detailsErr.append(
                                            "mz value of required item [" + requiredStr + "] is not numeric.");
                                }
                                if (intensityNotNumeric) {
                                    status = STATUS_ERR;
                                    detailsErr.append("intensity value of required item [" + requiredStr
                                            + "] is not numeric.");
                                }
                                if (invalidFormat) {
                                    status = STATUS_ERR;
                                    detailsErr.append(
                                            "value of required item [" + requiredStr + "] is not peak format.");
                                }
                                if (peakNum != 0 && valStrs.size() - 1 == 0) { // ?????N/A????PK$NUM_PEAK:?0???????
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn.append(
                                            "value of required item [PK$PEAK: ] is no value.  at that time, please add \""
                                                    + DEFAULT_VALUE + "\". ");
                                }
                                if (peakNum != valStrs.size() - 1) {
                                    if (status.equals(""))
                                        status = STATUS_WARN;
                                    detailsWarn
                                            .append("value of required item [PK$NUM_PEAK: ] is mismatch or \""
                                                    + DEFAULT_VALUE + "\".");
                                }
                            }
                        }
                    }
                }
            }
        }
        String details = detailsErr.toString() + detailsWarn.toString();
        if (status.equals("")) {
            status = STATUS_OK;
            details = " ";
        }
        validationMap.put(name, status + "\t" + details);
    }

    // ----------------------------------------------------
    // ????
    // ----------------------------------------------------
    // ?ID?DB
    HashSet<String> regIdList = new HashSet<String>();
    String[] sqls = { "SELECT ID FROM SPECTRUM ORDER BY ID", "SELECT ID FROM RECORD ORDER BY ID",
            "SELECT ID FROM PEAK GROUP BY ID ORDER BY ID", "SELECT ID FROM CH_NAME ID ORDER BY ID",
            "SELECT ID FROM CH_LINK ID ORDER BY ID",
            "SELECT ID FROM TREE WHERE ID IS NOT NULL AND ID<>'' ORDER BY ID" };
    for (int i = 0; i < sqls.length; i++) {
        String execSql = sqls[i];
        ResultSet rs = null;
        try {
            rs = db.executeQuery(execSql);
            while (rs.next()) {
                String idStr = rs.getString("ID");
                regIdList.add(idStr);
            }
        } catch (SQLException e) {
            Logger.getLogger("global").severe("    sql : " + execSql);
            e.printStackTrace();
            op.println(msgErr("database access error."));
            return new TreeMap<String, String>();
        } finally {
            try {
                if (rs != null) {
                    rs.close();
                }
            } catch (SQLException e) {
            }
        }
    }
    // ?ID?
    final String[] recFileList = (new File(registPath)).list();
    for (int i = 0; i < recFileList.length; i++) {
        String name = recFileList[i];
        File file = new File(registPath + File.separator + name);
        if (!file.isFile() || file.isHidden() || name.lastIndexOf(REC_EXTENSION) == -1) {
            continue;
        }
        String idStr = name.replace(REC_EXTENSION, "");
        regIdList.add(idStr);
    }

    // ??
    for (Map.Entry<String, String> e : validationMap.entrySet()) {
        String statusStr = e.getValue().split("\t")[0];
        if (statusStr.equals(STATUS_ERR)) {
            continue;
        }
        String nameStr = e.getKey();
        String idStr = e.getKey().replace(REC_EXTENSION, "");
        String detailsStr = e.getValue().split("\t")[1];
        if (regIdList.contains(idStr)) {
            statusStr = STATUS_WARN;
            detailsStr += "id [" + idStr + "] of file name [" + nameStr + "] already registered.";
            validationMap.put(nameStr, statusStr + "\t" + detailsStr);
        }
    }

    return validationMap;
}