List of usage examples for javax.ejb TransactionAttributeType NOT_SUPPORTED
TransactionAttributeType NOT_SUPPORTED
To view the source code for javax.ejb TransactionAttributeType NOT_SUPPORTED.
Click Source Link
NOT_SUPPORTED
with an unspecified transaction context. From source file:org.ejbca.core.ejb.services.ServiceSessionBean.java
/** * Cancels all existing timeouts for this id. * /*from www . ja va 2 s . co m*/ * @param id the id of the timer */ // We don't want the appserver to persist/update the timer in the same transaction if they are stored in different non XA DataSources. This method // should not be run from within a transaction. @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @Override public void cancelTimer(Integer id) { if (log.isDebugEnabled()) { log.debug("cancelTimer: " + id); } for (Timer next : (Collection<Timer>) timerService.getTimers()) { try { if (id.equals(next.getInfo())) { next.cancel(); break; } } catch (Exception e) { /* * EJB 2.1 only?: We need to catch this because Weblogic 10 * throws an exception if we have not scheduled this timer, so * we don't have anything to cancel. Only weblogic though... */ log.error("Caught exception canceling timer: " + e.getMessage(), e); } } }
From source file:org.ejbca.core.ejb.services.ServiceSessionBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @Override//from w w w . j a v a 2 s. c o m public long getServiceInterval(Integer serviceId) { long ret = IInterval.DONT_EXECUTE; ServiceData htp = serviceDataSession.findById(serviceId); if (htp != null) { ServiceConfiguration serviceConfiguration = htp.getServiceConfiguration(); if (serviceConfiguration.isActive()) { IWorker worker = getWorker(serviceConfiguration, "temp", 0, 0); // A bit dirty, but it works.. if (worker != null) { ret = worker.getNextInterval(); } } else { if (log.isDebugEnabled()) { log.debug("Service " + serviceId + " is inactive."); } } } return ret; }
From source file:org.ejbca.core.ejb.upgrade.UpgradeSessionBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @Override/*from w w w . j av a 2 s .c o m*/ public boolean upgrade(String dbtype, String sOldVersion, boolean isPost) { try { log.debug("Upgrading from version=" + sOldVersion); final int oldVersion; { final String[] oldVersionArray = sOldVersion.split("\\."); // Split around the '.'-char oldVersion = Integer.parseInt(oldVersionArray[0]) * 100 + Integer.parseInt(oldVersionArray[1]); } if (isPost) { return postUpgrade(oldVersion, dbtype); } return upgrade(dbtype, oldVersion); } catch (RuntimeException e) { // We want to log in server.log so we can analyze the error log.error("Error thrown during upgrade: ", e); throw e; } finally { log.trace("<upgrade()"); } }
From source file:org.ejbca.core.protocol.ws.EjbcaWS.java
/** * @throws EndEntityProfileNotFoundException * @see org.ejbca.core.protocol.ws.common.IEjbcaWS#findUser(org.ejbca.core.protocol.ws.objects.UserMatch) *//*www. j a v a2 s . co m*/ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<UserDataVOWS> findUser(UserMatch usermatch) throws AuthorizationDeniedException, IllegalQueryException, EjbcaException, EndEntityProfileNotFoundException { List<UserDataVOWS> retval = null; if (log.isDebugEnabled()) { log.debug("Find user with match '" + usermatch.getMatchvalue() + "'."); } final IPatternLogger logger = TransactionLogger.getPatternLogger(); try { final EjbcaWSHelper ejbhelper = new EjbcaWSHelper(wsContext, authorizationSession, caAdminSession, caSession, certificateProfileSession, certificateStoreSession, endEntityAccessSession, endEntityProfileSession, hardTokenSession, endEntityManagementSession, webAuthenticationSession, cryptoTokenManagementSession); final AuthenticationToken admin = ejbhelper.getAdmin(); logAdminName(admin, logger); final Query query = ejbhelper.convertUserMatch(admin, usermatch); final Collection<EndEntityInformation> result = endEntityManagementSession.query(admin, query, null, null, MAXNUMBEROFROWS); // also checks authorization if (result.size() > 0) { retval = new ArrayList<UserDataVOWS>(result.size()); for (final EndEntityInformation userdata : result) { retval.add(ejbhelper.convertEndEntityInformation(userdata)); } } } catch (CesecoreException e) { // Convert cesecore exception to EjbcaException EjbcaWSHelper.getEjbcaException(e, null, e.getErrorCode(), null); } catch (RuntimeException e) { // ClassCastException, EJBException ... throw EjbcaWSHelper.getInternalException(e, logger); } finally { logger.writeln(); logger.flush(); } return retval; }
From source file:org.ejbca.core.protocol.ws.EjbcaWS.java
/** * @see org.ejbca.core.protocol.ws.common.IEjbcaWS#findCerts(java.lang.String, boolean) */// ww w . j av a 2 s . c om @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<Certificate> findCerts(String username, boolean onlyValid) throws AuthorizationDeniedException, EjbcaException { if (log.isDebugEnabled()) { log.debug("Find certs for user '" + username + "'."); } final IPatternLogger logger = TransactionLogger.getPatternLogger(); List<Certificate> retval = new ArrayList<Certificate>(0); try { final EjbcaWSHelper ejbhelper = new EjbcaWSHelper(wsContext, authorizationSession, caAdminSession, caSession, certificateProfileSession, certificateStoreSession, endEntityAccessSession, endEntityProfileSession, hardTokenSession, endEntityManagementSession, webAuthenticationSession, cryptoTokenManagementSession); final AuthenticationToken admin = ejbhelper.getAdmin(); logAdminName(admin, logger); if (endEntityAccessSession.findUser(admin, username) != null) { // checks authorization on CA and profiles and view_end_entity Collection<java.security.cert.Certificate> certs; if (onlyValid) { certs = certificateStoreSession.findCertificatesByUsernameAndStatus(username, CertificateConstants.CERT_ACTIVE); } else { certs = certificateStoreSession.findCertificatesByUsername(username); } retval = ejbhelper.returnAuthorizedCertificates(admin, certs, onlyValid); } else { if (log.isDebugEnabled()) { log.debug(intres.getLocalizedMessage("ra.errorentitynotexist", username)); } } } catch (RuntimeException e) { // EJBException ... throw EjbcaWSHelper.getInternalException(e, logger); } finally { logger.writeln(); logger.flush(); } return retval; }
From source file:org.ejbca.core.protocol.ws.EjbcaWS.java
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public boolean isAuthorized(String resource) throws EjbcaException { final IPatternLogger logger = TransactionLogger.getPatternLogger(); try {//from ww w . j av a 2 s .c o m final EjbcaWSHelper ejbhelper = new EjbcaWSHelper(wsContext, authorizationSession, caAdminSession, caSession, certificateProfileSession, certificateStoreSession, endEntityAccessSession, endEntityProfileSession, hardTokenSession, endEntityManagementSession, webAuthenticationSession, cryptoTokenManagementSession); final AuthenticationToken admin = ejbhelper.getAdmin(); logAdminName(admin, logger); return authorizationSession.isAuthorized(admin, resource); } catch (AuthorizationDeniedException ade) { return false; } catch (RuntimeException e) { // EJBException, ClassCastException, ... throw EjbcaWSHelper.getInternalException(e, logger); } finally { logger.writeln(); logger.flush(); } }
From source file:org.gss_project.gss.server.ejb.ExternalAPIBean.java
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public File uploadFile(InputStream stream, Long userId) throws IOException, ObjectNotFoundException { if (userId == null) throw new ObjectNotFoundException("No user specified"); User owner = dao.getEntityById(User.class, userId); if (owner == null) throw new ObjectNotFoundException("No user specified"); long start = 0, end = 0; if (logger.isDebugEnabled()) start = System.currentTimeMillis(); File result = new File(generateRepositoryFilePath()); try {//from w ww.ja v a2s . c om final FileOutputStream output = new FileOutputStream(result); final byte[] buffer = new byte[UPLOAD_BUFFER_SIZE]; int n = 0; while (-1 != (n = stream.read(buffer))) output.write(buffer, 0, n); output.close(); stream.close(); } catch (IOException e) { if (!result.delete()) logger.warn("Could not delete " + result.getPath()); throw e; } if (logger.isDebugEnabled()) { end = System.currentTimeMillis(); logger.debug("Time to upload: " + (end - start) + " (msec)"); } return result; }
From source file:org.jboss.ejb3.test.entity.EntityTestBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void testOutsideTransaction() { Transaction tx = null;// w w w .jav a2 s. c om try { tx = tm.getTransaction(); } catch (SystemException e) { throw new RuntimeException(e); } if (tx != null) throw new RuntimeException("THERE IS A TRANSACTION!!!"); Query q = manager.createQuery("SELECT c FROM Customer c"); List l = q.getResultList(); if (l.size() == 0) throw new RuntimeException("failed"); org.hibernate.Query q2 = session.createQuery("Select c FROM Customer c"); l = q2.list(); if (l.size() == 0) throw new RuntimeException("failed"); }
From source file:org.jboss.test.jpa.entity.EntityTestBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void testOutsideTransaction() { Transaction tx = null;//from ww w.ja v a 2 s . c o m try { tx = tm.getTransaction(); } catch (SystemException e) { throw new RuntimeException(e); } if (tx != null) throw new RuntimeException("THERE IS A TRANSACTION!!!"); Query q = manager.createQuery("SELECT c FROM Customer c"); List l = q.getResultList(); if (l.size() == 0) throw new RuntimeException("failed"); org.hibernate.Query q2 = session.createQuery("FROM Customer c"); l = q2.list(); if (l.size() == 0) throw new RuntimeException("failed"); }
From source file:org.rhq.core.domain.test.SetupBean.java
@PostConstruct @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void init() throws RuntimeException { LOG.info("Begin core domain tests setup"); LOG.info("RHQ_VERSION = " + RHQ_VERSION); createStorageNodeVersionColumnIfNeeded(); createServerVersionColumnIfNeeded(); LOG.info("End core domain tests setup"); }