KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > knowgate > http > portlets > HipergatePortletConfig


1 /*
2   Copyright (C) 2003-2006 Know Gate S.L. All rights reserved.
3                            C/Oņa, 107 1š2 28050 Madrid (Spain)
4
5   Redistribution and use in source and binary forms, with or without
6   modification, are permitted provided that the following conditions
7   are met:
8
9   1. Redistributions of source code must retain the above copyright
10      notice, this list of conditions and the following disclaimer.
11
12   2. The end-user documentation included with the redistribution,
13      if any, must include the following acknowledgment:
14      "This product includes software parts from hipergate
15      (http://www.hipergate.org/)."
16      Alternately, this acknowledgment may appear in the software itself,
17      if and wherever such third-party acknowledgments normally appear.
18
19   3. The name hipergate must not be used to endorse or promote products
20      derived from this software without prior written permission.
21      Products derived from this software may not be called hipergate,
22      nor may hipergate appear in their name, without prior written
23      permission.
24
25   This library is distributed in the hope that it will be useful,
26   but WITHOUT ANY WARRANTY; without even the implied warranty of
27   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
28
29   You should have received a copy of hipergate License with this code;
30   if not, visit http://www.hipergate.org or mail to info@hipergate.org
31 */

32
33 package com.knowgate.http.portlets;
34
35 import java.util.Enumeration JavaDoc;
36 import java.util.ResourceBundle JavaDoc;
37 import java.util.Locale JavaDoc;
38 import java.util.Date JavaDoc;
39
40 import javax.portlet.PortletConfig;
41 import javax.portlet.PortletContext;
42
43 import java.sql.Connection JavaDoc;
44 import java.sql.PreparedStatement JavaDoc;
45 import java.sql.SQLException JavaDoc;
46 import java.sql.Timestamp JavaDoc;
47
48 import com.knowgate.debug.DebugFile;
49 import com.knowgate.dataobjs.DB;
50
51 /**
52  * @author Sergio Montoro Ten
53  * @version 1.0
54  */

55
56 public class HipergatePortletConfig implements PortletConfig {
57
58   private HipergatePortletContext oCtx;
59
60   public HipergatePortletConfig() {
61     oCtx = new HipergatePortletContext();
62   }
63
64   public String JavaDoc getPortletName () {
65     return null;
66   }
67
68   public PortletContext getPortletContext() {
69     return oCtx;
70   }
71
72   public ResourceBundle JavaDoc getResourceBundle(Locale JavaDoc locale) {
73     return null;
74   }
75
76   public String JavaDoc getInitParameter(String JavaDoc name) {
77     return oCtx.getInitParameter(name);
78   }
79
80   public Enumeration JavaDoc getInitParameterNames() {
81     return oCtx.getInitParameterNames();
82   }
83
84   // ---------------------------------------------------------------------------
85

86   /**
87    * <p>Touch portlet last modified date</p>
88    * Portlet last modified date is used for caching portlet output
89    * @param oCon JDBC database connection
90    * @param sUserId GUID of ACLUser owner of the portlet
91    * @param sPortletNm GenericPortlet subclass name
92    * @param sWrkAId GUID of WorkArea where portlet is shown
93    * @throws SQLException
94    */

95   public static void touch (Connection JavaDoc oCon, String JavaDoc sUserId, String JavaDoc sPortletNm, String JavaDoc sWrkAId)
96     throws SQLException JavaDoc {
97
98     if (DebugFile.trace) {
99       DebugFile.writeln("Begin HipergatePortletConfig.touch([Connection],"+sUserId+","+sPortletNm+","+sWrkAId+")");
100       DebugFile.incIdent();
101     }
102
103     PreparedStatement JavaDoc oStm = null;
104     int iAffected = 0;
105
106     try {
107       oStm = oCon.prepareStatement("UPDATE " + DB.k_x_portlet_user + " SET " + DB.dt_modified + "=? WHERE " + DB.gu_user + "=? AND " + DB.nm_portlet + "=? AND " + DB.gu_workarea + "=?");
108       try { oStm.setQueryTimeout(2000); } catch (SQLException JavaDoc ignore) {}
109       oStm.setTimestamp(1, new Timestamp JavaDoc(new Date JavaDoc().getTime()));
110       oStm.setString(2, sUserId);
111       oStm.setString(3, sPortletNm);
112       oStm.setString(4, sWrkAId);
113       iAffected = oStm.executeUpdate();
114       oStm.close();
115       oStm = null;
116     }
117     catch (SQLException JavaDoc sqle) {
118       DebugFile.decIdent();
119       try { if (null!=oStm) oStm.close(); } catch (SQLException JavaDoc ignore) {}
120       throw new SQLException JavaDoc (sqle.getMessage(),sqle.getSQLState(), sqle.getErrorCode());
121     }
122     if (DebugFile.trace) {
123       DebugFile.decIdent();
124       DebugFile.writeln("End HipergatePortletConfig.touch() : " + String.valueOf(iAffected));
125     }
126   } // touch
127
}
128
Popular Tags