balld 01/05/21 12:43:20
Modified: src/org/apache/cocoon/acting AbstractDatabaseAction.java
Log:
fixed blob uploading and image attribute setting
Revision Changes Path
1.4 +24 -5
xml-cocoon2/src/org/apache/cocoon/acting/AbstractDatabaseAction.java
Index: AbstractDatabaseAction.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/acting/AbstractDatabaseAction.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractDatabaseAction.java 2001/05/18 20:03:16 1.3
+++ AbstractDatabaseAction.java 2001/05/21 19:43:16 1.4
@@ -173,7 +173,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Donald Ball</a>
- * @version CVS $Revision: 1.3 $ $Date: 2001/05/18 20:03:16 $
+ * @version CVS $Revision: 1.4 $ $Date: 2001/05/21 19:43:16 $
*/
public abstract class AbstractDatabaseAction extends
AbstractComplementaryConfigurableAction implements Configurable, Disposable {
protected Map files = new HashMap();
@@ -395,8 +395,12 @@
*/
if (value == null) {
/** If the value is null, set the column value null and return
**/
- statement.setNull(position, typeObject.intValue());
- return;
+ if (typeName.equals("image-width") ||
typeName.equals("image-height") || typeName.equals("image-size")) {
+ /** these column types are automatically generated so it's ok
**/
+ } else {
+ statement.setNull(position, typeObject.intValue());
+ return;
+ }
}
if ("".equals(value)) {
switch (typeObject.intValue()) {
@@ -406,6 +410,11 @@
/** If the value is an empty string and the column is
a string type, we can continue **/
break;
+ case Types.INTEGER:
+ if (typeName.equals("image-width") ||
typeName.equals("image-height") || typeName.equals("image-size")) {
+ /** again, these types are okay to be absent **/
+ break;
+ }
default:
/** If the value is an empty string and the column
is something else, we treat it as a null value **/
@@ -543,8 +552,15 @@
statement.setTimestamp(position, new Timestamp((new
java.util.Date()).getTime()));
break;
case Types.BLOB:
- file = (File)value;
- InputStream input = new BufferedInputStream(new
FileInputStream(file));
+ if (value instanceof File) {
+ file = (File)value;
+ } else if (value instanceof String) {
+ file = new File((String)value);
+ } else {
+ throw new SQLException("Invalid type for blob:
"+value.getClass().getName());
+ }
+ //InputStream input = new BufferedInputStream(new
FileInputStream(file));
+ FileInputStream input = new FileInputStream(file);
statement.setBinaryStream(position, input,
(int)file.length());
if ("image".equals(typeName)) {
/** If this column type is an image, store the
@@ -582,6 +598,7 @@
Why do we do this? **/
setRequestAttribute(request,param,parameters.getParameter("image-width",""));
}
+ break;
} else if ("image-height".equals(typeName)) {
/** Get the image height from the cached image data **/
String imageAttr = param.substring(0, (param.length() -
"-height".length()));
@@ -591,6 +608,7 @@
statement.setInt(position,
parameters.getParameterAsInteger("image-height", -1));
setRequestAttribute(request,param,parameters.getParameter("image-height",""));
}
+ break;
} else if ("image-size".equals(typeName)) {
/** Get the image file size from the cached image data
**/
String imageAttr = param.substring(0, (param.length() -
"-size".length()));
@@ -600,6 +618,7 @@
statement.setInt(position,
parameters.getParameterAsInteger("image-size", -1));
setRequestAttribute(request,param,parameters.getParameter("image-size",""));
}
+ break;
}
default:
throw new SQLException("Impossible exception - invalid type
"+typeName);
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]