Update of /var/cvs/applications/resources/src/org/mmbase/datatypes/processors In directory james.mmbase.org:/tmp/cvs-serv11648/src/org/mmbase/datatypes/processors
Modified Files: BinaryFile.java Log Message: Using 'deleteprocessor' to delete the file on delete of the node 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.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- BinaryFile.java 24 Apr 2009 15:07:45 -0000 1.2 +++ BinaryFile.java 30 Apr 2009 14:47:27 -0000 1.3 @@ -41,11 +41,29 @@ private static File getFile(final Node node, final Field field, String fileName) { + return new File(getDirectory(), getFileName(node, field, fileName).replace("/", File.separator)); + } + + public static String getFileName(final Node node, final Field field, String fileName) { StringBuilder buf = new StringBuilder(); org.mmbase.storage.implementation.database.DatabaseStorageManager.appendDirectory(buf, node.getNumber(), "/"); buf.append("/").append(node.getNumber()).append("."); buf.append(fileName); - return new File(getDirectory(), buf.toString().replace("/", File.separator)); + return buf.toString(); + } + + public static class Delete implements CommitProcessor { + public void commit(final Node node, final Field field) { + String existing = (String) node.getValue(field.getName()); + if (existing != null) { + File ef = new File(getDirectory(), existing); + if (ef.exists()) { + ef.delete(); + } else { + log.warn("Could not find " + ef + " so could not delete it"); + } + } + } } @@ -64,7 +82,7 @@ log.debug("Removing existing field " + ef); ef.delete(); } else { - log.warn("Could not fined " + ef + " so could not delete it"); + log.warn("Could not find " + ef + " so could not delete it"); } } File f = getFile(node, field, name); _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs