javax.jdo.JDODataStoreException Java Examples
The following examples show how to use
javax.jdo.JDODataStoreException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PersistenceManagerFactoryUtils.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Convert the given JDOException to an appropriate exception from the * {@code org.springframework.dao} hierarchy. * <p>The most important cases like object not found or optimistic locking failure * are covered here. For more fine-granular conversion, JdoTransactionManager * supports sophisticated translation of exceptions via a JdoDialect. * @param ex JDOException that occured * @return the corresponding DataAccessException instance * @see JdoTransactionManager#convertJdoAccessException * @see JdoDialect#translateException */ public static DataAccessException convertJdoAccessException(JDOException ex) { if (ex instanceof JDOObjectNotFoundException) { throw new JdoObjectRetrievalFailureException((JDOObjectNotFoundException) ex); } if (ex instanceof JDOOptimisticVerificationException) { throw new JdoOptimisticLockingFailureException((JDOOptimisticVerificationException) ex); } if (ex instanceof JDODataStoreException) { return new JdoResourceFailureException((JDODataStoreException) ex); } if (ex instanceof JDOFatalDataStoreException) { return new JdoResourceFailureException((JDOFatalDataStoreException) ex); } if (ex instanceof JDOUserException) { return new JdoUsageException((JDOUserException) ex); } if (ex instanceof JDOFatalUserException) { return new JdoUsageException((JDOFatalUserException) ex); } // fallback return new JdoSystemException(ex); }
Example #2
Source File: HMSHandlerProxy.java From metacat with Apache License 2.0 | 6 votes |
@Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { Deadline.registerIfNot(timeout); try { Deadline.startTimer(method.getName()); final Object object = method.invoke(metacatHMSHandler, args); Deadline.stopTimer(); return object; } catch (InvocationTargetException e) { for (Throwable ex : Throwables.getCausalChain(e)) { if (ex instanceof JDODataStoreException) { throw ex; } } throw e.getCause(); } }
Example #3
Source File: PersistenceManagerFactoryUtils.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Convert the given JDOException to an appropriate exception from the * {@code org.springframework.dao} hierarchy. * <p>The most important cases like object not found or optimistic locking failure * are covered here. For more fine-granular conversion, JdoTransactionManager * supports sophisticated translation of exceptions via a JdoDialect. * @param ex JDOException that occured * @return the corresponding DataAccessException instance * @see JdoTransactionManager#convertJdoAccessException * @see JdoDialect#translateException */ public static DataAccessException convertJdoAccessException(JDOException ex) { if (ex instanceof JDOObjectNotFoundException) { throw new JdoObjectRetrievalFailureException((JDOObjectNotFoundException) ex); } if (ex instanceof JDOOptimisticVerificationException) { throw new JdoOptimisticLockingFailureException((JDOOptimisticVerificationException) ex); } if (ex instanceof JDODataStoreException) { return new JdoResourceFailureException((JDODataStoreException) ex); } if (ex instanceof JDOFatalDataStoreException) { return new JdoResourceFailureException((JDOFatalDataStoreException) ex); } if (ex instanceof JDOUserException) { return new JdoUsageException((JDOUserException) ex); } if (ex instanceof JDOFatalUserException) { return new JdoUsageException((JDOFatalUserException) ex); } // fallback return new JdoSystemException(ex); }
Example #4
Source File: CategoryRepository_createTaxonomy_IntegTest.java From estatio with Apache License 2.0 | 5 votes |
@Test public void when_name_already_in_use() { // given Taxonomy italianColours = (Taxonomy) categoryRepository.findByReference("ITACOL"); assertThat(italianColours.getName()).isEqualTo("Italian Colours"); sessionManagementService.nextSession(); // then expectedException.expect(JDODataStoreException.class); expectedException.expectMessage("Classification_fullyQualifiedName_UNQ"); // when categoryRepository.createTaxonomy("Italian Colours"); }
Example #5
Source File: SentryStore.java From incubator-sentry with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private MSentryVersion getMSentryVersion() throws SentryNoSuchObjectException, SentryAccessDeniedException { boolean rollbackTransaction = true; PersistenceManager pm = null; try { pm = openTransaction(); Query query = pm.newQuery(MSentryVersion.class); List<MSentryVersion> mSentryVersions = (List<MSentryVersion>) query .execute(); pm.retrieveAll(mSentryVersions); rollbackTransaction = false; commitTransaction(pm); if (mSentryVersions.isEmpty()) { throw new SentryNoSuchObjectException("No matching version found"); } if (mSentryVersions.size() > 1) { throw new SentryAccessDeniedException( "Metastore contains multiple versions"); } return mSentryVersions.get(0); } catch (JDODataStoreException e) { if (e.getCause() instanceof MissingTableException) { throw new SentryAccessDeniedException("Version table not found. " + "The sentry store is not set or corrupt "); } else { throw e; } } finally { if (rollbackTransaction) { rollbackTransaction(pm); } } }
Example #6
Source File: SentryStore.java From incubator-sentry with Apache License 2.0 | 5 votes |
/** * Drop given privilege from all roles */ public void dropPrivilege(TSentryAuthorizable tAuthorizable) throws SentryNoSuchObjectException, SentryInvalidInputException { PersistenceManager pm = null; boolean rollbackTransaction = true; TSentryPrivilege tPrivilege = toSentryPrivilege(tAuthorizable); try { pm = openTransaction(); if (isMultiActionsSupported(tPrivilege)) { for (String privilegeAction : ALL_ACTIONS) { tPrivilege.setAction(privilegeAction); dropPrivilegeForAllRoles(pm, new TSentryPrivilege(tPrivilege)); } } else { dropPrivilegeForAllRoles(pm, new TSentryPrivilege(tPrivilege)); } rollbackTransaction = false; commitTransaction(pm); } catch (JDODataStoreException e) { throw new SentryInvalidInputException("Failed to get privileges: " + e.getMessage()); } finally { if (rollbackTransaction) { rollbackTransaction(pm); } } }
Example #7
Source File: SentryStore.java From incubator-sentry with Apache License 2.0 | 5 votes |
/** * Rename given privilege from all roles drop the old privilege and create the new one * @param tAuthorizable * @param newTAuthorizable * @throws SentryNoSuchObjectException * @throws SentryInvalidInputException */ public void renamePrivilege(TSentryAuthorizable tAuthorizable, TSentryAuthorizable newTAuthorizable) throws SentryNoSuchObjectException, SentryInvalidInputException { PersistenceManager pm = null; boolean rollbackTransaction = true; TSentryPrivilege tPrivilege = toSentryPrivilege(tAuthorizable); TSentryPrivilege newPrivilege = toSentryPrivilege(newTAuthorizable); try { pm = openTransaction(); // In case of tables or DBs, check all actions if (isMultiActionsSupported(tPrivilege)) { for (String privilegeAction : ALL_ACTIONS) { tPrivilege.setAction(privilegeAction); newPrivilege.setAction(privilegeAction); renamePrivilegeForAllRoles(pm, tPrivilege, newPrivilege); } } else { renamePrivilegeForAllRoles(pm, tPrivilege, newPrivilege); } rollbackTransaction = false; commitTransaction(pm); } catch (JDODataStoreException e) { throw new SentryInvalidInputException("Failed to get privileges: " + e.getMessage()); } finally { if (rollbackTransaction) { rollbackTransaction(pm); } } }
Example #8
Source File: JdoResourceFailureException.java From lams with GNU General Public License v2.0 | 4 votes |
public JdoResourceFailureException(JDODataStoreException ex) { super(ex.getMessage(), ex); }
Example #9
Source File: JdoResourceFailureException.java From spring4-understanding with Apache License 2.0 | 4 votes |
public JdoResourceFailureException(JDODataStoreException ex) { super(ex.getMessage(), ex); }