Example usage for org.springframework.dao DataAccessException getClass

List of usage examples for org.springframework.dao DataAccessException getClass

Introduction

In this page you can find the example usage for org.springframework.dao DataAccessException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.opennms.ng.dao.support.DistributedStatusResourceType.java

/**
 * <p>getResourcesForLocationMonitor</p>
 *
 * @param locationMonitorId a int./*  w  ww.  j  a v a2 s.c o  m*/
 * @return a {@link java.util.List} object.
 */
public List<OnmsResource> getResourcesForLocationMonitor(int locationMonitorId) {
    ArrayList<OnmsResource> resources = new ArrayList<OnmsResource>();

    /*
     * Verify that the node directory exists so we can throw a good
     * error message if not.
     */
    File locationMonitorDirectory;
    try {
        locationMonitorDirectory = getLocationMonitorDirectory(locationMonitorId, true);
    } catch (DataAccessException e) {
        throw new ObjectRetrievalFailureException("The '" + getName()
                + "' resource type does not exist on this location Monitor.  Nested exception is: "
                + e.getClass().getName() + ": " + e.getMessage(), e);
    }

    File[] intfDirs = locationMonitorDirectory.listFiles(RrdFileConstants.INTERFACE_DIRECTORY_FILTER);

    // XXX is this test even needed?
    if (intfDirs == null) {
        return resources;
    }

    // XXX this isn't right at all
    for (File intfDir : intfDirs) {
        String d = intfDir.getName();
        String defName = getDefinitionNameFromLocationMonitorDirectory(d);
        int id = getLocationMonitorIdFromLocationMonitorDirectory(d);
        resources.add(createResource(defName, id, intfDir.getName()));
    }

    return resources;
}

From source file:org.sakaiproject.delegatedaccess.dao.impl.DelegatedAccessDaoImpl.java

public void cleanupOrphanedPermissions() {
    try {//from   w  w  w  .  java 2 s . c o m
        getJdbcTemplate().update(getStatement("delete.orphaned.permissions"));
    } catch (DataAccessException ex) {
        log.error("Error executing query: " + ex.getClass() + ":" + ex.getMessage(), ex);
    }
}

From source file:org.sakaiproject.delegatedaccess.dao.impl.DelegatedAccessDaoImpl.java

public List<String> getDelegatedAccessUsers() {
    try {/*ww w  . j  ava2s.com*/
        return getJdbcTemplate().query(getStatement("select.delegatedaccess.user"), new RowMapper() {
            public Object mapRow(ResultSet resultSet, int i) throws SQLException {
                return resultSet.getString("userId");
            }
        });
    } catch (DataAccessException ex) {
        log.error("Error executing query: " + ex.getClass() + ":" + ex.getMessage(), ex);
        return null;
    }
}

From source file:org.sakaiproject.delegatedaccess.dao.impl.DelegatedAccessDaoImpl.java

@SuppressWarnings("unchecked")
public List<String> getDistinctSiteTerms(String termField) {
    try {//ww w.ja  va2s .  c o m
        return getJdbcTemplate().query(getStatement("select.distinctTerms"), new String[] { termField },
                new RowMapper() {
                    public Object mapRow(ResultSet resultSet, int i) throws SQLException {
                        return resultSet.getString(1);
                    }
                });
    } catch (DataAccessException ex) {
        log.error("Error executing query: " + ex.getClass() + ":" + ex.getMessage(), ex);
        return null;
    }
}

From source file:org.sakaiproject.delegatedaccess.dao.impl.DelegatedAccessDaoImpl.java

public String getSiteProperty(String propertyName, String siteId) {
    try {//from   w  ww  . ja  va 2s.  co m
        return (String) getJdbcTemplate().queryForObject(getStatement("select.siteProperty"),
                new Object[] { propertyName, siteId }, new RowMapper() {

                    public Object mapRow(ResultSet resultSet, int i) throws SQLException {
                        return resultSet.getString("VALUE");
                    }
                });
    } catch (DataAccessException ex) {
        log.error("Error executing query: " + ex.getClass() + ":" + ex.getMessage(), ex);
        return null;
    }
}

From source file:org.sakaiproject.delegatedaccess.dao.impl.DelegatedAccessDaoImpl.java

public List<String> getEmptyNonSiteNodes(String hierarchyId) {
    try {/*from w w  w . j  ava2 s.  c  om*/
        return (List<String>) getJdbcTemplate().query(getStatement("select.emptyNodes"),
                new Object[] { hierarchyId }, new RowMapper() {

                    public Object mapRow(ResultSet resultSet, int i) throws SQLException {
                        return resultSet.getString("ID");
                    }
                });
    } catch (DataAccessException ex) {
        log.error("Error executing query: " + ex.getClass() + ":" + ex.getMessage(), ex);
        return null;
    }
}

From source file:org.sakaiproject.delegatedaccess.dao.impl.DelegatedAccessDaoImpl.java

public void removeSiteProperty(String[] siteIds, String propertyName) {
    try {//w w  w  .  j  a v  a  2  s. co  m
        if (siteIds == null || siteIds.length == 0) {
            return;
        }
        int subArrayIndex = 0;
        do {
            int subArraySize = ORACLE_IN_CLAUSE_SIZE_LIMIT;
            if (subArrayIndex + subArraySize > siteIds.length) {
                subArraySize = (siteIds.length - subArrayIndex);
            }
            String[] subSiteRefs = Arrays.copyOfRange(siteIds, subArrayIndex, subArrayIndex + subArraySize);

            String query1 = getStatement("delete.siteProperty");

            String inParams = "(";
            for (int i = 0; i < subSiteRefs.length; i++) {
                inParams += "?";
                if (i < subSiteRefs.length - 1) {
                    inParams += ",";
                }
            }
            inParams += ")";
            query1 = query1.replace("(?)", inParams);
            List<String> parameters = new ArrayList<String>();
            parameters.add(propertyName);
            parameters.addAll(Arrays.asList(subSiteRefs));
            getJdbcTemplate().update(query1, parameters.toArray());
            subArrayIndex = subArrayIndex + subArraySize;
        } while (subArrayIndex < siteIds.length);
    } catch (DataAccessException ex) {
        log.error("Error executing query: " + ex.getClass() + ":" + ex.getMessage(), ex);
    }
}

From source file:org.sakaiproject.delegatedaccess.dao.impl.DelegatedAccessDaoImpl.java

public void removeAnonAndAuthRoles(String[] siteRefs) {
    try {/*  ww  w.  jav a2 s . c o  m*/
        if (siteRefs == null || siteRefs.length == 0) {
            return;
        }
        int subArrayIndex = 0;
        do {
            int subArraySize = ORACLE_IN_CLAUSE_SIZE_LIMIT;
            if (subArrayIndex + subArraySize > siteRefs.length) {
                subArraySize = (siteRefs.length - subArrayIndex);
            }
            String[] subSiteRefs = Arrays.copyOfRange(siteRefs, subArrayIndex, subArrayIndex + subArraySize);

            String query1 = getStatement("delete.anon.auth.roles");
            String query2 = getStatement("delete.anon.auth.permissions");

            String inParams = "(";
            for (int i = 0; i < subSiteRefs.length; i++) {
                inParams += "?";
                if (i < subSiteRefs.length - 1) {
                    inParams += ",";
                }
            }
            inParams += ")";
            query1 = query1.replace("(?)", inParams);
            query2 = query2.replace("(?)", inParams);
            getJdbcTemplate().update(query1, subSiteRefs);
            getJdbcTemplate().update(query2, subSiteRefs);
            subArrayIndex = subArrayIndex + subArraySize;
        } while (subArrayIndex < siteRefs.length);
    } catch (DataAccessException ex) {
        log.error("Error executing query: " + ex.getClass() + ":" + ex.getMessage(), ex);
    }
}

From source file:org.sakaiproject.delegatedaccess.dao.impl.DelegatedAccessDaoImpl.java

public void updateSiteProperty(String[] siteIds, String propertyName, String propertyValue) {
    try {//from  w w  w  .  ja  v  a 2  s  . co  m
        if (siteIds == null || siteIds.length == 0) {
            return;
        }
        String query = getStatement("update.siteProperty");

        if (oracle) {
            //Create Replace query:
            String values = "";
            for (String siteId : siteIds) {
                if (!"".equals(values)) {
                    values += " union ";
                }
                values += "select '" + siteId + "' SITE_ID, '" + propertyName + "' NAME, '" + propertyValue
                        + "' VALUE from dual";
            }
            query = query.replace("?", values);
        } else {
            //Create Replace query:
            String values = "";
            for (String siteId : siteIds) {
                if (!"".equals(values)) {
                    values += ",";
                }
                values += "('" + siteId + "', '" + propertyName + "','" + propertyValue + "')";
            }
            query = query + values;
        }

        getJdbcTemplate().update(query);
    } catch (DataAccessException ex) {
        log.error("Error executing query: " + ex.getClass() + ":" + ex.getMessage(), ex);
    }
}

From source file:org.sakaiproject.delegatedaccess.dao.impl.DelegatedAccessDaoImpl.java

public void copyRole(String fromRealm, String fromRole, String[] toRealm, String toRole) {
    if (toRealm == null || toRealm.length == 0) {
        return;//w w  w .j  a  v a 2 s. co  m
    }
    try {
        int subArrayIndex = 0;
        do {
            int subArraySize = ORACLE_IN_CLAUSE_SIZE_LIMIT;
            if (subArrayIndex + subArraySize > toRealm.length) {
                subArraySize = (toRealm.length - subArrayIndex);
            }
            String[] subSiteRefs = Arrays.copyOfRange(toRealm, subArrayIndex, subArrayIndex + subArraySize);

            String query1 = getStatement("insert.copyrole");
            String query2 = getStatement("insert.copyroledesc");

            String inParams = "(";
            for (int i = 0; i < subSiteRefs.length; i++) {
                inParams += "?";
                if (i < subSiteRefs.length - 1) {
                    inParams += ",";
                }
            }
            inParams += ")";
            query1 = query1.replace("(?)", inParams);
            query2 = query2.replace("(?)", inParams);
            List<String> parameters1 = new ArrayList<String>();
            parameters1.addAll(Arrays.asList(subSiteRefs));
            parameters1.add(fromRealm);
            parameters1.add(fromRole);
            parameters1.add(toRole);
            List<String> parameters2 = new ArrayList<String>();
            parameters2.addAll(Arrays.asList(subSiteRefs));
            parameters2.add(toRole);
            getJdbcTemplate().update(query1, parameters1.toArray());
            getJdbcTemplate().update(query2, parameters2.toArray());
            subArrayIndex = subArrayIndex + subArraySize;
        } while (subArrayIndex < toRealm.length);
    } catch (DataAccessException ex) {
        log.error("Error executing query: " + ex.getClass() + ":" + ex.getMessage(), ex);
    }
}