public String getUserName() { try { return ejbContext.getCallerPrincipal() != null ? ejbContext.getCallerPrincipal().getName() : null; } catch (Exception e) { e.printStackTrace(); } return null; } }
public boolean isUserArchitect() { try { return ejbContext.isCallerInRole("architect"); } catch (Exception e) { e.printStackTrace(); } return false; }
public void setRollbackOnly() throws IllegalStateException, SystemException { ejbContext.setRollbackOnly(); }
Principal p = ctx.getCallerPrincipal(); String userid = p.getName(); if (p instanceof DatawavePrincipal) { try { ctx.getUserTransaction().begin(); ctx.getUserTransaction().setRollbackOnly(); } catch (Exception ex) { log.error("Error marking transaction for roll back", ex); ctx.getUserTransaction().setRollbackOnly(); } catch (Exception ex) { log.error("Error marking transaction for roll back", ex); ctx.getUserTransaction().setRollbackOnly(); } catch (Exception ex) { log.error("Error marking transaction for roll back", ex); queryCache.unlock(id); try { if (ctx.getUserTransaction().getStatus() == Status.STATUS_MARKED_ROLLBACK) { ctx.getUserTransaction().rollback(); } else if (ctx.getUserTransaction().getStatus() != Status.STATUS_NO_TRANSACTION) { ctx.getUserTransaction().commit();
public boolean isTransactional() { ctx.setRollbackOnly(); return ctx.getRollbackOnly(); } }
public void setTransactionTimeout(int timeout) throws SystemException { ejbContext.getUserTransaction().setTransactionTimeout(timeout); }
public int getStatus() throws SystemException { try { // TODO: not correct for SUPPORTS or NEVER! if (!ejbContext.getRollbackOnly()) { return Status.STATUS_ACTIVE; } else { return Status.STATUS_MARKED_ROLLBACK; } } catch (IllegalStateException ise) { try { return ejbContext.getUserTransaction().getStatus(); } catch (IllegalStateException is) { return Status.STATUS_NO_TRANSACTION; } } }
public void setRollbackOnly() throws IllegalStateException, SystemException { ejbContext.setRollbackOnly(); }
public boolean isTransactional() { ctx.setRollbackOnly(); return ctx.getRollbackOnly(); } }
public void setTransactionTimeout(int timeout) throws SystemException { ejbContext.getUserTransaction().setTransactionTimeout(timeout); }
public int getStatus() throws SystemException { try { //TODO: not correct for SUPPORTS or NEVER! if ( !ejbContext.getRollbackOnly() ) { return Status.STATUS_ACTIVE; } else { return Status.STATUS_MARKED_ROLLBACK; } } catch (IllegalStateException ise) { try { return ejbContext.getUserTransaction().getStatus(); } catch (IllegalStateException is) { return Status.STATUS_NO_TRANSACTION; } } }
@RolesAllowed("architect") public String getUserName() { try { return ejbContext.getCallerPrincipal() != null ? ejbContext.getCallerPrincipal().getName() : null; } catch (Exception e) { e.printStackTrace(); } return null; }
} catch (Exception e) { ejbContext.setRollbackOnly(); throw new RollbackSajgException();
@Override public boolean hasRole(String role) { return context.isCallerInRole(role); }
public void rollback() throws IllegalStateException, SecurityException, SystemException { UserTransaction userTransaction = ejbContext.getUserTransaction(); try { userTransaction.rollback(); } finally { getSynchronizations().afterTransactionRollback(); } }
/** * Find out who/what called this method * * @return */ private DatawavePrincipal getPrincipal() { DatawavePrincipal dp = null; Principal p = ctx.getCallerPrincipal(); if (p instanceof DatawavePrincipal) { dp = (DatawavePrincipal) p; } return dp; }
@TransactionAttribute(TransactionAttributeType.REQUIRED) public void initTransaction() throws SystemException { ctx.setRollbackOnly(); beanManager.fireEvent(new Foo()); } }
public static final boolean inRole(String role) { EJBContext context = ThreadLocalServiceSecurityManager.get(); if (context == null) { return false; } return context.isCallerInRole(role); }
public void begin() throws NotSupportedException, SystemException { ejbContext.getUserTransaction().begin(); getSynchronizations().afterTransactionBegin(); }
@Resource EJBContext context; ... context.getCallerPrincipal()