You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(48) |
Dec
(31) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(22) |
Feb
(68) |
Mar
(185) |
Apr
(11) |
May
(21) |
Jun
(23) |
Jul
(46) |
Aug
(69) |
Sep
(211) |
Oct
(26) |
Nov
(51) |
Dec
(52) |
2006 |
Jan
(13) |
Feb
(13) |
Mar
(8) |
Apr
(21) |
May
(17) |
Jun
(100) |
Jul
(34) |
Aug
(23) |
Sep
(26) |
Oct
(16) |
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(66) |
Oct
(10) |
Nov
(1) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(3) |
May
(8) |
Jun
(5) |
Jul
(31) |
Aug
(8) |
Sep
(11) |
Oct
(6) |
Nov
|
Dec
|
2012 |
Jan
(13) |
Feb
(2) |
Mar
(9) |
Apr
(6) |
May
(24) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(120) |
2013 |
Jan
(6) |
Feb
(35) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ssk...@vh...> - 2005-09-16 08:35:46
|
Author: sskracic Date: 2005-09-16 10:26:30 +0200 (Fri, 16 Sep 2005) New Revision: 816 Modified: ccm-core/trunk/src/com/arsdigita/caching/CacheTable.java Log: A CacheTable instance can now be local, ie. it's possible to suppress cache syncing on per-table basis. Amended constructors to take additional boolean parameter "isShared". Modified: ccm-core/trunk/src/com/arsdigita/caching/CacheTable.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/caching/CacheTable.java 2005-09-15 14:25:13 UTC (rev 815) +++ ccm-core/trunk/src/com/arsdigita/caching/CacheTable.java 2005-09-16 08:26:30 UTC (rev 816) @@ -64,6 +64,7 @@ private static Map s_caches = new Hashtable(); private String m_cacheID; + private boolean m_shared = true; private DynamicList m_list; /** For debugging only. */ @@ -87,10 +88,21 @@ * @throws NullPointerException if <code>id</code> is <code>null</code> */ public CacheTable(final String id) { - this(id, DEFAULT_CACHE_SIZE, DEFAULT_CACHE_AGE); + this(id, DEFAULT_CACHE_SIZE, DEFAULT_CACHE_AGE, true); } /** + * @param isShared should this cache table be synced with other peers in cluster + */ + public CacheTable(final String id, boolean isShared) { + this(id, DEFAULT_CACHE_SIZE, DEFAULT_CACHE_AGE, isShared); + } + + public CacheTable(final String id, int defSize, int defAge) { + this(id, defSize, defAge, true); + } + + /** * <p>Creates cache storage tagged with the passed in identificator. This * tag must be unique in the sense that no other cache table loaded by this * <code>CacheTable</code>'s {@link java.lang.ClassLoader class loader} may @@ -106,13 +118,15 @@ * @param id Unique identifier for the new storage area * @param size Initial default size * @param age Initial default age + * @param isShared should this cache table be synced with other peers in cluster * @pre id != null * @throws NullPointerException if <code>id</code> is <code>null</code> */ - public CacheTable(final String id, int defSize, int defAge) { + public CacheTable(final String id, int defSize, int defAge, boolean isShared) { if ( id == null ) { throw new NullPointerException("id"); } m_cacheID = id; + m_shared = isShared; final Parameter sizeParam = new IntegerParameter ("waf.util.caching." + id + ".size", @@ -278,7 +292,9 @@ } // If peer webservers don't contain the latest value, // remove this entry from their caches. - CacheServlet.removeOutdatedFromPeers(m_cacheID, key, hashCode); + if (m_shared) { + CacheServlet.removeOutdatedFromPeers(m_cacheID, key, hashCode); + } } public synchronized void removeAll() { @@ -293,7 +309,11 @@ * @param key key of the object we're removing from cache */ public void remove(String key) { - remove(m_cacheID, key); + if (m_shared) { + remove(m_cacheID, key); + } else { + removeLocally(key); + } } /** |
Author: sskracic Date: 2005-09-15 16:25:13 +0200 (Thu, 15 Sep 2005) New Revision: 815 Modified: ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupport.java ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupportListener.java ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupportProfiler.java ccm-core/trunk/src/com/arsdigita/kernel/permissions/PermissionCache.java ccm-core/trunk/src/com/arsdigita/webdevsupport/Dispatcher.java ccm-core/trunk/src/com/arsdigita/webdevsupport/QueryInfo.java ccm-core/trunk/src/com/arsdigita/webdevsupport/WebDevSupport.java ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSProfiler.java ccm-core/trunk/src/com/redhat/persistence/profiler/rdbms/CompoundProfiler.java ccm-core/trunk/src/com/redhat/persistence/profiler/rdbms/StatementProfiler.java Log: Changed contract of some profiler interfaces so that we can track JDBC Connection object as well. While we're at it, changed developer support code so that it now displays connection tag in 'Conn' column, instead of completely useless Profiler's hash code. Modified: ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupport.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupport.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupport.java 2005-09-15 14:25:13 UTC (rev 815) @@ -118,7 +118,7 @@ * sqle should be null if no exception was thrown, otherwise * it should be the exception thrown */ - static public void logQuery(int connection_id, + static public void logQuery(String connection_id, String type, String query, HashMap bindvars, Modified: ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupportListener.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupportListener.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupportListener.java 2005-09-15 14:25:13 UTC (rev 815) @@ -55,7 +55,7 @@ * logQuery * Callback logging a database query */ - public void logQuery(int connection_id, + public void logQuery(String connection_id, String type, String query, HashMap bindvars, Modified: ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupportProfiler.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupportProfiler.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/arsdigita/developersupport/DeveloperSupportProfiler.java 2005-09-15 14:25:13 UTC (rev 815) @@ -18,9 +18,11 @@ */ package com.arsdigita.developersupport; +import com.arsdigita.persistence.PooledConnectionSource; import com.redhat.persistence.engine.rdbms.RDBMSProfiler; import com.redhat.persistence.engine.rdbms.RDBMSStatement; import com.redhat.persistence.engine.rdbms.StatementLifecycle; +import java.sql.Connection; import java.sql.SQLException; import java.util.HashMap; @@ -37,9 +39,9 @@ public DeveloperSupportProfiler() {} - public StatementLifecycle getLifecycle(RDBMSStatement stmt) { + public StatementLifecycle getLifecycle(Connection conn, RDBMSStatement stmt) { if (DeveloperSupport.getListenerCount() > 0) { - return new Lifecycle(stmt); + return new Lifecycle(conn, stmt); } else { return null; } @@ -48,10 +50,12 @@ private class Lifecycle implements StatementLifecycle { private RDBMSStatement m_stmt; + private Connection m_conn; private long m_start; private HashMap m_bindings = new HashMap(); - public Lifecycle(RDBMSStatement stmt) { + public Lifecycle(Connection conn, RDBMSStatement stmt) { + m_conn = conn; m_stmt = stmt; } @@ -76,9 +80,9 @@ public void endExecute(SQLException e) { long end = System.currentTimeMillis(); - DeveloperSupport.logQuery - (System.identityHashCode(DeveloperSupportProfiler.this), - (m_stmt.getSignature() == null + DeveloperSupport.logQuery( + PooledConnectionSource.getConnectionTag(m_conn), + (m_stmt.getSignature() == null ? "executeUpdate" : "executeQuery"), m_stmt.getText(), m_bindings, end - m_start, e); } Modified: ccm-core/trunk/src/com/arsdigita/kernel/permissions/PermissionCache.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/kernel/permissions/PermissionCache.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/arsdigita/kernel/permissions/PermissionCache.java 2005-09-15 14:25:13 UTC (rev 815) @@ -177,7 +177,7 @@ bindVars.put("1", obj.get("id")); bindVars.put("2", party.get("id")); DeveloperSupport.logQuery - (conn.hashCode(), + (conn.toString(), "executeQuery", privQuery, bindVars, Modified: ccm-core/trunk/src/com/arsdigita/webdevsupport/Dispatcher.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/webdevsupport/Dispatcher.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/arsdigita/webdevsupport/Dispatcher.java 2005-09-15 14:25:13 UTC (rev 815) @@ -363,7 +363,7 @@ return result.toString(); } case 1: return current.getTime() + " ms"; - case 2: return current.getConnectionID() + ""; + case 2: return current.getConnectionID(); case 3: return "<blockquote><pre>" + current.getQuery() + "</pre><br>BINDS: " + Modified: ccm-core/trunk/src/com/arsdigita/webdevsupport/QueryInfo.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/webdevsupport/QueryInfo.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/arsdigita/webdevsupport/QueryInfo.java 2005-09-15 14:25:13 UTC (rev 815) @@ -31,7 +31,7 @@ public class QueryInfo { public static final String versionId = "$Id$ by $Author$, $DateTime: 2004/08/16 18:10:38 $"; private int m_id; - private int m_connection_id; + private String m_connection_id; private String m_type; private String m_query; private TreeMap m_bindvars; @@ -40,7 +40,7 @@ private Throwable m_stack_trace; public QueryInfo(int id, - int connection_id, + String connection_id, String type, String query, Map bindvars, @@ -59,7 +59,7 @@ public int getID() { return m_id; } - public int getConnectionID() { + public String getConnectionID() { return m_connection_id; } public String getType() { Modified: ccm-core/trunk/src/com/arsdigita/webdevsupport/WebDevSupport.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/webdevsupport/WebDevSupport.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/arsdigita/webdevsupport/WebDevSupport.java 2005-09-15 14:25:13 UTC (rev 815) @@ -154,7 +154,7 @@ * logQuery * Callback logging a database query */ - public void logQuery(int connection_id, + public void logQuery(String connection_id, String type, String query, HashMap bindvars, Modified: ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java =================================================================== --- ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java 2005-09-15 14:25:13 UTC (rev 815) @@ -466,7 +466,7 @@ for (Iterator it = op.getEvents().iterator(); it.hasNext(); ) { stmt.addEvent((Event) it.next()); } - cycle = m_profiler.getLifecycle(stmt); + cycle = m_profiler.getLifecycle(m_conn, stmt); } PreparedStatement ps; Modified: ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSProfiler.java =================================================================== --- ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSProfiler.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSProfiler.java 2005-09-15 14:25:13 UTC (rev 815) @@ -18,6 +18,8 @@ */ package com.redhat.persistence.engine.rdbms; +import java.sql.Connection; + /** * RDBMSProfiler * @@ -29,6 +31,6 @@ public final static String versionId = "$Id$ by $Author$, $DateTime: 2004/08/16 18:10:38 $"; - StatementLifecycle getLifecycle(RDBMSStatement stmt); + StatementLifecycle getLifecycle(Connection conn, RDBMSStatement stmt); } Modified: ccm-core/trunk/src/com/redhat/persistence/profiler/rdbms/CompoundProfiler.java =================================================================== --- ccm-core/trunk/src/com/redhat/persistence/profiler/rdbms/CompoundProfiler.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/redhat/persistence/profiler/rdbms/CompoundProfiler.java 2005-09-15 14:25:13 UTC (rev 815) @@ -21,6 +21,7 @@ import com.redhat.persistence.engine.rdbms.RDBMSProfiler; import com.redhat.persistence.engine.rdbms.RDBMSStatement; import com.redhat.persistence.engine.rdbms.StatementLifecycle; +import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; import java.util.Iterator; @@ -45,11 +46,11 @@ m_children.add(child); } - public StatementLifecycle getLifecycle(RDBMSStatement stmt) { + public StatementLifecycle getLifecycle(Connection conn, RDBMSStatement stmt) { CompoundLifecycle result = null; for (Iterator it = m_children.iterator(); it.hasNext(); ) { RDBMSProfiler child = (RDBMSProfiler) it.next(); - StatementLifecycle sl = child.getLifecycle(stmt); + StatementLifecycle sl = child.getLifecycle(conn, stmt); if (sl == null) { continue; } if (result == null) { result = new CompoundLifecycle(); } result.add(sl); Modified: ccm-core/trunk/src/com/redhat/persistence/profiler/rdbms/StatementProfiler.java =================================================================== --- ccm-core/trunk/src/com/redhat/persistence/profiler/rdbms/StatementProfiler.java 2005-09-15 14:21:27 UTC (rev 814) +++ ccm-core/trunk/src/com/redhat/persistence/profiler/rdbms/StatementProfiler.java 2005-09-15 14:25:13 UTC (rev 815) @@ -32,6 +32,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; import java.util.Iterator; @@ -52,7 +53,7 @@ m_inPhase = false; } - public StatementLifecycle getLifecycle(final RDBMSStatement statement) { + public StatementLifecycle getLifecycle(final Connection conn, final RDBMSStatement statement) { if (m_isEnabled) { Assert.exists(m_out, PrintWriter.class); |
From: <ssk...@vh...> - 2005-09-15 14:30:41
|
Author: sskracic Date: 2005-09-15 16:21:27 +0200 (Thu, 15 Sep 2005) New Revision: 814 Modified: ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java Log: Connection tag table might be useful for some other debugging purposes, so let's have it exposed. Modified: ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java 2005-09-15 12:27:38 UTC (rev 813) +++ ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java 2005-09-15 14:21:27 UTC (rev 814) @@ -141,6 +141,10 @@ } } + public static final String getConnectionTag(Connection conn) { + return (String) s_connectionTags.get(conn.toString()); + } + private static final String tag(final Connection conn) { final int database = DbHelper.getDatabase(conn); try { |
From: <ssk...@vh...> - 2005-09-15 12:37:04
|
Author: sskracic Date: 2005-09-15 14:27:38 +0200 (Thu, 15 Sep 2005) New Revision: 813 Modified: ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java ccm-core/trunk/src/com/arsdigita/runtime/RuntimeConfig.java Log: JDBC connection debugging aid. Keeps track of all open JDBC connections in a CacheTable, so they can be monitored through webdev support. In addition to connection count tracking, a 'tag' is associated with every open JDBC connection. The tag is obtained as a db-dependent query result. For postgres, it will be the PID of a server backend serving that JDBC conn. For Oracle, it will be audited session identifier. /ccm/ds/cache-table browser will display all JDBC connections together with their associated tags (under 'Value' column). The tag can also be used to rename the thread using a particular JDBC conn. Whenever a thread acquires JDBC connection, its name gets '-db$tag' suffix. This can be of great help when a thread dump is performed, b/c we can now correlate Java threads with database sessions to see, for example, where Java code holds exclusive db locks so that other threads are waiting etc. There are two caveats though: 1. single persistence Session can span multiple JDBC connections 2. thread renaming is sticky, which means a thread will retain its '-db$tag' suffix even after it releases the database connection. In practice, this will often manifest as two or more threads having the same -'db$tag' suffix when a thread dump is performed. However, it's not such a big deal, b/c at most one of them will be involved in db activity. And finally, thread renaming gimmick can be disabled by setting the waf.runtime.thread_tagging to 'false' (it's enabled by default). Modified: ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java 2005-09-15 09:03:01 UTC (rev 812) +++ ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java 2005-09-15 12:27:38 UTC (rev 813) @@ -18,10 +18,14 @@ */ package com.arsdigita.persistence; +import com.arsdigita.caching.CacheTable; +import com.arsdigita.db.DbHelper; +import com.arsdigita.runtime.RuntimeConfig; import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.jdbc.Connections; import java.sql.Connection; import java.sql.DatabaseMetaData; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; @@ -45,6 +49,11 @@ private static final Logger s_log = Logger.getLogger(PooledConnectionSource.class); + private static CacheTable s_connectionTags = + new CacheTable("jdbcConnectionTags", + RuntimeConfig.getConfig().getJDBCPoolSize() + 10, + CacheTable.MAX_CACHE_AGE); + private String m_url; private int m_size; private long m_interval; @@ -52,6 +61,9 @@ private List m_available = new ArrayList(); private List m_untested = new ArrayList(); + private static boolean s_taggingEnabled = + RuntimeConfig.getConfig().isThreadTaggingEnabled(); + public PooledConnectionSource(String url, int size, long interval) { m_url = url; m_size = size; @@ -82,7 +94,8 @@ return (Connection) m_available.remove(ndx); } else { if (s_log.isDebugEnabled()) { - s_log.debug("Reacquisition failed: " + pref); + s_log.debug("Reacquisition failed: " + pref + + ", tag: " + s_connectionTags.get(pref.toString())); } return acquire(); } @@ -91,10 +104,14 @@ public synchronized Connection acquire() { while (true) { if (!m_available.isEmpty()) { - return (Connection) m_available.remove(0); + Connection conn = (Connection) m_available.remove(0); + renameThread(conn); + return conn; } else if (m_connections.size() < m_size) { Connection result = (Connection) Connections.acquire(m_url); + s_connectionTags.put(result.toString(), tag(result)); m_connections.add(result); + renameThread(result); return result; } else { try { wait(); } @@ -105,6 +122,53 @@ } } + private void renameThread(Connection conn) { + if (s_taggingEnabled) { + Thread curr = Thread.currentThread(); + String tname = curr.getName(); + String ctag = (String) s_connectionTags.get(conn.toString()); + if (ctag == null) { + s_log.warn("Could not obtain conn tag for: " + conn); + return; + } + String newName = tname.replaceAll("(-db[0-9]*)*$", "") + "-db" + ctag; + if (!tname.equals(newName)) { + if (s_log.isDebugEnabled()) { + s_log.debug("setting the thread name to: " + newName); + } + curr.setName(newName); + } + } + } + + private static final String tag(final Connection conn) { + final int database = DbHelper.getDatabase(conn); + try { + String sql = ""; + String tag = ""; + switch (database) { + case DbHelper.DB_POSTGRES: + sql = "select pg_backend_pid() as tag"; + break; + case DbHelper.DB_ORACLE: + sql = "select userenv('SESSIONID') as tag from dual"; + break; + } + PreparedStatement stmt = conn.prepareStatement(sql); + ResultSet rs = stmt.executeQuery(); + if (rs.next()) { + tag = rs.getString(1).trim(); + rs.close(); + } + stmt.close(); + s_log.info("Tagging JDBC connection: " + conn + " with tag: " + tag); + return tag; + } catch (SQLException e) { + throw new UncheckedWrapperException(e); + } + } + + public synchronized void release(Connection conn) { if (!m_connections.contains(conn)) { throw new IllegalArgumentException @@ -131,6 +195,8 @@ private synchronized void remove(Connection conn) { m_connections.remove(conn); m_available.remove(conn); + s_log.info("removed: " + conn + ", tag: " + s_connectionTags.get(conn.toString())); + s_connectionTags.remove(conn.toString()); } synchronized void testAvailable() { @@ -173,7 +239,9 @@ Connection conn = (Connection) it.next(); SQLException e = test(conn); if (e != null) { - s_log.warn("connection failed test", e); + s_log.warn("connection " + conn + + ", tag: " + s_connectionTags.get(conn.toString()) + + " failed test", e); try { conn.close(); } catch (SQLException ex) { Modified: ccm-core/trunk/src/com/arsdigita/runtime/RuntimeConfig.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/runtime/RuntimeConfig.java 2005-09-15 09:03:01 UTC (rev 812) +++ ccm-core/trunk/src/com/arsdigita/runtime/RuntimeConfig.java 2005-09-15 12:27:38 UTC (rev 813) @@ -19,6 +19,7 @@ package com.arsdigita.runtime; import com.arsdigita.util.jdbc.JDBCURLParameter; +import com.arsdigita.util.parameter.BooleanParameter; import com.arsdigita.util.parameter.IntegerParameter; import com.arsdigita.util.parameter.Parameter; import org.apache.log4j.Logger; @@ -59,6 +60,7 @@ private final Parameter m_poolSize; private final Parameter m_pingInterval; private final Parameter m_queryCacheSize; + private final Parameter m_threadTagging; /** * Constructs an empty RuntimeConfig object. @@ -75,11 +77,16 @@ m_queryCacheSize = new IntegerParameter ("waf.runtime.query_cache_size", Parameter.OPTIONAL, new Integer(2000)); + m_threadTagging = new BooleanParameter + ("waf.runtime.thread_tagging", + Parameter.REQUIRED, + Boolean.TRUE); register(m_url); register(m_poolSize); register(m_pingInterval); register(m_queryCacheSize); + register(m_threadTagging); loadInfo(); } @@ -112,4 +119,8 @@ return ((Integer) get(m_queryCacheSize)).intValue(); } + public final boolean isThreadTaggingEnabled() { + return ((Boolean)get(m_threadTagging)).booleanValue(); + } + } |
From: <cl...@vh...> - 2005-09-15 09:12:09
|
Author: clasohm Date: 2005-09-15 11:03:01 +0200 (Thu, 15 Sep 2005) New Revision: 812 Modified: contrib/ccm-ldn-camden-consultation/trunk/pdl/com/arsdigita/camden/cms/contenttypes/Consultation.pdl Log: fixed file associations so files are copied during publication Modified: contrib/ccm-ldn-camden-consultation/trunk/pdl/com/arsdigita/camden/cms/contenttypes/Consultation.pdl =================================================================== --- contrib/ccm-ldn-camden-consultation/trunk/pdl/com/arsdigita/camden/cms/contenttypes/Consultation.pdl 2005-09-15 08:50:20 UTC (rev 811) +++ contrib/ccm-ldn-camden-consultation/trunk/pdl/com/arsdigita/camden/cms/contenttypes/Consultation.pdl 2005-09-15 09:03:01 UTC (rev 812) @@ -47,7 +47,7 @@ join cam_consult_method_file_map.consultation_id to cam_consultations.consultation_id; - FileAsset[0..n] methodologyDocuments = + component FileAsset[0..n] methodologyDocuments = join cam_consultations.consultation_id to cam_consult_method_file_map.consultation_id, join cam_consult_method_file_map.file_id @@ -61,7 +61,7 @@ join cam_consult_feedback_file_map.consultation_id to cam_consultations.consultation_id; - FileAsset[0..n] feedbackDocuments = + component FileAsset[0..n] feedbackDocuments = join cam_consultations.consultation_id to cam_consult_feedback_file_map.consultation_id, join cam_consult_feedback_file_map.file_id |
From: <ssk...@vh...> - 2005-09-15 08:59:57
|
Author: sskracic Date: 2005-09-15 10:50:20 +0200 (Thu, 15 Sep 2005) New Revision: 811 Modified: ccm-core/trunk/src/com/arsdigita/persistence/ConnectionSource.java ccm-core/trunk/src/com/arsdigita/persistence/DedicatedConnectionSource.java ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java ccm-core/trunk/src/com/arsdigita/persistence/Session.java Log: Expanding the idea of reacquiring the connection that was already used by a particular Session (I stole it from mdbooth, but please don't tell anyone). Added acquire(preferredConn) method to the ConnectionSource interface, so that we can specify what Connection object we prefer (and naturally, this shuld be the same Connection we've already had). If the preferred Connection is not available, return the least used connection. Modified: ccm-core/trunk/src/com/arsdigita/persistence/ConnectionSource.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/persistence/ConnectionSource.java 2005-09-15 08:38:57 UTC (rev 810) +++ ccm-core/trunk/src/com/arsdigita/persistence/ConnectionSource.java 2005-09-15 08:50:20 UTC (rev 811) @@ -33,6 +33,8 @@ Connection acquire(); + Connection acquire(Connection preferred); + void release(Connection conn); } Modified: ccm-core/trunk/src/com/arsdigita/persistence/DedicatedConnectionSource.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/persistence/DedicatedConnectionSource.java 2005-09-15 08:38:57 UTC (rev 810) +++ ccm-core/trunk/src/com/arsdigita/persistence/DedicatedConnectionSource.java 2005-09-15 08:50:20 UTC (rev 811) @@ -47,6 +47,10 @@ return (Connection) m_connections.get(); } + public Connection acquire(Connection preferred) { + return acquire(); + } + public void release(Connection conn) { // do nothing } Modified: ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java 2005-09-15 08:38:57 UTC (rev 810) +++ ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java 2005-09-15 08:50:20 UTC (rev 811) @@ -68,10 +68,30 @@ } } + /** + * Tries to acquire preferred JDBC connection, if + * it's available. If not, grab the least recently used + * connection. + */ + public synchronized Connection acquire(Connection pref) { + if (pref == null) { + return acquire(); + } + int ndx = m_available.indexOf(pref); + if (ndx > -1) { + return (Connection) m_available.remove(ndx); + } else { + if (s_log.isDebugEnabled()) { + s_log.debug("Reacquisition failed: " + pref); + } + return acquire(); + } + } + public synchronized Connection acquire() { while (true) { if (!m_available.isEmpty()) { - return (Connection) m_available.remove(m_available.size()-1); + return (Connection) m_available.remove(0); } else if (m_connections.size() < m_size) { Connection result = (Connection) Connections.acquire(m_url); m_connections.add(result); Modified: ccm-core/trunk/src/com/arsdigita/persistence/Session.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/persistence/Session.java 2005-09-15 08:38:57 UTC (rev 810) +++ ccm-core/trunk/src/com/arsdigita/persistence/Session.java 2005-09-15 08:50:20 UTC (rev 811) @@ -89,8 +89,12 @@ com.redhat.persistence.engine.rdbms.ConnectionSource src = new com.redhat.persistence.engine.rdbms.ConnectionSource() { + + private Connection m_conn = null; + public Connection acquire() { - return m_source.acquire(); + m_conn = m_source.acquire(m_conn); + return m_conn; } public void release(Connection conn) { |
From: <ssk...@vh...> - 2005-09-15 08:48:09
|
Author: sskracic Date: 2005-09-15 10:38:57 +0200 (Thu, 15 Sep 2005) New Revision: 810 Modified: ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java Log: Sometimes, when connection to the database is interrupted and an SQLException is thrown, the connection is still marked as acquired. This is not good, since it will not undergo JDBC connection validity test in PooledConnectionSource$Tester. Instead, it will keep hanging on forever, resulting in unpredictable 500 Error pages whenever persistence choses to use it (and why it does so even if the conn is marked as acquired is beyond me). Modified: ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java =================================================================== --- ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java 2005-09-14 20:08:43 UTC (rev 809) +++ ccm-core/trunk/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java 2005-09-15 08:38:57 UTC (rev 810) @@ -511,6 +511,7 @@ } catch (SQLException e) { if (cycle != null) { cycle.endExecute(e); } logQueryDetails(Priority.ERROR, sql, w, op, e); + release(); throw new RDBMSException(e.getMessage()) {}; } catch (RuntimeException e) { logQueryDetails(Priority.ERROR, sql, w, op, e); |
From: <ssk...@vh...> - 2005-09-14 20:17:53
|
Author: sskracic Date: 2005-09-14 22:08:43 +0200 (Wed, 14 Sep 2005) New Revision: 809 Modified: ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java Log: Connection acquisition should go LIFO, and not FIFO. Why? Imagine that, at some point in time, server has 10 available connections (and production servers can have 100+ available connections). Let's label them conn1, conn2, ..., conn10. Now suppose a non-DML (ie. SELECT only) request comes which fires say 50 queries. Those queries will be distributed like this: 1st query : conn1 2nd query : conn2 3rd query : conn3 .. 10th query : conn10 11th query : conn1 12th query : conn2 .. Not only this is extremely inefficient when it comes to network layer, but it also defeats the whole purpose of server-side database caching, since a single request can be distributed among 100 different database backends!! And finally, it makes debugging database problems (eg. deadlocking due to horrendous code at some places) almost impossible. The patch addresses this issue by trying to reacquire the same database connection it has just released. It will not always succeed, since the persistence pooling mechanism is designed in a way that acquired connection is used as little time as possible. Hence whenever we're doing some Java CPU cycles between two database requests our just-released db connection can get acquired by some other thread. But in majority of cases (like 99%) we will acquire the same connection throughout the whole request. Modified: ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java 2005-09-14 19:51:59 UTC (rev 808) +++ ccm-core/trunk/src/com/arsdigita/persistence/PooledConnectionSource.java 2005-09-14 20:08:43 UTC (rev 809) @@ -71,7 +71,7 @@ public synchronized Connection acquire() { while (true) { if (!m_available.isEmpty()) { - return (Connection) m_available.remove(0); + return (Connection) m_available.remove(m_available.size()-1); } else if (m_connections.size() < m_size) { Connection result = (Connection) Connections.acquire(m_url); m_connections.add(result); |
From: <ssk...@vh...> - 2005-09-14 20:01:15
|
Author: sskracic Date: 2005-09-14 21:51:59 +0200 (Wed, 14 Sep 2005) New Revision: 808 Modified: ccm-core/trunk/src/com/arsdigita/caching/CacheTable.java Log: There's no reason for this symbols to be private, they might be useful. Modified: ccm-core/trunk/src/com/arsdigita/caching/CacheTable.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/caching/CacheTable.java 2005-09-14 16:03:05 UTC (rev 807) +++ ccm-core/trunk/src/com/arsdigita/caching/CacheTable.java 2005-09-14 19:51:59 UTC (rev 808) @@ -53,13 +53,13 @@ // this was 20, which was too high for small setups // cached Templates were eating 4megs each, so there you go - private static final int MIN_CACHE_SIZE = 2; + public static final int MIN_CACHE_SIZE = 2; - private static final int MAX_CACHE_SIZE = 1000000; - private static final int MIN_CACHE_AGE = 5; - private static final int MAX_CACHE_AGE = 60*60*24*30; - private static final int DEFAULT_CACHE_SIZE = 1000; - private static final int DEFAULT_CACHE_AGE = 300; + public static final int MAX_CACHE_SIZE = 1000000; + public static final int MIN_CACHE_AGE = 5; + public static final int MAX_CACHE_AGE = 60*60*24*30; + public static final int DEFAULT_CACHE_SIZE = 1000; + public static final int DEFAULT_CACHE_AGE = 300; private static Map s_caches = new Hashtable(); |
From: <ap...@vh...> - 2005-09-14 16:12:14
|
Author: apevec Date: 2005-09-14 18:03:05 +0200 (Wed, 14 Sep 2005) New Revision: 807 Modified: tools/trunk/tools/lib/CCM/Runtime.pm Log: remove debug helper Modified: tools/trunk/tools/lib/CCM/Runtime.pm =================================================================== --- tools/trunk/tools/lib/CCM/Runtime.pm 2005-09-14 16:01:56 UTC (rev 806) +++ tools/trunk/tools/lib/CCM/Runtime.pm 2005-09-14 16:03:05 UTC (rev 807) @@ -37,7 +37,6 @@ use CCM::Util; use File::Spec; -use Data::Dumper; sub new { my $proto = shift; |
From: <ap...@vh...> - 2005-09-14 16:11:09
|
Author: apevec Date: 2005-09-14 18:01:56 +0200 (Wed, 14 Sep 2005) New Revision: 806 Modified: tools/trunk/tools/lib/CCM/Runtime.pm Log: fix pg jdbc searching to work with different PostgreSQL versions/packagings Modified: tools/trunk/tools/lib/CCM/Runtime.pm =================================================================== --- tools/trunk/tools/lib/CCM/Runtime.pm 2005-09-14 09:57:10 UTC (rev 805) +++ tools/trunk/tools/lib/CCM/Runtime.pm 2005-09-14 16:01:56 UTC (rev 806) @@ -37,6 +37,7 @@ use CCM::Util; use File::Spec; +use Data::Dumper; sub new { my $proto = shift; @@ -158,16 +159,18 @@ $classpath = CCM::Util::catpath($classpath, $jar); } my $postgresql_jdbc = $ENV{'PG_JDBC2_LIB'}; - my @pg_jdbc_locs = ( - "/usr/share/java/rh-postgresql3.jar", - "/usr/share/pgsql/java/rh-postgresql3.jar", - "/usr/share/java/postgresql-jdbc3.jar", - "/usr/share/java/postgresql.jar" ); - # try 8.0, then 7.4, then everything else - my @pg80jars = glob("/usr/share/java/postgresql-8.0.*.jar"); - unshift @pg_jdbc_locs, (pop @pg80jars) if @pg80jars; + # try universal symlink first (pg8.0-FC4 rpm) + my @pg_jdbc_locs = ( "/usr/share/java/postgresql.jar", + "/usr/share/java/postgresql-jdbc3.jar" ); + # then 8.0 (PGDG rpm) + my @pg80jars = glob("/usr/share/java/postgresql-8.0*jdbc3.jar"); + push @pg_jdbc_locs, (pop @pg80jars) if @pg80jars; + # then 7.4 (FC3 rpm) my @pg74jars = glob("/usr/share/java/pg74*jdbc3.jar"); - unshift @pg_jdbc_locs, (pop @pg74jars) if @pg74jars; + push @pg_jdbc_locs, (pop @pg74jars) if @pg74jars; + # then RHDB (RHEL3 rpm) + push @pg_jdbc_locs, ("/usr/share/java/rh-postgresql3.jar", + "/usr/share/pgsql/java/rh-postgresql3.jar"); for my $jar (@pg_jdbc_locs) { last if defined $postgresql_jdbc; $postgresql_jdbc = $jar if -f $jar; |
From: <ssk...@vh...> - 2005-09-14 10:06:33
|
Author: sskracic Date: 2005-09-14 11:57:10 +0200 (Wed, 14 Sep 2005) New Revision: 805 Modified: ccm-cms/trunk/src/com/arsdigita/cms/lifecycle/Scheduler.java Log: Made survival of LC thread across db restarts possible. Set LC thread name to 'cycle', while we're at it. Modified: ccm-cms/trunk/src/com/arsdigita/cms/lifecycle/Scheduler.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/lifecycle/Scheduler.java 2005-09-14 09:08:15 UTC (rev 804) +++ ccm-cms/trunk/src/com/arsdigita/cms/lifecycle/Scheduler.java 2005-09-14 09:57:10 UTC (rev 805) @@ -154,8 +154,12 @@ fireCycleEvents(i, false); } catch (Throwable t) { - if (txn != null) { - txn.abortTxn(); + try { + if (txn != null) { + txn.abortTxn(); + } + } catch (Throwable t2) { + s_log.warn("Transaction cleanup failed: ", t2); } } finally { s_running = false; @@ -198,6 +202,7 @@ * run - Run the task */ public static synchronized void run() { + Thread.currentThread().setName("cycle"); Session ssn = SessionManager.getSession(); if ( !s_running ) { new KernelExcursion() { |
From: <ssk...@vh...> - 2005-09-14 09:17:36
|
Author: sskracic Date: 2005-09-14 11:08:15 +0200 (Wed, 14 Sep 2005) New Revision: 804 Modified: ccm-cms/trunk/src/com/arsdigita/cms/publishToFile/QueueManager.java Log: P2fs should be able to survive database restarts. The problem was in tnx.abortTnx() which was outside try/catch block so it was causing the p2fs thread to die whenever a database connection was temporarily lost. Modified: ccm-cms/trunk/src/com/arsdigita/cms/publishToFile/QueueManager.java =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/publishToFile/QueueManager.java 2005-09-13 14:45:49 UTC (rev 803) +++ ccm-cms/trunk/src/com/arsdigita/cms/publishToFile/QueueManager.java 2005-09-14 09:08:15 UTC (rev 804) @@ -509,15 +509,20 @@ } catch (Exception e) { s_log.warn("Ignoring uncaught exception", e); } finally { - if ( query != null ) { - query.close(); + try { + if ( query != null ) { + query.close(); + } + + if ( txn.inTxn() ) { + txn.abortTxn(); + s_log.info("Aborting transaction"); + } + } catch (Exception e) { + s_log.warn("Txn cleanup failed", e); + } finally { query = null; } - - if ( txn.inTxn() ) { - txn.abortTxn(); - s_log.info("Aborting transaction"); - } } // Tell the caller if there are more items to process. |
From: <fa...@vh...> - 2005-09-13 14:55:01
|
Author: fabrice Date: 2005-09-13 16:45:49 +0200 (Tue, 13 Sep 2005) New Revision: 803 Modified: ccm-cms-types-siteproxy/trunk/src/com/arsdigita/cms/contenttypes/SiteProxy.java Log: fixed Modified: ccm-cms-types-siteproxy/trunk/src/com/arsdigita/cms/contenttypes/SiteProxy.java =================================================================== --- ccm-cms-types-siteproxy/trunk/src/com/arsdigita/cms/contenttypes/SiteProxy.java 2005-09-13 11:23:00 UTC (rev 802) +++ ccm-cms-types-siteproxy/trunk/src/com/arsdigita/cms/contenttypes/SiteProxy.java 2005-09-13 14:45:49 UTC (rev 803) @@ -20,7 +20,6 @@ import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentPage; -import com.arsdigita.cms.ExtraXMLGenerator; import com.arsdigita.cms.dispatcher.SiteProxyPanel; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.persistence.OID; |
From: <cl...@vh...> - 2005-09-13 11:32:06
|
Author: clasohm Date: 2005-09-13 13:23:00 +0200 (Tue, 13 Sep 2005) New Revision: 802 Modified: contrib/ccm-ldn-camden-consultation/trunk/web/packages/consultations/templates/consultations-index.jsp Log: fixed redirect target Modified: contrib/ccm-ldn-camden-consultation/trunk/web/packages/consultations/templates/consultations-index.jsp =================================================================== --- contrib/ccm-ldn-camden-consultation/trunk/web/packages/consultations/templates/consultations-index.jsp 2005-09-12 15:49:09 UTC (rev 801) +++ contrib/ccm-ldn-camden-consultation/trunk/web/packages/consultations/templates/consultations-index.jsp 2005-09-13 11:23:00 UTC (rev 802) @@ -1,11 +1,12 @@ <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"> - <jsp:directive.page import="com.arsdigita.kernel.security.Initializer"/> <jsp:directive.page import="com.arsdigita.web.URL"/> <jsp:directive.page import="com.arsdigita.web.RedirectSignal"/> + <jsp:directive.page import="com.arsdigita.camden.cms.contenttypes.ConsultationApp"/> <jsp:directive.page extends="com.arsdigita.web.BaseJSP"/> <jsp:scriptlet> - throw new RedirectSignal("http://localhost:9008/ccm/consultations/", false); + ConsultationApp app = ConsultationApp.retrieveApplication(); + throw new RedirectSignal(URL.there(request, app, null), false); </jsp:scriptlet> </jsp:root> |
From: <fa...@vh...> - 2005-09-12 15:58:11
|
Author: fabrice Date: 2005-09-12 17:49:09 +0200 (Mon, 12 Sep 2005) New Revision: 801 Removed: ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/default/content-section/table-cms_form_item.sql Log: Un-undoing patch 688 Deleted: ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/default/content-section/table-cms_form_item.sql |
From: <fa...@vh...> - 2005-09-12 15:56:32
|
Author: fabrice Date: 2005-09-12 17:47:31 +0200 (Mon, 12 Sep 2005) New Revision: 800 Modified: ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/oracle-se-create.sql ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/postgres-create.sql Log: Un-undoing patch 688 Modified: ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/oracle-se-create.sql =================================================================== --- ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/oracle-se-create.sql 2005-09-12 15:12:35 UTC (rev 799) +++ ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/oracle-se-create.sql 2005-09-12 15:47:31 UTC (rev 800) @@ -20,7 +20,6 @@ @@ ddl/oracle-se/create.sql -@@ default/content-section/table-cms_form_item.sql @@ default/content-section/index-cms_form_item.sql @@ ddl/oracle-se/deferred.sql Modified: ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/postgres-create.sql =================================================================== --- ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/postgres-create.sql 2005-09-12 15:12:35 UTC (rev 799) +++ ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/postgres-create.sql 2005-09-12 15:47:31 UTC (rev 800) @@ -20,7 +20,6 @@ \i ddl/postgres/create.sql -\i default/content-section/table-cms_form_item.sql \i default/content-section/index-cms_form_item.sql \i ddl/postgres/deferred.sql |
From: <fa...@vh...> - 2005-09-12 15:21:36
|
Author: fabrice Date: 2005-09-12 17:12:35 +0200 (Mon, 12 Sep 2005) New Revision: 799 Added: ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/default/content-section/table-cms_form_item.sql Log: Missing sql file Added: ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/default/content-section/table-cms_form_item.sql =================================================================== --- ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/default/content-section/table-cms_form_item.sql 2005-09-12 15:11:00 UTC (rev 798) +++ ccm-cms-types-formitem/trunk/sql/ccm-cms-types-formitem/default/content-section/table-cms_form_item.sql 2005-09-12 15:12:35 UTC (rev 799) @@ -0,0 +1,30 @@ +-- +-- Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved. +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public License +-- as published by the Free Software Foundation; either version 2.1 of +-- the License, or (at your option) any later version. +-- +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-- +-- $Id: table-cms_form_item.sql 285 2005-02-22 00:29:02Z sskracic $ +-- $DateTime: 2004/08/17 23:15:09 $ + +create table cms_form_item ( + item_id integer + constraint cms_form_item_fk references + cms_pages (item_id) + constraint cms_form_item_pk primary key, + form_id integer + constraint cms_form_item_frm_fk references + bebop_form_sections (form_section_id) on delete cascade, + css varchar(700) +); |
From: <fa...@vh...> - 2005-09-12 15:20:02
|
Author: fabrice Date: 2005-09-12 17:11:00 +0200 (Mon, 12 Sep 2005) New Revision: 798 Modified: ccm-core/trunk/src/com/arsdigita/web/URL.java Log: Use dynamic host provider to get the host URL in emails Modified: ccm-core/trunk/src/com/arsdigita/web/URL.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/web/URL.java 2005-09-12 15:10:24 UTC (rev 797) +++ ccm-core/trunk/src/com/arsdigita/web/URL.java 2005-09-12 15:11:00 UTC (rev 798) @@ -691,6 +691,46 @@ } /** + * Method similar to there(), but which checks the + * waf.web.dynamic_host_provider parameter to generate + * the site name and port dynamically. + * + * @see com.arsdigita.web.DispatcherServlet + * @param sreq the servlet request + * @param path a <code>String</code> path to which to dispatch + * @param params a <code>ParameterMap</code> of parameters to use; + * this value may be null + * @return a <code>URL</code> with a path to dispatch to + */ + public static final URL dynamicHostThere(final HttpServletRequest sreq, + final String path, + final ParameterMap params) { + final WebConfig config = Web.getConfig(); + DynamicHostProvider provider = Web.getConfig().getDynamicHostProvider(); + + if (provider == null) { + return there(sreq, path, params); + } + + Assert.assertNotNull(sreq, "HttpServletRequest sreq"); + Assert.assertNotNull(config, "WebConfig config"); + + if (params != null) { + params.runListeners(sreq); + } + + final HttpHost host = new HttpHost(sreq); + + return new URL(sreq.getScheme(), + provider.getName(), + provider.getPort(), + config.getDispatcherContextPath(), + config.getDispatcherServletPath(), + path, + params); + } + + /** * <p>Creates a URL with no local parameters to <code>path</code> * under the CCM main dispatcher. This method implicitly creates * an empty parameter map (not a null one); this empty map may be |
From: <fa...@vh...> - 2005-09-12 15:19:31
|
Author: fabrice Date: 2005-09-12 17:10:24 +0200 (Mon, 12 Sep 2005) New Revision: 797 Added: ccm-core/trunk/src/com/arsdigita/web/HostDynamicHostProvider.java ccm-core/trunk/src/com/arsdigita/web/ServerDynamicHostProvider.java Log: Use dynamic host provider to get the host URL in emails Added: ccm-core/trunk/src/com/arsdigita/web/HostDynamicHostProvider.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/web/HostDynamicHostProvider.java 2005-09-12 15:08:13 UTC (rev 796) +++ ccm-core/trunk/src/com/arsdigita/web/HostDynamicHostProvider.java 2005-09-12 15:10:24 UTC (rev 797) @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005 RuntimeCollective Ltd. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.web; + +import com.arsdigita.util.servlet.HttpHost; + +public class HostDynamicHostProvider implements DynamicHostProvider { + + final HttpHost host = Web.getConfig().getHost(); + + public HostDynamicHostProvider() { + } + + public String getName() { + return host.getName(); + } + + public int getPort() { + return host.getPort(); + } +} Added: ccm-core/trunk/src/com/arsdigita/web/ServerDynamicHostProvider.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/web/ServerDynamicHostProvider.java 2005-09-12 15:08:13 UTC (rev 796) +++ ccm-core/trunk/src/com/arsdigita/web/ServerDynamicHostProvider.java 2005-09-12 15:10:24 UTC (rev 797) @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005 RuntimeCollective Ltd. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.web; + +import com.arsdigita.util.servlet.HttpHost; + +public class ServerDynamicHostProvider implements DynamicHostProvider { + + final HttpHost host = Web.getConfig().getServer(); + + public ServerDynamicHostProvider() { + } + + public String getName() { + return host.getName(); + } + + public int getPort() { + return host.getPort(); + } +} |
From: <fa...@vh...> - 2005-09-12 15:19:19
|
Author: fabrice Date: 2005-09-12 17:08:13 +0200 (Mon, 12 Sep 2005) New Revision: 796 Added: ccm-core/trunk/lib/PDFBox-0.7.1.jar Removed: ccm-core/trunk/lib/PDFBox-0.6.5.jar Log: Upgrading PDFBox Deleted: ccm-core/trunk/lib/PDFBox-0.6.5.jar Added: ccm-core/trunk/lib/PDFBox-0.7.1.jar =================================================================== (Binary files differ) Property changes on: ccm-core/trunk/lib/PDFBox-0.7.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream |
From: <fa...@vh...> - 2005-09-12 15:16:23
|
Author: fabrice Date: 2005-09-12 17:07:11 +0200 (Mon, 12 Sep 2005) New Revision: 795 Added: ccm-ldn-subsite/trunk/src/com/arsdigita/london/subsite/SubsiteDynamicHostProvider.java Log: DynamicHostProvider for subsites Added: ccm-ldn-subsite/trunk/src/com/arsdigita/london/subsite/SubsiteDynamicHostProvider.java =================================================================== --- ccm-ldn-subsite/trunk/src/com/arsdigita/london/subsite/SubsiteDynamicHostProvider.java 2005-09-12 15:06:53 UTC (rev 794) +++ ccm-ldn-subsite/trunk/src/com/arsdigita/london/subsite/SubsiteDynamicHostProvider.java 2005-09-12 15:07:11 UTC (rev 795) @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2005 RuntimeCollective Ltd. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.london.subsite; + +import com.arsdigita.util.servlet.HttpHost; +import com.arsdigita.web.ServerDynamicHostProvider; + +import org.apache.log4j.Logger; + +import java.net.URL; +import java.net.MalformedURLException; + +public class SubsiteDynamicHostProvider extends ServerDynamicHostProvider { + + private static final Logger s_log = Logger.getLogger(SubsiteDynamicHostProvider.class); + + public SubsiteDynamicHostProvider() { + super(); + } + + public String getName() { + if (!Subsite.getContext().hasSite()) { + return super.getName(); + } + + URL url = getSubsiteURL(); + return url.getHost(); + } + + public int getPort() { + if (!Subsite.getContext().hasSite()) { + return super.getPort(); + } + + URL url = getSubsiteURL(); + int port = url.getPort(); + if (port == -1) { + port = 80; + } + + return port; + } + + public URL getSubsiteURL() { + String hostname = Subsite.getContext().getSite().getHostname(); + if (hostname.indexOf('/') == -1) { + hostname = "http://"+hostname; + } + + URL url = null; + try { + url = new URL(hostname); + } catch (MalformedURLException e) { + s_log.error("Could not generate URL out of subsite hostname : "+hostname, e); + } + + return url; + } +} |
From: <fa...@vh...> - 2005-09-12 15:15:56
|
Author: fabrice Date: 2005-09-12 17:06:53 +0200 (Mon, 12 Sep 2005) New Revision: 794 Modified: ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/Shortcut.java ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutFilter.java ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutUtil.java ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutsConfig.java Log: Code layout and fix transaction close Modified: ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/Shortcut.java =================================================================== --- ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/Shortcut.java 2005-09-12 15:06:00 UTC (rev 793) +++ ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/Shortcut.java 2005-09-12 15:06:53 UTC (rev 794) @@ -13,24 +13,21 @@ * */ - package com.arsdigita.london.shortcuts; - import com.arsdigita.db.Sequences; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DomainObject; +import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.SessionManager; +import com.arsdigita.persistence.Session; +import com.arsdigita.util.UncheckedWrapperException; import java.math.BigDecimal; -import com.arsdigita.persistence.DataCollection; -import com.arsdigita.util.UncheckedWrapperException; import java.sql.SQLException; -import com.arsdigita.persistence.Session; - /** * A shortcut * @author <a href="mailto:tzu...@ar...">Tzu-Mainn Chen</a> @@ -86,10 +83,8 @@ public static ShortcutCollection retrieveAll() { Session session = SessionManager.getSession(); DataCollection shortcuts = session.retrieve(BASE_DATA_OBJECT_TYPE); - shortcuts.addOrder(URL_KEY); - - return new ShortcutCollection(shortcuts); + return new ShortcutCollection(shortcuts); } public static Shortcut findByURL(String url) Modified: ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutFilter.java =================================================================== --- ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutFilter.java 2005-09-12 15:06:00 UTC (rev 793) +++ ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutFilter.java 2005-09-12 15:06:53 UTC (rev 794) @@ -16,20 +16,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - package com.arsdigita.london.shortcuts; -import javax.servlet.FilterChain; +import com.arsdigita.web.BaseFilter; +import java.io.IOException; +import javax.servlet.FilterChain; import javax.servlet.ServletException; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -import com.arsdigita.web.BaseFilter; - import org.apache.log4j.Logger; public class ShortcutFilter extends BaseFilter { Modified: ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutUtil.java =================================================================== --- ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutUtil.java 2005-09-12 15:06:00 UTC (rev 793) +++ ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutUtil.java 2005-09-12 15:06:53 UTC (rev 794) @@ -15,10 +15,7 @@ package com.arsdigita.london.shortcuts; - - import com.arsdigita.caching.CacheTable; - import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.TransactionContext; @@ -27,7 +24,6 @@ import org.apache.log4j.Logger; - public class ShortcutUtil { private static final Logger s_log = @@ -73,22 +69,31 @@ try { s_remote.put("shortcuts", "shortcuts"); + if (s_log.isDebugEnabled()) { s_log.debug("Actually repopulating the cache"); + } s_cache.clear(); ShortcutCollection shortcuts = Shortcut.retrieveAll(); while (shortcuts.next()) { Shortcut shortcut = shortcuts.getShortcut(); + if (s_log.isDebugEnabled()) { s_log.debug(shortcut.getUrlKey() + " -> " + shortcut.getRedirect()); + } s_cache.put(shortcut.getUrlKey().toLowerCase(), shortcut.getRedirect()); } - if (s_log.isDebugEnabled()) { + + // only commit the Txn if we started it + if (doTxn) { + if (s_log.isDebugEnabled()) { s_log.debug("Committing DB transaction"); } txn.commitTxn(); + } + } finally { - if (txn.inTxn() && doTxn) { + if (doTxn && txn.inTxn()) { if (s_log.isDebugEnabled()) { s_log.debug("Aborting DB transaction"); } Modified: ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutsConfig.java =================================================================== --- ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutsConfig.java 2005-09-12 15:06:00 UTC (rev 793) +++ ccm-ldn-shortcuts/trunk/src/com/arsdigita/london/shortcuts/ShortcutsConfig.java 2005-09-12 15:06:53 UTC (rev 794) @@ -19,6 +19,8 @@ package com.arsdigita.london.shortcuts; import com.arsdigita.runtime.AbstractConfig; +import com.arsdigita.util.parameter.IntegerParameter; +import com.arsdigita.util.parameter.Parameter; import org.apache.log4j.Logger; @@ -33,6 +35,7 @@ * @version $Id$ */ public final class ShortcutsConfig extends AbstractConfig { + public static final String versionId = "$Id$" + "$Author$" + @@ -43,5 +46,4 @@ public ShortcutsConfig() { loadInfo(); } - } |
From: <fa...@vh...> - 2005-09-12 15:15:18
|
Author: fabrice Date: 2005-09-12 17:06:00 +0200 (Mon, 12 Sep 2005) New Revision: 793 Modified: ccm-ldn-portal/trunk/src/com/arsdigita/london/portal/ui/portlet/ContentDirectoryPortletRenderer.java Log: Output the sortKey Modified: ccm-ldn-portal/trunk/src/com/arsdigita/london/portal/ui/portlet/ContentDirectoryPortletRenderer.java =================================================================== --- ccm-ldn-portal/trunk/src/com/arsdigita/london/portal/ui/portlet/ContentDirectoryPortletRenderer.java 2005-09-12 15:05:35 UTC (rev 792) +++ ccm-ldn-portal/trunk/src/com/arsdigita/london/portal/ui/portlet/ContentDirectoryPortletRenderer.java 2005-09-12 15:06:00 UTC (rev 793) @@ -15,33 +15,29 @@ package com.arsdigita.london.portal.ui.portlet; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.portal.AbstractPortletRenderer; import com.arsdigita.categorization.Category; import com.arsdigita.categorization.CategoryCollection; - +import com.arsdigita.london.portal.portlet.ContentDirectoryPortlet; +import com.arsdigita.london.portal.ui.PortalConstants; import com.arsdigita.persistence.OID; - -import com.arsdigita.bebop.PageState; - +import com.arsdigita.portal.Portlet; import com.arsdigita.web.URL; import com.arsdigita.web.ParameterMap; import com.arsdigita.web.Web; - import com.arsdigita.xml.Element; import com.arsdigita.xml.XML; - - -import com.arsdigita.london.portal.portlet.ContentDirectoryPortlet; -import com.arsdigita.london.portal.ui.PortalConstants; -import com.arsdigita.bebop.portal.AbstractPortletRenderer; - import org.apache.log4j.Logger; import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Iterator; -import java.util.List; -import java.util.ArrayList; +import java.util.TreeSet; public class ContentDirectoryPortletRenderer extends AbstractPortletRenderer { @@ -69,6 +65,7 @@ CategoryCollection cats = root.getDescendants(); cats.addEqualsFilter("parents.link.relationType", "child"); + cats.addPath("parents.link.sortKey"); cats.addPath("parents.id"); cats.addOrder("parents.link.sortKey"); @@ -77,13 +74,14 @@ Category cat = cats.getCategory(); BigDecimal parentID = (BigDecimal)cats.get("parents.id"); - List childList = (List)children.get(parentID); + TreeSet childList = (TreeSet) children.get(parentID); if (childList == null) { - childList = new ArrayList(); + childList = new TreeSet(); children.put(parentID, childList); } - childList.add(cat); + childList.add(new CategorySortKeyPair + (cat, (BigDecimal)cats.get("parents.link.sortKey"))); } processChildren(element, root, children, 1, m_portlet.getDepth()); @@ -95,13 +93,15 @@ int depth, int maxDepth) { if (depth <= maxDepth) { - List c = (List)children.get(cat.getID()); + TreeSet c = (TreeSet) children.get(cat.getID()); if (c != null) { Iterator i = c.iterator(); while (i.hasNext()) { - Category child = (Category)i.next(); + CategorySortKeyPair pair = (CategorySortKeyPair) i.next(); + Category child = pair.getCategory(); + BigDecimal childSortKey = pair.getSortKey(); if (child.isEnabled()) { - Element el = generateCategory(child, depth); + Element el = generateCategory(child, depth, childSortKey); parent.addContent(el); processChildren(el, child, children, depth+1, maxDepth); @@ -112,7 +112,8 @@ } public Element generateCategory(Category cat, - int depth) { + int depth, + BigDecimal childSortKey) { Element el = new Element(depth == 1 ? "portlet:contentDirectoryEntry" : "portlet:contentDirectorySubentry", @@ -123,6 +124,7 @@ el.addAttribute("description", cat.getDescription()); el.addAttribute("isAbstract", cat.isAbstract() ? "1" : "0"); el.addAttribute("url", redirectURL(cat.getOID())); + el.addAttribute("sortKey", XML.format(childSortKey)); return el; } @@ -140,4 +142,23 @@ "/redirect/", map )).toString(); } + private class CategorySortKeyPair implements Comparable { + private Category m_category; + private BigDecimal m_sortKey; + + public CategorySortKeyPair(Category category, BigDecimal sortKey) { + m_category = category; + m_sortKey = sortKey; + } + public Category getCategory() { + return m_category; + } + public BigDecimal getSortKey() { + return m_sortKey; + } + + public int compareTo(Object o) { + return m_sortKey.compareTo(((CategorySortKeyPair)o).m_sortKey); + } + } } |
From: <fa...@vh...> - 2005-09-12 15:14:56
|
Author: fabrice Date: 2005-09-12 17:05:35 +0200 (Mon, 12 Sep 2005) New Revision: 792 Modified: ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/NavigationFileResolver.java Log: Filter out non-existing categories, or categories which are not in the correct tree Modified: ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/NavigationFileResolver.java =================================================================== --- ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/NavigationFileResolver.java 2005-09-12 15:04:51 UTC (rev 791) +++ ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/NavigationFileResolver.java 2005-09-12 15:05:35 UTC (rev 792) @@ -18,25 +18,27 @@ package com.arsdigita.london.navigation; - +import com.arsdigita.categorization.Categorization; +import com.arsdigita.categorization.Category; +import com.arsdigita.categorization.CategoryCollection; +import com.arsdigita.cms.TemplateContext; +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.london.terms.Domain; +import com.arsdigita.persistence.DataCollection; +import com.arsdigita.persistence.SessionManager; +import com.arsdigita.util.Assert; +import com.arsdigita.util.StringUtils; +import com.arsdigita.web.Application; import com.arsdigita.web.DefaultApplicationFileResolver; -import com.arsdigita.web.Application; import com.arsdigita.web.Web; -import com.arsdigita.cms.TemplateContext; -import com.arsdigita.util.StringUtils; -import com.arsdigita.util.Assert; -import com.arsdigita.categorization.Category; -import com.arsdigita.categorization.CategoryCollection; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.RequestDispatcher; import java.math.BigDecimal; - +import java.util.ArrayList; import java.util.List; -import java.util.ArrayList; import org.apache.log4j.Logger; @@ -73,7 +75,42 @@ useContext = Template.DEFAULT_USE_CONTEXT; } - Category cat = new Category(new BigDecimal(id)); + Category cat = null; + + // if the category doesn't exist, send a 404, nicer + try { + cat = new Category(new BigDecimal(id)); + } catch (Exception e) { + s_log.warn("Could not load category for id "+id); + return null; + } + + // check that the category is in the tree of categories + Category root = null; + DataCollection objs = SessionManager.getSession() + .retrieve(Domain.BASE_DATA_OBJECT_TYPE); + objs.addEqualsFilter("model.ownerUseContext.categoryOwner.id", nav.getID()); + objs.addEqualsFilter("model.ownerUseContext.useContext", null); + DomainCollection domains = new DomainCollection(objs); + if (domains.next()) { + root = ((Domain) domains.getDomainObject()).getModel(); + } else { + // can't find domain, 404 + return null; + } + domains.close(); + if (root == null) { + // no root category, 404 + return null; + } + + if (!root.isMemberOfSubtree(cat)) { + // send of 404 + s_log.warn("Category doesn't belong to navigation tree."); + return null; + } + + CategoryCollection parents = cat.getDefaultAscendants(); parents.addOrder(Category.DEFAULT_ANCESTORS); List cats = new ArrayList(); |