/** * Method declaration * * @return * @see */ private Connection getConnection() { try { Connection con = DBUtil.makeConnection(dbName); return con; } catch (Exception e) { throw new FavoritRuntimeException("root.MSG_GEN_CONNECTION_OPEN_FAILED", e); } }
/** @return the DB connection */ private Connection getConnection() throws WorkflowException { try { Connection con = DBUtil.makeConnection(dbName); return con; } catch (Exception e) { throw new WorkflowException( "ProcessInstanceManagerImpl.getConnection()", "root.EX_CONNECTION_OPEN_FAILED", e); } }
private Connection getConnection() { try { return DBUtil.makeConnection(JNDINames.STATISTIC_DATASOURCE); } catch (Exception e) { throw new StatisticRuntimeException( "StatisticBmEJB().getConnection()", SilverpeasRuntimeException.ERROR, "root.EX_CONNECTION_OPEN_FAILED", e); } }
/** * Method declaration * * @return * @see */ private Connection getConnection() { try { return DBUtil.makeConnection(dbName); } catch (Exception e) { throw new SubscribeRuntimeException( "SubscribeBmEJB.getConnection()", SilverpeasRuntimeException.ERROR, "root.EX_CONNECTION_OPEN_FAILED", e); } }
/** * Method declaration * * @return * @see */ private static Connection getConnection() { try { return DBUtil.makeConnection(DB_NAME); } catch (Exception e) { throw new StatisticsRuntimeException( "SilverStatisticsManagerDAO.getConnection()", SilverpeasRuntimeException.ERROR, "root.EX_CONNECTION_OPEN_FAILED", "DbName=" + DB_NAME, e); } }
/** getConnection */ private Connection getConnection() throws PersistenceException { try { Connection con = null; switch (connectionType) { case CONNECTION_TYPE_DATASOURCE: { con = DBUtil.makeConnection(datasourceName); break; } case CONNECTION_TYPE_JDBC_CLASSIC: { Class.forName(jdbcConnectionParameters.JDBCdriverName); con = DriverManager.getConnection( jdbcConnectionParameters.JDBCurl, jdbcConnectionParameters.JDBClogin, jdbcConnectionParameters.JDBCpassword); break; } case CONNECTION_TYPE_DATASOURCE_SILVERPEAS: { con = DBUtil.makeConnection(JNDINames.PERSISTENCE_DB_DATASOURCE); break; } default: { con = DBUtil.makeConnection(JNDINames.PERSISTENCE_EJB_DATASOURCE); break; } } return con; } catch (Exception e) { throw new PersistenceException( "SilverpeasBeanDAOImpl.getConnection()", SilverpeasException.ERROR, "root.EX_CONNECTION_OPEN_FAILED", "", e); } }
private Connection getConnection() throws AttachmentException { SilverTrace.info("attachment", "AttachmentBmImpl.getConnection()", "root.MSG_GEN_ENTER_METHOD"); try { Connection con = DBUtil.makeConnection(JNDINames.ATTACHMENT_DATASOURCE); return con; } catch (Exception e) { throw new AttachmentException( "AttachmentBmImpl.getConnection()", SilverpeasException.ERROR, "root.EX_CONNECTION_OPEN_FAILED", e); } }
/** * Method declaration * * @return * @see */ private Connection getConnection() { try { Connection con = DBUtil.makeConnection(dbName); return con; } catch (Exception e) { throw new StatisticRuntimeException( "StatisticBmEJB().getConnection()", SilverpeasRuntimeException.ERROR, "root.EX_CONNECTION_OPEN_FAILED", e); } }
public Group getGroup(String groupId) throws AdminException { Connection con = null; try { con = DBUtil.makeConnection(JNDINames.ADMIN_DATASOURCE); Group group = groupDao.getGroup(con, groupId); return group; } catch (Exception e) { throw new AdminException( "GroupManager.getGroup", SilverpeasException.ERROR, "admin.EX_ERR_GET_GROUP", e); } finally { DBUtil.close(con); } }
private Connection initCon() { Connection con; // initialisation de la connexion try { con = DBUtil.makeConnection(JNDINames.DATABASE_DATASOURCE); } catch (UtilException e) { // traitement des exceptions throw new ResourcesManagerRuntimeException( "ResourcesManagerBmEJB.initCon()", SilverpeasException.ERROR, "root.EX_CONNECTION_OPEN_FAILED", e); } return con; }
@Override public void updateThumbnail(ThumbnailDetail thumbDetail) throws ThumbnailException { Connection con = null; try { con = DBUtil.makeConnection(JNDINames.THUMBNAIL_DATASOURCE); dao.updateThumbnail(con, thumbDetail); } catch (SQLException se) { throw new ThumbnailException( "ThumbnailBmImpl.updateAttachment()", SilverpeasException.ERROR, "thumbnail.EX_MSG_RECORD_NOT_UPDATE", se); } finally { DBUtil.close(con); } }
@Override public void deleteAllThumbnail(String componentId) throws ThumbnailException { Connection con = null; try { con = DBUtil.makeConnection(JNDINames.THUMBNAIL_DATASOURCE); dao.deleteAllThumbnails(con, componentId); } catch (SQLException se) { throw new ThumbnailException( "ThumbnailBmImpl.deleteAllThumbnail()", SilverpeasException.ERROR, "thumbnail_MSG_DELETE_ALL_FAILED", se); } finally { DBUtil.close(con); } }
/** * Get the all the sub groups id of a given group * * @param superGroupId * @return * @throws AdminException */ public List<String> getAllSubGroupIdsRecursively(String superGroupId) throws AdminException { Connection con = null; try { con = DBUtil.makeConnection(JNDINames.ADMIN_DATASOURCE); return getSubGroupIds(con, superGroupId); } catch (Exception e) { throw new AdminException( "GroupManager.getAllSubGroupIdsRecursively", SilverpeasException.ERROR, "admin.EX_ERR_GET_CHILDREN_GROUP_IDS", "father group Id: '" + superGroupId + "'", e); } finally { DBUtil.close(con); } }
@Override public void deleteThumbnail(ThumbnailDetail thumbDetail) throws ThumbnailException { Connection con = null; try { con = DBUtil.makeConnection(JNDINames.THUMBNAIL_DATASOURCE); dao.deleteThumbnail( con, thumbDetail.getObjectId(), thumbDetail.getObjectType(), thumbDetail.getInstanceId()); } catch (SQLException se) { throw new ThumbnailException( "ThumbnailBmImpl.deleteThumbnail()", SilverpeasException.ERROR, "thumbnail.EX_MSG_RECORD_NOT_DELETE", se); } finally { DBUtil.close(con); } }
@Override public void moveThumbnail(ThumbnailDetail thumbDetail, String toInstanceId) throws ThumbnailException { Connection con = null; try { con = DBUtil.makeConnection(JNDINames.THUMBNAIL_DATASOURCE); dao.moveThumbnail(con, thumbDetail, toInstanceId); } catch (SQLException se) { throw new ThumbnailException( "ThumbnailBmImpl.moveThumbnail()", SilverpeasException.ERROR, "thumbnail.EX_MSG_CANT_MOVE_THUMBNAIL", se); } finally { DBUtil.close(con); } }
public List<String> getManageableGroupIds(String userId, List<String> groupIds) throws AdminException { Connection con = null; try { con = DBUtil.makeConnection(JNDINames.ADMIN_DATASOURCE); return groupDao.getManageableGroupIds(con, userId, groupIds); } catch (Exception e) { throw new AdminException( "GroupManager.getManageableGroupIds", SilverpeasException.ERROR, "admin.EX_ERR_GET_USER_MANAGEABLE_GROUP_IDS", e); } finally { DBUtil.close(con); } }
public List<String> getSuggestions(String fieldName, String templateName, String componentId) { List<String> suggestions = new ArrayList<String>(); Connection connection = null; PreparedStatement statement = null; ResultSet rs = null; try { connection = DBUtil.makeConnection(JNDINames.FORMTEMPLATE_DATASOURCE); statement = connection.prepareStatement(suggestionsQuery); statement.setString(1, fieldName); statement.setString(2, componentId + ":" + templateName); SilverTrace.debug( "formTemplate", "TextFieldImpl.getSuggestions", "root.MSG_GEN_PARAM_VALUE", "fieldName = " + fieldName + ", componentId = " + componentId + ", templateName = " + templateName); rs = statement.executeQuery(); String oneSuggestion = ""; while (rs.next()) { oneSuggestion = rs.getString(1); if (StringUtil.isDefined(oneSuggestion)) suggestions.add(oneSuggestion); } } catch (Exception e) { SilverTrace.error( "formTemplate", "TextFieldImpl.getSuggestions", "root.EX_SQL_QUERY_FAILED", e); } finally { DBUtil.close(rs, statement); try { if (connection != null && !connection.isClosed()) connection.close(); } catch (SQLException e) { SilverTrace.error( "formTemplate", "TextFieldImpl.getSuggestions", "root.EX_CONNECTION_CLOSE_FAILED", e); } } return suggestions; }
@Override public ThumbnailDetail getCompleteThumbnail(ThumbnailDetail thumbDetail) throws ThumbnailException { Connection con = null; try { con = DBUtil.makeConnection(JNDINames.THUMBNAIL_DATASOURCE); return dao.selectByKey( con, thumbDetail.getInstanceId(), thumbDetail.getObjectId(), thumbDetail.getObjectType()); } catch (SQLException se) { throw new ThumbnailException( "ThumbnailBmImpl.getCompleteThumbnail()", SilverpeasException.ERROR, "thumbnail.EX_MSG_NOT_FOUND", se); } finally { DBUtil.close(con); } }
/** * Gets the groups that match the specified criteria. * * @param criteria the criteria in searching of user groups. * @return an array of user groups matching the criteria or an empty array of no ones are found. * @throws AdminException if an error occurs while getting the user groups. */ public Group[] getGroupsMatchingCriteria(final GroupSearchCriteriaForDAO criteria) throws AdminException { Connection connection = null; try { connection = DBUtil.makeConnection(JNDINames.ADMIN_DATASOURCE); List<Group> groups = groupDao.getGroupsByCriteria(connection, (GroupSearchCriteriaForDAO) criteria); String domainIdConstraint = null; List<String> domainIds = criteria.getCriterionOnDomainIds(); for (String domainId : domainIds) { if (!domainId.equals(Domain.MIXED_DOMAIN_ID)) { domainIdConstraint = domainId; break; } } SearchCriteriaDAOFactory factory = SearchCriteriaDAOFactory.getFactory(); for (Group group : groups) { List<String> groupIds = getAllSubGroupIdsRecursively(group.getId()); groupIds.add(group.getId()); UserSearchCriteriaForDAO criteriaOnUsers = factory.getUserSearchCriteriaDAO(); List<UserDetail> users = userDao.getUsersByCriteria( connection, criteriaOnUsers .onDomainId(domainIdConstraint) .and() .onGroupIds(groupIds.toArray(new String[groupIds.size()]))); group.setTotalNbUsers(users.size()); } return groups.toArray(new Group[groups.size()]); } catch (Exception e) { throw new AdminException( "GroupManager.getGroupsMatchingCriteria", SilverpeasException.ERROR, "admin.EX_ERR_GET_USER_GROUPS", e); } finally { DBUtil.close(connection); } }
@Override public ThumbnailDetail createThumbnail(ThumbnailDetail thumbDetail) throws ThumbnailException { Connection con = null; try { con = DBUtil.makeConnection(JNDINames.THUMBNAIL_DATASOURCE); return dao.insertThumbnail(con, thumbDetail); } catch (SQLException se) { throw new ThumbnailException( "ThumbnailBmImpl.createThumbnail()", SilverpeasException.ERROR, "thumbnail.EX_INSERT_ROW", se); } catch (UtilException e) { throw new ThumbnailException( "ThumbnailBmImpl.createThumbnail()", SilverpeasException.ERROR, "thumbnail.EX_MSG_RECORD_NOT_INSERT", e); } finally { DBUtil.close(con); } }