001: /*
002: Copyright (C) 2003-2006 Know Gate S.L. All rights reserved.
003: C/Oņa, 107 1š2 28050 Madrid (Spain)
004:
005: Redistribution and use in source and binary forms, with or without
006: modification, are permitted provided that the following conditions
007: are met:
008:
009: 1. Redistributions of source code must retain the above copyright
010: notice, this list of conditions and the following disclaimer.
011:
012: 2. The end-user documentation included with the redistribution,
013: if any, must include the following acknowledgment:
014: "This product includes software parts from hipergate
015: (http://www.hipergate.org/)."
016: Alternately, this acknowledgment may appear in the software itself,
017: if and wherever such third-party acknowledgments normally appear.
018:
019: 3. The name hipergate must not be used to endorse or promote products
020: derived from this software without prior written permission.
021: Products derived from this software may not be called hipergate,
022: nor may hipergate appear in their name, without prior written
023: permission.
024:
025: This library is distributed in the hope that it will be useful,
026: but WITHOUT ANY WARRANTY; without even the implied warranty of
027: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029: You should have received a copy of hipergate License with this code;
030: if not, visit http://www.hipergate.org or mail to info@hipergate.org
031: */
032:
033: package com.knowgate.http.portlets;
034:
035: import java.util.Enumeration;
036: import java.util.ResourceBundle;
037: import java.util.Locale;
038: import java.util.Date;
039:
040: import javax.portlet.PortletConfig;
041: import javax.portlet.PortletContext;
042:
043: import java.sql.Connection;
044: import java.sql.PreparedStatement;
045: import java.sql.SQLException;
046: import java.sql.Timestamp;
047:
048: import com.knowgate.debug.DebugFile;
049: import com.knowgate.dataobjs.DB;
050:
051: /**
052: * @author Sergio Montoro Ten
053: * @version 1.0
054: */
055:
056: public class HipergatePortletConfig implements PortletConfig {
057:
058: private HipergatePortletContext oCtx;
059:
060: public HipergatePortletConfig() {
061: oCtx = new HipergatePortletContext();
062: }
063:
064: public String getPortletName() {
065: return null;
066: }
067:
068: public PortletContext getPortletContext() {
069: return oCtx;
070: }
071:
072: public ResourceBundle getResourceBundle(Locale locale) {
073: return null;
074: }
075:
076: public String getInitParameter(String name) {
077: return oCtx.getInitParameter(name);
078: }
079:
080: public Enumeration getInitParameterNames() {
081: return oCtx.getInitParameterNames();
082: }
083:
084: // ---------------------------------------------------------------------------
085:
086: /**
087: * <p>Touch portlet last modified date</p>
088: * Portlet last modified date is used for caching portlet output
089: * @param oCon JDBC database connection
090: * @param sUserId GUID of ACLUser owner of the portlet
091: * @param sPortletNm GenericPortlet subclass name
092: * @param sWrkAId GUID of WorkArea where portlet is shown
093: * @throws SQLException
094: */
095: public static void touch(Connection oCon, String sUserId,
096: String sPortletNm, String sWrkAId) throws SQLException {
097:
098: if (DebugFile.trace) {
099: DebugFile
100: .writeln("Begin HipergatePortletConfig.touch([Connection],"
101: + sUserId
102: + ","
103: + sPortletNm
104: + ","
105: + sWrkAId + ")");
106: DebugFile.incIdent();
107: }
108:
109: PreparedStatement oStm = null;
110: int iAffected = 0;
111:
112: try {
113: oStm = oCon
114: .prepareStatement("UPDATE " + DB.k_x_portlet_user
115: + " SET " + DB.dt_modified + "=? WHERE "
116: + DB.gu_user + "=? AND " + DB.nm_portlet
117: + "=? AND " + DB.gu_workarea + "=?");
118: try {
119: oStm.setQueryTimeout(2000);
120: } catch (SQLException ignore) {
121: }
122: oStm.setTimestamp(1, new Timestamp(new Date().getTime()));
123: oStm.setString(2, sUserId);
124: oStm.setString(3, sPortletNm);
125: oStm.setString(4, sWrkAId);
126: iAffected = oStm.executeUpdate();
127: oStm.close();
128: oStm = null;
129: } catch (SQLException sqle) {
130: DebugFile.decIdent();
131: try {
132: if (null != oStm)
133: oStm.close();
134: } catch (SQLException ignore) {
135: }
136: throw new SQLException(sqle.getMessage(), sqle
137: .getSQLState(), sqle.getErrorCode());
138: }
139: if (DebugFile.trace) {
140: DebugFile.decIdent();
141: DebugFile.writeln("End HipergatePortletConfig.touch() : "
142: + String.valueOf(iAffected));
143: }
144: } // touch
145: }
|