List of usage examples for javax.ejb TransactionAttributeType SUPPORTS
TransactionAttributeType SUPPORTS
To view the source code for javax.ejb TransactionAttributeType SUPPORTS.
Click Source Link
REQUIRED
case. From source file:com.flexive.ejb.beans.UserGroupEngineBean.java
/** * {@inheritDoc}//from ww w .ja va2s . c o m */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public List<UserGroup> loadAll(long mandatorId) throws FxApplicationException { Connection con = null; Statement stmt = null; String sql = null; try { // Obtain a database connection con = Database.getDbConnection(); // Create the new workflow instance stmt = con.createStatement(); // 1 2 3 4 5 6 sql = "SELECT ID,MANDATOR,NAME,COLOR,AUTOMANDATOR,ISSYSTEM FROM " + TBL_USERGROUPS + // Never display the dummy NULL group " WHERE ID!=" + UserGroup.GROUP_NULL; if (mandatorId != -1) sql += " AND (MANDATOR=" + mandatorId + " or ID in (" + UserGroup.GROUP_EVERYONE + "," + UserGroup.GROUP_OWNER + "))"; sql += " ORDER BY MANDATOR,NAME"; ResultSet rs = stmt.executeQuery(sql); // Process resultset final List<UserGroup> result = new ArrayList<UserGroup>(); while (rs != null && rs.next()) { long autoMandator = rs.getLong(5); if (rs.wasNull()) autoMandator = -1; result.add(new UserGroup(rs.getLong(1), rs.getLong(2), autoMandator, rs.getBoolean(6), rs.getString(3), rs.getString(4))); } // Sanity check if (indexOfSelectableObject(result, UserGroup.GROUP_EVERYONE) == -1 || indexOfSelectableObject(result, UserGroup.GROUP_OWNER) == -1) { FxLoadException le = new FxLoadException("ex.usergroup.oneOfSystemGroupsIsMissing"); LOG.fatal(le); throw le; } return result; } catch (SQLException exc) { FxLoadException de = new FxLoadException(exc, "ex.usergroup.sqlError", exc.getMessage(), sql); LOG.error(de); throw de; } finally { Database.closeObjects(UserGroupEngineBean.class, con, stmt); } }
From source file:fr.ortolang.diffusion.store.binary.BinaryStoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public File getFile(String identifier) throws BinaryStoreServiceException, DataNotFoundException { Path path = getPathForIdentifier(identifier); if (!Files.exists(path)) { throw new DataNotFoundException("Unable to find an object with id [" + identifier + "] in the storage"); }/*from w w w . j av a 2 s . c o m*/ try { return path.toFile(); } catch (Exception e) { throw new BinaryStoreServiceException(e); } }
From source file:com.flexive.ejb.beans.TreeEngineBean.java
/** * {@inheritDoc}// w ww . jav a 2 s . c o m */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public long getIdByFQNPath(FxTreeMode mode, long startNode, String path) throws FxApplicationException { Connection con = null; try { con = Database.getDbConnection(); return StorageManager.getTreeStorage().getIdByFQNPath(con, mode, startNode, path); } catch (FxApplicationException ae) { throw ae; } catch (Throwable t) { throw new FxTreeException(LOG, t, "ex.tree.getIdByPath.failed", path, mode); } finally { Database.closeObjects(TreeEngineBean.class, con, null); } }
From source file:com.flexive.ejb.beans.LanguageBean.java
/** * {@inheritDoc}/*from w ww .j a va 2s. c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public List<FxLanguage> loadDisabled() throws FxApplicationException { return loadAll(false, false); }
From source file:fr.ortolang.diffusion.store.binary.BinaryStoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public long size(String identifier) throws BinaryStoreServiceException, DataNotFoundException { Path path = getPathForIdentifier(identifier); if (!Files.exists(path)) { throw new DataNotFoundException("Unable to find an object with id [" + identifier + "] in the storage"); }/*w w w . j a v a 2 s. c o m*/ try { return Files.size(path); } catch (Exception e) { throw new BinaryStoreServiceException(e); } }
From source file:com.flexive.ejb.beans.LanguageBean.java
/** * {@inheritDoc}/*from www .j a v a 2s. com*/ */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public List<FxLanguage> loadAvailable(boolean excludeSystemLanguage) throws FxApplicationException { List<FxLanguage> tmp = loadAvailable(); ArrayList<FxLanguage> result = new ArrayList<FxLanguage>(); for (FxLanguage lang : tmp) { if (excludeSystemLanguage && lang.getId() == 0) continue; result.add(lang); } return result; }
From source file:com.flexive.ejb.beans.TreeEngineBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public long getIdByLabelPath(FxTreeMode mode, long startNode, String path) throws FxApplicationException { Connection con = null;//from w w w .j av a 2 s .c om try { con = Database.getDbConnection(); return StorageManager.getTreeStorage().getIdByLabelPath(con, mode, startNode, path); } catch (FxApplicationException ae) { throw ae; } catch (Throwable t) { throw new FxTreeException(LOG, t, "ex.tree.getIdByPath.failed", path, mode); } finally { Database.closeObjects(TreeEngineBean.class, con, null); } }
From source file:fr.ortolang.diffusion.store.binary.BinaryStoreServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public String type(String identifier) throws BinaryStoreServiceException, DataNotFoundException { Path path = getPathForIdentifier(identifier); if (!Files.exists(path)) { throw new DataNotFoundException("Unable to find an object with id [" + identifier + "] in the storage"); }/* w ww . ja v a 2 s. co m*/ try { Tika tika = new Tika(); return tika.detect(path.toFile()); } catch (Exception e) { throw new BinaryStoreServiceException(e); } }
From source file:com.flexive.ejb.beans.HistoryTrackerEngineBean.java
/** * {@inheritDoc}//w ww. j av a2 s . c o m */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public void track(FxType type, FxPK pk, String data, String key, Object... args) { Connection con = null; PreparedStatement ps = null; try { final UserTicket ticket = FxContext.getUserTicket(); con = Database.getDbConnection(); ps = con.prepareStatement(StorageManager.escapeReservedWords(HISTORY_INSERT)); ps.setLong(1, ticket.getUserId()); ps.setString(2, ticket.getLoginName()); ps.setLong(3, System.currentTimeMillis()); ps.setString(4, key); StorageManager.setBigString(ps, 5, StringUtils.join(args, '|')); try { ps.setString(6, FxSharedUtils.getLocalizedMessage("History", FxLanguage.ENGLISH, "en", key, args)); } catch (Exception e) { ps.setString(6, key); } FxContext si = FxContext.get(); ps.setString(7, (si.getSessionId() == null ? "<unknown>" : si.getSessionId())); ps.setString(8, (si.getApplicationId() == null ? "<unknown>" : si.getApplicationId())); ps.setString(9, (si.getRemoteHost() == null ? "<unknown>" : si.getRemoteHost())); if (type != null) { ps.setLong(10, type.getId()); ps.setString(11, type.getName()); } else { ps.setNull(10, java.sql.Types.NUMERIC); ps.setNull(11, java.sql.Types.VARCHAR); } if (pk != null) { ps.setLong(12, pk.getId()); ps.setInt(13, pk.getVersion()); } else { ps.setNull(12, java.sql.Types.NUMERIC); ps.setNull(13, java.sql.Types.NUMERIC); } if (data != null) StorageManager.setBigString(ps, 14, data); else ps.setNull(14, java.sql.Types.VARCHAR); ps.executeUpdate(); } catch (Exception ex) { LOG.error(ex.getMessage()); } finally { Database.closeObjects(HistoryTrackerEngineBean.class, con, ps); } }
From source file:com.flexive.ejb.beans.LanguageBean.java
/** * {@inheritDoc}//w ww . j a v a2s . c o m */ @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public boolean isValid(long languageId) { // Does the language exist at all? Check via constructor try { load(languageId); } catch (FxApplicationException exc) { return false; } return true; }