Example usage for java.lang StringIndexOutOfBoundsException printStackTrace

List of usage examples for java.lang StringIndexOutOfBoundsException printStackTrace

Introduction

In this page you can find the example usage for java.lang StringIndexOutOfBoundsException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:it.cnr.icar.eric.server.persistence.rdb.SubscriptionDAO.java

@SuppressWarnings("unchecked")
protected void loadObject(Object obj, ResultSet rs) throws RegistryException {
    try {//  ww  w.  j  a  v  a 2 s.  c o m
        if (!(obj instanceof SubscriptionType)) {
            throw new RegistryException(ServerResourceBundle.getInstance()
                    .getString("message.SubscriptionTypeExpected", new Object[] { obj }));
        }

        SubscriptionType ebSubscriptionType = (SubscriptionType) obj;
        super.loadObject(obj, rs);

        String selector = rs.getString("selector");
        ebSubscriptionType.setSelector(selector);

        // Need to work around a bug in PostgreSQL and loading of
        // ClassificationScheme data from NIST tests
        try {
            Timestamp endTimestamp = rs.getTimestamp("endTime");

            if (endTimestamp != null) {
                // Calendar calendar = Calendar.getInstance();
                // calendar.setTimeInMillis(endTime.getTime());

                GregorianCalendar calendar = new GregorianCalendar();
                calendar.setTimeInMillis(endTimestamp.getTime());
                XMLGregorianCalendar endTime = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);

                ebSubscriptionType.setEndTime(endTime);
            }
        } catch (StringIndexOutOfBoundsException e) {
            String id = rs.getString("id");
            log.error(ServerResourceBundle.getInstance().getString("message.SubscriptionDAOId",
                    new Object[] { id }), e);
        }

        String notificationIntervalString = rs.getString("notificationInterval");

        if (notificationIntervalString != null) {
            Duration notificationInterval = DatatypeFactory.newInstance()
                    .newDuration(notificationIntervalString);
            ebSubscriptionType.setNotificationInterval(notificationInterval);
        }

        // Need to work around a bug in PostgreSQL and loading of
        // ClassificationScheme data from NIST tests
        try {
            Timestamp startTimestamp = rs.getTimestamp("startTime");

            if (startTimestamp != null) {
                // Calendar calendar = Calendar.getInstance();
                // calendar.setTimeInMillis(startTime.getTime());

                GregorianCalendar calendar = new GregorianCalendar();
                calendar.setTimeInMillis(startTimestamp.getTime());

                XMLGregorianCalendar startTime = DatatypeFactory.newInstance()
                        .newXMLGregorianCalendar(new GregorianCalendar());

                ebSubscriptionType.setStartTime(startTime);
            }
        } catch (StringIndexOutOfBoundsException e) {
            String id = rs.getString("id");
            log.error(ServerResourceBundle.getInstance().getString("message.SubscriptionDAOId",
                    new Object[] { id }), e);
        }

        NotifyActionDAO notifyActionDAO = new NotifyActionDAO(context);
        notifyActionDAO.setParent(ebSubscriptionType);
        @SuppressWarnings("rawtypes")
        List notifyActions = notifyActionDAO.getByParent();
        if (notifyActions != null) {
            bu.getActionTypeListFromElements(ebSubscriptionType.getAction()).addAll(notifyActions);
        }

    } catch (SQLException e) {
        log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e);
        throw new RegistryException(e);
    } catch (DatatypeConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}