{
return new JDOQueryInterruptedException(ne.getMessage());
}
else if (ne instanceof QueryTimeoutException)
{
return new JDODataStoreException(ne.getMessage(), ne);
}
else if (ne instanceof NucleusUnsupportedOptionException)
{
return new JDOUnsupportedOptionException(ne.getMessage(), ne);
}
else if (ne instanceof DatastoreReadOnlyException)
{
ClassLoaderResolver clr = ((DatastoreReadOnlyException)ne).getClassLoaderResolver();
try
{
Class cls = clr.classForName("javax.jdo.JDOReadOnlyException");
throw (JDOUserException)ClassUtils.newInstance(cls,
new Class[] {String.class}, new Object[] {ne.getMessage()});
}
catch (NucleusException ne2)
{
// No JDOReadOnlyException so JDO1.0-JDO2.1
throw new JDOUserException(ne2.getMessage());
}
}
else if (ne instanceof NucleusDataStoreException)
{
if (ne.isFatal())
{
//sadly JDOFatalDataStoreException dont allow nested exceptions and failed objects together
if (ne.getFailedObject() != null)
{
return new JDOFatalDataStoreException(ne.getMessage(), ne.getFailedObject());
}
else if (ne.getNestedExceptions() != null)
{
return new JDOFatalDataStoreException(ne.getMessage(), ne.getNestedExceptions());
}
else
{
return new JDOFatalDataStoreException(ne.getMessage(), ne);
}
}
else
{
if (ne.getNestedExceptions() != null)
{
if (ne.getFailedObject() != null)
{
return new JDODataStoreException(ne.getMessage(), ne.getNestedExceptions(), ne.getFailedObject());
}
return new JDODataStoreException(ne.getMessage(), ne.getNestedExceptions());
}
else if (ne.getFailedObject() != null)
{
JDOPersistenceManager.LOGGER.info("Exception thrown", ne);
return new JDODataStoreException(ne.getMessage(), ne.getFailedObject());
}
else
{
JDOPersistenceManager.LOGGER.info("Exception thrown", ne);
return new JDODataStoreException(ne.getMessage(), ne);
}
}
}
else if (ne instanceof NucleusObjectNotFoundException)
{
if (ne.getFailedObject() != null)
{
if (ne.getNestedExceptions() != null)
{
return new JDOObjectNotFoundException(ne.getMessage(), ne.getNestedExceptions(), ne.getFailedObject());
}
else
{
return new JDOObjectNotFoundException(ne.getMessage(), ne, ne.getFailedObject());
}
}
else if (ne.getNestedExceptions() != null)
{
return new JDOObjectNotFoundException(ne.getMessage(), ne.getNestedExceptions());
}
else
{
return new JDOObjectNotFoundException(ne.getMessage(), new Throwable[]{ne});
}
}
else if (ne instanceof NucleusCanRetryException)
{
if (ne.getNestedExceptions() != null)
{
if (ne.getFailedObject() != null)
{
return new JDOCanRetryException(ne.getMessage(), ne.getNestedExceptions(), ne.getFailedObject());
}
return new JDOCanRetryException(ne.getMessage(), ne.getNestedExceptions());
}
else if (ne.getFailedObject() != null)
{
JDOPersistenceManager.LOGGER.info("Exception thrown", ne);
return new JDOCanRetryException(ne.getMessage(), ne.getFailedObject());
}
else
{
JDOPersistenceManager.LOGGER.info("Exception thrown", ne);
return new JDOCanRetryException(ne.getMessage(), ne);
}
}
else if (ne instanceof NucleusUserException)
{
if (ne.isFatal())
{
if (ne.getNestedExceptions() != null)
{
if (ne.getFailedObject() != null)
{
return new JDOFatalUserException(ne.getMessage(), ne.getNestedExceptions(), ne.getFailedObject());
}
return new JDOFatalUserException(ne.getMessage(), ne.getNestedExceptions());
}
else if (ne.getFailedObject() != null)
{
JDOPersistenceManager.LOGGER.info("Exception thrown", ne);
return new JDOFatalUserException(ne.getMessage(), ne.getFailedObject());
}
else
{
JDOPersistenceManager.LOGGER.info("Exception thrown", ne);
return new JDOFatalUserException(ne.getMessage(), ne);
}
}
else
{
if (ne.getNestedExceptions() != null)
{
if (ne.getFailedObject() != null)
{
return new JDOUserException(ne.getMessage(), ne.getNestedExceptions(), ne.getFailedObject());
}
return new JDOUserException(ne.getMessage(), ne.getNestedExceptions());
}
else if (ne.getFailedObject() != null)
{
JDOPersistenceManager.LOGGER.info("Exception thrown", ne);
return new JDOUserException(ne.getMessage(), ne.getFailedObject());
}
else
{
JDOPersistenceManager.LOGGER.info("Exception thrown", ne);
return new JDOUserException(ne.getMessage(), ne);
}
}
}
else if (ne instanceof NucleusOptimisticException)
{
//sadly JDOOptimisticVerificationException dont allow nested exceptions and failed objects together
if (ne.getFailedObject() != null)
{
return new JDOOptimisticVerificationException(ne.getMessage(), ne.getFailedObject());
}
else if (ne.getNestedExceptions() != null)
{
return new JDOOptimisticVerificationException(ne.getMessage(), ne.getNestedExceptions());
}
else
{
return new JDOOptimisticVerificationException(ne.getMessage(), ne);
}
}
else if (ne instanceof org.datanucleus.transaction.HeuristicRollbackException
&& ne.getNestedExceptions().length==1
&& ne.getNestedExceptions()[0].getCause() instanceof SQLException)
{
// if there was a single failure in the transaction, we want to properly propagate the
// single nested SQLException that was the cause of the failure, so application code
// can decide on what to do with it
return new JDODataStoreException(ne.getMessage(), ((XAException)ne.getNestedExceptions()[0]).getCause());
}
else
{
if (ne.isFatal())
{