0001: /* Copyright 2001, 2002 The JA-SIG Collaborative. All rights reserved.
0002: * See license distributed with this file and
0003: * available online at http://www.uportal.org/license.html
0004: */
0005:
0006: package org.jasig.portal;
0007:
0008: import java.sql.Connection;
0009: import java.sql.PreparedStatement;
0010: import java.sql.ResultSet;
0011: import java.sql.SQLException;
0012: import java.sql.Statement;
0013: import java.util.ArrayList;
0014: import java.util.Date;
0015: import java.util.Iterator;
0016: import java.util.List;
0017:
0018: import org.apache.commons.logging.Log;
0019: import org.apache.commons.logging.LogFactory;
0020: import org.apache.pluto.om.common.Preference;
0021: import org.apache.pluto.om.common.PreferenceSet;
0022: import org.jasig.portal.channels.portlet.CPortletAdapter;
0023: import org.jasig.portal.container.om.common.PreferenceSetImpl;
0024: import org.jasig.portal.groups.GroupsException;
0025: import org.jasig.portal.groups.IEntity;
0026: import org.jasig.portal.groups.IEntityGroup;
0027: import org.jasig.portal.groups.IGroupConstants;
0028: import org.jasig.portal.groups.IGroupMember;
0029: import org.jasig.portal.groups.ILockableEntityGroup;
0030: import org.jasig.portal.i18n.LocaleManager;
0031: import org.jasig.portal.properties.PropertiesManager;
0032: import org.jasig.portal.rdbm.DatabaseMetaDataImpl;
0033: import org.jasig.portal.security.IPerson;
0034: import org.jasig.portal.services.EntityCachingService;
0035: import org.jasig.portal.services.GroupService;
0036: import org.jasig.portal.tools.versioning.VersionsManager;
0037: import org.jasig.portal.utils.CounterStoreFactory;
0038:
0039: /**
0040: * Reference implementation of IChannelRegistryStore.
0041: * @author Ken Weiner, kweiner@unicon.net
0042: * @version $Revision: 42099 $
0043: */
0044: public class RDBMChannelRegistryStore implements IChannelRegistryStore {
0045:
0046: private static final Log log = LogFactory
0047: .getLog(RDBMChannelRegistryStore.class);
0048:
0049: /**
0050: * Add join queries for databases that are known to support them
0051: */
0052: static {
0053: try {
0054: if (RDBMServices.getDbMetaData().supportsOuterJoins()) {
0055: if (RDBMServices.getDbMetaData().getJoinQuery() instanceof DatabaseMetaDataImpl.JdbcDb) {
0056: RDBMServices
0057: .getDbMetaData()
0058: .getJoinQuery()
0059: .addQuery(
0060: "channel",
0061: "{oj UP_CHANNEL UC LEFT OUTER JOIN UP_CHANNEL_PARAM UCP ON UC.CHAN_ID = UCP.CHAN_ID} WHERE");
0062: } else if (RDBMServices.getDbMetaData().getJoinQuery() instanceof DatabaseMetaDataImpl.PostgreSQLDb) {
0063: RDBMServices
0064: .getDbMetaData()
0065: .getJoinQuery()
0066: .addQuery(
0067: "channel",
0068: "UP_CHANNEL UC LEFT OUTER JOIN UP_CHANNEL_PARAM UCP ON UC.CHAN_ID = UCP.CHAN_ID WHERE");
0069: } else if (RDBMServices.getDbMetaData().getJoinQuery() instanceof DatabaseMetaDataImpl.OracleDb) {
0070: RDBMServices
0071: .getDbMetaData()
0072: .getJoinQuery()
0073: .addQuery("channel",
0074: "UP_CHANNEL UC, UP_CHANNEL_PARAM UCP WHERE UC.CHAN_ID = UCP.CHAN_ID(+) AND");
0075: } else {
0076: throw new Exception("Unknown database driver");
0077: }
0078: }
0079: } catch (Exception e) {
0080: log
0081: .error(
0082: "RDBMChannelRegistryStore: Error in static initializer",
0083: e);
0084: }
0085: }
0086:
0087: // I18n property
0088: protected static final boolean localeAware = PropertiesManager
0089: .getPropertyAsBoolean(
0090: "org.jasig.portal.i18n.LocaleManager.locale_aware",
0091: LocaleManager.DEFAULT_LOCALE_AWARE);
0092:
0093: /**
0094: * Create a new ChannelType object.
0095: * @return channelType, the new channel type
0096: * @throws java.lang.Exception
0097: */
0098: public ChannelType newChannelType() throws Exception {
0099: int nextChanTypeId = CounterStoreFactory.getCounterStoreImpl()
0100: .getIncrementIntegerId("UP_CHAN_TYPE");
0101: return new ChannelType(nextChanTypeId);
0102: }
0103:
0104: /**
0105: * Get the channel type associated with a particular identifier.
0106: * @param channelTypeId the channel type identifier
0107: * @return channelType the channel type
0108: * @throws java.sql.SQLException
0109: */
0110: public ChannelType getChannelType(int channelTypeId)
0111: throws SQLException {
0112: ChannelType channelType = null;
0113: Connection con = RDBMServices.getConnection();
0114:
0115: try {
0116: Statement stmt = con.createStatement();
0117: try {
0118: String query = "SELECT * FROM UP_CHAN_TYPE WHERE TYPE_ID="
0119: + channelTypeId;
0120: if (log.isDebugEnabled())
0121: log
0122: .debug("RDBMChannelRegistryStore.getChannelType(): "
0123: + query);
0124: ResultSet rs = stmt.executeQuery(query);
0125: try {
0126: if (rs.next()) {
0127: String javaClass = rs.getString("TYPE");
0128: String name = rs.getString("TYPE_NAME");
0129: String descr = rs.getString("TYPE_DESCR");
0130: String cpdUri = rs.getString("TYPE_DEF_URI");
0131:
0132: channelType = new ChannelType(channelTypeId);
0133: channelType.setJavaClass(javaClass);
0134: channelType.setName(name);
0135: channelType.setDescription(descr);
0136: channelType.setCpdUri(cpdUri);
0137: }
0138: } finally {
0139: rs.close();
0140: }
0141: } finally {
0142: stmt.close();
0143: }
0144: } finally {
0145: RDBMServices.releaseConnection(con);
0146: }
0147: return channelType;
0148: }
0149:
0150: /**
0151: * Get channel types.
0152: * @return types, the channel types
0153: * @throws java.sql.SQLException
0154: */
0155: public ChannelType[] getChannelTypes() throws SQLException {
0156: ChannelType[] channelTypes = null;
0157: Connection con = RDBMServices.getConnection();
0158:
0159: try {
0160: Statement stmt = con.createStatement();
0161: try {
0162: String query = "SELECT TYPE_ID, TYPE, TYPE_NAME, TYPE_DESCR, TYPE_DEF_URI FROM UP_CHAN_TYPE";
0163: if (log.isDebugEnabled())
0164: log
0165: .debug("RDBMChannelRegistryStore.getChannelTypes(): "
0166: + query);
0167: ResultSet rs = stmt.executeQuery(query);
0168: try {
0169: List channelTypesList = new ArrayList();
0170: while (rs.next()) {
0171: int channelTypeId = rs.getInt(1);
0172: String javaClass = rs.getString(2);
0173: String name = rs.getString(3);
0174: String descr = rs.getString(4);
0175: String cpdUri = rs.getString(5);
0176:
0177: ChannelType channelType = new ChannelType(
0178: channelTypeId);
0179: channelType.setJavaClass(javaClass);
0180: channelType.setName(name);
0181: channelType.setDescription(descr);
0182: channelType.setCpdUri(cpdUri);
0183: channelTypesList.add(channelType);
0184: }
0185: channelTypes = (ChannelType[]) channelTypesList
0186: .toArray(new ChannelType[0]);
0187: } finally {
0188: rs.close();
0189: }
0190: } finally {
0191: stmt.close();
0192: }
0193: } finally {
0194: RDBMServices.releaseConnection(con);
0195: }
0196: return channelTypes;
0197: }
0198:
0199: /**
0200: * Persists a channel type.
0201: * @param chanType a channel type
0202: * @throws java.sql.SQLException
0203: */
0204: public void saveChannelType(ChannelType chanType)
0205: throws SQLException {
0206: Connection con = null;
0207:
0208: // Check if channel type exists. If it doesn't exist, do an insert.
0209: // Otherwise, do an update.
0210: ChannelType chanTypeInStore = getChannelType(chanType.getId());
0211: int chanTypeId = chanType.getId();
0212: String javaClass = chanType.getJavaClass();
0213: String name = chanType.getName();
0214: String descr = chanType.getDescription();
0215: String cpdUri = chanType.getCpdUri();
0216: con = RDBMServices.getConnection();
0217:
0218: if (chanTypeInStore == null) {
0219: try {
0220: String insert = "INSERT INTO UP_CHAN_TYPE VALUES ("
0221: + "?, ?, ?, ?, ?)";
0222: PreparedStatement pstmt = con.prepareStatement(insert);
0223: try {
0224: pstmt.setInt(1, chanTypeId);
0225: pstmt.setString(2, javaClass);
0226: pstmt.setString(3, name);
0227: pstmt.setString(4, descr);
0228: pstmt.setString(5, cpdUri);
0229:
0230: if (log.isDebugEnabled())
0231: log.debug("Save Channel Type SQL('"
0232: + chanTypeId + "', " + "'" + javaClass
0233: + "', " + "'" + name + "', " + "'"
0234: + descr + "', " + "'" + cpdUri + "'): "
0235: + insert);
0236: pstmt.executeUpdate();
0237: } finally {
0238: pstmt.close();
0239: }
0240: } finally {
0241: RDBMServices.releaseConnection(con);
0242: }
0243: } else {
0244: // The channel type exists, so do an update
0245: try {
0246: String update = "UPDATE UP_CHAN_TYPE SET TYPE=?, TYPE_NAME=?, "
0247: + "TYPE_DESCR=?, TYPE_DEF_URI=? WHERE TYPE_ID=?";
0248: PreparedStatement pstmt = con.prepareStatement(update);
0249: try {
0250: pstmt.setString(1, javaClass);
0251: pstmt.setString(2, name);
0252: pstmt.setString(3, descr);
0253: pstmt.setString(4, cpdUri);
0254: pstmt.setInt(5, chanTypeId);
0255: if (log.isDebugEnabled())
0256: log.debug("Save Channel Type SQL('" + javaClass
0257: + "', " + "'" + name + "', " + "'"
0258: + descr + "', " + "'" + cpdUri + "'"
0259: + chanTypeId + "', " + "'): " + update);
0260: pstmt.executeUpdate();
0261: } finally {
0262: pstmt.close();
0263: }
0264: } finally {
0265: RDBMServices.releaseConnection(con);
0266: }
0267: }
0268: }
0269:
0270: /**
0271: * Deletes a channel type. The deletion will only succeed if no existing
0272: * channels reference the channel type.
0273: * @param chanType a channel type
0274: * @throws java.sql.SQLException
0275: */
0276: public void deleteChannelType(ChannelType chanType)
0277: throws SQLException {
0278: Connection con = null;
0279:
0280: try {
0281: con = RDBMServices.getConnection();
0282:
0283: // Set autocommit false for the connection
0284: RDBMServices.setAutoCommit(con, false);
0285: Statement stmt = con.createStatement();
0286:
0287: try {
0288: // First check to see if any channels are still referencing this channel type
0289: int chanTypeId = chanType.getId();
0290: String select = "SELECT * FROM UP_CHANNEL WHERE CHAN_TYPE_ID="
0291: + chanTypeId;
0292: if (log.isDebugEnabled())
0293: log
0294: .debug("RDBMChannelRegistryStore.deleteChannelType(): "
0295: + select);
0296: ResultSet rs = stmt.executeQuery(select);
0297:
0298: // If there are channels referencing this channel type, throw an exception
0299: if (rs.next()) {
0300: String message = "Cannot delete channel type "
0301: + chanTypeId
0302: + ". It is still in use by channels ";
0303: do {
0304: int channelPublishId = rs.getInt("CHAN_ID");
0305: message += channelPublishId + " ";
0306: } while (rs.next());
0307: throw new SQLException(message);
0308: // Otherwise delete the channel type
0309: } else {
0310: String delete = "DELETE FROM UP_CHAN_TYPE WHERE TYPE_ID="
0311: + chanTypeId;
0312: if (log.isDebugEnabled())
0313: log
0314: .debug("RDBMChannelRegistryStore.deleteChannelType(): "
0315: + delete);
0316: stmt.executeUpdate(delete);
0317: }
0318:
0319: // Commit the transaction
0320: RDBMServices.commit(con);
0321: } catch (SQLException sqle) {
0322: // Roll back the transaction
0323: RDBMServices.rollback(con);
0324: throw sqle;
0325: } finally {
0326: stmt.close();
0327: }
0328: } finally {
0329: RDBMServices.releaseConnection(con);
0330: }
0331: }
0332:
0333: /**
0334: * Create a new ChannelDefinition object.
0335: * @return channelDefinition, the new channel definition
0336: * @throws java.lang.Exception
0337: */
0338: public ChannelDefinition newChannelDefinition() throws Exception {
0339: int nextChanDefId = CounterStoreFactory.getCounterStoreImpl()
0340: .getIncrementIntegerId("UP_CHANNEL");
0341: return new ChannelDefinition(nextChanDefId);
0342: }
0343:
0344: /**
0345: * Create a new ChannelDefinition object.
0346: * @return channelDefinition, the new channel definition
0347: * @throws java.lang.Exception
0348: */
0349: public ChannelDefinition newChannelDefinition(final int id)
0350: throws Exception {
0351: return new ChannelDefinition(id);
0352: }
0353:
0354: /**
0355: * Get a channel definition.
0356: * @param channelPublishId a channel publish ID
0357: * @return channelDefinition, a definition of the channel or <code>null</code>
0358: * if no matching channel definition can be found
0359: * @throws java.sql.SQLException
0360: * @throws java.lang.IllegalArgumentException
0361: */
0362: public ChannelDefinition getChannelDefinition(int channelPublishId)
0363: throws SQLException {
0364: if (channelPublishId < 1) {
0365: throw new IllegalArgumentException(
0366: "Invalid channel Id requested: " + channelPublishId);
0367: }
0368:
0369: ChannelDefinition channelDef = null;
0370:
0371: // Check the cache
0372: try {
0373: channelDef = (ChannelDefinition) EntityCachingService
0374: .instance().get(ChannelDefinition.class,
0375: String.valueOf(channelPublishId));
0376: } catch (Exception e) {
0377: log.error(
0378: "Error checking cache for definition of channel with publish id "
0379: + channelPublishId, e);
0380: }
0381:
0382: // If not found in cache, get it from the store and cache it, otherwise return it
0383: if (channelDef == null) {
0384: Connection con = null;
0385: PreparedStatement pstmtChannel = null;
0386: PreparedStatement pstmtChannelParam = null;
0387: PreparedStatement pstmtChannelMdata = null;
0388: ResultSet rs = null;
0389:
0390: try {
0391: con = RDBMServices.getConnection();
0392: pstmtChannel = getChannelPstmt(con);
0393: pstmtChannelParam = getChannelParamPstmt(con);
0394: pstmtChannelMdata = getChannelMdataPstmt(con);
0395: pstmtChannel.setInt(1, channelPublishId);
0396: if (log.isDebugEnabled())
0397: log
0398: .debug("RDBMChannelRegistryStore.getChannelDefinition(): "
0399: + pstmtChannel);
0400: rs = pstmtChannel.executeQuery();
0401:
0402: if (rs.next()) {
0403: int chanType = rs.getInt(4);
0404: if (rs.wasNull()) {
0405: chanType = 0;
0406: }
0407: int publisherId = rs.getInt(5);
0408: if (rs.wasNull()) {
0409: publisherId = 0;
0410: }
0411: int approverId = rs.getInt(6);
0412: if (rs.wasNull()) {
0413: approverId = 0;
0414: }
0415: int timeout = rs.getInt(9);
0416: if (rs.wasNull()) {
0417: timeout = 0;
0418: }
0419: channelDef = new ChannelDefinition(channelPublishId);
0420: channelDef.setTitle(rs.getString(1));
0421: channelDef.setDescription(rs.getString(2));
0422: channelDef.setJavaClass(rs.getString(3));
0423: channelDef.setTypeId(chanType);
0424: channelDef.setPublisherId(publisherId);
0425: channelDef.setApproverId(approverId);
0426: channelDef.setPublishDate(rs.getTimestamp(7));
0427: channelDef.setApprovalDate(rs.getTimestamp(8));
0428: channelDef.setTimeout(timeout);
0429: channelDef.setEditable(RDBMServices.dbFlag(rs
0430: .getString(10)));
0431: channelDef.setHasHelp(RDBMServices.dbFlag(rs
0432: .getString(11)));
0433: channelDef.setHasAbout(RDBMServices.dbFlag(rs
0434: .getString(12)));
0435: channelDef.setName(rs.getString(13));
0436: channelDef.setFName(rs.getString(14));
0437: channelDef.setIsSecure(RDBMServices.dbFlag(rs
0438: .getString(15)));
0439:
0440: // Don't use the following line to attain DB compatibility
0441: // channelDef.setLocale("en_US");
0442:
0443: int dbOffset = 0;
0444: if (pstmtChannelParam == null) { // we are using a join statement so no need for a new query
0445: dbOffset = 15;
0446: } else {
0447: rs.close();
0448: pstmtChannelParam.clearParameters();
0449: pstmtChannelParam.setInt(1, channelPublishId);
0450: if (log.isDebugEnabled())
0451: log
0452: .debug("RDBMChannelRegistryStore.getChannelDefinition(): "
0453: + pstmtChannelParam);
0454: rs = pstmtChannelParam.executeQuery();
0455: }
0456:
0457: while (true) {
0458: if (pstmtChannelParam != null && !rs.next()) {
0459: break;
0460: }
0461: String name = rs.getString(dbOffset + 1);
0462: String value = rs.getString(dbOffset + 2);
0463: String override = rs.getString(dbOffset + 3);
0464: if (name != null) {
0465: channelDef.addParameter(name, value,
0466: override);
0467: }
0468: if (pstmtChannelParam == null && !rs.next()) {
0469: break;
0470: }
0471: }
0472:
0473: IPortletPreferencesStore portletPrefStore = PortletPreferencesStoreFactory
0474: .getPortletPreferencesStoreImpl();
0475: PreferenceSet preferences = null;
0476: try {
0477: preferences = portletPrefStore
0478: .getDefinitionPreferences(channelPublishId);
0479: } catch (Exception e) {
0480: log.error(e, e);
0481: preferences = null;
0482: }
0483: if (preferences != null) {
0484: for (Iterator prefItr = preferences.iterator(); prefItr
0485: .hasNext();) {
0486: Preference pref = (Preference) prefItr
0487: .next();
0488:
0489: String name = pref.getName();
0490: String value = "";
0491: String override;
0492:
0493: if (pref.isReadOnly()) {
0494: override = "N";
0495: } else {
0496: override = "Y";
0497: }
0498:
0499: //Since publish params only support single valued params just look for the first value.
0500: Iterator valuesItr = pref.getValues();
0501: if (valuesItr.hasNext())
0502: value = (String) valuesItr.next();
0503:
0504: channelDef
0505: .addParameter(
0506: CPortletAdapter.portletPreferenceNamePrefix
0507: + name, value,
0508: override);
0509: }
0510: }
0511:
0512: if (localeAware) {
0513: // Read UP_CHANNEL_MDATA
0514: rs.close();
0515: pstmtChannelMdata.clearParameters();
0516: pstmtChannelMdata.setInt(1, channelPublishId);
0517: if (log.isDebugEnabled())
0518: log
0519: .debug("RDBMChannelRegistryStore.getChannelDefinition(): "
0520: + pstmtChannelMdata);
0521: try {
0522: rs = pstmtChannelMdata.executeQuery();
0523:
0524: String locale;
0525: while (true) {
0526: if (pstmtChannelMdata != null
0527: && !rs.next()) {
0528: break;
0529: }
0530: locale = rs.getString(1);
0531: channelDef.putChanTitles(locale, rs
0532: .getString(2));
0533: channelDef.putChanDescs(locale, rs
0534: .getString(3));
0535: channelDef.putChanNames(locale, rs
0536: .getString(4));
0537:
0538: if (pstmtChannelMdata == null
0539: && !rs.next()) {
0540: break;
0541: }
0542: }
0543: } catch (SQLException e) {
0544: log
0545: .error(
0546: "RDBMChannelRegistryStore.getChannelDefinition(): "
0547: + "Database being used is not internationalized. "
0548: + "Execute `ant i18n-db' for internationalized database setting.",
0549: e);
0550: }
0551: }
0552: }
0553:
0554: if (log.isDebugEnabled())
0555: log
0556: .debug("RDBMChannelRegistryStore.getChannelDefinition(): Read channel "
0557: + channelPublishId
0558: + " from the store");
0559:
0560: // Add the channel definition to the cache
0561: try {
0562: if (channelDef != null) {
0563: EntityCachingService.instance().add(channelDef);
0564: }
0565: } catch (Exception e) {
0566: log.error("Error caching channel definition "
0567: + channelDef, e);
0568: }
0569:
0570: } finally {
0571: try {
0572: rs.close();
0573: } catch (Exception e) {
0574: }
0575: try {
0576: pstmtChannel.close();
0577: } catch (Exception e) {
0578: }
0579: try {
0580: pstmtChannelParam.close();
0581: } catch (Exception e) {
0582: }
0583: try {
0584: pstmtChannelMdata.close();
0585: } catch (Exception e) {
0586: }
0587: try {
0588: RDBMServices.releaseConnection(con);
0589: } catch (Exception e) {
0590: }
0591: }
0592: }
0593: return channelDef;
0594: }
0595:
0596: /**
0597: * Get a channel definition. If there is more than one channel definition
0598: * with the given functional name, then the one with the most recent
0599: * approval date will be returned.
0600: * @param channelFunctionalName a channel functional name
0601: * @return channelDefinition, a definition of the channel or <code>null</code>
0602: * if no matching channel definition can be found
0603: * @throws java.sql.SQLException
0604: */
0605: public ChannelDefinition getChannelDefinition(
0606: String channelFunctionalName) throws SQLException {
0607: ChannelDefinition channelDef = null;
0608: Connection con = RDBMServices.getConnection();
0609:
0610: try {
0611: String query = "SELECT CHAN_ID FROM UP_CHANNEL WHERE CHAN_FNAME=? ORDER BY CHAN_APVL_DT DESC";
0612: PreparedStatement pstmt = con.prepareStatement(query);
0613: try {
0614: if (log.isDebugEnabled())
0615: log.debug("Executing '" + query
0616: + "' with CHAN_FNAME="
0617: + channelFunctionalName);
0618:
0619: pstmt.setString(1, channelFunctionalName);
0620: ResultSet rs = pstmt.executeQuery();
0621: try {
0622: if (rs.next()) {
0623: channelDef = getChannelDefinition(rs
0624: .getInt("CHAN_ID"));
0625: }
0626: } finally {
0627: rs.close();
0628: }
0629: } finally {
0630: pstmt.close();
0631: }
0632: } finally {
0633: RDBMServices.releaseConnection(con);
0634: }
0635: return channelDef;
0636: }
0637:
0638: /**
0639: * Get all channel definitions including ones that haven't been approved.
0640: * @return channelDefs, the channel definitions
0641: * @throws java.sql.SQLException
0642: */
0643: public ChannelDefinition[] getChannelDefinitions()
0644: throws SQLException {
0645: ChannelDefinition[] channelDefs = null;
0646: Connection con = RDBMServices.getConnection();
0647:
0648: try {
0649: Statement stmt = con.createStatement();
0650: try {
0651: String query = "SELECT CHAN_ID FROM UP_CHANNEL";
0652: if (log.isDebugEnabled())
0653: log
0654: .debug("RDBMChannelRegistryStore.getChannelDefinitions(): "
0655: + query);
0656: ResultSet rs = stmt.executeQuery(query);
0657: try {
0658: List channelDefsList = new ArrayList();
0659: while (rs.next()) {
0660: ChannelDefinition channelDef = getChannelDefinition(rs
0661: .getInt("CHAN_ID"));
0662: channelDefsList.add(channelDef);
0663: }
0664: channelDefs = (ChannelDefinition[]) channelDefsList
0665: .toArray(new ChannelDefinition[0]);
0666: } finally {
0667: rs.close();
0668: }
0669: } finally {
0670: stmt.close();
0671: }
0672: } finally {
0673: RDBMServices.releaseConnection(con);
0674: }
0675: return channelDefs;
0676: }
0677:
0678: /**
0679: * Persists a channel definition.
0680: * @param channelDef the channel definition
0681: * @throws java.sql.SQLException
0682: */
0683: public void saveChannelDefinition(ChannelDefinition channelDef)
0684: throws Exception {
0685: Connection con = RDBMServices.getConnection();
0686: try {
0687: int channelPublishId = channelDef.getId();
0688:
0689: // Set autocommit false for the connection
0690: RDBMServices.setAutoCommit(con, false);
0691: try {
0692: saveChannelDef(con, channelDef);
0693: deleteChannelParams(con, channelPublishId);
0694: ChannelParameter[] parameters = channelDef
0695: .getParameters();
0696:
0697: if (parameters != null) {
0698: // Keep track of any portlet preferences
0699: PreferenceSetImpl preferences = new PreferenceSetImpl();
0700:
0701: for (int i = 0; i < parameters.length; i++) {
0702: String paramName = parameters[i].getName();
0703: String paramValue = parameters[i].getValue();
0704: boolean paramOverride = parameters[i]
0705: .getOverride();
0706:
0707: if (paramName == null && paramValue == null) {
0708: throw new RuntimeException(
0709: "Invalid parameter node");
0710: }
0711:
0712: if (paramName
0713: .startsWith(CPortletAdapter.portletPreferenceNamePrefix)) {
0714: // We have a portlet preference
0715: String prefName = paramName
0716: .substring(CPortletAdapter.portletPreferenceNamePrefix
0717: .length());
0718: String prefValue = paramValue;
0719: List prefValues = (List) preferences
0720: .get(prefName);
0721: // Unfortunately, we can only support single-valued preferences
0722: // at this level unless we change a lot of uPortal code :(
0723: prefValues = new ArrayList(1);
0724: prefValues.add(prefValue);
0725: preferences.add(prefName, prefValues,
0726: !paramOverride);
0727: } else {
0728: insertChannelParam(con, channelPublishId,
0729: paramName, paramValue,
0730: paramOverride);
0731: }
0732: }
0733: if (preferences.size() > 0) {
0734: PortletPreferencesStoreFactory
0735: .getPortletPreferencesStoreImpl()
0736: .setDefinitionPreferences(
0737: channelPublishId, preferences);
0738: }
0739: }
0740:
0741: // Commit the transaction
0742: RDBMServices.commit(con);
0743:
0744: // Notify the cache
0745: try {
0746: EntityCachingService.instance().update(channelDef);
0747: } catch (Exception e) {
0748: log.error(
0749: "Error updating cache for channel definition "
0750: + channelDef, e);
0751: }
0752:
0753: } catch (SQLException sqle) {
0754: log.error("Exception saving channel definition "
0755: + channelDef, sqle);
0756: RDBMServices.rollback(con);
0757: throw sqle;
0758: }
0759: } finally {
0760: RDBMServices.releaseConnection(con);
0761: }
0762: }
0763:
0764: private static void saveChannelDef(Connection con,
0765: ChannelDefinition channelDef) throws SQLException {
0766: int channelPublishId = channelDef.getId();
0767: String sqlTitle = RDBMServices.sqlEscape(channelDef.getTitle());
0768: String sqlDescription = RDBMServices.sqlEscape(channelDef
0769: .getDescription());
0770: String sqlClass = channelDef.getJavaClass();
0771: int sqlTypeID = channelDef.getTypeId();
0772: int chanPublisherId = channelDef.getPublisherId();
0773: String chanPublishDate = RDBMServices.getDbMetaData()
0774: .sqlTimeStamp(channelDef.getPublishDate());
0775: int chanApproverId = channelDef.getApproverId();
0776: String chanApprovalDate = RDBMServices.getDbMetaData()
0777: .sqlTimeStamp(channelDef.getApprovalDate());
0778: int sqlTimeout = channelDef.getTimeout();
0779: String sqlEditable = RDBMServices.dbFlag(channelDef
0780: .isEditable());
0781: String sqlHasHelp = RDBMServices.dbFlag(channelDef.hasHelp());
0782: String sqlHasAbout = RDBMServices.dbFlag(channelDef.hasAbout());
0783: String sqlName = RDBMServices.sqlEscape(channelDef.getName());
0784: String sqlFName = RDBMServices.sqlEscape(channelDef.getFName());
0785: String sqlIsSecure = RDBMServices.dbFlag(channelDef.isSecure());
0786:
0787: // If channel is already there, do an update, otherwise do an insert
0788: String sql;
0789: if (channelExists(con, channelPublishId)) {
0790: sql = "UPDATE UP_CHANNEL SET " + "CHAN_TITLE='" + sqlTitle
0791: + "', " + "CHAN_DESC='" + sqlDescription + "', "
0792: + "CHAN_CLASS='" + sqlClass + "', "
0793: + "CHAN_TYPE_ID=" + sqlTypeID + ", "
0794: + "CHAN_PUBL_ID=" + chanPublisherId + ", "
0795: + "CHAN_PUBL_DT=" + chanPublishDate + ", "
0796: + "CHAN_APVL_ID=" + chanApproverId + ", "
0797: + "CHAN_APVL_DT=" + chanApprovalDate + ", "
0798: + "CHAN_TIMEOUT=" + sqlTimeout + ", "
0799: + "CHAN_EDITABLE='" + sqlEditable + "', "
0800: + "CHAN_HAS_HELP='" + sqlHasHelp + "', "
0801: + "CHAN_HAS_ABOUT='" + sqlHasAbout + "', "
0802: + "CHAN_NAME='" + sqlName + "', " + "CHAN_FNAME='"
0803: + sqlFName + "', " + "CHAN_SECURE='" + sqlIsSecure
0804: + "' " + "WHERE CHAN_ID=" + channelPublishId;
0805: } else {
0806: sql = "INSERT INTO UP_CHANNEL (CHAN_ID, CHAN_TITLE, CHAN_DESC, CHAN_CLASS, CHAN_TYPE_ID, CHAN_PUBL_ID, CHAN_PUBL_DT, "
0807: + "CHAN_APVL_ID, CHAN_APVL_DT, CHAN_TIMEOUT, CHAN_EDITABLE, CHAN_HAS_HELP, CHAN_HAS_ABOUT, CHAN_NAME, CHAN_FNAME, CHAN_SECURE) ";
0808: sql += "VALUES (" + channelPublishId + ", '" + sqlTitle
0809: + "', '" + sqlDescription + "', '" + sqlClass
0810: + "', " + sqlTypeID + ", " + chanPublisherId + ", "
0811: + chanPublishDate + ", " + chanApproverId + ", "
0812: + chanApprovalDate + ", " + sqlTimeout + ", '"
0813: + sqlEditable + "', '" + sqlHasHelp + "', '"
0814: + sqlHasAbout + "', '" + sqlName + "', '"
0815: + sqlFName + "', '" + sqlIsSecure + "')";
0816: }
0817: if (log.isDebugEnabled())
0818: log.debug(sql);
0819: Statement stmt = con.createStatement();
0820: try {
0821: stmt.executeUpdate(sql);
0822: } finally {
0823: stmt.close();
0824: }
0825: }
0826:
0827: private static boolean channelExists(Connection con,
0828: int channelPublishId) throws SQLException {
0829: String query = "SELECT CHAN_ID FROM UP_CHANNEL WHERE CHAN_ID="
0830: + channelPublishId;
0831: if (log.isDebugEnabled())
0832: log.debug(query);
0833: Statement stmt = con.createStatement();
0834: boolean doUpdate = false;
0835: try {
0836: ResultSet rs = stmt.executeQuery(query);
0837: doUpdate = rs.next();
0838: } finally {
0839: stmt.close();
0840: }
0841: return doUpdate;
0842: }
0843:
0844: private static void insertChannelParam(Connection con,
0845: int channelPublishId, String paramName, String paramValue,
0846: boolean paramOverride) throws SQLException {
0847: Statement stmt2 = con.createStatement();
0848: try {
0849: // We have a normal channel parameter
0850: String sql = "INSERT INTO UP_CHANNEL_PARAM (CHAN_ID, CHAN_PARM_NM, CHAN_PARM_VAL, CHAN_PARM_OVRD) VALUES ("
0851: + channelPublishId
0852: + ",'"
0853: + paramName
0854: + "','"
0855: + paramValue
0856: + "', '"
0857: + (paramOverride ? "Y" : "N")
0858: + "')";
0859: if (log.isDebugEnabled())
0860: log.debug(sql);
0861: stmt2.executeUpdate(sql);
0862: } finally {
0863: stmt2.close();
0864: }
0865: }
0866:
0867: private static void deleteChannelParams(Connection con,
0868: int channelPublishId) throws SQLException {
0869: Statement stmt2 = con.createStatement();
0870: try {
0871: // First delete existing parameters for this channel
0872: String sql = "DELETE FROM UP_CHANNEL_PARAM WHERE CHAN_ID="
0873: + channelPublishId;
0874: if (log.isDebugEnabled())
0875: log.debug(sql);
0876: stmt2.executeUpdate(sql);
0877: } finally {
0878: stmt2.close();
0879: }
0880: }
0881:
0882: /**
0883: * Permanently deletes a channel definition from the store.
0884: * All references to this channel definition are also deleted.
0885: * @param channelDef the channel definition
0886: * @throws java.sql.SQLException
0887: * @throws org.jasig.portal.groups.GroupsException
0888: */
0889: public void deleteChannelDefinition(ChannelDefinition channelDef)
0890: throws SQLException, GroupsException {
0891: Connection con = RDBMServices.getConnection();
0892: try {
0893: Statement stmt = con.createStatement();
0894: try {
0895: int channelPublishId = channelDef.getId();
0896:
0897: // Remove versioning information for channel if found.
0898: VersionsManager mgr = VersionsManager.getInstance();
0899: mgr.removeVersion(channelDef.getFName());
0900:
0901: // Delete from UP_CHANNEL
0902: String delete = "DELETE FROM UP_CHANNEL WHERE CHAN_ID="
0903: + channelPublishId;
0904: if (log.isDebugEnabled())
0905: log
0906: .debug("RDBMChannelRegistryStore.deleteChannelDefinition(): "
0907: + delete);
0908: stmt.executeUpdate(delete);
0909:
0910: // Delete from UP_CHANNEL_PARAM
0911: delete = "DELETE FROM UP_CHANNEL_PARAM WHERE CHAN_ID="
0912: + channelPublishId;
0913: if (log.isDebugEnabled())
0914: log
0915: .debug("RDBMChannelRegistryStore.deleteChannelDefinition(): "
0916: + delete);
0917: stmt.executeUpdate(delete);
0918:
0919: // Delete from UP_PERMISSION
0920: // This needs to be updated to work with permission interfaces!!!
0921: delete = "DELETE FROM UP_PERMISSION WHERE OWNER='CHAN_ID."
0922: + channelPublishId
0923: + "' OR TARGET='CHAN_ID."
0924: + channelPublishId + "'";
0925: if (log.isDebugEnabled())
0926: log
0927: .debug("RDBMChannelRegistryStore.deleteChannelDefinition(): "
0928: + delete);
0929: stmt.executeUpdate(delete);
0930:
0931: // Delete from UPC_KEYWORD
0932: delete = "DELETE FROM UPC_KEYWORD WHERE CHAN_ID="
0933: + channelPublishId;
0934: if (log.isDebugEnabled())
0935: log
0936: .debug("RDBMChannelRegistryStore.deleteChannelDefinition(): "
0937: + delete);
0938: stmt.executeUpdate(delete);
0939:
0940: // Disassociate from parent categories (delete from UP_GROUP_MEMBERSHIP)
0941: IEntity channelDefEntity = GroupService.getEntity(
0942: String.valueOf(channelPublishId),
0943: ChannelDefinition.class);
0944: Iterator iter = channelDefEntity.getContainingGroups();
0945: while (iter.hasNext()) {
0946: IEntityGroup parentGroup = (IEntityGroup) iter
0947: .next();
0948: parentGroup.removeMember(channelDefEntity);
0949: parentGroup.updateMembers();
0950: }
0951:
0952: // Notify the cache
0953: try {
0954: EntityCachingService.instance().remove(channelDef);
0955: } catch (Exception e) {
0956: log.error("Error removing channel definition "
0957: + channelDef + " from cache.", e);
0958: }
0959:
0960: } finally {
0961: stmt.close();
0962: }
0963: } finally {
0964: RDBMServices.releaseConnection(con);
0965: }
0966: }
0967:
0968: /**
0969: * Sets a channel definition as "approved". This effectively makes a
0970: * channel definition available in the channel registry, making the channel
0971: * available for subscription to those authorized to subscribe to it.
0972: * This method is a convenience method. As an alternative to calling
0973: * this method, one could simply set the approver ID and approval date
0974: * and then call saveChannelDefinition(ChannelDefinition chanDef).
0975: * @param channelDef the channel definition to approve
0976: * @param approver the user that approves this channel definition
0977: * @param approveDate the date when the channel definition should be approved (can be future dated)
0978: * @throws Exception
0979: */
0980: public void approveChannelDefinition(ChannelDefinition channelDef,
0981: IPerson approver, Date approveDate) throws Exception {
0982: channelDef.setApproverId(approver.getID());
0983: channelDef.setApprovalDate(approveDate);
0984: saveChannelDefinition(channelDef);
0985: }
0986:
0987: /**
0988: * Removes a channel from the channel registry by changing
0989: * its status from "approved" to "unapproved". Afterwards, no one
0990: * will be able to subscribe to or render the channel.
0991: * This method is a convenience method. As an alternative to calling
0992: * this method, one could simply set the approver ID and approval date
0993: * to NULL and then call saveChannelDefinition(ChannelDefinition chanDef).
0994: * @param channelDef the channel definition to disapprove
0995: * @throws Exception
0996: */
0997: public void disapproveChannelDefinition(ChannelDefinition channelDef)
0998: throws Exception {
0999: channelDef.setApproverId(-1);
1000: channelDef.setApprovalDate(null);
1001: saveChannelDefinition(channelDef);
1002: }
1003:
1004: /**
1005: * Creates a new channel category.
1006: * @return channelCategory the new channel category
1007: * @throws org.jasig.portal.groups.GroupsException
1008: */
1009: public ChannelCategory newChannelCategory() throws GroupsException {
1010: IEntityGroup categoryGroup = GroupService
1011: .newGroup(ChannelDefinition.class);
1012: categoryGroup.setName(""); // name cannot be null
1013: categoryGroup.setCreatorID(""); // creatorId cannot be null
1014: categoryGroup.update();
1015: String id = categoryGroup.getKey();
1016: return new ChannelCategory(id);
1017: }
1018:
1019: /**
1020: * Creates a new channel category with the specified values.
1021: * @param name the name of the category
1022: * @param description the name of the description
1023: * @param creatorId the id of the creator or system
1024: * @return channelCategory the new channel category
1025: * @throws GroupsException
1026: */
1027: public ChannelCategory newChannelCategory(String name,
1028: String description, String creatorId)
1029: throws GroupsException {
1030: IEntityGroup categoryGroup = GroupService
1031: .newGroup(ChannelDefinition.class);
1032: categoryGroup.setName(name); // name cannot be null
1033: categoryGroup.setCreatorID(creatorId); // creatorId cannot be null
1034: categoryGroup.setDescription(description);
1035: categoryGroup.update();
1036: String id = categoryGroup.getKey();
1037: ChannelCategory cat = new ChannelCategory(id);
1038: cat.setName(name);
1039: cat.setDescription(description);
1040: cat.setCreatorId(creatorId);
1041: return cat;
1042: }
1043:
1044: /**
1045: * Gets an existing channel category.
1046: * @param channelCategoryId the id of the category to get
1047: * @return channelCategory the channel category
1048: * @throws org.jasig.portal.groups.GroupsException
1049: */
1050: public ChannelCategory getChannelCategory(String channelCategoryId)
1051: throws GroupsException {
1052: IEntityGroup categoryGroup = GroupService
1053: .findGroup(channelCategoryId);
1054: ChannelCategory category = new ChannelCategory(
1055: channelCategoryId);
1056: category.setName(categoryGroup.getName());
1057: category.setDescription(categoryGroup.getDescription());
1058: category.setCreatorId(categoryGroup.getCreatorID());
1059: return category;
1060: }
1061:
1062: /**
1063: * Gets top level channel category
1064: * @return channelCategories the new channel category
1065: * @throws org.jasig.portal.groups.GroupsException
1066: */
1067: public ChannelCategory getTopLevelChannelCategory()
1068: throws GroupsException {
1069: IEntityGroup categoryGroup = GroupService
1070: .getDistinguishedGroup(IGroupConstants.CHANNEL_CATEGORIES);
1071: return getChannelCategory(categoryGroup.getKey());
1072: }
1073:
1074: /**
1075: * Gets all child channel categories for a parent category.
1076: * @return channelCategories the children categories
1077: * @throws org.jasig.portal.groups.GroupsException
1078: */
1079: public ChannelCategory[] getChildCategories(ChannelCategory parent)
1080: throws GroupsException {
1081: String parentKey = String.valueOf(parent.getId());
1082: IEntityGroup parentGroup = GroupService.findGroup(parentKey);
1083: List categories = new ArrayList();
1084: Iterator iter = parentGroup.getMembers();
1085: while (iter.hasNext()) {
1086: IGroupMember gm = (IGroupMember) iter.next();
1087: if (gm.isGroup()) {
1088: String categoryId = gm.getKey();
1089: categories.add(getChannelCategory(categoryId));
1090: }
1091: }
1092: return (ChannelCategory[]) categories
1093: .toArray(new ChannelCategory[0]);
1094: }
1095:
1096: /**
1097: * Gets all child channel definitions for a parent category.
1098: * @return channelDefinitions the children channel definitions
1099: * @throws java.sql.SQLException
1100: * @throws org.jasig.portal.groups.GroupsException
1101: */
1102: public ChannelDefinition[] getChildChannels(ChannelCategory parent)
1103: throws SQLException, GroupsException {
1104: String parentKey = String.valueOf(parent.getId());
1105: IEntityGroup parentGroup = GroupService.findGroup(parentKey);
1106: List channelDefs = new ArrayList();
1107: Iterator iter = parentGroup.getMembers();
1108: while (iter.hasNext()) {
1109: IGroupMember gm = (IGroupMember) iter.next();
1110: if (gm.isEntity()) {
1111: int channelPublishId = Integer.parseInt(gm.getKey());
1112: channelDefs.add(getChannelDefinition(channelPublishId));
1113: }
1114: }
1115: return (ChannelDefinition[]) channelDefs
1116: .toArray(new ChannelDefinition[0]);
1117: }
1118:
1119: /**
1120: * Gets the immediate parent categories of this category.
1121: * @return parents, the parent categories.
1122: * @throws org.jasig.portal.groups.GroupsException
1123: */
1124: public ChannelCategory[] getParentCategories(ChannelCategory child)
1125: throws GroupsException {
1126: String childKey = String.valueOf(child.getId());
1127: IEntityGroup childGroup = GroupService.findGroup(childKey);
1128: List parents = new ArrayList();
1129: Iterator iter = childGroup.getContainingGroups();
1130: while (iter.hasNext()) {
1131: IGroupMember gm = (IGroupMember) iter.next();
1132: if (gm.isGroup()) {
1133: String categoryId = gm.getKey();
1134: parents.add(getChannelCategory(categoryId));
1135: }
1136: }
1137: return (ChannelCategory[]) parents
1138: .toArray(new ChannelCategory[0]);
1139: }
1140:
1141: /**
1142: * Gets the immediate parent categories of this channel definition.
1143: * @return parents, the parent categories.
1144: * @throws org.jasig.portal.groups.GroupsException
1145: */
1146: public ChannelCategory[] getParentCategories(ChannelDefinition child)
1147: throws GroupsException {
1148: String childKey = String.valueOf(child.getId());
1149: IEntity childEntity = GroupService.getEntity(childKey,
1150: ChannelDefinition.class);
1151: List parents = new ArrayList();
1152: Iterator iter = childEntity.getContainingGroups();
1153: while (iter.hasNext()) {
1154: IGroupMember gm = (IGroupMember) iter.next();
1155: if (gm.isGroup()) {
1156: String categoryId = gm.getKey();
1157: parents.add(getChannelCategory(categoryId));
1158: }
1159: }
1160: return (ChannelCategory[]) parents
1161: .toArray(new ChannelCategory[0]);
1162: }
1163:
1164: /**
1165: * Persists a channel category.
1166: * @param category the channel category to persist
1167: * @throws org.jasig.portal.groups.GroupsException
1168: */
1169: public void saveChannelCategory(ChannelCategory category)
1170: throws GroupsException {
1171: IEntityGroup categoryGroup = GroupService.findGroup(category
1172: .getId());
1173: categoryGroup.setName(category.getName());
1174: categoryGroup.setDescription(category.getDescription());
1175: categoryGroup.setCreatorID(category.getCreatorId());
1176: categoryGroup.update();
1177: }
1178:
1179: /**
1180: * Deletes a channel category.
1181: * @param category the channel category to delete
1182: * @throws org.jasig.portal.groups.GroupsException
1183: */
1184: public void deleteChannelCategory(ChannelCategory category)
1185: throws GroupsException {
1186: String key = String.valueOf(category.getId());
1187: ILockableEntityGroup categoryGroup = GroupService
1188: .findLockableGroup(key, "UP_FRAMEWORK");
1189: categoryGroup.delete();
1190: }
1191:
1192: /**
1193: * Makes one category a child of another.
1194: * @param child the source category
1195: * @param parent the destination category
1196: * @throws org.jasig.portal.groups.GroupsException
1197: */
1198: public void addCategoryToCategory(ChannelCategory child,
1199: ChannelCategory parent) throws GroupsException {
1200: String childKey = String.valueOf(child.getId());
1201: IEntityGroup childGroup = GroupService.findGroup(childKey);
1202: String parentKey = String.valueOf(parent.getId());
1203: IEntityGroup parentGroup = GroupService.findGroup(parentKey);
1204: parentGroup.addMember(childGroup);
1205: parentGroup.updateMembers();
1206: }
1207:
1208: /**
1209: * Makes one category a child of another.
1210: * @param child the category to remove
1211: * @param parent the category to remove from
1212: * @throws org.jasig.portal.groups.GroupsException
1213: */
1214: public void removeCategoryFromCategory(ChannelCategory child,
1215: ChannelCategory parent) throws GroupsException {
1216: String childKey = String.valueOf(child.getId());
1217: IEntityGroup childGroup = GroupService.findGroup(childKey);
1218: String parentKey = String.valueOf(parent.getId());
1219: IEntityGroup parentGroup = GroupService.findGroup(parentKey);
1220: parentGroup.removeMember(childGroup);
1221: parentGroup.updateMembers();
1222: }
1223:
1224: /**
1225: * Associates a channel definition with a category.
1226: * @param channelDef the channel definition
1227: * @param category the channel category to which to associate the channel definition
1228: * @throws org.jasig.portal.PortalException
1229: */
1230: public void addChannelToCategory(ChannelDefinition channelDef,
1231: ChannelCategory category) throws PortalException {
1232: String channelDefKey = String.valueOf(channelDef.getId());
1233: IEntity channelDefEntity = GroupService.getEntity(
1234: channelDefKey, ChannelDefinition.class);
1235: IEntityGroup categoryGroup = GroupService.findGroup(category
1236: .getId());
1237: categoryGroup.addMember(channelDefEntity);
1238: categoryGroup.updateMembers();
1239: }
1240:
1241: /**
1242: * Disassociates a channel definition from a category.
1243: * @param channelDef the channel definition
1244: * @param category the channel category from which to disassociate the channel definition
1245: * @throws org.jasig.portal.PortalException
1246: */
1247: public void removeChannelFromCategory(ChannelDefinition channelDef,
1248: ChannelCategory category) throws PortalException {
1249: String channelDefKey = String.valueOf(channelDef.getId());
1250: IEntity channelDefEntity = GroupService.getEntity(
1251: channelDefKey, ChannelDefinition.class);
1252: String categoryKey = String.valueOf(category.getId());
1253: IEntityGroup categoryGroup = GroupService
1254: .findGroup(categoryKey);
1255: categoryGroup.removeMember(channelDefEntity);
1256: categoryGroup.updateMembers();
1257: }
1258:
1259: protected static final PreparedStatement getChannelPstmt(
1260: Connection con) throws SQLException {
1261: String sql = "SELECT UC.CHAN_TITLE, UC.CHAN_DESC, UC.CHAN_CLASS, UC.CHAN_TYPE_ID, "
1262: + "UC.CHAN_PUBL_ID, UC.CHAN_APVL_ID, UC.CHAN_PUBL_DT, UC.CHAN_APVL_DT, "
1263: + "UC.CHAN_TIMEOUT, UC.CHAN_EDITABLE, UC.CHAN_HAS_HELP, UC.CHAN_HAS_ABOUT, "
1264: + "UC.CHAN_NAME, UC.CHAN_FNAME, UC.CHAN_SECURE";
1265:
1266: if (RDBMServices.getDbMetaData().supportsOuterJoins()) {
1267: sql += ", CHAN_PARM_NM, CHAN_PARM_VAL, CHAN_PARM_OVRD, CHAN_PARM_DESC FROM "
1268: + RDBMServices.getDbMetaData().getJoinQuery()
1269: .getQuery("channel");
1270: } else {
1271: sql += " FROM UP_CHANNEL UC WHERE";
1272: }
1273:
1274: sql += " UC.CHAN_ID=?";
1275:
1276: return con.prepareStatement(sql);
1277: }
1278:
1279: protected static final PreparedStatement getChannelParamPstmt(
1280: Connection con) throws SQLException {
1281: if (RDBMServices.getDbMetaData().supportsOuterJoins()) {
1282: return null;
1283: } else {
1284: return con
1285: .prepareStatement("SELECT CHAN_PARM_NM, CHAN_PARM_VAL,CHAN_PARM_OVRD,CHAN_PARM_DESC FROM UP_CHANNEL_PARAM WHERE CHAN_ID=?");
1286: }
1287: }
1288:
1289: protected static final PreparedStatement getChannelMdataPstmt(
1290: Connection con) throws SQLException {
1291: return con
1292: .prepareStatement("SELECT LOCALE, CHAN_TITLE, CHAN_DESC, CHAN_NAME FROM UP_CHANNEL_MDATA WHERE CHAN_ID=?");
1293: }
1294:
1295: }
|