List of usage examples for org.springframework.orm ObjectRetrievalFailureException ObjectRetrievalFailureException
public ObjectRetrievalFailureException(String persistentClassName, Object identifier, String msg,
@Nullable Throwable cause)
From source file:org.opennms.netmgt.config.DefaultEventConfDao.java
private void processEvents(Events events, Resource resource, EventConfiguration eventConfiguration, String resourceDescription, boolean denyIncludes) { if (denyIncludes) { if (events.getGlobal() != null) { throw new ObjectRetrievalFailureException(Resource.class, resource, "The event resource " + resource + " included from the root event configuration file cannot have a 'global' element", null);/*from w w w .ja va2s . c om*/ } if (events.getEventFileCollection().size() > 0) { throw new ObjectRetrievalFailureException(Resource.class, resource, "The event resource " + resource + " included from the root event configuration file cannot include other configuration files: " + StringUtils.collectionToCommaDelimitedString(events.getEventFileCollection()), null); } } eventConfiguration.getEventFiles().put(resource, events); for (Event event : events.getEventCollection()) { eventConfiguration.getEventConfData().put(event); } log().info("DefaultEventConfDao: Loaded " + events.getEventCollection().size() + " events from " + resourceDescription + " event configuration resource: " + resource); eventConfiguration.incrementEventCount(events.getEventCount()); }
From source file:org.opennms.netmgt.dao.support.DefaultResourceDao.java
/** * <p>getChildResource</p>//from w ww. ja v a 2s .com * * @param parentResource a {@link org.opennms.netmgt.model.OnmsResource} object. * @param resourceType a {@link java.lang.String} object. * @param resource a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.model.OnmsResource} object. */ protected OnmsResource getChildResource(OnmsResource parentResource, String resourceType, String resource) { final OnmsResourceType targetType = m_resourceTypes.get(resourceType); if (targetType == null) { throw new ObjectRetrievalFailureException(OnmsResource.class, resourceType + "/" + resource, "Unsupported resource type: " + resourceType, null); } final OnmsResource childResource = targetType.getChildByName(parentResource, resource); if (childResource != null) { LOG.debug("getChildResource: returning resource {}", childResource); return childResource; } throw new ObjectRetrievalFailureException(OnmsResource.class, resourceType + "/" + resource, "Could not find child resource '" + resource + "' with resource type '" + resourceType + "' on resource '" + resource + "'", null); }
From source file:org.opennms.netmgt.dao.support.PropertiesGraphDao.java
/** {@inheritDoc} */ @Override//from w w w. j av a 2 s.c o m public PrefabGraph getPrefabGraph(final String name) { for (final FileReloadContainer<PrefabGraphTypeDao> container : m_types.values()) { final PrefabGraphTypeDao type = container.getObject(); this.rescanIncludeDirectory(type); final PrefabGraph graph = type.getQuery(name); if (graph != null) { return graph; } } throw new ObjectRetrievalFailureException(PrefabGraph.class, name, "Could not find prefabricated graph report with name '" + name + "'", null); }
From source file:org.springframework.orm.jpa.vendor.HibernateJpaDialect.java
/** * Convert the given HibernateException to an appropriate exception * from the {@code org.springframework.dao} hierarchy. * @param ex HibernateException that occurred * @return the corresponding DataAccessException instance *//* ww w. jav a 2s . c om*/ protected DataAccessException convertHibernateAccessException(HibernateException ex) { if (ex instanceof JDBCConnectionException) { return new DataAccessResourceFailureException(ex.getMessage(), ex); } if (ex instanceof SQLGrammarException) { SQLGrammarException jdbcEx = (SQLGrammarException) ex; return new InvalidDataAccessResourceUsageException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex); } if (ex instanceof QueryTimeoutException) { QueryTimeoutException jdbcEx = (QueryTimeoutException) ex; return new org.springframework.dao.QueryTimeoutException( ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex); } if (ex instanceof LockAcquisitionException) { LockAcquisitionException jdbcEx = (LockAcquisitionException) ex; return new CannotAcquireLockException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex); } if (ex instanceof PessimisticLockException) { PessimisticLockException jdbcEx = (PessimisticLockException) ex; return new PessimisticLockingFailureException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex); } if (ex instanceof ConstraintViolationException) { ConstraintViolationException jdbcEx = (ConstraintViolationException) ex; return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]; constraint [" + jdbcEx.getConstraintName() + "]", ex); } if (ex instanceof DataException) { DataException jdbcEx = (DataException) ex; return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex); } // end of JDBCException subclass handling if (ex instanceof QueryException) { return new InvalidDataAccessResourceUsageException(ex.getMessage(), ex); } if (ex instanceof NonUniqueResultException) { return new IncorrectResultSizeDataAccessException(ex.getMessage(), 1, ex); } if (ex instanceof NonUniqueObjectException) { return new DuplicateKeyException(ex.getMessage(), ex); } if (ex instanceof PropertyValueException) { return new DataIntegrityViolationException(ex.getMessage(), ex); } if (ex instanceof PersistentObjectException) { return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); } if (ex instanceof TransientObjectException) { return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); } if (ex instanceof ObjectDeletedException) { return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); } if (ex instanceof UnresolvableObjectException) { UnresolvableObjectException hibEx = (UnresolvableObjectException) ex; return new ObjectRetrievalFailureException(hibEx.getEntityName(), hibEx.getIdentifier(), ex.getMessage(), ex); } if (ex instanceof WrongClassException) { WrongClassException hibEx = (WrongClassException) ex; return new ObjectRetrievalFailureException(hibEx.getEntityName(), hibEx.getIdentifier(), ex.getMessage(), ex); } if (ex instanceof StaleObjectStateException) { StaleObjectStateException hibEx = (StaleObjectStateException) ex; return new ObjectOptimisticLockingFailureException(hibEx.getEntityName(), hibEx.getIdentifier(), ex); } if (ex instanceof StaleStateException) { return new ObjectOptimisticLockingFailureException(ex.getMessage(), ex); } if (ex instanceof OptimisticEntityLockException) { return new ObjectOptimisticLockingFailureException(ex.getMessage(), ex); } if (ex instanceof PessimisticEntityLockException) { if (ex.getCause() instanceof LockAcquisitionException) { return new CannotAcquireLockException(ex.getMessage(), ex.getCause()); } return new PessimisticLockingFailureException(ex.getMessage(), ex); } // fallback return new JpaSystemException(ex); }