Souds you are talking about a forum where reactions can be placed which expire
after some time. Typically, this is relational stuff, where you query for fora
which fall within a certain date. But anyway, in your case, if you really want
to go along the way you suggest, then as Andrew suggested, do it outside cocoon
is a better option. If you really want to hold to cocoon, in flow, you more or
less could accompish it like
importClass(Packages.org.apache.excalibur.source.SourceUtil);
importClass(Packages.org.apache.excalibur.source.SourceResolver);
// necessary packages
-----------------------------------------
function yourfunction(){
documentUri = "cocoon://directorygenerator" // This pipeline calls the
directorygenerator or xpath-tg for the
// folder you need
var fileXML = loadDocument(documentUri);
var filelist = filelistXML.getElementsByTagName("dir:file");
for (var i = 0; i < filelist.getLength(); i++) {
var Fileuri = filelist.getAttribute("name");
// now you have the Fileuri's.of the docs. Load them now one by one
with
// loadDocument, then search for the expire-date element and make your
choice if you
// want to delete. Therefor you can call deleteDocument(uri)
// of course this all stuff in flow has to be called every day with the
cron block.
}
cocoon.sendPage('succes.html');
}
}
--------------------------------
// functions you need
function loadDocument(uri) {
var parser = null;
var source = null;
var resolver = null;
try {
parser =
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
source = resolver.resolveURI(uri);
var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
is.setSystemId(source.getURI());
return parser.parseDocument(is);
} finally {
if (source != null)
resolver.release(source);
cocoon.releaseComponent(parser);
cocoon.releaseComponent(resolver);
}
}
function deleteDocument(uri) {
var source = null;
var resolver = null;
try {
resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
source = resolver.resolveURI(uri);
source["delete"]();
}
catch (error) {
cocoon.log.error("Error occured while deleting document: " + error);
}
finally {
if (source != null)
resolver.release(source);
cocoon.releaseComponent(resolver);
}
}
AS
>
>
> Hi!
>
>
> >
> > First, of all, how many and large files are we talking
> about? It would be rather expensive to loop through them in
> flow, open them each by each, looking for the element
> <expiry-date/>, and if it is found, delete the file.
>
> Well, the number is not predictable, but it would be rather a
> few than a
> lot (<10).
>
> >
> > But, if you look every day, then files that are not
> modified within the last 24 hours won't have to be checked
> again. Therefor, you could use the directory generator.
> >
>
> Well, the files aren't going to be modified ever. They are
> messages to
> users, that expire after a certain date. Each message is contained in
> one file and these files are then aggregated into one message
> file that
> is presented to the user. When a message has expired it is
> supposed to
> be deleted so that in the next aggregation run it won't re-appear.
>
> Maybe this is not the easiest way to do it. I thought about
> putting all
> messages into one file from the beginning and then have them searched
> for expired ones when the file is called for display, but I
> thought the
> other approach was better.
>
> christian
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]