bloritsch 01/08/09 14:12:44
Modified: src/org/apache/cocoon/acting Tag: cocoon_20_branch
DatabaseAuthenticatorAction.java
src/org/apache/cocoon/components/classloader Tag:
cocoon_20_branch ClassLoaderManagerImpl.java
src/org/apache/cocoon/reading Tag: cocoon_20_branch
DatabaseReader.java
Log:
Add messages for DBAuthenticator, cleaned up ClassLoaderManagerImpl a bit, and
added functionality to qualify the Database reader more carefully (where and order-by
parameters). Also added code to handle the condition of the dbcolumn that was
supposed
to house the last-modified date is null.
Revision Changes Path
No revision
No revision
1.3.2.5 +6 -3
xml-cocoon2/src/org/apache/cocoon/acting/DatabaseAuthenticatorAction.java
Index: DatabaseAuthenticatorAction.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/acting/DatabaseAuthenticatorAction.java,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.5
diff -u -r1.3.2.4 -r1.3.2.5
--- DatabaseAuthenticatorAction.java 2001/07/20 13:35:49 1.3.2.4
+++ DatabaseAuthenticatorAction.java 2001/08/09 21:12:43 1.3.2.5
@@ -1,4 +1,4 @@
-// $Id: DatabaseAuthenticatorAction.java,v 1.3.2.4 2001/07/20 13:35:49 cziegeler
Exp $
+// $Id: DatabaseAuthenticatorAction.java,v 1.3.2.5 2001/08/09 21:12:43 bloritsch
Exp $
package org.apache.cocoon.acting;
import java.sql.Connection;
@@ -51,7 +51,7 @@
* not verified.
*
* @author Martin Man <[EMAIL PROTECTED]>
- * @version CVS $Revision: 1.3.2.4 $ $Date: 2001/07/20 13:35:49 $
+ * @version CVS $Revision: 1.3.2.5 $ $Date: 2001/08/09 21:12:43 $
*/
public class DatabaseAuthenticatorAction extends AbstractDatabaseAction
{
@@ -98,6 +98,7 @@
String query = this.getAuthQuery (conf, req);
if (query == null) {
getLogger ().debug ("DBAUTH: have not got query");
+ req.setAttribute("message", "The authenticator is misconfigured");
return null;
}
@@ -129,6 +130,8 @@
}
conn.rollback();
+
+ req.setAttribute("message", "The username or password were incorrect,
please check your CAPS LOCK key and try again.");
getLogger ().debug ("DBAUTH: no results for query");
} catch (Exception e) {
if (conn != null) {
@@ -249,5 +252,5 @@
}
}
-// $Id: DatabaseAuthenticatorAction.java,v 1.3.2.4 2001/07/20 13:35:49 cziegeler
Exp $
+// $Id: DatabaseAuthenticatorAction.java,v 1.3.2.5 2001/08/09 21:12:43 bloritsch
Exp $
// vim: set et ts=4 sw=4:
No revision
No revision
1.2.2.1 +17 -4
xml-cocoon2/src/org/apache/cocoon/components/classloader/ClassLoaderManagerImpl.java
Index: ClassLoaderManagerImpl.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/classloader/ClassLoaderManagerImpl.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1
--- ClassLoaderManagerImpl.java 2001/05/31 17:37:47 1.2
+++ ClassLoaderManagerImpl.java 2001/08/09 21:12:43 1.2.2.1
@@ -11,6 +11,10 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+import java.util.Vector;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.util.ClassUtils;
@@ -18,7 +22,7 @@
* A singleton-like implementation of <code>ClassLoaderManager</code>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
- * @version CVS $Revision: 1.2 $ $Date: 2001/05/31 17:37:47 $
+ * @version CVS $Revision: 1.2.2.1 $ $Date: 2001/08/09 21:12:43 $
*/
public class ClassLoaderManagerImpl implements ClassLoaderManager, ThreadSafe {
/**
@@ -26,6 +30,8 @@
*/
protected static RepositoryClassLoader instance = null;
+ protected static Set fileSet = Collections.synchronizedSet(new HashSet());
+
/**
* A constructor that ensures only a single class loader instance exists
*
@@ -43,7 +49,10 @@
* @exception IOException If the directory is invalid
*/
public void addDirectory(File directoryName) throws IOException {
- instance.addDirectory(directoryName);
+ if ( ! ClassLoaderManagerImpl.fileSet.contains(directoryName)) {
+ ClassLoaderManagerImpl.fileSet.add(directoryName);
+ ClassLoaderManagerImpl.instance.addDirectory(directoryName);
+ }
}
/**
@@ -54,7 +63,7 @@
* @exception ClassNotFoundException If the class is not found
*/
public Class loadClass(String className) throws ClassNotFoundException {
- return instance.loadClass(className);
+ return ClassLoaderManagerImpl.instance.loadClass(className);
}
/**
@@ -62,6 +71,10 @@
*
*/
public void reinstantiate() {
- instance = new RepositoryClassLoader();
+ if ( ClassLoaderManagerImpl.fileSet.isEmpty()) {
+ ClassLoaderManagerImpl.instance = new RepositoryClassLoader();
+ } else {
+ ClassLoaderManagerImpl.instance = new RepositoryClassLoader(new
Vector(ClassLoaderManagerImpl.fileSet));
+ }
}
}
No revision
No revision
1.2.2.3 +30 -4 xml-cocoon2/src/org/apache/cocoon/reading/DatabaseReader.java
Index: DatabaseReader.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/reading/DatabaseReader.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- DatabaseReader.java 2001/07/12 10:29:45 1.2.2.2
+++ DatabaseReader.java 2001/08/09 21:12:43 1.2.2.3
@@ -53,7 +53,7 @@
public class DatabaseReader extends AbstractReader implements Composable,
Configurable, Disposable, Cacheable, Poolable {
private ComponentSelector dbselector;
private String dsn;
- private long lastModified = 0;
+ private long lastModified = new Date().getTime();
private Blob resource = null;
private Connection con = null;
private DataSourceComponent datasource = null;
@@ -100,7 +100,7 @@
PreparedStatement statement = con.prepareStatement(getQuery());
statement.setString(1, this.source);
ResultSet set = statement.executeQuery();
- if (set.next() == false) throw new ResourceNotFoundException("There is
no image with that key");
+ if (set.next() == false) throw new ResourceNotFoundException("There is
no resource with that key");
Response response = (Response)
objectModel.get(Constants.RESPONSE_OBJECT);
Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
@@ -144,6 +144,8 @@
* <parameter name="last-modified"
value="database_timestamp_column_name"/>
* <parameter name="content-type" value="content_mime_type"/>
* <parameter name="expires" value="number_of_millis_before_refresh"/>
+ * <parameter name="where" value="alternate_key = 'foo'"/>
+ * <parameter name="order-by" value="alternate_key DESC"/>
* </pre>
*
* Lastly, the <code>key</code> value is derived from the value of
@@ -175,6 +177,8 @@
String table = this.parameters.getParameter("table", null);
String column = this.parameters.getParameter("image", null);
String key = this.parameters.getParameter("key", null);
+ String where = this.parameters.getParameter("where", null);
+ String orderBy = this.parameters.getParameter("order-by", null);
if (table == null || column == null || key==null) {
throw new ProcessingException("We are missing a required parameter.
Please include 'table', 'image', and 'key'");
@@ -189,9 +193,27 @@
query.append(", ").append(date);
}
+ if (null != orderBy) {
+ query.append(", ");
+
+ if (orderBy.endsWith(" DESC")) {
+ query.append(orderBy.substring(0, orderBy.length() - 5));
+ } else {
+ query.append(orderBy);
+ }
+ }
+
query.append(" FROM ").append(table);
query.append(" WHERE ").append(key).append(" = ?");
+ if (null != where) {
+ query.append(" AND ").append(where);
+ }
+
+ if (null != orderBy) {
+ query.append(" ORDER BY ").append(orderBy);
+ }
+
return query.toString();
}
@@ -213,11 +235,15 @@
if (lastModified != null) {
Timestamp modified = set.getTimestamp(lastModified, null);
- this.lastModified = modified.getTime();
+ if (null != modified) {
+ this.lastModified = modified.getTime();
+ } else {
+ // assume it has never been modified
+ }
response.setDateHeader("Last-Modified", this.lastModified);
- return modified.getTime() > request.getDateHeader("if-modified-since");
+ return this.lastModified > request.getDateHeader("if-modified-since");
}
// if we have nothing to compare to, then we must assume it
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]