Example usage for org.apache.commons.httpclient.util DateUtil formatDate

List of usage examples for org.apache.commons.httpclient.util DateUtil formatDate

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.util DateUtil formatDate.

Prototype

public static String formatDate(Date paramDate) 

Source Link

Usage

From source file:proai.cache.Updater.java

private void pollAndUpdate() throws ServerException {

    Connection conn = null;// w ww  .  j a v a2 s. c o m
    boolean startedTransaction = false;
    try {
        conn = RecordCache.getConnection();
        conn.setAutoCommit(false);
        startedTransaction = true;

        _db.queueFailedRecords(conn, _maxFailedRetries);

        if (_db.isPollingEnabled(conn)) {
            Date latestRemoteDate = _driver.getLatestDate();
            Date earliestPollDate = new Date(_db.getEarliestPollDate(conn));

            logger.debug(String.format("Latest modification reported by Fedora: %s",
                    DateUtil.formatDate(latestRemoteDate)));
            logger.debug(String.format("Earliest poll date: %s", DateUtil.formatDate(earliestPollDate)));

            if (latestRemoteDate.after(earliestPollDate)) {

                logger.debug("Starting update process; source data of interest may have changed.");
                checkImmediateShutdown();
                updateIdentify(conn);

                checkImmediateShutdown();
                List<String> allPrefixes = updateFormats(conn);

                checkImmediateShutdown();
                updateSets(conn);

                checkImmediateShutdown();
                queueUpdatedRecords(conn, allPrefixes, latestRemoteDate);
            } else {
                logger.debug("Skipping update process; source data of interest has not changed");
            }
        } else {
            logger.debug("Remote polling skipped -- polling is disabled");
        }

        conn.commit();
    } catch (Throwable th) {
        if (startedTransaction) {
            try {
                conn.rollback();
            } catch (SQLException e) {
                logger.error("Failed to roll back failed transaction", e);
            }
        }
        throw new ServerException("Update cycle phase one aborted", th);
    } finally {
        if (conn != null) {
            try {
                if (startedTransaction)
                    conn.setAutoCommit(false);
            } catch (SQLException e) {
                logger.error("Failed to set autoCommit to false", e);
            } finally {
                RecordCache.releaseConnection(conn);
            }
        }
    }

}