bloritsch 01/03/02 12:27:03
Modified: src/org/apache/cocoon/acting Tag: xml-cocoon2
AbstractDatabaseAction.java DatabaseAddAction.java
DatabaseDeleteAction.java DatabaseUpdateAction.java
Removed: src/org/apache/cocoon/acting Tag: xml-cocoon2
ImageUploadAction.java
Log:
Updated DatabaseActions so that Images can be handled as well.
Revision Changes Path
No revision
No revision
1.1.2.9 +72 -1
xml-cocoon/src/org/apache/cocoon/acting/Attic/AbstractDatabaseAction.java
Index: AbstractDatabaseAction.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/AbstractDatabaseAction.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- AbstractDatabaseAction.java 2001/02/27 19:32:13 1.1.2.8
+++ AbstractDatabaseAction.java 2001/03/02 20:26:21 1.1.2.9
@@ -138,13 +138,39 @@
* <td>now</td>
* <td>a Timestamp with the current day/time--the form value is
ignored.</td>
* </tr>
+ * <tr>
+ * <td>image</td>
+ * <td>a binary image file, we cache the attribute information</td>
+ * </tr>
+ * <tr>
+ * <td>image-width</td>
+ * <td>
+ * the width attribute of the cached file attribute. NOTE:
+ * param attribute must equal the same param for image.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>image-height</td>
+ * <td>
+ * the width attribute of the cached file attribute NOTE:
+ * param attribute must equal the same param for image.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>image-size</td>
+ * <td>
+ * the size attribute of the cached file attribute NOTE:
+ * param attribute must equal the same param for image.
+ * </td>
+ * </tr>
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.2.8 $ $Date: 2001/02/27 19:32:13 $
+ * @version CVS $Revision: 1.1.2.9 $ $Date: 2001/03/02 20:26:21 $
*/
public abstract class AbstractDatabaseAction extends ComposerAction
implements Configurable {
private static Map configurations = new HashMap();
+ protected Map files = new HashMap();
private static final Map typeConstants;
protected ComponentSelector dbselector;
@@ -165,6 +191,10 @@
constants.put("time", new Integer(Types.TIME));
constants.put("time-stamp", new Integer(Types.TIMESTAMP));
constants.put("now", new Integer(Types.OTHER));
+ constants.put("image", new Integer(Types.DISTINCT));
+ constants.put("image-width", new Integer(Types.ARRAY));
+ constants.put("image-height", new Integer(Types.BIT));
+ constants.put("image-size", new Integer(Types.CHAR));
typeConstants = Collections.unmodifiableMap(constants);
}
@@ -310,6 +340,47 @@
break;
case Types.OTHER:
statement.setTimestamp(position, new Timestamp((new
java.util.Date()).getTime()));
+ break;
+ case Types.DISTINCT:
+ // Upload an image (just like binary), but cache attributes
+ Parameters param = new Parameters();
+ File imageFile = (File) request.get(attribute);
+ FileInputStream imageStream = new FileInputStream(imageFile);
+ statement.setBinaryStream(position, imageStream, (int)
imageFile.length());
+
+ param.setParameter("image-size",
Long.toString(imageFile.length()));
+
+ int [] dimensions =
ImageDirectoryGenerator.getSize(imageFile);
+ param.setParameter("image-width",
Integer.toString(dimensions[0]));
+ param.setParameter("image-height",
Integer.toString(dimensions[1]));
+
+ synchronized (this.files) {
+ this.files.put(imageFile, param);
+ }
+ break;
+ case Types.ARRAY:
+ // Grab the image-width attribute from the cached attributes
+ imageFile = (File) request.get(attribute);
+ synchronized (this.files) {
+ param = (Parameters) this.files.get(imageFile);
+ statement.setInt(position,
param.getParameterAsInteger("image-width", -1));
+ }
+ break;
+ case Types.BIT:
+ // Grab the image-height attribute from the cached attributes
+ imageFile = (File) request.get(attribute);
+ synchronized (this.files) {
+ param = (Parameters) this.files.get(imageFile);
+ statement.setInt(position,
param.getParameterAsInteger("image-height", -1));
+ }
+ break;
+ case Types.CHAR:
+ // Grab the image-size attribute from the cached attributes
+ imageFile = (File) request.get(attribute);
+ synchronized (this.files) {
+ param = (Parameters) this.files.get(imageFile);
+ statement.setInt(position,
param.getParameterAsInteger("image-size", -1));
+ }
break;
}
}
1.1.2.9 +3 -3
xml-cocoon/src/org/apache/cocoon/acting/Attic/DatabaseAddAction.java
Index: DatabaseAddAction.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/DatabaseAddAction.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- DatabaseAddAction.java 2001/02/27 19:32:13 1.1.2.8
+++ DatabaseAddAction.java 2001/03/02 20:26:27 1.1.2.9
@@ -40,7 +40,7 @@
* only one table at a time to update.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.2.8 $ $Date: 2001/02/27 19:32:13 $
+ * @version CVS $Revision: 1.1.2.9 $ $Date: 2001/03/02 20:26:27 $
*/
public class DatabaseAddAction extends AbstractDatabaseAction {
private static final Map addStatements = new HashMap();
@@ -182,9 +182,9 @@
queryBuffer.append(")");
query = queryBuffer.toString();
- }
- DatabaseAddAction.addStatements.put(conf, query);
+ DatabaseAddAction.addStatements.put(conf, query);
+ }
}
return query;
1.1.2.6 +3 -3
xml-cocoon/src/org/apache/cocoon/acting/Attic/DatabaseDeleteAction.java
Index: DatabaseDeleteAction.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/DatabaseDeleteAction.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- DatabaseDeleteAction.java 2001/02/27 18:19:08 1.1.2.5
+++ DatabaseDeleteAction.java 2001/03/02 20:26:31 1.1.2.6
@@ -43,7 +43,7 @@
* the keys.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/02/27 18:19:08 $
+ * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/03/02 20:26:31 $
*/
public final class DatabaseDeleteAction extends AbstractDatabaseAction {
private static final Map deleteStatements = new HashMap();
@@ -130,9 +130,9 @@
}
query = queryBuffer.toString();
- }
- DatabaseDeleteAction.deleteStatements.put(conf, query);
+ DatabaseDeleteAction.deleteStatements.put(conf, query);
+ }
}
return query;
1.1.2.10 +3 -3
xml-cocoon/src/org/apache/cocoon/acting/Attic/DatabaseUpdateAction.java
Index: DatabaseUpdateAction.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/DatabaseUpdateAction.java,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- DatabaseUpdateAction.java 2001/02/27 18:19:09 1.1.2.9
+++ DatabaseUpdateAction.java 2001/03/02 20:26:34 1.1.2.10
@@ -40,7 +40,7 @@
* only one table at a time to update.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.1.2.9 $ $Date: 2001/02/27 18:19:09 $
+ * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/03/02 20:26:34 $
*/
public class DatabaseUpdateAction extends AbstractDatabaseAction {
private static final Map updateStatements = new HashMap();
@@ -151,9 +151,9 @@
}
query = queryBuffer.toString();
- }
- DatabaseUpdateAction.updateStatements.put(conf, query);
+ DatabaseUpdateAction.updateStatements.put(conf, query);
+ }
}
return query;