/** * @deprecated As of Judson (7.1.x), replaced by {@link #getConnection()} */ @Deprecated public static Connection getUpgradeOptimizedConnection() throws SQLException { return getConnection(); }
@Override public void upgrade() throws UpgradeException { try (Connection con = DataAccess.getUpgradeOptimizedConnection()) { if (hasAnyPortletId(con, getPortletIds())) { super.upgrade(); } } catch (SQLException sqle) { throw new UpgradeException(sqle); } }
@Override public void upgrade() throws UpgradeException { try (Connection con = DataAccess.getUpgradeOptimizedConnection()) { if (_getBuildNumber(con, getNewBundleSymbolicName()) == null) { super.upgrade(); } } catch (SQLException sqle) { throw new UpgradeException(sqle); } }
public Connection getUpgradeOptimizedConnection() { try { return DataAccess.getConnection(); } catch (SQLException sqle) { throw new RuntimeException(sqle); } }
public Connection getDataAccess() { try { return DataAccess.getConnection(); } catch (SQLException sqle) { throw new RuntimeException(sqle); } }
protected long getCompanyId(String sql, long primaryKey) throws Exception { long companyId = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = connection.prepareStatement(sql); ps.setLong(1, primaryKey); rs = ps.executeQuery(); while (rs.next()) { companyId = rs.getLong("companyId"); } } finally { DataAccess.cleanUp(ps, rs); } return companyId; }
public static String getDefaultLanguageId(long companyId) throws SQLException { String languageId = _languageIds.get(companyId); if (languageId != null) { return languageId; } try (Connection con = DataAccess.getConnection(); PreparedStatement ps = con.prepareStatement( "select languageId from User_ where companyId = ? and " + "defaultUser = ?")) { ps.setLong(1, companyId); ps.setBoolean(2, true); try (ResultSet rs = ps.executeQuery()) { if (rs.next()) { languageId = rs.getString("languageId"); _languageIds.put(companyId, languageId); return languageId; } return LocaleUtil.toLanguageId(LocaleUtil.US); } } }
/** * @deprecated As of Judson (7.1.x) */ @Deprecated protected void updatePortletPreferences( long portletPreferencesId, String preferences) throws Exception { PreparedStatement ps = null; try { ps = connection.prepareStatement( "update PortletPreferences set preferences = ? where " + "portletPreferencesId = " + portletPreferencesId); ps.setString(1, preferences); ps.executeUpdate(); } finally { DataAccess.cleanUp(ps); } }
public void upgrade() throws UpgradeException { long start = System.currentTimeMillis(); String message = "Completed upgrade process "; try (Connection con = DataAccess.getConnection()) { connection = con; if (isSkipUpgradeProcess()) { return; } if (_log.isInfoEnabled()) { _log.info("Upgrading " + ClassUtil.getClassName(this)); } doUpgrade(); } catch (Throwable t) { message = "Failed upgrade process "; throw new UpgradeException(t); } finally { connection = null; if (_log.isInfoEnabled()) { _log.info( StringBundler.concat( message, ClassUtil.getClassName(this), " in ", String.valueOf(System.currentTimeMillis() - start), " ms")); } } }
protected Object[] getGroup(long groupId) throws Exception { Object[] group = null; PreparedStatement ps = null; ResultSet rs = null; try { ps = connection.prepareStatement( "select companyId from Group_ where groupId = ?"); ps.setLong(1, groupId); rs = ps.executeQuery(); while (rs.next()) { long companyId = rs.getLong("companyId"); group = new Object[] {groupId, companyId}; } } finally { DataAccess.cleanUp(ps, rs); } return group; }
@Override public final Void call() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer(_tableName); Connection connection = DataAccess.getConnection()) { if (_createCompanyIdColumn) { if (_log.isInfoEnabled()) { _log.info( "Adding column companyId to table " + _tableName); } runSQL( connection, "alter table " + _tableName + " add companyId LONG"); } else { if (_log.isInfoEnabled()) { _log.info( "Skipping the creation of companyId column for " + "table " + _tableName); } } update(connection); } return null; }
protected long getRoleId(long companyId, String name) throws Exception { String roleIdsKey = companyId + StringPool.POUND + name; Long roleId = _roleIds.get(roleIdsKey); if (roleId != null) { return roleId; } PreparedStatement ps = null; ResultSet rs = null; try { ps = connection.prepareStatement( "select roleId from Role_ where companyId = ? and name = ?"); ps.setLong(1, companyId); ps.setString(2, name); rs = ps.executeQuery(); if (rs.next()) { roleId = rs.getLong("roleId"); } _roleIds.put(roleIdsKey, roleId); return roleId; } finally { DataAccess.cleanUp(ps, rs); } }
protected Map<String, Long> getBitwiseValues(String name) throws Exception { Map<String, Long> bitwiseValues = _bitwiseValues.get(name); if (bitwiseValues != null) { return bitwiseValues; } PreparedStatement ps = null; ResultSet rs = null; try { ps = connection.prepareStatement( "select actionId, bitwiseValue from ResourceAction where " + "name = ?"); ps.setString(1, name); rs = ps.executeQuery(); bitwiseValues = new HashMap<>(); while (rs.next()) { String actionId = rs.getString("actionId"); long bitwiseValue = rs.getLong("bitwiseValue"); bitwiseValues.put(actionId, bitwiseValue); } _bitwiseValues.put(name, bitwiseValues); return bitwiseValues; } finally { DataAccess.cleanUp(ps, rs); } }
protected Object[] getLayoutRevision(long layoutRevisionId) throws Exception { Object[] layoutRevision = null; PreparedStatement ps = null; ResultSet rs = null; try { ps = connection.prepareStatement( "select groupId, companyId, privateLayout, layoutRevisionId " + "from LayoutRevision where layoutRevisionId = ?"); ps.setLong(1, layoutRevisionId); rs = ps.executeQuery(); while (rs.next()) { long groupId = rs.getLong("groupId"); long companyId = rs.getLong("companyId"); boolean privateLayout = rs.getBoolean("privateLayout"); long layoutId = rs.getLong("layoutRevisionId"); layoutRevision = new Object[] { groupId, companyId, privateLayout, layoutId }; } } finally { DataAccess.cleanUp(ps, rs); } return layoutRevision; }
protected long getRepositoryId( long groupId, long companyId, long userId, String userName, Timestamp createDate, long classNameId, String portletId) throws Exception { PreparedStatement ps = null; ResultSet rs = null; try { ps = connection.prepareStatement( "select repositoryId from Repository where groupId = ? and " + "name = ? and portletId = ?"); ps.setLong(1, groupId); ps.setString(2, portletId); ps.setString(3, portletId); rs = ps.executeQuery(); while (rs.next()) { long repositoryId = rs.getLong(1); return repositoryId; } } finally { DataAccess.cleanUp(ps); } return addRepository( groupId, companyId, userId, userName, createDate, classNameId, portletId); }
protected String getLayoutUuid(long plid, long layoutId) throws Exception { Object[] layout = getLayout(plid); if (layout == null) { return null; } String uuid = null; PreparedStatement ps = null; ResultSet rs = null; try { ps = connection.prepareStatement( "select uuid_ from Layout where groupId = ? and " + "privateLayout = ? and layoutId = ?"); long groupId = (Long)layout[0]; boolean privateLayout = (Boolean)layout[2]; ps.setLong(1, groupId); ps.setBoolean(2, privateLayout); ps.setLong(3, layoutId); rs = ps.executeQuery(); if (rs.next()) { uuid = rs.getString("uuid_"); } } finally { DataAccess.cleanUp(ps, rs); } return uuid; }
protected Object[] getLayout(long plid) throws Exception { Object[] layout = null; PreparedStatement ps = null; ResultSet rs = null; try { ps = connection.prepareStatement( "select groupId, companyId, privateLayout, layoutId from " + "Layout where plid = ?"); ps.setLong(1, plid); rs = ps.executeQuery(); while (rs.next()) { long groupId = rs.getLong("groupId"); long companyId = rs.getLong("companyId"); boolean privateLayout = rs.getBoolean("privateLayout"); long layoutId = rs.getLong("layoutId"); layout = new Object[] { groupId, companyId, privateLayout, layoutId }; } } finally { DataAccess.cleanUp(ps, rs); } if (layout == null) { layout = getLayoutRevision(plid); } return layout; }