本文整理汇总了Java中javax.jdo.JDOException类的典型用法代码示例。如果您正苦于以下问题:Java JDOException类的具体用法?Java JDOException怎么用?Java JDOException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JDOException类属于javax.jdo包,在下文中一共展示了JDOException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import javax.jdo.JDOException; //导入依赖的package包/类
public void invoke(Long kioskId, List<IApprover> newApprovers, String userName) {
if (kioskId == null || newApprovers == null) {
throw new IllegalArgumentException("Invalid parameters for adding Approver");
}
PersistenceManager pm = PMF.get().getPersistenceManager();
List<IApprover> approvers = entitiesService.getApprovers(kioskId, pm);
List<IApprover> deleteApproversList = getDeleteApproversList(approvers, newApprovers);
List<IApprover> persistApproversList = getPersistApproversList(approvers, newApprovers);
try {
deleteApprovers(deleteApproversList, pm);
persistApprovers(persistApproversList, pm, userName);
generateEvent();
} catch (JDOException e) {
throw new SystemException(e, "Could not persist approver for entity " + kioskId);
} finally {
pm.close();
}
}
示例2: convertJdoAccessException
import javax.jdo.JDOException; //导入依赖的package包/类
/**
* 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);
}
示例3: doCommit
import javax.jdo.JDOException; //导入依赖的package包/类
@Override
protected void doCommit(DefaultTransactionStatus status) {
JdoTransactionObject txObject = (JdoTransactionObject) status.getTransaction();
if (status.isDebug()) {
logger.debug("Committing JDO transaction on PersistenceManager [" +
txObject.getPersistenceManagerHolder().getPersistenceManager() + "]");
}
try {
Transaction tx = txObject.getPersistenceManagerHolder().getPersistenceManager().currentTransaction();
tx.commit();
}
catch (JDOException ex) {
// Assumably failed to flush changes to database.
throw convertJdoAccessException(ex);
}
}
示例4: doRollback
import javax.jdo.JDOException; //导入依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status) {
JdoTransactionObject txObject = (JdoTransactionObject) status.getTransaction();
if (status.isDebug()) {
logger.debug("Rolling back JDO transaction on PersistenceManager [" +
txObject.getPersistenceManagerHolder().getPersistenceManager() + "]");
}
try {
Transaction tx = txObject.getPersistenceManagerHolder().getPersistenceManager().currentTransaction();
if (tx.isActive()) {
tx.rollback();
}
}
catch (JDOException ex) {
throw new TransactionSystemException("Could not roll back JDO transaction", ex);
}
}
示例5: migrateDataToSingleSelectTable
import javax.jdo.JDOException; //导入依赖的package包/类
private void migrateDataToSingleSelectTable(String dstTable, String field) throws DataMigrationFailedException {
String srcTable = dstTable + "_" + field.toUpperCase();
String mdsDataBase = mdsConfig.getDataDatabaseName();
try {
if (!sqlDBManager.hasColumn(mdsDataBase, dstTable, field)) {
LOGGER.info(String.format("Adding column %s to table %s.", field, dstTable));
executeQuery(prepareAddColumnQuery(dstTable, field));
}
LOGGER.info(String.format("Migrating data from table %s to table %s.", srcTable, dstTable));
executeQuery(prepareMigrationToSingleSelectQuery(srcTable, dstTable, field));
} catch (JDOException|SQLException e) {
throw new DataMigrationFailedException(String.format("Error while migrating data to from %s to %s.", srcTable, dstTable), e);
}
}
示例6: convertJdoAccessException
import javax.jdo.JDOException; //导入依赖的package包/类
/**
* 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, JdoAccessor and
* JdoTransactionManager support sophisticated translation of exceptions via a
* JdoDialect.
* @param ex JDOException that occured
* @return the corresponding DataAccessException instance
* @see JdoAccessor#convertJdoAccessException
* @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);
}
示例7: find
import javax.jdo.JDOException; //导入依赖的package包/类
public <T> Collection<T> find(
final Class<T> entityClass, final String filter, final String parameters, final Object[] values,
final String ordering) throws DataAccessException {
return execute(new JdoCallback<Collection<T>>() {
@SuppressWarnings("unchecked")
public Collection<T> doInJdo(PersistenceManager pm) throws JDOException {
Query query = pm.newQuery(entityClass, filter);
prepareQuery(query);
query.declareParameters(parameters);
if (ordering != null) {
query.setOrdering(ordering);
}
return (Collection<T>) query.executeWithArray(values);
}
}, true);
}
示例8: testTranslateException
import javax.jdo.JDOException; //导入依赖的package包/类
@Test
public void testTranslateException() {
JdoDialect dialect = mock(JdoDialect.class);
final JDOException ex = new JDOException();
given(dialect.translateException(ex)).willReturn(new DataIntegrityViolationException("test", ex));
try {
JdoTemplate template = createTemplate();
template.setJdoDialect(dialect);
template.execute(new JdoCallback() {
@Override
public Object doInJdo(PersistenceManager pm) {
throw ex;
}
});
fail("Should have thrown DataIntegrityViolationException");
}
catch (DataIntegrityViolationException dive) {
// expected
}
}
示例9: getAccessToken
import javax.jdo.JDOException; //导入依赖的package包/类
@Override
public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication) {
OAuth2AccessToken accessToken = null;
String key = authenticationKeyGenerator.extractKey(authentication);
try {
GaeOAuthAccessToken gaeOAuthAccessToken = accessTokens.findByAuthenticationId(key);
if (gaeOAuthAccessToken != null) {
accessToken = gaeOAuthAccessToken.getToken();
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Failed to find access token for authentication " + authentication);
}
}
} catch (JDOException e) {
LOG.error("Could not extract access token for authentication " + authentication, e);
}
if (accessToken != null && !key.equals(authenticationKeyGenerator.extractKey(readAuthentication(accessToken.getValue())))) {
removeAccessToken(accessToken.getValue());
// Keep the store consistent (maybe the same user is represented by this authentication but the details have changed)
storeAccessToken(accessToken, authentication);
}
return accessToken;
}
示例10: readAccessToken
import javax.jdo.JDOException; //导入依赖的package包/类
@Override
public OAuth2AccessToken readAccessToken(String tokenValue) {
OAuth2AccessToken accessToken = null;
try {
GaeOAuthAccessToken gaeOAuthAccessToken = accessTokens.findByTokenId(extractTokenKey(tokenValue));
if (gaeOAuthAccessToken != null) {
accessToken = gaeOAuthAccessToken.getToken();
} else {
if (LOG.isInfoEnabled()) {
LOG.info("Failed to find access token for token " + tokenValue);
}
}
} catch (JDOException e) {
LOG.warn("Failed to deserialize access token for " + tokenValue, e);
removeAccessToken(tokenValue);
}
return accessToken;
}
示例11: readAuthentication
import javax.jdo.JDOException; //导入依赖的package包/类
@Override
public OAuth2Authentication readAuthentication(String token) {
OAuth2Authentication authentication = null;
try {
GaeOAuthAccessToken gaeOAuthAccessToken = accessTokens.findByTokenId(extractTokenKey(token));
if (gaeOAuthAccessToken != null) {
authentication = gaeOAuthAccessToken.getAuthentication();
} else {
if (LOG.isInfoEnabled()) {
LOG.info("Failed to find access token for token " + token);
}
}
} catch (JDOException e) {
LOG.warn("Failed to deserialize authentication for " + token, e);
removeAccessToken(token);
}
return authentication;
}
示例12: readRefreshToken
import javax.jdo.JDOException; //导入依赖的package包/类
@Override
public OAuth2RefreshToken readRefreshToken(String tokenValue) {
OAuth2RefreshToken refreshToken = null;
try {
GaeOAuthRefreshToken gaeOAuthRefreshToken = refreshTokens.findByTokenId(extractTokenKey(tokenValue));
if (gaeOAuthRefreshToken != null) {
refreshToken = gaeOAuthRefreshToken.getToken();
} else {
if (LOG.isInfoEnabled()) {
LOG.info("Failed to find refresh token for token " + tokenValue);
}
}
} catch (JDOException e) {
LOG.warn("Failed to deserialize refresh token for token " + tokenValue, e);
removeRefreshToken(tokenValue);
}
return refreshToken;
}
示例13: readAuthenticationForRefreshToken
import javax.jdo.JDOException; //导入依赖的package包/类
public OAuth2Authentication readAuthenticationForRefreshToken(String value) {
OAuth2Authentication authentication = null;
try {
GaeOAuthRefreshToken gaeOAuthRefreshToken = refreshTokens.findByTokenId(extractTokenKey(value));
if (gaeOAuthRefreshToken != null) {
authentication = gaeOAuthRefreshToken.getAuthentication();
} else {
if (LOG.isInfoEnabled()) {
LOG.info("Failed to find access token for token " + value);
}
}
} catch (JDOException e) {
LOG.warn("Failed to deserialize access token for " + value, e);
removeRefreshToken(value);
}
return authentication;
}
示例14: findTokensByClientId
import javax.jdo.JDOException; //导入依赖的package包/类
@Override
public Collection<OAuth2AccessToken> findTokensByClientId(String clientId) {
List<OAuth2AccessToken> accessTokens = new ArrayList<OAuth2AccessToken>();
List<GaeOAuthAccessToken> gaeOAuthAccessTokens = this.accessTokens.findByClientId(clientId);
if (gaeOAuthAccessTokens.isEmpty()) {
if (LOG.isInfoEnabled()) {
LOG.info("Failed to find access token for clientId " + clientId);
}
}
for (GaeOAuthAccessToken gaeOAuthAccessToken : gaeOAuthAccessTokens) {
try {
accessTokens.add(gaeOAuthAccessToken.getToken());
} catch (JDOException e) {
this.accessTokens.deleteByTokenId(gaeOAuthAccessToken.getTokenId());
}
}
accessTokens = removeNulls(accessTokens);
return accessTokens;
}
示例15: findTokensByClientIdAndUserName
import javax.jdo.JDOException; //导入依赖的package包/类
@Override
public Collection<OAuth2AccessToken> findTokensByClientIdAndUserName(String clientId, String userName) {
List<OAuth2AccessToken> accessTokens = new ArrayList<OAuth2AccessToken>();
List<GaeOAuthAccessToken> gaeOAuthAccessTokens = this.accessTokens.findByUsernameAndClientId(userName, clientId);
if (gaeOAuthAccessTokens.isEmpty()) {
if (LOG.isInfoEnabled()) {
LOG.info("Failed to find access token for userName " + userName);
}
}
for (GaeOAuthAccessToken gaeOAuthAccessToken : gaeOAuthAccessTokens) {
try {
accessTokens.add(gaeOAuthAccessToken.getToken());
} catch (JDOException e) {
this.accessTokens.deleteByTokenId(gaeOAuthAccessToken.getTokenId());
}
}
accessTokens = removeNulls(accessTokens);
return accessTokens;
}