Update of /var/cvs/applications/resources/src/org/mmbase/datatypes/processors
In directory james.mmbase.org:/tmp/cvs-serv13580
Modified Files:
BinaryFile.java
Log Message:
See also:
http://cvs.mmbase.org/viewcvs/applications/resources/src/org/mmbase/datatypes/processors
Index: BinaryFile.java
===================================================================
RCS file:
/var/cvs/applications/resources/src/org/mmbase/datatypes/processors/BinaryFile.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- BinaryFile.java 24 Apr 2009 07:30:57 -0000 1.1
+++ BinaryFile.java 24 Apr 2009 15:07:45 -0000 1.2
@@ -54,27 +54,30 @@
private static final long serialVersionUID = 1L;
public Object process(final Node node, final Field field, final Object
value) {
-
-
SerializableInputStream is =
Casting.toSerializableInputStream(value);
-
String name = is.getName();
if (name != null) {
- name = field.getName();
+ String existing = (String) node.getValue(field.getName());
+ if (existing != null) {
+ File ef = new File(getDirectory(), existing);
+ if (ef.exists()) {
+ log.debug("Removing existing field " + ef);
+ ef.delete();
+ } else {
+ log.warn("Could not fined " + ef + " so could not
delete it");
+ }
}
File f = getFile(node, field, name);
if (log.isDebugEnabled()) {
- log.debug("" + value + " -> " + is + " -> " + f, new
Exception());
- }
-
- try {
- FileOutputStream dest = new FileOutputStream(f);
- IOUtil.copy(is, dest);
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
+ log.debug("" + value + " -> " + is + " -> " + f + " " +
Logging.applicationStacktrace());
}
+ is.moveTo(f);
return f.getName();
+ } else {
+ log.debug("No name given, ignoring this processor (not an
upload)");
+ return value;
+ }
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs